@mrts/soltw 0.3.10 → 0.3.13

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.
Files changed (51) hide show
  1. package/dist/Block.d.ts +13 -0
  2. package/dist/Block.js +33 -0
  3. package/dist/Block.jsx +24 -0
  4. package/dist/_tw_styles.ts +76 -0
  5. package/dist/index.d.ts +10 -125
  6. package/dist/index.js +10 -413
  7. package/dist/index.jsx +10 -367
  8. package/dist/items/IdLabel.d.ts +15 -0
  9. package/dist/items/IdLabel.js +19 -0
  10. package/dist/items/IdLabel.jsx +19 -0
  11. package/dist/items/Item.d.ts +25 -0
  12. package/dist/items/Item.js +75 -0
  13. package/dist/items/Item.jsx +60 -0
  14. package/dist/items/ItemGroup.d.ts +24 -0
  15. package/dist/items/ItemGroup.js +86 -0
  16. package/dist/items/ItemGroup.jsx +63 -0
  17. package/dist/node_modules/solid-js/dist/solid.js +677 -0
  18. package/dist/node_modules/solid-js/dist/solid.jsx +654 -0
  19. package/dist/node_modules/solid-js/web/dist/web.js +694 -0
  20. package/dist/node_modules/solid-js/web/dist/web.jsx +678 -0
  21. package/dist/node_modules/tailwind-merge/dist/bundle-mjs.js +1893 -0
  22. package/dist/node_modules/tailwind-merge/dist/bundle-mjs.jsx +1893 -0
  23. package/dist/packages/common/dist/index.js +4 -0
  24. package/dist/packages/common/dist/index.jsx +4 -0
  25. package/dist/packages/common/dist/messages/index.js +1 -0
  26. package/dist/packages/common/dist/messages/index.jsx +1 -0
  27. package/dist/packages/common/dist/messages/logMessages.js +14 -0
  28. package/dist/packages/common/dist/messages/logMessages.jsx +14 -0
  29. package/dist/packages/common/dist/strings/index.js +1 -0
  30. package/dist/packages/common/dist/strings/index.jsx +1 -0
  31. package/dist/packages/common/dist/strings/tokenize.js +47 -0
  32. package/dist/packages/common/dist/strings/tokenize.jsx +47 -0
  33. package/dist/soltw.d.ts +7 -0
  34. package/dist/soltw.js +10 -0
  35. package/dist/soltw.jsx +7 -0
  36. package/dist/stylers/SVTStyler.d.ts +32 -0
  37. package/dist/stylers/SVTStyler.js +65 -0
  38. package/dist/stylers/SVTStyler.jsx +65 -0
  39. package/dist/stylers/Stylers.d.ts +12 -0
  40. package/dist/stylers/Stylers.js +23 -0
  41. package/dist/stylers/Stylers.jsx +23 -0
  42. package/dist/stylers/base.styler.d.ts +6 -0
  43. package/dist/stylers/base.styler.js +71 -0
  44. package/dist/stylers/base.styler.jsx +71 -0
  45. package/dist/stylers/index.js +4 -0
  46. package/dist/stylers/index.jsx +4 -0
  47. package/dist/stylers/normalizers.d.ts +6 -0
  48. package/dist/stylers/normalizers.js +32 -0
  49. package/dist/stylers/normalizers.jsx +32 -0
  50. package/dist/stylers/types.d.ts +14 -0
  51. package/package.json +6 -8
package/dist/index.jsx CHANGED
@@ -1,369 +1,12 @@
1
- import { For, Show, createMemo } from "solid-js";
2
- import { twMerge } from "tailwind-merge";
3
- import { argTokenizeBySpaces, deduplicate, tokenizeFilterString } from "@mrts/common";
4
- import { Dynamic } from "solid-js/web";
1
+ import { buildIdLabel } from "./items/IdLabel.jsx";
2
+ import { exclusiveTagsNormalize, mainTagNormalize, twMergeNormalize } from "./stylers/normalizers.jsx";
3
+ import { SVTStyler, tagRuleMatches } from "./stylers/SVTStyler.jsx";
4
+ import { baseStyler } from "./stylers/base.styler.jsx";
5
+ import { Stylers } from "./stylers/Stylers.jsx";
6
+ import { Item } from "./items/Item.jsx";
7
+ import "./stylers/index.jsx";
8
+ import { Block } from "./Block.jsx";
9
+ import { ItemGroup } from "./items/ItemGroup.jsx";
10
+ import { SolTw } from "./soltw.jsx";
5
11
 
6
- //#region src/items/IdLabel.ts
7
- function buildIdLabel(arg) {
8
- if (typeof arg == "string") return {
9
- id: arg,
10
- label: arg
11
- };
12
- else if (Array.isArray(arg)) return {
13
- id: arg[0],
14
- label: arg[1]
15
- };
16
- else {
17
- const r = Object.assign({}, arg);
18
- if (r.label == void 0) r["label"] = r.id;
19
- return r;
20
- }
21
- }
22
-
23
- //#endregion
24
- //#region src/stylers/normalizers.ts
25
- function twMergeNormalize(raw) {
26
- return tokenizeFilterString(twMerge(...raw));
27
- }
28
- function mainTagNormalize(rawTags, defaultTag) {
29
- return exclusiveTagsNormalize(rawTags, (tag) => tag.length == 1 && tag.toUpperCase() == tag, defaultTag);
30
- }
31
- function exclusiveTagsNormalize(rawTags, tagSet, defaultTag) {
32
- const rhead = [];
33
- const rtail = [];
34
- let rtag = void 0;
35
- const tagSetFunc = typeof tagSet == "function" ? tagSet : (tag) => tagSet.has(tag);
36
- for (const tag of rawTags) if (tagSetFunc(tag)) {
37
- rtag = tag;
38
- rhead.push(...rtail);
39
- rtail.length = 0;
40
- } else if (rtag == void 0) rhead.push(tag);
41
- else rtail.push(tag);
42
- rtag = rtag ?? defaultTag;
43
- return rtag == void 0 ? [...rhead, ...rtail] : [
44
- ...rhead,
45
- rtag,
46
- ...rtail
47
- ];
48
- }
49
-
50
- //#endregion
51
- //#region src/stylers/SVTStyler.ts
52
- var SVTStyler = class SVTStyler {
53
- _rules = [];
54
- options;
55
- constructor(rules, options = {}) {
56
- for (const r of rules) this._rules.push(SVTStyler.normalizeRule(r));
57
- this.options = { ...options };
58
- }
59
- with(rules, options = {}) {
60
- const addedRules = [];
61
- for (const r of rules) addedRules.push(SVTStyler.normalizeRule(r));
62
- const styler = new SVTStyler([], { ...this.options });
63
- styler._rules.push(...this._rules, ...addedRules);
64
- return styler;
65
- }
66
- classes(stags, vtags) {
67
- const r = [];
68
- let stagsNormalized = argTokenizeBySpaces(stags);
69
- let vtagsNormalized = argTokenizeBySpaces(vtags);
70
- if (this.options.stagsNormaliser) stagsNormalized = this.options.stagsNormaliser(stagsNormalized);
71
- if (this.options.vtagsNormaliser) vtagsNormalized = this.options.vtagsNormaliser(vtagsNormalized);
72
- for (const rule of this._rules) if (this.ruleMatches(rule, stagsNormalized, vtagsNormalized)) r.push(...rule.classes);
73
- return this.options.normalizer ? this.options.normalizer(r) : r;
74
- }
75
- static normalizeRule(rule) {
76
- let stagMode = rule.stagMode ?? "or";
77
- let vtagMode = rule.vtagMode ?? "or";
78
- let stags = deduplicate(argTokenizeBySpaces(rule.stags));
79
- let vtags = deduplicate(argTokenizeBySpaces(rule.vtags));
80
- let classes = deduplicate(argTokenizeBySpaces(rule.classes));
81
- if (rule.stags == void 0 && rule.stagMode == void 0) stagMode = "any";
82
- if (rule.vtags == void 0 && rule.vtagMode == void 0) vtagMode = "any";
83
- return {
84
- stagRule: {
85
- mode: stagMode,
86
- tags: stags
87
- },
88
- vtagRule: {
89
- mode: vtagMode,
90
- tags: vtags
91
- },
92
- classes
93
- };
94
- }
95
- ruleMatches(rule, stags, vtags) {
96
- return tagRuleMatches(rule.stagRule, stags) && tagRuleMatches(rule.vtagRule, vtags);
97
- }
98
- };
99
- function tagRuleMatches(rule, candidateTags) {
100
- if (rule.mode == "any") return true;
101
- else if (rule.mode == "or") {
102
- for (const ctag of candidateTags) if (rule.tags.indexOf(ctag) >= 0) return true;
103
- return false;
104
- } else if (rule.mode == "and") {
105
- for (const rtag of rule.tags) if (candidateTags.indexOf(rtag) < 0) return false;
106
- return true;
107
- }
108
- return false;
109
- }
110
-
111
- //#endregion
112
- //#region src/stylers/base.styler.ts
113
- const baseStyler = new SVTStyler([
114
- {
115
- vtags: "A",
116
- classes: "bg-slate-100 text-slate-800"
117
- },
118
- {
119
- vtags: "B",
120
- classes: "bg-slate-800 text-slate-100"
121
- },
122
- {
123
- vtags: "C",
124
- classes: "bg-stone-300 text-orange-950"
125
- },
126
- {
127
- vtags: "D",
128
- classes: "bg-orange-900 text-stone-100"
129
- },
130
- {
131
- vtags: "LG",
132
- classes: "text-xl p-2"
133
- },
134
- {
135
- vtags: "BASE",
136
- classes: "text-base p-1"
137
- },
138
- {
139
- vtags: "SM",
140
- classes: "text-sm p-0.5"
141
- },
142
- {
143
- vtags: "LG",
144
- stags: "item",
145
- classes: "text-xl px-2 py-1"
146
- },
147
- {
148
- vtags: "BASE",
149
- stags: "item",
150
- classes: "text-base px-1 py-0.5"
151
- },
152
- {
153
- vtags: "SM",
154
- stags: "item",
155
- classes: "text-sm p-0.5"
156
- },
157
- {
158
- stags: "item:selected",
159
- classes: "underline font-bold"
160
- },
161
- {
162
- stags: "item:disabled",
163
- classes: "blur-[1px]"
164
- },
165
- {
166
- stags: "item/disabler",
167
- classes: "bg-slate-300/85 cursor-not-allowed"
168
- }
169
- ], {
170
- normalizer: twMergeNormalize,
171
- vtagsNormaliser: (tags) => exclusiveTagsNormalize(mainTagNormalize(tags, "A"), new Set([
172
- "SM",
173
- "BASE",
174
- "LG"
175
- ]), "BASE")
176
- });
177
-
178
- //#endregion
179
- //#region src/stylers/Stylers.ts
180
- var Stylers = class {
181
- static _base;
182
- static _stylersMap = /* @__PURE__ */ new Map();
183
- static get base() {
184
- return this._base;
185
- }
186
- static setBase(base) {
187
- return this._base = base;
188
- }
189
- static {
190
- this._stylersMap.set("default", baseStyler);
191
- this.setBase(baseStyler);
192
- }
193
- static get(name) {
194
- return this._stylersMap.get(name);
195
- }
196
- };
197
-
198
- //#endregion
199
- //#region src/items/Item.tsx
200
- const Item = (props) => {
201
- const itemData = () => buildIdLabel(props.idLabel);
202
- const currentSTags = () => {
203
- const r = [];
204
- r.push("item");
205
- if (props.selected) r.push("item:selected");
206
- if (props.disabled) r.push("item:disabled");
207
- return r;
208
- };
209
- const currentStyler = () => {
210
- if (props.styler) return props.styler;
211
- else return Stylers.base;
212
- };
213
- const classProp = createMemo(() => {
214
- if (props.class == void 0) return {};
215
- else if (typeof props.class == "string") return { item: props.class };
216
- else return props.class;
217
- });
218
- const itemClasses = createMemo(() => {
219
- const stags = currentSTags();
220
- const styler = currentStyler();
221
- const rawClasses = [];
222
- const stylerClasses = styler ? styler.classes(stags, props.vtags) : void 0;
223
- rawClasses.push(...stylerClasses ?? []);
224
- if (props.callback) rawClasses.push("select-none cursor-pointer");
225
- const customClasses = classProp();
226
- if (customClasses.item) rawClasses.push(customClasses.item);
227
- if (props.selected && customClasses.selected) rawClasses.push(customClasses.selected);
228
- if (props.disabled && customClasses.disabled) rawClasses.push(customClasses.disabled);
229
- rawClasses.push("relative");
230
- return twMerge(rawClasses);
231
- });
232
- const disablerClasses = createMemo(() => {
233
- const rawClasses = [];
234
- if (currentStyler()) rawClasses.push(...currentStyler().classes("item/disabler", props.vtags));
235
- if (classProp().disabler) rawClasses.push(classProp().disabler);
236
- rawClasses.push("absolute inset-0");
237
- return twMerge(rawClasses);
238
- });
239
- function handleClick() {
240
- if (props.callback != void 0) props.callback(itemData());
241
- }
242
- return <div onClick={handleClick} class={itemClasses()}>
243
- {itemData().label}
244
- <Show when={props.disabled}>
245
- <div class={disablerClasses()} onClick={(e) => {
246
- if (!props.clickableWhendisabled) e.stopPropagation();
247
- }}></div>
248
- </Show>
249
- </div>;
250
- };
251
-
252
- //#endregion
253
- //#region src/Block.tsx
254
- const Block = (props) => {
255
- const elementTag = () => props.element ?? "div";
256
- const currentStyler = () => {
257
- if (props.styler) return props.styler;
258
- else return Stylers.base;
259
- };
260
- function blockClasses() {
261
- const classes = currentStyler().classes("block", props.vtags) ?? [];
262
- if (props.class) classes.push(props.class);
263
- return twMerge(classes);
264
- }
265
- return <Dynamic component={elementTag()} class={blockClasses()}>
266
- {props.children}
267
- </Dynamic>;
268
- };
269
-
270
- //#endregion
271
- //#region ../common/dist/strings/tokenize.js
272
- function buildTokenizeFuncUsingSplitters(splitters) {
273
- splitters = Array.isArray(splitters) ? splitters : [splitters];
274
- const tokenize = (s) => {
275
- let r = s.split(splitters[0]).filter((t) => t != "" && t != void 0);
276
- for (const splitter of splitters.slice(1)) {
277
- const r0 = [...r];
278
- r = [];
279
- for (const s$1 of r0) r.push(...tokenizeFilterString$1(s$1, {
280
- splitter,
281
- filter: (t) => t != "" && t != void 0
282
- }));
283
- }
284
- return r;
285
- };
286
- return tokenize;
287
- }
288
- function buildArgTokenizeFunc(tokenize) {
289
- const argTokenize = (arg) => {
290
- if (arg == void 0) return [];
291
- else if (Array.isArray(arg)) {
292
- const r = [];
293
- for (const a of arg) r.push(...argTokenize(a));
294
- return r;
295
- } else return tokenize(arg);
296
- };
297
- return argTokenize;
298
- }
299
- const tokenizeBySpaces = buildTokenizeFuncUsingSplitters(/\s+/);
300
- const argTokenizeBySpaces$1 = buildArgTokenizeFunc(tokenizeBySpaces);
301
- function tokenizeFilterString$1(s, options = {}) {
302
- const separator = options.splitter ?? /\s+/;
303
- const filter = options.filter ?? ((s$1) => s$1.length > 0);
304
- return s.split(separator).filter(filter);
305
- }
306
-
307
- //#endregion
308
- //#region src/items/ItemGroup.tsx
309
- const ItemGroup = (props) => {
310
- const items = () => props.items.map(buildIdLabel);
311
- const currentVTags = createMemo(() => {
312
- const item = [];
313
- const group = [];
314
- const _vtags = props.vtags;
315
- if (Array.isArray(_vtags) || typeof _vtags == "string") group.push(...argTokenizeBySpaces$1(_vtags));
316
- else if (typeof _vtags == "object" && _vtags != null) {
317
- group.push(...argTokenizeBySpaces$1(_vtags.group));
318
- item.push(...argTokenizeBySpaces$1(_vtags.item));
319
- }
320
- return {
321
- group,
322
- item
323
- };
324
- });
325
- const classes = createMemo(() => {
326
- let group = "";
327
- let item = "";
328
- if (typeof props.class == "string") group = props.class;
329
- else if (props.class != void 0) {
330
- props.class;
331
- group = props.class.group ?? "";
332
- item = props.class.item ?? "";
333
- }
334
- return {
335
- group,
336
- item
337
- };
338
- });
339
- const blockClasses = () => {
340
- return twMerge("flex flex-row gap-1", classes().group);
341
- };
342
- const itemClasses = () => {
343
- return classes().item;
344
- };
345
- const callCallback = (item) => {
346
- if (props.callback) props.callback(item);
347
- };
348
- const itemSelected = (id) => {
349
- if (typeof props.selection == "string") return id == props.selection;
350
- else if (typeof props.selection == "object") return !!props.selection[id];
351
- return false;
352
- };
353
- return <Block class={blockClasses()} vtags={currentVTags().group}>
354
- <For each={items()}>
355
- {(item) => {
356
- return <Item idLabel={item} selected={itemSelected(item.id)} callback={() => callCallback(item)} class={itemClasses()} vtags={currentVTags().item}></Item>;
357
- }}
358
- </For>
359
- </Block>;
360
- };
361
-
362
- //#endregion
363
- //#region src/soltw.tsx
364
- const SolTw = (props) => {
365
- return <div class="bg-red-600">- - S O L T W - -</div>;
366
- };
367
-
368
- //#endregion
369
12
  export { Block, Item, ItemGroup, SVTStyler, SolTw, Stylers, baseStyler, buildIdLabel, exclusiveTagsNormalize, mainTagNormalize, tagRuleMatches, twMergeNormalize };
@@ -0,0 +1,15 @@
1
+ //#region src/items/IdLabel.d.ts
2
+ interface IdLabel {
3
+ id: string;
4
+ label: string;
5
+ [x: string | symbol]: unknown;
6
+ }
7
+ type IdLabelDef = {
8
+ id: string;
9
+ label?: string;
10
+ [x: string | symbol]: unknown;
11
+ };
12
+ type IdLabelArg = IdLabelDef | [string, string] | string;
13
+ declare function buildIdLabel(arg: IdLabelArg): IdLabel;
14
+ //#endregion
15
+ export { IdLabel, IdLabelArg, IdLabelDef, buildIdLabel };
@@ -0,0 +1,19 @@
1
+ //#region src/items/IdLabel.ts
2
+ function buildIdLabel(arg) {
3
+ if (typeof arg == "string") return {
4
+ id: arg,
5
+ label: arg
6
+ };
7
+ else if (Array.isArray(arg)) return {
8
+ id: arg[0],
9
+ label: arg[1]
10
+ };
11
+ else {
12
+ const r = Object.assign({}, arg);
13
+ if (r.label == void 0) r["label"] = r.id;
14
+ return r;
15
+ }
16
+ }
17
+
18
+ //#endregion
19
+ export { buildIdLabel };
@@ -0,0 +1,19 @@
1
+ //#region src/items/IdLabel.ts
2
+ function buildIdLabel(arg) {
3
+ if (typeof arg == "string") return {
4
+ id: arg,
5
+ label: arg
6
+ };
7
+ else if (Array.isArray(arg)) return {
8
+ id: arg[0],
9
+ label: arg[1]
10
+ };
11
+ else {
12
+ const r = Object.assign({}, arg);
13
+ if (r.label == void 0) r["label"] = r.id;
14
+ return r;
15
+ }
16
+ }
17
+
18
+ //#endregion
19
+ export { buildIdLabel };
@@ -0,0 +1,25 @@
1
+ import { IdLabel, IdLabelArg } from "./IdLabel.js";
2
+ import { ISVTStyler, TagListArgument } from "../stylers/types.js";
3
+ import { Component } from "solid-js";
4
+
5
+ //#region src/items/Item.d.ts
6
+ type TItemClass = {
7
+ item?: string;
8
+ selected?: string;
9
+ disabled?: string;
10
+ disabler?: string;
11
+ };
12
+ type TItemClassArg = TItemClass | string;
13
+ type TItemProps = {
14
+ idLabel: IdLabelArg;
15
+ callback?: (item: IdLabel) => void;
16
+ selected?: boolean;
17
+ disabled?: boolean;
18
+ clickableWhendisabled?: boolean;
19
+ styler?: ISVTStyler;
20
+ vtags?: TagListArgument;
21
+ class?: TItemClassArg;
22
+ };
23
+ declare const Item: Component<TItemProps>;
24
+ //#endregion
25
+ export { Item, TItemClass, TItemClassArg, TItemProps };
@@ -0,0 +1,75 @@
1
+ import { buildIdLabel } from "./IdLabel.js";
2
+ import { Show, createComponent, createMemo, createRenderEffect } from "../node_modules/solid-js/dist/solid.js";
3
+ import { className, delegateEvents, insert, template } from "../node_modules/solid-js/web/dist/web.js";
4
+ import { twMerge } from "../node_modules/tailwind-merge/dist/bundle-mjs.js";
5
+ import { Stylers } from "../stylers/Stylers.js";
6
+
7
+ //#region src/items/Item.tsx
8
+ var _tmpl$ = /* @__PURE__ */ template(`<div>`);
9
+ const Item = (props) => {
10
+ const itemData = () => buildIdLabel(props.idLabel);
11
+ const currentSTags = () => {
12
+ const r = [];
13
+ r.push("item");
14
+ if (props.selected) r.push("item:selected");
15
+ if (props.disabled) r.push("item:disabled");
16
+ return r;
17
+ };
18
+ const currentStyler = () => {
19
+ if (props.styler) return props.styler;
20
+ else return Stylers.base;
21
+ };
22
+ const classProp = createMemo(() => {
23
+ if (props.class == void 0) return {};
24
+ else if (typeof props.class == "string") return { item: props.class };
25
+ else return props.class;
26
+ });
27
+ const itemClasses = createMemo(() => {
28
+ const stags = currentSTags();
29
+ const styler = currentStyler();
30
+ const rawClasses = [];
31
+ const stylerClasses = styler ? styler.classes(stags, props.vtags) : void 0;
32
+ rawClasses.push(...stylerClasses ?? []);
33
+ if (props.callback) rawClasses.push("select-none cursor-pointer");
34
+ const customClasses = classProp();
35
+ if (customClasses.item) rawClasses.push(customClasses.item);
36
+ if (props.selected && customClasses.selected) rawClasses.push(customClasses.selected);
37
+ if (props.disabled && customClasses.disabled) rawClasses.push(customClasses.disabled);
38
+ rawClasses.push("relative");
39
+ return twMerge(rawClasses);
40
+ });
41
+ const disablerClasses = createMemo(() => {
42
+ const rawClasses = [];
43
+ if (currentStyler()) rawClasses.push(...currentStyler().classes("item/disabler", props.vtags));
44
+ if (classProp().disabler) rawClasses.push(classProp().disabler);
45
+ rawClasses.push("absolute inset-0");
46
+ return twMerge(rawClasses);
47
+ });
48
+ function handleClick() {
49
+ if (props.callback != void 0) props.callback(itemData());
50
+ }
51
+ return (() => {
52
+ var _el$ = _tmpl$();
53
+ _el$.$$click = handleClick;
54
+ insert(_el$, () => itemData().label, null);
55
+ insert(_el$, createComponent(Show, {
56
+ get when() {
57
+ return props.disabled;
58
+ },
59
+ get children() {
60
+ var _el$2 = _tmpl$();
61
+ _el$2.$$click = (e) => {
62
+ if (!props.clickableWhendisabled) e.stopPropagation();
63
+ };
64
+ createRenderEffect(() => className(_el$2, disablerClasses()));
65
+ return _el$2;
66
+ }
67
+ }), null);
68
+ createRenderEffect(() => className(_el$, itemClasses()));
69
+ return _el$;
70
+ })();
71
+ };
72
+ delegateEvents(["click"]);
73
+
74
+ //#endregion
75
+ export { Item };
@@ -0,0 +1,60 @@
1
+ import { buildIdLabel } from "./IdLabel.jsx";
2
+ import { Show, createMemo } from "../node_modules/solid-js/dist/solid.jsx";
3
+ import { twMerge } from "../node_modules/tailwind-merge/dist/bundle-mjs.jsx";
4
+ import { Stylers } from "../stylers/Stylers.jsx";
5
+
6
+ //#region src/items/Item.tsx
7
+ const Item = (props) => {
8
+ const itemData = () => buildIdLabel(props.idLabel);
9
+ const currentSTags = () => {
10
+ const r = [];
11
+ r.push("item");
12
+ if (props.selected) r.push("item:selected");
13
+ if (props.disabled) r.push("item:disabled");
14
+ return r;
15
+ };
16
+ const currentStyler = () => {
17
+ if (props.styler) return props.styler;
18
+ else return Stylers.base;
19
+ };
20
+ const classProp = createMemo(() => {
21
+ if (props.class == void 0) return {};
22
+ else if (typeof props.class == "string") return { item: props.class };
23
+ else return props.class;
24
+ });
25
+ const itemClasses = createMemo(() => {
26
+ const stags = currentSTags();
27
+ const styler = currentStyler();
28
+ const rawClasses = [];
29
+ const stylerClasses = styler ? styler.classes(stags, props.vtags) : void 0;
30
+ rawClasses.push(...stylerClasses ?? []);
31
+ if (props.callback) rawClasses.push("select-none cursor-pointer");
32
+ const customClasses = classProp();
33
+ if (customClasses.item) rawClasses.push(customClasses.item);
34
+ if (props.selected && customClasses.selected) rawClasses.push(customClasses.selected);
35
+ if (props.disabled && customClasses.disabled) rawClasses.push(customClasses.disabled);
36
+ rawClasses.push("relative");
37
+ return twMerge(rawClasses);
38
+ });
39
+ const disablerClasses = createMemo(() => {
40
+ const rawClasses = [];
41
+ if (currentStyler()) rawClasses.push(...currentStyler().classes("item/disabler", props.vtags));
42
+ if (classProp().disabler) rawClasses.push(classProp().disabler);
43
+ rawClasses.push("absolute inset-0");
44
+ return twMerge(rawClasses);
45
+ });
46
+ function handleClick() {
47
+ if (props.callback != void 0) props.callback(itemData());
48
+ }
49
+ return <div onClick={handleClick} class={itemClasses()}>
50
+ {itemData().label}
51
+ <Show when={props.disabled}>
52
+ <div class={disablerClasses()} onClick={(e) => {
53
+ if (!props.clickableWhendisabled) e.stopPropagation();
54
+ }}></div>
55
+ </Show>
56
+ </div>;
57
+ };
58
+
59
+ //#endregion
60
+ export { Item };
@@ -0,0 +1,24 @@
1
+ import { IdLabel, IdLabelArg } from "./IdLabel.js";
2
+ import { TagListArgument } from "../stylers/types.js";
3
+ import { TItemClassArg } from "./Item.js";
4
+ import { Component } from "solid-js";
5
+
6
+ //#region src/items/ItemGroup.d.ts
7
+ type TProps = {
8
+ items: IdLabelArg[];
9
+ callback?: (item: IdLabel) => void;
10
+ class?: string | {
11
+ group?: string;
12
+ item?: TItemClassArg;
13
+ };
14
+ selection?: string | {
15
+ [id: string]: boolean;
16
+ };
17
+ vtags?: TagListArgument | {
18
+ group?: TagListArgument;
19
+ item?: TagListArgument;
20
+ };
21
+ };
22
+ declare const ItemGroup: Component<TProps>;
23
+ //#endregion
24
+ export { ItemGroup };