slexkit 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.slexkit.md +29 -0
- package/CHANGELOG.md +90 -0
- package/LICENSE +21 -0
- package/README.md +165 -0
- package/README.zh-CN.md +165 -0
- package/dist/ai/llms-authoring.txt +44 -0
- package/dist/ai/llms-components.txt +669 -0
- package/dist/ai/llms-full.txt +6586 -0
- package/dist/ai/llms-runtime.txt +1475 -0
- package/dist/ai/llms-toolhost.txt +295 -0
- package/dist/ai/llms.txt +69 -0
- package/dist/ai/slexkit-ai-manifest.json +2922 -0
- package/dist/base.css +621 -0
- package/dist/chunks/accordion-5f0nvjjm.js +376 -0
- package/dist/chunks/accordion-830dw78f.js +221 -0
- package/dist/chunks/accordion-cfjyxw93.js +630 -0
- package/dist/chunks/accordion-cw5r75jm.js +424 -0
- package/dist/chunks/accordion-ehnhpeca.js +492 -0
- package/dist/chunks/accordion-hzyrngd6.js +2377 -0
- package/dist/chunks/accordion-nw12ytps.js +6823 -0
- package/dist/components/accordion.js +163 -0
- package/dist/components/badge.js +80 -0
- package/dist/components/button.css +114 -0
- package/dist/components/button.js +16 -0
- package/dist/components/callout.js +154 -0
- package/dist/components/card.js +95 -0
- package/dist/components/checkbox.js +114 -0
- package/dist/components/choice.css +165 -0
- package/dist/components/code-block.js +264 -0
- package/dist/components/collapsible.js +111 -0
- package/dist/components/column.js +49 -0
- package/dist/components/content.css +474 -0
- package/dist/components/disclosure.css +162 -0
- package/dist/components/display.css +259 -0
- package/dist/components/divider.js +98 -0
- package/dist/components/feedback.css +219 -0
- package/dist/components/grid.js +67 -0
- package/dist/components/index.js +13364 -0
- package/dist/components/input.css +1247 -0
- package/dist/components/input.js +384 -0
- package/dist/components/link.js +77 -0
- package/dist/components/progress.js +111 -0
- package/dist/components/radio-group.js +189 -0
- package/dist/components/row.js +200 -0
- package/dist/components/section.js +161 -0
- package/dist/components/select.css +260 -0
- package/dist/components/select.js +16 -0
- package/dist/components/slider.css +125 -0
- package/dist/components/slider.js +175 -0
- package/dist/components/specs.js +1090 -0
- package/dist/components/stat.js +178 -0
- package/dist/components/submit.css +9 -0
- package/dist/components/submit.js +77 -0
- package/dist/components/switch.css +114 -0
- package/dist/components/switch.js +114 -0
- package/dist/components/table.js +157 -0
- package/dist/components/tabs.css +192 -0
- package/dist/components/tabs.js +17 -0
- package/dist/components/text-input.css +245 -0
- package/dist/components/text.js +50 -0
- package/dist/components/toast.js +240 -0
- package/dist/components/tooling.css +1009 -0
- package/dist/components/tooling.js +48951 -0
- package/dist/runtime.cjs +3728 -0
- package/dist/runtime.js +3686 -0
- package/dist/slexkit.cjs +18539 -0
- package/dist/slexkit.css +4776 -0
- package/dist/slexkit.js +18497 -0
- package/dist/tooling.js +59141 -0
- package/dist/types/components/accordion.d.ts +2 -0
- package/dist/types/components/badge.d.ts +2 -0
- package/dist/types/components/button.d.ts +2 -0
- package/dist/types/components/callout.d.ts +2 -0
- package/dist/types/components/card.d.ts +2 -0
- package/dist/types/components/checkbox.d.ts +2 -0
- package/dist/types/components/code-block.d.ts +2 -0
- package/dist/types/components/collapsible.d.ts +2 -0
- package/dist/types/components/column.d.ts +2 -0
- package/dist/types/components/divider.d.ts +2 -0
- package/dist/types/components/entries/accordion.d.ts +3 -0
- package/dist/types/components/entries/badge.d.ts +3 -0
- package/dist/types/components/entries/button.d.ts +3 -0
- package/dist/types/components/entries/callout.d.ts +3 -0
- package/dist/types/components/entries/card.d.ts +3 -0
- package/dist/types/components/entries/checkbox.d.ts +3 -0
- package/dist/types/components/entries/code-block.d.ts +3 -0
- package/dist/types/components/entries/collapsible.d.ts +3 -0
- package/dist/types/components/entries/column.d.ts +3 -0
- package/dist/types/components/entries/divider.d.ts +3 -0
- package/dist/types/components/entries/grid.d.ts +3 -0
- package/dist/types/components/entries/input.d.ts +3 -0
- package/dist/types/components/entries/link.d.ts +3 -0
- package/dist/types/components/entries/progress.d.ts +3 -0
- package/dist/types/components/entries/radio-group.d.ts +3 -0
- package/dist/types/components/entries/row.d.ts +3 -0
- package/dist/types/components/entries/section.d.ts +3 -0
- package/dist/types/components/entries/select.d.ts +3 -0
- package/dist/types/components/entries/slider.d.ts +3 -0
- package/dist/types/components/entries/specs.d.ts +1 -0
- package/dist/types/components/entries/stat.d.ts +3 -0
- package/dist/types/components/entries/submit.d.ts +3 -0
- package/dist/types/components/entries/switch.d.ts +3 -0
- package/dist/types/components/entries/table.d.ts +3 -0
- package/dist/types/components/entries/tabs.d.ts +3 -0
- package/dist/types/components/entries/text.d.ts +3 -0
- package/dist/types/components/entries/toast.d.ts +3 -0
- package/dist/types/components/entries/tooling.d.ts +1 -0
- package/dist/types/components/grid.d.ts +2 -0
- package/dist/types/components/index.d.ts +6 -0
- package/dist/types/components/input.d.ts +2 -0
- package/dist/types/components/link.d.ts +2 -0
- package/dist/types/components/progress.d.ts +2 -0
- package/dist/types/components/radio-group.d.ts +2 -0
- package/dist/types/components/row.d.ts +2 -0
- package/dist/types/components/section.d.ts +2 -0
- package/dist/types/components/select.d.ts +2 -0
- package/dist/types/components/slider.d.ts +2 -0
- package/dist/types/components/spec-helpers.d.ts +23 -0
- package/dist/types/components/spec-registry.d.ts +12 -0
- package/dist/types/components/spec-schema.d.ts +74 -0
- package/dist/types/components/specs.d.ts +2 -0
- package/dist/types/components/stat.d.ts +2 -0
- package/dist/types/components/submit.d.ts +2 -0
- package/dist/types/components/svelte/adapter.d.ts +3 -0
- package/dist/types/components/svelte/bindProps.d.ts +2 -0
- package/dist/types/components/svelte/helpers.d.ts +33 -0
- package/dist/types/components/svelte/layout/balancedTiles.d.ts +14 -0
- package/dist/types/components/svelte/types.d.ts +12 -0
- package/dist/types/components/switch.d.ts +2 -0
- package/dist/types/components/table.d.ts +2 -0
- package/dist/types/components/tabs.d.ts +2 -0
- package/dist/types/components/text.d.ts +2 -0
- package/dist/types/components/toast.d.ts +2 -0
- package/dist/types/components/tooling.d.ts +2 -0
- package/dist/types/components-svelte.d.ts +5 -0
- package/dist/types/engine/component-scope.d.ts +14 -0
- package/dist/types/engine/component-state.d.ts +9 -0
- package/dist/types/engine/diagnostics.d.ts +24 -0
- package/dist/types/engine/engineering.d.ts +11 -0
- package/dist/types/engine/eval.d.ts +5 -0
- package/dist/types/engine/index.d.ts +26 -0
- package/dist/types/engine/markdown-runtime.d.ts +33 -0
- package/dist/types/engine/merge.d.ts +1 -0
- package/dist/types/engine/reactive.d.ts +11 -0
- package/dist/types/engine/registry.d.ts +4 -0
- package/dist/types/engine/renderer.d.ts +6 -0
- package/dist/types/engine/sandbox-runner.d.ts +2 -0
- package/dist/types/engine/secure-runtime.d.ts +214 -0
- package/dist/types/engine/store.d.ts +12 -0
- package/dist/types/engine/types.d.ts +58 -0
- package/dist/types/icons/manager.d.ts +17 -0
- package/dist/types/icons/phosphor.d.ts +45 -0
- package/dist/types/index.d.ts +61 -0
- package/dist/types/runtime.d.ts +32 -0
- package/dist/types/toolhost/index.d.ts +78 -0
- package/dist/types/tooling-umd.d.ts +47 -0
- package/dist/types/version.d.ts +8 -0
- package/dist/umd/slexkit.tooling.umd.js +66553 -0
- package/dist/umd/slexkit.umd.js +18552 -0
- package/package.json +136 -0
- package/scripts/cli.mjs +47 -0
- package/skills/slexkit/SKILL.md +27 -0
- package/skills/slexkit-author/SKILL.md +50 -0
- package/skills/slexkit-host-integration/SKILL.md +33 -0
- package/skills/slexkit-secure-runtime/SKILL.md +31 -0
- package/skills/slexkit-toolhost/SKILL.md +38 -0
- package/skills/slexkit-update/SKILL.md +23 -0
- package/src/components/svelte/InlineIcon.svelte +66 -0
- package/src/components/svelte/adapter.ts +76 -0
- package/src/components/svelte/bindProps.ts +9 -0
- package/src/components/svelte/content/Badge.svelte +19 -0
- package/src/components/svelte/content/Callout.svelte +57 -0
- package/src/components/svelte/content/CodeBlock.svelte +130 -0
- package/src/components/svelte/content/Divider.svelte +21 -0
- package/src/components/svelte/content/Link.svelte +21 -0
- package/src/components/svelte/content/Section.svelte +24 -0
- package/src/components/svelte/content/Table.svelte +44 -0
- package/src/components/svelte/disclosure/Accordion.svelte +100 -0
- package/src/components/svelte/disclosure/Collapsible.svelte +45 -0
- package/src/components/svelte/display/Stat.svelte +102 -0
- package/src/components/svelte/display/Text.svelte +11 -0
- package/src/components/svelte/feedback/Progress.svelte +34 -0
- package/src/components/svelte/feedback/Toast.svelte +105 -0
- package/src/components/svelte/helpers.ts +148 -0
- package/src/components/svelte/input/Button.svelte +78 -0
- package/src/components/svelte/input/Checkbox.svelte +52 -0
- package/src/components/svelte/input/Input.svelte +202 -0
- package/src/components/svelte/input/RadioGroup.svelte +71 -0
- package/src/components/svelte/input/Select.svelte +220 -0
- package/src/components/svelte/input/Slider.svelte +96 -0
- package/src/components/svelte/input/Submit.svelte +32 -0
- package/src/components/svelte/input/Switch.svelte +53 -0
- package/src/components/svelte/input/Tabs.svelte +188 -0
- package/src/components/svelte/layout/Card.svelte +17 -0
- package/src/components/svelte/layout/Column.svelte +15 -0
- package/src/components/svelte/layout/Grid.svelte +26 -0
- package/src/components/svelte/layout/Row.svelte +105 -0
- package/src/components/svelte/layout/balancedTiles.ts +85 -0
- package/src/components/svelte/tooling/CodeMirror.svelte +91 -0
- package/src/components/svelte/tooling/Playground.svelte +765 -0
- package/src/components/svelte/tooling/PlaygroundMarkdown.svelte +26 -0
- package/src/components/svelte/tooling/PlaygroundSlexCode.svelte +76 -0
- package/src/components/svelte/types.ts +17 -0
- package/src/styles/animation.css +98 -0
- package/src/styles/components/button.css +114 -0
- package/src/styles/components/choice.css +165 -0
- package/src/styles/components/select.css +260 -0
- package/src/styles/components/slider.css +125 -0
- package/src/styles/components/submit.css +9 -0
- package/src/styles/components/switch.css +114 -0
- package/src/styles/components/tabs.css +192 -0
- package/src/styles/components/text-input.css +245 -0
- package/src/styles/content.css +474 -0
- package/src/styles/disclosure.css +162 -0
- package/src/styles/display.css +259 -0
- package/src/styles/entry.css +34 -0
- package/src/styles/feedback.css +219 -0
- package/src/styles/input.css +8 -0
- package/src/styles/layout.css +365 -0
- package/src/styles/theme.css +31 -0
- package/src/styles/tooling.css +1009 -0
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import {
|
|
2
|
+
InlineIcon
|
|
3
|
+
} from "../chunks/accordion-cw5r75jm.js";
|
|
4
|
+
import {
|
|
5
|
+
append,
|
|
6
|
+
bindPropStore,
|
|
7
|
+
child,
|
|
8
|
+
createSvelteRenderer,
|
|
9
|
+
delegate,
|
|
10
|
+
delegated,
|
|
11
|
+
each,
|
|
12
|
+
emit,
|
|
13
|
+
from_html,
|
|
14
|
+
get,
|
|
15
|
+
if_block,
|
|
16
|
+
index,
|
|
17
|
+
list,
|
|
18
|
+
pop,
|
|
19
|
+
proxy,
|
|
20
|
+
push,
|
|
21
|
+
remove_input_defaults,
|
|
22
|
+
reset,
|
|
23
|
+
set,
|
|
24
|
+
set_attribute,
|
|
25
|
+
set_checked,
|
|
26
|
+
set_text,
|
|
27
|
+
set_value,
|
|
28
|
+
sibling,
|
|
29
|
+
state,
|
|
30
|
+
template_effect,
|
|
31
|
+
text1 as text,
|
|
32
|
+
user_derived,
|
|
33
|
+
user_effect
|
|
34
|
+
} from "../chunks/accordion-nw12ytps.js";
|
|
35
|
+
|
|
36
|
+
// src/components/entries/radio-group.ts
|
|
37
|
+
import { register } from "../runtime.js";
|
|
38
|
+
|
|
39
|
+
// src/components/svelte/input/RadioGroup.svelte
|
|
40
|
+
var root_3 = from_html(`<span> </span>`);
|
|
41
|
+
var root_1 = from_html(`<div class="slex-radio-group-label"><!> <!></div>`);
|
|
42
|
+
var root_4 = from_html(`<span class="slex-choice-event-layer"><label class="slex-radio-field"><input type="radio" class="slex-radio"/> <span class="slex-radio-label"><!> <span> </span></span></label></span>`);
|
|
43
|
+
var root = from_html(`<div class="slex-radio-group" data-scope="radio-group" data-part="root" role="radiogroup"><!> <div class="slex-radio-group-list"></div></div>`);
|
|
44
|
+
function RadioGroup($$anchor, $$props) {
|
|
45
|
+
push($$props, true);
|
|
46
|
+
let p = state(proxy({}));
|
|
47
|
+
let value = state(undefined);
|
|
48
|
+
const lastHapticAt = new Map;
|
|
49
|
+
user_effect(() => bindPropStore($$props.props, (next) => {
|
|
50
|
+
set(p, next, true);
|
|
51
|
+
set(value, next.value, true);
|
|
52
|
+
}));
|
|
53
|
+
function choose(next) {
|
|
54
|
+
set(value, next, true);
|
|
55
|
+
emit($$props.ctx, "change", next);
|
|
56
|
+
}
|
|
57
|
+
function vibrate(disabled, duration = 8) {
|
|
58
|
+
if (disabled || get(p).haptic === false || get(p).haptics === false)
|
|
59
|
+
return;
|
|
60
|
+
const api = globalThis.navigator;
|
|
61
|
+
api?.vibrate?.(duration);
|
|
62
|
+
}
|
|
63
|
+
function haptic(key, disabled, duration = 8) {
|
|
64
|
+
const now = Date.now();
|
|
65
|
+
if (now - (lastHapticAt.get(key) ?? 0) < 80)
|
|
66
|
+
return;
|
|
67
|
+
lastHapticAt.set(key, now);
|
|
68
|
+
vibrate(disabled, duration);
|
|
69
|
+
}
|
|
70
|
+
function groupName() {
|
|
71
|
+
return text(get(p).name ?? $$props.ctx.id, $$props.ctx.id);
|
|
72
|
+
}
|
|
73
|
+
var div = root();
|
|
74
|
+
var node = child(div);
|
|
75
|
+
{
|
|
76
|
+
var consequent_2 = ($$anchor2) => {
|
|
77
|
+
var div_1 = root_1();
|
|
78
|
+
var node_1 = child(div_1);
|
|
79
|
+
{
|
|
80
|
+
var consequent = ($$anchor3) => {
|
|
81
|
+
InlineIcon($$anchor3, {
|
|
82
|
+
get name() {
|
|
83
|
+
return get(p).icon;
|
|
84
|
+
},
|
|
85
|
+
className: "slex-radio-group-icon"
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
if_block(node_1, ($$render) => {
|
|
89
|
+
if (get(p).icon)
|
|
90
|
+
$$render(consequent);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
var node_2 = sibling(node_1, 2);
|
|
94
|
+
{
|
|
95
|
+
var consequent_1 = ($$anchor3) => {
|
|
96
|
+
var span = root_3();
|
|
97
|
+
var text_1 = child(span, true);
|
|
98
|
+
reset(span);
|
|
99
|
+
template_effect(($0) => set_text(text_1, $0), [() => text(get(p).label)]);
|
|
100
|
+
append($$anchor3, span);
|
|
101
|
+
};
|
|
102
|
+
if_block(node_2, ($$render) => {
|
|
103
|
+
if (get(p).label)
|
|
104
|
+
$$render(consequent_1);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
reset(div_1);
|
|
108
|
+
append($$anchor2, div_1);
|
|
109
|
+
};
|
|
110
|
+
if_block(node, ($$render) => {
|
|
111
|
+
if (get(p).label || get(p).icon)
|
|
112
|
+
$$render(consequent_2);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
var div_2 = sibling(node, 2);
|
|
116
|
+
each(div_2, 21, () => list(get(p).options), index, ($$anchor2, item) => {
|
|
117
|
+
const itemValue = user_derived(() => get(item).value ?? get(item).label);
|
|
118
|
+
const disabled = user_derived(() => !!get(item).disabled || !!get(p).disabled);
|
|
119
|
+
const hapticKey = user_derived(() => text(get(itemValue)));
|
|
120
|
+
var span_1 = root_4();
|
|
121
|
+
var label = child(span_1);
|
|
122
|
+
var input = child(label);
|
|
123
|
+
remove_input_defaults(input);
|
|
124
|
+
var span_2 = sibling(input, 2);
|
|
125
|
+
var node_3 = child(span_2);
|
|
126
|
+
{
|
|
127
|
+
var consequent_3 = ($$anchor3) => {
|
|
128
|
+
{
|
|
129
|
+
let $0 = user_derived(() => get(itemValue) === get(value));
|
|
130
|
+
InlineIcon($$anchor3, {
|
|
131
|
+
get name() {
|
|
132
|
+
return get(item).icon;
|
|
133
|
+
},
|
|
134
|
+
get selected() {
|
|
135
|
+
return get($0);
|
|
136
|
+
},
|
|
137
|
+
className: "slex-radio-icon"
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
if_block(node_3, ($$render) => {
|
|
142
|
+
if (get(item).icon)
|
|
143
|
+
$$render(consequent_3);
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
var span_3 = sibling(node_3, 2);
|
|
147
|
+
var text_2 = child(span_3, true);
|
|
148
|
+
reset(span_3);
|
|
149
|
+
reset(span_2);
|
|
150
|
+
reset(label);
|
|
151
|
+
reset(span_1);
|
|
152
|
+
template_effect(($0, $1, $2) => {
|
|
153
|
+
set_attribute(input, "name", $0);
|
|
154
|
+
set_value(input, $1);
|
|
155
|
+
set_checked(input, get(itemValue) === get(value));
|
|
156
|
+
input.disabled = get(disabled);
|
|
157
|
+
set_attribute(input, "data-state", get(itemValue) === get(value) ? "checked" : "unchecked");
|
|
158
|
+
set_text(text_2, $2);
|
|
159
|
+
}, [
|
|
160
|
+
() => groupName(),
|
|
161
|
+
() => text(get(itemValue)),
|
|
162
|
+
() => text(get(item).label)
|
|
163
|
+
]);
|
|
164
|
+
delegated("pointerdown", span_1, () => haptic(get(hapticKey), get(disabled), 8));
|
|
165
|
+
delegated("click", span_1, () => haptic(get(hapticKey), get(disabled), 8));
|
|
166
|
+
delegated("change", input, () => choose(get(itemValue)));
|
|
167
|
+
append($$anchor2, span_1);
|
|
168
|
+
});
|
|
169
|
+
reset(div_2);
|
|
170
|
+
reset(div);
|
|
171
|
+
template_effect(($0, $1) => {
|
|
172
|
+
set_attribute(div, "data-orientation", $0);
|
|
173
|
+
set_attribute(div, "aria-label", $1);
|
|
174
|
+
}, [
|
|
175
|
+
() => text(get(p).orientation, "vertical"),
|
|
176
|
+
() => text(get(p)["aria-label"] ?? get(p).ariaLabel ?? get(p).label) || undefined
|
|
177
|
+
]);
|
|
178
|
+
append($$anchor, div);
|
|
179
|
+
pop();
|
|
180
|
+
}
|
|
181
|
+
delegate(["pointerdown", "click", "change"]);
|
|
182
|
+
|
|
183
|
+
// src/components/entries/radio-group.ts
|
|
184
|
+
register("radio-group", createSvelteRenderer("radio-group", RadioGroup), { state: "value" });
|
|
185
|
+
var radio_group_default = RadioGroup;
|
|
186
|
+
export {
|
|
187
|
+
radio_group_default as default,
|
|
188
|
+
RadioGroup
|
|
189
|
+
};
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import {
|
|
2
|
+
action,
|
|
3
|
+
append,
|
|
4
|
+
bindPropStore,
|
|
5
|
+
createSvelteRenderer,
|
|
6
|
+
from_html,
|
|
7
|
+
get,
|
|
8
|
+
pop,
|
|
9
|
+
proxy,
|
|
10
|
+
push,
|
|
11
|
+
renderChildren,
|
|
12
|
+
set,
|
|
13
|
+
set_attribute,
|
|
14
|
+
set_class,
|
|
15
|
+
set_style,
|
|
16
|
+
state,
|
|
17
|
+
template_effect,
|
|
18
|
+
text1 as text,
|
|
19
|
+
user_effect
|
|
20
|
+
} from "../chunks/accordion-nw12ytps.js";
|
|
21
|
+
|
|
22
|
+
// src/components/entries/row.ts
|
|
23
|
+
import { register } from "../runtime.js";
|
|
24
|
+
|
|
25
|
+
// src/components/svelte/layout/balancedTiles.ts
|
|
26
|
+
function chooseBalancedColumns({
|
|
27
|
+
itemCount,
|
|
28
|
+
containerWidth,
|
|
29
|
+
targetTileWidth = 136,
|
|
30
|
+
gap = 16
|
|
31
|
+
}) {
|
|
32
|
+
if (!Number.isFinite(itemCount) || itemCount <= 1)
|
|
33
|
+
return Math.max(1, Math.floor(itemCount || 1));
|
|
34
|
+
const usableWidth = Number.isFinite(containerWidth) && containerWidth > 0 ? containerWidth : Infinity;
|
|
35
|
+
const target = Math.max(80, targetTileWidth);
|
|
36
|
+
const spacing = Math.max(0, gap);
|
|
37
|
+
const maxFit = Number.isFinite(usableWidth) ? Math.max(1, Math.min(itemCount, Math.floor((usableWidth + spacing) / (target + spacing)))) : itemCount;
|
|
38
|
+
if (maxFit >= itemCount)
|
|
39
|
+
return itemCount;
|
|
40
|
+
let bestColumns = 1;
|
|
41
|
+
let bestScore = Number.POSITIVE_INFINITY;
|
|
42
|
+
for (let columns = 1;columns <= maxFit; columns += 1) {
|
|
43
|
+
const rows = Math.ceil(itemCount / columns);
|
|
44
|
+
const lastRowCount = itemCount - columns * (rows - 1);
|
|
45
|
+
const orphanPenalty = rows > 1 && lastRowCount === 1 ? 100 : 0;
|
|
46
|
+
const balancePenalty = rows > 1 ? (columns - lastRowCount) / columns * 10 : 0;
|
|
47
|
+
const rowPenalty = rows;
|
|
48
|
+
const widthPenalty = (maxFit - columns) * 0.05;
|
|
49
|
+
const score = orphanPenalty + balancePenalty + rowPenalty + widthPenalty;
|
|
50
|
+
if (score < bestScore) {
|
|
51
|
+
bestScore = score;
|
|
52
|
+
bestColumns = columns;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return bestColumns;
|
|
56
|
+
}
|
|
57
|
+
function createBalancedTileLayout(itemCount, columns) {
|
|
58
|
+
const count = Math.max(0, Math.floor(itemCount));
|
|
59
|
+
const safeColumns = Math.max(1, Math.min(count || 1, Math.floor(columns)));
|
|
60
|
+
const rows = Math.ceil(count / safeColumns);
|
|
61
|
+
const lastRowCount = count - safeColumns * (rows - 1);
|
|
62
|
+
const hasPartialLastRow = rows > 1 && lastRowCount > 0 && lastRowCount < safeColumns;
|
|
63
|
+
const tracks = hasPartialLastRow ? lcm(safeColumns, lastRowCount) : safeColumns;
|
|
64
|
+
const fullRowSpan = Math.max(1, tracks / safeColumns);
|
|
65
|
+
const lastRowSpan = hasPartialLastRow ? Math.max(1, tracks / lastRowCount) : fullRowSpan;
|
|
66
|
+
return {
|
|
67
|
+
columns: safeColumns,
|
|
68
|
+
tracks,
|
|
69
|
+
spans: Array.from({ length: count }, (_, index) => {
|
|
70
|
+
const isLastPartialRow = hasPartialLastRow && Math.floor(index / safeColumns) === rows - 1;
|
|
71
|
+
return isLastPartialRow ? lastRowSpan : fullRowSpan;
|
|
72
|
+
})
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function gcd(a, b) {
|
|
76
|
+
let x = Math.abs(Math.floor(a));
|
|
77
|
+
let y = Math.abs(Math.floor(b));
|
|
78
|
+
while (y > 0) {
|
|
79
|
+
const next = x % y;
|
|
80
|
+
x = y;
|
|
81
|
+
y = next;
|
|
82
|
+
}
|
|
83
|
+
return x || 1;
|
|
84
|
+
}
|
|
85
|
+
function lcm(a, b) {
|
|
86
|
+
return Math.max(1, Math.abs(Math.floor(a * b / gcd(a, b))));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// src/components/svelte/layout/Row.svelte
|
|
90
|
+
var root = from_html(`<div></div>`);
|
|
91
|
+
function Row($$anchor, $$props) {
|
|
92
|
+
push($$props, true);
|
|
93
|
+
let p = state(proxy({}));
|
|
94
|
+
user_effect(() => bindPropStore($$props.props, (next) => set(p, next, true)));
|
|
95
|
+
function tileKind(children) {
|
|
96
|
+
if (children.length < 2)
|
|
97
|
+
return null;
|
|
98
|
+
if (children.every((child) => child.classList.contains("slex-stat")))
|
|
99
|
+
return "stat";
|
|
100
|
+
if (children.every((child) => child.classList.contains("slex-card")))
|
|
101
|
+
return "card";
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
function numericStyle(value, fallback) {
|
|
105
|
+
const n = Number.parseFloat(value);
|
|
106
|
+
return Number.isFinite(n) ? n : fallback;
|
|
107
|
+
}
|
|
108
|
+
function renderBalancedChildren(node, options) {
|
|
109
|
+
const children = renderChildren(node, $$props.ctx);
|
|
110
|
+
let current = options;
|
|
111
|
+
let pending = false;
|
|
112
|
+
const reset = () => {
|
|
113
|
+
node.classList.remove("slex-row--balanced-tiles");
|
|
114
|
+
node.removeAttribute("data-tile-kind");
|
|
115
|
+
node.style.removeProperty("--slex-balanced-cols");
|
|
116
|
+
node.style.removeProperty("--slex-balanced-tracks");
|
|
117
|
+
for (const child of Array.from(node.children)) {
|
|
118
|
+
if (child instanceof HTMLElement)
|
|
119
|
+
child.style.removeProperty("grid-column");
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
const rebalance = () => {
|
|
123
|
+
pending = false;
|
|
124
|
+
reset();
|
|
125
|
+
if (current.disabled)
|
|
126
|
+
return;
|
|
127
|
+
const directChildren = Array.from(node.children);
|
|
128
|
+
const kind = tileKind(directChildren);
|
|
129
|
+
if (!kind)
|
|
130
|
+
return;
|
|
131
|
+
const styles = getComputedStyle(node);
|
|
132
|
+
const gap = numericStyle(styles.columnGap || styles.gap, 16);
|
|
133
|
+
const targetTileWidth = numericStyle(styles.getPropertyValue("--slex-balanced-tile-width"), 136);
|
|
134
|
+
const width = node.getBoundingClientRect().width || node.clientWidth;
|
|
135
|
+
const columns = chooseBalancedColumns({
|
|
136
|
+
itemCount: directChildren.length,
|
|
137
|
+
containerWidth: width,
|
|
138
|
+
targetTileWidth,
|
|
139
|
+
gap
|
|
140
|
+
});
|
|
141
|
+
const layout = createBalancedTileLayout(directChildren.length, columns);
|
|
142
|
+
node.classList.add("slex-row--balanced-tiles");
|
|
143
|
+
node.dataset.tileKind = kind;
|
|
144
|
+
node.style.setProperty("--slex-balanced-cols", String(layout.columns));
|
|
145
|
+
node.style.setProperty("--slex-balanced-tracks", String(layout.tracks));
|
|
146
|
+
directChildren.forEach((child, index) => {
|
|
147
|
+
if (child instanceof HTMLElement)
|
|
148
|
+
child.style.gridColumn = `span ${layout.spans[index]}`;
|
|
149
|
+
});
|
|
150
|
+
};
|
|
151
|
+
const schedule = () => {
|
|
152
|
+
if (pending)
|
|
153
|
+
return;
|
|
154
|
+
pending = true;
|
|
155
|
+
queueMicrotask(rebalance);
|
|
156
|
+
};
|
|
157
|
+
const resizeObserver = new ResizeObserver(schedule);
|
|
158
|
+
resizeObserver.observe(node);
|
|
159
|
+
const mutationObserver = new MutationObserver(schedule);
|
|
160
|
+
mutationObserver.observe(node, { childList: true });
|
|
161
|
+
schedule();
|
|
162
|
+
return {
|
|
163
|
+
update(next) {
|
|
164
|
+
current = next;
|
|
165
|
+
schedule();
|
|
166
|
+
},
|
|
167
|
+
destroy() {
|
|
168
|
+
resizeObserver.disconnect();
|
|
169
|
+
mutationObserver.disconnect();
|
|
170
|
+
children.destroy();
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
var div = root();
|
|
175
|
+
let styles_1;
|
|
176
|
+
action(div, ($$node, $$action_arg) => renderBalancedChildren?.($$node, $$action_arg), () => ({ disabled: !!(get(p).align || get(p).justify) }));
|
|
177
|
+
template_effect(($0, $1, $2) => {
|
|
178
|
+
set_class(div, 1, $0);
|
|
179
|
+
set_attribute(div, "id", $1);
|
|
180
|
+
styles_1 = set_style(div, "", styles_1, $2);
|
|
181
|
+
}, [
|
|
182
|
+
() => `slex-row${get(p).class ? ` ${text(get(p).class)}` : ""}`,
|
|
183
|
+
() => get(p).id ? text(get(p).id) : undefined,
|
|
184
|
+
() => ({
|
|
185
|
+
"align-items": text(get(p).align),
|
|
186
|
+
"justify-content": text(get(p).justify),
|
|
187
|
+
gap: text(get(p).gap)
|
|
188
|
+
})
|
|
189
|
+
]);
|
|
190
|
+
append($$anchor, div);
|
|
191
|
+
pop();
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// src/components/entries/row.ts
|
|
195
|
+
register("row", createSvelteRenderer("row", Row), { state: "none" });
|
|
196
|
+
var row_default = Row;
|
|
197
|
+
export {
|
|
198
|
+
row_default as default,
|
|
199
|
+
Row
|
|
200
|
+
};
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import {
|
|
2
|
+
InlineIcon
|
|
3
|
+
} from "../chunks/accordion-cw5r75jm.js";
|
|
4
|
+
import {
|
|
5
|
+
action,
|
|
6
|
+
append,
|
|
7
|
+
bindPropStore,
|
|
8
|
+
child,
|
|
9
|
+
createSvelteRenderer,
|
|
10
|
+
from_html,
|
|
11
|
+
get,
|
|
12
|
+
if_block,
|
|
13
|
+
pop,
|
|
14
|
+
proxy,
|
|
15
|
+
push,
|
|
16
|
+
renderChildren,
|
|
17
|
+
reset,
|
|
18
|
+
set,
|
|
19
|
+
set_attribute,
|
|
20
|
+
set_text,
|
|
21
|
+
sibling,
|
|
22
|
+
state,
|
|
23
|
+
template_effect,
|
|
24
|
+
text1 as text,
|
|
25
|
+
user_effect
|
|
26
|
+
} from "../chunks/accordion-nw12ytps.js";
|
|
27
|
+
|
|
28
|
+
// src/components/entries/section.ts
|
|
29
|
+
import { register } from "../runtime.js";
|
|
30
|
+
|
|
31
|
+
// src/components/svelte/content/Section.svelte
|
|
32
|
+
var root_2 = from_html(`<div class="slex-section-eyebrow"> </div>`);
|
|
33
|
+
var root_5 = from_html(`<span> </span>`);
|
|
34
|
+
var root_3 = from_html(`<h2 class="slex-section-title"><!><!></h2>`);
|
|
35
|
+
var root_6 = from_html(`<p class="slex-section-subtitle"> </p>`);
|
|
36
|
+
var root_7 = from_html(`<a class="slex-section-action"> </a>`);
|
|
37
|
+
var root_1 = from_html(`<header class="slex-section-header"><!> <!> <!> <!></header>`);
|
|
38
|
+
var root = from_html(`<section class="slex-section"><!> <div class="slex-section-body"></div></section>`);
|
|
39
|
+
function Section($$anchor, $$props) {
|
|
40
|
+
push($$props, true);
|
|
41
|
+
let p = state(proxy({}));
|
|
42
|
+
user_effect(() => bindPropStore($$props.props, (next) => set(p, next, true)));
|
|
43
|
+
var section = root();
|
|
44
|
+
var node = child(section);
|
|
45
|
+
{
|
|
46
|
+
var consequent_6 = ($$anchor2) => {
|
|
47
|
+
var header = root_1();
|
|
48
|
+
var node_1 = child(header);
|
|
49
|
+
{
|
|
50
|
+
var consequent = ($$anchor3) => {
|
|
51
|
+
var div = root_2();
|
|
52
|
+
var text_1 = child(div, true);
|
|
53
|
+
reset(div);
|
|
54
|
+
template_effect(($0) => set_text(text_1, $0), [() => text(get(p).eyebrow)]);
|
|
55
|
+
append($$anchor3, div);
|
|
56
|
+
};
|
|
57
|
+
if_block(node_1, ($$render) => {
|
|
58
|
+
if (get(p).eyebrow)
|
|
59
|
+
$$render(consequent);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
var node_2 = sibling(node_1, 2);
|
|
63
|
+
{
|
|
64
|
+
var consequent_3 = ($$anchor3) => {
|
|
65
|
+
var h2 = root_3();
|
|
66
|
+
var node_3 = child(h2);
|
|
67
|
+
{
|
|
68
|
+
var consequent_1 = ($$anchor4) => {
|
|
69
|
+
InlineIcon($$anchor4, {
|
|
70
|
+
get name() {
|
|
71
|
+
return get(p).icon;
|
|
72
|
+
},
|
|
73
|
+
className: "slex-section-icon"
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
if_block(node_3, ($$render) => {
|
|
77
|
+
if (get(p).icon)
|
|
78
|
+
$$render(consequent_1);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
var node_4 = sibling(node_3);
|
|
82
|
+
{
|
|
83
|
+
var consequent_2 = ($$anchor4) => {
|
|
84
|
+
var span = root_5();
|
|
85
|
+
var text_2 = child(span, true);
|
|
86
|
+
reset(span);
|
|
87
|
+
template_effect(($0) => set_text(text_2, $0), [() => text(get(p).title)]);
|
|
88
|
+
append($$anchor4, span);
|
|
89
|
+
};
|
|
90
|
+
if_block(node_4, ($$render) => {
|
|
91
|
+
if (get(p).title)
|
|
92
|
+
$$render(consequent_2);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
reset(h2);
|
|
96
|
+
append($$anchor3, h2);
|
|
97
|
+
};
|
|
98
|
+
if_block(node_2, ($$render) => {
|
|
99
|
+
if (get(p).title || get(p).icon)
|
|
100
|
+
$$render(consequent_3);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
var node_5 = sibling(node_2, 2);
|
|
104
|
+
{
|
|
105
|
+
var consequent_4 = ($$anchor3) => {
|
|
106
|
+
var p_1 = root_6();
|
|
107
|
+
var text_3 = child(p_1, true);
|
|
108
|
+
reset(p_1);
|
|
109
|
+
template_effect(($0) => set_text(text_3, $0), [() => text(get(p).subtitle)]);
|
|
110
|
+
append($$anchor3, p_1);
|
|
111
|
+
};
|
|
112
|
+
if_block(node_5, ($$render) => {
|
|
113
|
+
if (get(p).subtitle)
|
|
114
|
+
$$render(consequent_4);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
var node_6 = sibling(node_5, 2);
|
|
118
|
+
{
|
|
119
|
+
var consequent_5 = ($$anchor3) => {
|
|
120
|
+
var a = root_7();
|
|
121
|
+
var text_4 = child(a, true);
|
|
122
|
+
reset(a);
|
|
123
|
+
template_effect(($0, $1) => {
|
|
124
|
+
set_attribute(a, "href", $0);
|
|
125
|
+
set_text(text_4, $1);
|
|
126
|
+
}, [
|
|
127
|
+
() => text(get(p).actionHref, "#"),
|
|
128
|
+
() => text(get(p).actionLabel)
|
|
129
|
+
]);
|
|
130
|
+
append($$anchor3, a);
|
|
131
|
+
};
|
|
132
|
+
if_block(node_6, ($$render) => {
|
|
133
|
+
if (get(p).actionLabel)
|
|
134
|
+
$$render(consequent_5);
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
reset(header);
|
|
138
|
+
append($$anchor2, header);
|
|
139
|
+
};
|
|
140
|
+
if_block(node, ($$render) => {
|
|
141
|
+
if (get(p).title || get(p).subtitle || get(p).eyebrow)
|
|
142
|
+
$$render(consequent_6);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
var div_1 = sibling(node, 2);
|
|
146
|
+
action(div_1, ($$node, $$action_arg) => renderChildren?.($$node, $$action_arg), () => $$props.ctx);
|
|
147
|
+
reset(section);
|
|
148
|
+
template_effect(($0) => set_attribute(section, "id", $0), [
|
|
149
|
+
() => text(get(p).id ?? $$props.componentName) || undefined
|
|
150
|
+
]);
|
|
151
|
+
append($$anchor, section);
|
|
152
|
+
pop();
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// src/components/entries/section.ts
|
|
156
|
+
register("section", createSvelteRenderer("section", Section), { state: "readable" });
|
|
157
|
+
var section_default = Section;
|
|
158
|
+
export {
|
|
159
|
+
section_default as default,
|
|
160
|
+
Section
|
|
161
|
+
};
|