Brunobkr/llama.cpp_AlgMor24_github
ΩFFFΣLLIa • llama.cpp • AlgMor24 ██████╗ ███████╗███████╗███████╗██╗ ██╗ ██╗ █████╗ ██╔═══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██║██╔══██╗ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║███████║ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██╔══██║ ╚██████╔╝██║ ██║ ███████╗███████╗███████╗██║██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝╚═╝ ╚═╝ High-Performance LLM / VLM Inference & Autonomous Agentic Ecosystem… See the full description on the dataset page: https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github.
03.1k
1import { attachRef } from "svelte-toolbelt";2import { Context, watch } from "runed";3import { boolToStr, createBitsAttrs, getAriaChecked, boolToEmptyStrOrUndef, } from "../../internal/attrs.js";4import { kbd } from "../../internal/kbd.js";5import { arraysAreEqual } from "../../internal/arrays.js";6import { isHTMLElement } from "../../internal/is.js";7const checkboxAttrs = createBitsAttrs({8 component: "checkbox",9 parts: ["root", "group", "group-label", "input"],10});11export const CheckboxGroupContext = new Context("Checkbox.Group");12export class CheckboxGroupState {13 static create(opts) {14 return CheckboxGroupContext.set(new CheckboxGroupState(opts));15 }16 opts;17 attachment;18 labelId = $state(undefined);19 constructor(opts) {20 this.opts = opts;21 this.attachment = attachRef(this.opts.ref);22 }23 addValue(checkboxValue) {24 if (!checkboxValue)25 return;26 if (!this.opts.value.current.includes(checkboxValue)) {27 const newValue = [...$state.snapshot(this.opts.value.current), checkboxValue];28 this.opts.value.current = newValue;29 if (arraysAreEqual(this.opts.value.current, newValue))30 return;31 this.opts.onValueChange.current(newValue);32 }33 }34 removeValue(checkboxValue) {35 if (!checkboxValue)36 return;37 const index = this.opts.value.current.indexOf(checkboxValue);38 if (index === -1)39 return;40 const newValue = this.opts.value.current.filter((v) => v !== checkboxValue);41 this.opts.value.current = newValue;42 if (arraysAreEqual(this.opts.value.current, newValue))43 return;44 this.opts.onValueChange.current(newValue);45 }46 props = $derived.by(() => ({47 id: this.opts.id.current,48 role: "group",49 "aria-labelledby": this.labelId,50 "data-disabled": boolToEmptyStrOrUndef(this.opts.disabled.current),51 [checkboxAttrs.group]: "",52 ...this.attachment,53 }));54}55export class CheckboxGroupLabelState {56 static create(opts) {57 return new CheckboxGroupLabelState(opts, CheckboxGroupContext.get());58 }59 opts;60 group;61 attachment;62 constructor(opts, group) {63 this.opts = opts;64 this.group = group;65 this.group.labelId = this.opts.id.current;66 this.attachment = attachRef(this.opts.ref);67 watch.pre(() => this.opts.id.current, (id) => {68 this.group.labelId = id;69 });70 }71 props = $derived.by(() => ({72 id: this.opts.id.current,73 "data-disabled": boolToEmptyStrOrUndef(this.group.opts.disabled.current),74 [checkboxAttrs["group-label"]]: "",75 ...this.attachment,76 }));77}78const CheckboxRootContext = new Context("Checkbox.Root");79export class CheckboxRootState {80 static create(opts, group = null) {81 return CheckboxRootContext.set(new CheckboxRootState(opts, group));82 }83 opts;84 group;85 trueName = $derived.by(() => {86 if (this.group && this.group.opts.name.current)87 return this.group.opts.name.current;88 return this.opts.name.current;89 });90 trueRequired = $derived.by(() => {91 if (this.group && this.group.opts.required.current)92 return true;93 return this.opts.required.current;94 });95 trueDisabled = $derived.by(() => {96 if (this.group && this.group.opts.disabled.current)97 return true;98 return this.opts.disabled.current;99 });100 trueReadonly = $derived.by(() => {101 if (this.group && this.group.opts.readonly.current)102 return true;103 return this.opts.readonly.current;104 });105 attachment;106 constructor(opts, group) {107 this.opts = opts;108 this.group = group;109 this.attachment = attachRef(this.opts.ref);110 this.onkeydown = this.onkeydown.bind(this);111 this.onclick = this.onclick.bind(this);112 watch.pre([() => $state.snapshot(this.group?.opts.value.current), () => this.opts.value.current], ([groupValue, value]) => {113 if (!groupValue || !value)114 return;115 this.opts.checked.current = groupValue.includes(value);116 });117 watch.pre(() => this.opts.checked.current, (checked) => {118 if (!this.group)119 return;120 if (checked) {121 this.group?.addValue(this.opts.value.current);122 }123 else {124 this.group?.removeValue(this.opts.value.current);125 }126 });127 }128 onkeydown(e) {129 if (this.trueDisabled || this.trueReadonly)130 return;131 if (e.key === kbd.ENTER) {132 e.preventDefault();133 if (this.opts.type.current === "submit") {134 const form = e.currentTarget.closest("form");135 form?.requestSubmit();136 }137 return;138 }139 if (e.key === kbd.SPACE) {140 e.preventDefault();141 this.#toggle();142 }143 }144 #toggle() {145 if (this.opts.indeterminate.current) {146 this.opts.indeterminate.current = false;147 this.opts.checked.current = true;148 }149 else {150 this.opts.checked.current = !this.opts.checked.current;151 }152 }153 onclick(e) {154 if (this.trueDisabled || this.trueReadonly)155 return;156 if (this.opts.type.current === "submit") {157 this.#toggle();158 return;159 }160 e.preventDefault();161 this.#toggle();162 }163 snippetProps = $derived.by(() => ({164 checked: this.opts.checked.current,165 indeterminate: this.opts.indeterminate.current,166 }));167 props = $derived.by(() => ({168 id: this.opts.id.current,169 role: "checkbox",170 type: this.opts.type.current,171 disabled: this.trueDisabled,172 "aria-checked": getAriaChecked(this.opts.checked.current, this.opts.indeterminate.current),173 "aria-required": boolToStr(this.trueRequired),174 "aria-readonly": boolToStr(this.trueReadonly),175 "data-disabled": boolToEmptyStrOrUndef(this.trueDisabled),176 "data-readonly": boolToEmptyStrOrUndef(this.trueReadonly),177 "data-state": getCheckboxDataState(this.opts.checked.current, this.opts.indeterminate.current),178 [checkboxAttrs.root]: "",179 //180 onclick: this.onclick,181 onkeydown: this.onkeydown,182 ...this.attachment,183 }));184}185export class CheckboxInputState {186 static create() {187 return new CheckboxInputState(CheckboxRootContext.get());188 }189 root;190 trueChecked = $derived.by(() => {191 if (!this.root.group)192 return this.root.opts.checked.current;193 if (this.root.opts.value.current !== undefined &&194 this.root.group.opts.value.current.includes(this.root.opts.value.current)) {195 return true;196 }197 return false;198 });199 shouldRender = $derived.by(() => Boolean(this.root.trueName));200 constructor(root) {201 this.root = root;202 this.onfocus = this.onfocus.bind(this);203 }204 onfocus(_) {205 if (!isHTMLElement(this.root.opts.ref.current))206 return;207 this.root.opts.ref.current.focus();208 }209 props = $derived.by(() => ({210 type: "checkbox",211 checked: this.root.opts.checked.current === true,212 disabled: this.root.trueDisabled,213 required: this.root.trueRequired,214 name: this.root.trueName,215 value: this.root.opts.value.current,216 readonly: this.root.trueReadonly,217 onfocus: this.onfocus,218 }));219}220function getCheckboxDataState(checked, indeterminate) {221 if (indeterminate)222 return "indeterminate";223 return checked ? "checked" : "unchecked";224}225 