@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
@@ -0,0 +1,13 @@
1
+ import { ISVTStyler, TagListArgument } from "./stylers/types.js";
2
+ import { Component, ParentProps } from "solid-js";
3
+
4
+ //#region src/Block.d.ts
5
+ type TProps = ParentProps & {
6
+ vtags?: TagListArgument;
7
+ styler?: ISVTStyler;
8
+ class?: string;
9
+ element?: string;
10
+ };
11
+ declare const Block: Component<TProps>;
12
+ //#endregion
13
+ export { Block };
package/dist/Block.js ADDED
@@ -0,0 +1,33 @@
1
+ import { createComponent } from "./node_modules/solid-js/dist/solid.js";
2
+ import { Dynamic } from "./node_modules/solid-js/web/dist/web.js";
3
+ import { twMerge } from "./node_modules/tailwind-merge/dist/bundle-mjs.js";
4
+ import { Stylers } from "./stylers/Stylers.js";
5
+ import "./stylers/index.js";
6
+
7
+ //#region src/Block.tsx
8
+ const Block = (props) => {
9
+ const elementTag = () => props.element ?? "div";
10
+ const currentStyler = () => {
11
+ if (props.styler) return props.styler;
12
+ else return Stylers.base;
13
+ };
14
+ function blockClasses() {
15
+ const classes = currentStyler().classes("block", props.vtags) ?? [];
16
+ if (props.class) classes.push(props.class);
17
+ return twMerge(classes);
18
+ }
19
+ return createComponent(Dynamic, {
20
+ get component() {
21
+ return elementTag();
22
+ },
23
+ get ["class"]() {
24
+ return blockClasses();
25
+ },
26
+ get children() {
27
+ return props.children;
28
+ }
29
+ });
30
+ };
31
+
32
+ //#endregion
33
+ export { Block };
package/dist/Block.jsx ADDED
@@ -0,0 +1,24 @@
1
+ import { twMerge } from "./node_modules/tailwind-merge/dist/bundle-mjs.jsx";
2
+ import { Stylers } from "./stylers/Stylers.jsx";
3
+ import { Dynamic } from "./node_modules/solid-js/web/dist/web.jsx";
4
+ import "./stylers/index.jsx";
5
+
6
+ //#region src/Block.tsx
7
+ const Block = (props) => {
8
+ const elementTag = () => props.element ?? "div";
9
+ const currentStyler = () => {
10
+ if (props.styler) return props.styler;
11
+ else return Stylers.base;
12
+ };
13
+ function blockClasses() {
14
+ const classes = currentStyler().classes("block", props.vtags) ?? [];
15
+ if (props.class) classes.push(props.class);
16
+ return twMerge(classes);
17
+ }
18
+ return <Dynamic component={elementTag()} class={blockClasses()}>
19
+ {props.children}
20
+ </Dynamic>;
21
+ };
22
+
23
+ //#endregion
24
+ export { Block };
@@ -0,0 +1,76 @@
1
+ import {
2
+ mainTagNormalize,
3
+ twMergeNormalize,
4
+ exclusiveTagsNormalize,
5
+ } from "./normalizers.js";
6
+ import { SVTStyler } from "./SVTStyler.js";
7
+
8
+
9
+ export const baseStyler = new SVTStyler(
10
+ [
11
+ {
12
+ vtags: "A",
13
+ classes: "bg-slate-100 text-slate-800",
14
+ },
15
+ {
16
+ vtags: "B",
17
+ classes: "bg-slate-800 text-slate-100",
18
+ },
19
+ {
20
+ vtags: "C",
21
+ classes: "bg-stone-300 text-orange-950",
22
+ },
23
+ {
24
+ vtags: "D",
25
+ classes: "bg-orange-900 text-stone-100",
26
+ },
27
+ {
28
+ vtags: "LG",
29
+ classes: "text-xl p-2",
30
+ },
31
+ {
32
+ vtags: "BASE",
33
+ classes: "text-base p-1",
34
+ },
35
+ {
36
+ vtags: "SM",
37
+ classes: "text-sm p-0.5",
38
+ },
39
+ {
40
+ vtags: "LG",
41
+ stags: "item",
42
+ classes: "text-xl px-2 py-1",
43
+ },
44
+ {
45
+ vtags: "BASE",
46
+ stags: "item",
47
+ classes: "text-base px-1 py-0.5",
48
+ },
49
+ {
50
+ vtags: "SM",
51
+ stags: "item",
52
+ classes: "text-sm p-0.5",
53
+ },
54
+ {
55
+ stags: "item:selected",
56
+ classes: "underline font-bold",
57
+ },
58
+ {
59
+ stags: "item:disabled",
60
+ classes: "blur-[1px]",
61
+ },
62
+ {
63
+ stags: "item/disabler",
64
+ classes: "bg-slate-300/85 cursor-not-allowed",
65
+ },
66
+ ],
67
+ {
68
+ normalizer: twMergeNormalize,
69
+ vtagsNormaliser: (tags) =>
70
+ exclusiveTagsNormalize(
71
+ mainTagNormalize(tags, "A"),
72
+ new Set(["SM", "BASE", "LG"]),
73
+ "BASE"
74
+ ),
75
+ }
76
+ );
package/dist/index.d.ts CHANGED
@@ -1,126 +1,11 @@
1
- import { Component, ParentProps } from "solid-js";
2
- import { TokenizeArg } from "@mrts/common";
3
-
4
- //#region src/items/IdLabel.d.ts
5
- interface IdLabel {
6
- id: string;
7
- label: string;
8
- [x: string | symbol]: unknown;
9
- }
10
- type IdLabelDef = {
11
- id: string;
12
- label?: string;
13
- [x: string | symbol]: unknown;
14
- };
15
- type IdLabelArg = IdLabelDef | [string, string] | string;
16
- declare function buildIdLabel(arg: IdLabelArg): IdLabel;
17
- //#endregion
18
- //#region src/stylers/types.d.ts
19
- type TagListArgument = TokenizeArg;
20
- interface ISVTStyler {
21
- classes(stags: TagListArgument, vtags: TagListArgument): string[] | undefined;
22
- }
23
- type TagRuleMode = "or" | "and" | "any";
24
- type TagRule = {
25
- mode: TagRuleMode;
26
- tags: string[];
27
- };
28
- //#endregion
29
- //#region src/stylers/Stylers.d.ts
30
- declare class Stylers {
31
- private static _base;
32
- private static _stylersMap;
33
- static get base(): ISVTStyler | undefined;
34
- static setBase(base: ISVTStyler | undefined): ISVTStyler | undefined;
35
- static get(name: string): ISVTStyler | undefined;
36
- }
37
- //#endregion
38
- //#region src/stylers/normalizers.d.ts
39
- declare function twMergeNormalize(raw: string[]): string[];
40
- declare function mainTagNormalize(rawTags: string[], defaultTag?: string): string[];
41
- declare function exclusiveTagsNormalize(rawTags: string[], tagSet: Set<String> | ((tag: string) => boolean), defaultTag?: string): string[];
42
- //#endregion
43
- //#region src/stylers/SVTStyler.d.ts
44
- type SVTRule = {
45
- stagRule: TagRule;
46
- vtagRule: TagRule;
47
- classes: string[];
48
- };
49
- type SVTRuleDef = {
50
- stagMode?: TagRuleMode;
51
- vtagMode?: TagRuleMode;
52
- stags?: TagListArgument;
53
- vtags?: TagListArgument;
54
- classes?: TagListArgument;
55
- };
56
- type SVTStylerOptions = {
57
- normalizer?: (rawClasses: string[]) => string[];
58
- stagsNormaliser?: (rawTags: string[]) => string[];
59
- vtagsNormaliser?: (rawTags: string[]) => string[];
60
- };
61
- declare class SVTStyler implements ISVTStyler {
62
- readonly _rules: SVTRule[];
63
- readonly options: SVTStylerOptions;
64
- constructor(rules: SVTRuleDef[], options?: SVTStylerOptions);
65
- with(rules: SVTRuleDef[], options?: SVTStylerOptions): SVTStyler;
66
- classes(stags: TagListArgument, vtags: TagListArgument): string[];
67
- static normalizeRule(rule: SVTRuleDef): SVTRule;
68
- ruleMatches(rule: SVTRule, stags: string[], vtags: string[]): boolean;
69
- }
70
- declare function tagRuleMatches(rule: TagRule, candidateTags: string[]): boolean;
71
- //#endregion
72
- //#region src/stylers/base.styler.d.ts
73
- declare const baseStyler: SVTStyler;
74
- //#endregion
75
- //#region src/items/Item.d.ts
76
- type TItemClass = {
77
- item?: string;
78
- selected?: string;
79
- disabled?: string;
80
- disabler?: string;
81
- };
82
- type TItemClassArg = TItemClass | string;
83
- type TItemProps = {
84
- idLabel: IdLabelArg;
85
- callback?: (item: IdLabel) => void;
86
- selected?: boolean;
87
- disabled?: boolean;
88
- clickableWhendisabled?: boolean;
89
- styler?: ISVTStyler;
90
- vtags?: TagListArgument;
91
- class?: TItemClassArg;
92
- };
93
- declare const Item: Component<TItemProps>;
94
- //#endregion
95
- //#region src/Block.d.ts
96
- type TProps$2 = ParentProps & {
97
- vtags?: TagListArgument;
98
- styler?: ISVTStyler;
99
- class?: string;
100
- element?: string;
101
- };
102
- declare const Block: Component<TProps$2>;
103
- //#endregion
104
- //#region src/items/ItemGroup.d.ts
105
- type TProps$1 = {
106
- items: IdLabelArg[];
107
- callback?: (item: IdLabel) => void;
108
- class?: string | {
109
- group?: string;
110
- item?: TItemClassArg;
111
- };
112
- selection?: string | {
113
- [id: string]: boolean;
114
- };
115
- vtags?: TagListArgument | {
116
- group?: TagListArgument;
117
- item?: TagListArgument;
118
- };
119
- };
120
- declare const ItemGroup: Component<TProps$1>;
121
- //#endregion
122
- //#region src/soltw.d.ts
123
- type TProps = {};
124
- declare const SolTw: Component<TProps>;
125
- //#endregion
1
+ import { IdLabel, IdLabelArg, IdLabelDef, buildIdLabel } from "./items/IdLabel.js";
2
+ import { ISVTStyler, TagListArgument, TagRule, TagRuleMode } from "./stylers/types.js";
3
+ import { Stylers } from "./stylers/Stylers.js";
4
+ import { exclusiveTagsNormalize, mainTagNormalize, twMergeNormalize } from "./stylers/normalizers.js";
5
+ import { SVTRule, SVTRuleDef, SVTStyler, tagRuleMatches } from "./stylers/SVTStyler.js";
6
+ import { baseStyler } from "./stylers/base.styler.js";
7
+ import { Item, TItemClass, TItemClassArg, TItemProps } from "./items/Item.js";
8
+ import { Block } from "./Block.js";
9
+ import { ItemGroup } from "./items/ItemGroup.js";
10
+ import { SolTw } from "./soltw.js";
126
11
  export { Block, ISVTStyler, IdLabel, IdLabelArg, IdLabelDef, Item, ItemGroup, SVTRule, SVTRuleDef, SVTStyler, SolTw, Stylers, TItemClass, TItemClassArg, TItemProps, TagListArgument, TagRule, TagRuleMode, baseStyler, buildIdLabel, exclusiveTagsNormalize, mainTagNormalize, tagRuleMatches, twMergeNormalize };
package/dist/index.js CHANGED
@@ -1,415 +1,12 @@
1
- import { Dynamic, className, createComponent, delegateEvents, effect, insert, template } from "solid-js/web";
2
- import { For, Show, createMemo } from "solid-js";
3
- import { twMerge } from "tailwind-merge";
4
- import { argTokenizeBySpaces, deduplicate, tokenizeFilterString } from "@mrts/common";
1
+ import { buildIdLabel } from "./items/IdLabel.js";
2
+ import { exclusiveTagsNormalize, mainTagNormalize, twMergeNormalize } from "./stylers/normalizers.js";
3
+ import { SVTStyler, tagRuleMatches } from "./stylers/SVTStyler.js";
4
+ import { baseStyler } from "./stylers/base.styler.js";
5
+ import { Stylers } from "./stylers/Stylers.js";
6
+ import { Item } from "./items/Item.js";
7
+ import "./stylers/index.js";
8
+ import { Block } from "./Block.js";
9
+ import { ItemGroup } from "./items/ItemGroup.js";
10
+ import { SolTw } from "./soltw.js";
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
- var _tmpl$$1 = /* @__PURE__ */ template(`<div>`);
201
- const Item = (props) => {
202
- const itemData = () => buildIdLabel(props.idLabel);
203
- const currentSTags = () => {
204
- const r = [];
205
- r.push("item");
206
- if (props.selected) r.push("item:selected");
207
- if (props.disabled) r.push("item:disabled");
208
- return r;
209
- };
210
- const currentStyler = () => {
211
- if (props.styler) return props.styler;
212
- else return Stylers.base;
213
- };
214
- const classProp = createMemo(() => {
215
- if (props.class == void 0) return {};
216
- else if (typeof props.class == "string") return { item: props.class };
217
- else return props.class;
218
- });
219
- const itemClasses = createMemo(() => {
220
- const stags = currentSTags();
221
- const styler = currentStyler();
222
- const rawClasses = [];
223
- const stylerClasses = styler ? styler.classes(stags, props.vtags) : void 0;
224
- rawClasses.push(...stylerClasses ?? []);
225
- if (props.callback) rawClasses.push("select-none cursor-pointer");
226
- const customClasses = classProp();
227
- if (customClasses.item) rawClasses.push(customClasses.item);
228
- if (props.selected && customClasses.selected) rawClasses.push(customClasses.selected);
229
- if (props.disabled && customClasses.disabled) rawClasses.push(customClasses.disabled);
230
- rawClasses.push("relative");
231
- return twMerge(rawClasses);
232
- });
233
- const disablerClasses = createMemo(() => {
234
- const rawClasses = [];
235
- if (currentStyler()) rawClasses.push(...currentStyler().classes("item/disabler", props.vtags));
236
- if (classProp().disabler) rawClasses.push(classProp().disabler);
237
- rawClasses.push("absolute inset-0");
238
- return twMerge(rawClasses);
239
- });
240
- function handleClick() {
241
- if (props.callback != void 0) props.callback(itemData());
242
- }
243
- return (() => {
244
- var _el$ = _tmpl$$1();
245
- _el$.$$click = handleClick;
246
- insert(_el$, () => itemData().label, null);
247
- insert(_el$, createComponent(Show, {
248
- get when() {
249
- return props.disabled;
250
- },
251
- get children() {
252
- var _el$2 = _tmpl$$1();
253
- _el$2.$$click = (e) => {
254
- if (!props.clickableWhendisabled) e.stopPropagation();
255
- };
256
- effect(() => className(_el$2, disablerClasses()));
257
- return _el$2;
258
- }
259
- }), null);
260
- effect(() => className(_el$, itemClasses()));
261
- return _el$;
262
- })();
263
- };
264
- delegateEvents(["click"]);
265
-
266
- //#endregion
267
- //#region src/Block.tsx
268
- const Block = (props) => {
269
- const elementTag = () => props.element ?? "div";
270
- const currentStyler = () => {
271
- if (props.styler) return props.styler;
272
- else return Stylers.base;
273
- };
274
- function blockClasses() {
275
- const classes = currentStyler().classes("block", props.vtags) ?? [];
276
- if (props.class) classes.push(props.class);
277
- return twMerge(classes);
278
- }
279
- return createComponent(Dynamic, {
280
- get component() {
281
- return elementTag();
282
- },
283
- get ["class"]() {
284
- return blockClasses();
285
- },
286
- get children() {
287
- return props.children;
288
- }
289
- });
290
- };
291
-
292
- //#endregion
293
- //#region ../common/dist/strings/tokenize.js
294
- function buildTokenizeFuncUsingSplitters(splitters) {
295
- splitters = Array.isArray(splitters) ? splitters : [splitters];
296
- const tokenize = (s) => {
297
- let r = s.split(splitters[0]).filter((t) => t != "" && t != void 0);
298
- for (const splitter of splitters.slice(1)) {
299
- const r0 = [...r];
300
- r = [];
301
- for (const s$1 of r0) r.push(...tokenizeFilterString$1(s$1, {
302
- splitter,
303
- filter: (t) => t != "" && t != void 0
304
- }));
305
- }
306
- return r;
307
- };
308
- return tokenize;
309
- }
310
- function buildArgTokenizeFunc(tokenize) {
311
- const argTokenize = (arg) => {
312
- if (arg == void 0) return [];
313
- else if (Array.isArray(arg)) {
314
- const r = [];
315
- for (const a of arg) r.push(...argTokenize(a));
316
- return r;
317
- } else return tokenize(arg);
318
- };
319
- return argTokenize;
320
- }
321
- const tokenizeBySpaces = buildTokenizeFuncUsingSplitters(/\s+/);
322
- const argTokenizeBySpaces$1 = buildArgTokenizeFunc(tokenizeBySpaces);
323
- function tokenizeFilterString$1(s, options = {}) {
324
- const separator = options.splitter ?? /\s+/;
325
- const filter = options.filter ?? ((s$1) => s$1.length > 0);
326
- return s.split(separator).filter(filter);
327
- }
328
-
329
- //#endregion
330
- //#region src/items/ItemGroup.tsx
331
- const ItemGroup = (props) => {
332
- const items = () => props.items.map(buildIdLabel);
333
- const currentVTags = createMemo(() => {
334
- const item = [];
335
- const group = [];
336
- const _vtags = props.vtags;
337
- if (Array.isArray(_vtags) || typeof _vtags == "string") group.push(...argTokenizeBySpaces$1(_vtags));
338
- else if (typeof _vtags == "object" && _vtags != null) {
339
- group.push(...argTokenizeBySpaces$1(_vtags.group));
340
- item.push(...argTokenizeBySpaces$1(_vtags.item));
341
- }
342
- return {
343
- group,
344
- item
345
- };
346
- });
347
- const classes = createMemo(() => {
348
- let group = "";
349
- let item = "";
350
- if (typeof props.class == "string") group = props.class;
351
- else if (props.class != void 0) {
352
- props.class;
353
- group = props.class.group ?? "";
354
- item = props.class.item ?? "";
355
- }
356
- return {
357
- group,
358
- item
359
- };
360
- });
361
- const blockClasses = () => {
362
- return twMerge("flex flex-row gap-1", classes().group);
363
- };
364
- const itemClasses = () => {
365
- return classes().item;
366
- };
367
- const callCallback = (item) => {
368
- if (props.callback) props.callback(item);
369
- };
370
- const itemSelected = (id) => {
371
- if (typeof props.selection == "string") return id == props.selection;
372
- else if (typeof props.selection == "object") return !!props.selection[id];
373
- return false;
374
- };
375
- return createComponent(Block, {
376
- get ["class"]() {
377
- return blockClasses();
378
- },
379
- get vtags() {
380
- return currentVTags().group;
381
- },
382
- get children() {
383
- return createComponent(For, {
384
- get each() {
385
- return items();
386
- },
387
- children: (item) => {
388
- return createComponent(Item, {
389
- idLabel: item,
390
- get selected() {
391
- return itemSelected(item.id);
392
- },
393
- callback: () => callCallback(item),
394
- get ["class"]() {
395
- return itemClasses();
396
- },
397
- get vtags() {
398
- return currentVTags().item;
399
- }
400
- });
401
- }
402
- });
403
- }
404
- });
405
- };
406
-
407
- //#endregion
408
- //#region src/soltw.tsx
409
- var _tmpl$ = /* @__PURE__ */ template(`<div class=bg-red-600>- - S O L T W - -`);
410
- const SolTw = (props) => {
411
- return _tmpl$();
412
- };
413
-
414
- //#endregion
415
12
  export { Block, Item, ItemGroup, SVTStyler, SolTw, Stylers, baseStyler, buildIdLabel, exclusiveTagsNormalize, mainTagNormalize, tagRuleMatches, twMergeNormalize };