@mrts/soltw 0.3.1 → 0.3.2
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/dist/cjs/index.js +405 -39
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +399 -42
- package/dist/esm/index.js.map +1 -1
- package/dist/source/Block.jsx +25 -0
- package/dist/source/index.js +5 -1
- package/dist/source/items/Item.jsx +42 -23
- package/dist/source/items/ItemGroup.jsx +62 -0
- package/dist/source/stylers/SVTStyler.js +60 -0
- package/dist/source/stylers/Stylers.js +18 -0
- package/dist/source/stylers/base.styler.js +62 -0
- package/dist/source/stylers/index.js +5 -0
- package/dist/source/stylers/stylersUtils.js +63 -0
- package/dist/source/stylers/tagRules.js +36 -0
- package/dist/source/stylers/utils.js +17 -0
- package/dist/types/Block.d.ts +10 -0
- package/dist/types/index.d.ts +5 -1
- package/dist/types/items/Item.d.ts +4 -3
- package/dist/types/items/ItemGroup.d.ts +21 -0
- package/dist/types/stylers/SVTStyler.d.ts +28 -0
- package/dist/types/stylers/Stylers.d.ts +8 -0
- package/dist/types/stylers/base.styler.d.ts +2 -0
- package/dist/types/stylers/index.d.ts +5 -0
- package/dist/types/stylers/stylersUtils.d.ts +9 -0
- package/dist/types/stylers/tagRules.d.ts +3 -0
- package/dist/types/stylers/types.d.ts +9 -0
- package/dist/types/stylers/utils.d.ts +5 -0
- package/package.json +2 -2
- package/dist/source/items/index.js +0 -2
- package/dist/source/theme/StyleBoxes.js +0 -14
- package/dist/types/items/index.d.ts +0 -2
- package/dist/types/theme/StyleBox.d.ts +0 -6
- package/dist/types/theme/StyleBoxes.d.ts +0 -2
- /package/dist/source/{theme/StyleBox.js → stylers/types.js} +0 -0
|
@@ -1,13 +1,29 @@
|
|
|
1
1
|
import { createMemo, Show } from "solid-js";
|
|
2
2
|
import { twMerge } from "tailwind-merge";
|
|
3
|
+
import { Stylers } from "../stylers/Stylers.js";
|
|
3
4
|
import { buildIdLabel } from "./IdLabel.js";
|
|
4
|
-
import { themeAlpha } from "../theme/StyleBoxes.js";
|
|
5
5
|
export const Item = (props) => {
|
|
6
6
|
const itemData = () => buildIdLabel(props.idLabel);
|
|
7
|
-
const
|
|
8
|
-
|
|
7
|
+
const currentSTags = () => {
|
|
8
|
+
const r = [];
|
|
9
|
+
r.push("item");
|
|
10
|
+
if (props.selected) {
|
|
11
|
+
r.push("item:selected");
|
|
12
|
+
}
|
|
13
|
+
if (props.disabled) {
|
|
14
|
+
r.push("item:disabled");
|
|
15
|
+
}
|
|
16
|
+
return r;
|
|
9
17
|
};
|
|
10
|
-
const
|
|
18
|
+
const currentStyler = () => {
|
|
19
|
+
if (props.styler) {
|
|
20
|
+
return props.styler;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
return Stylers.base;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const classProp = createMemo(() => {
|
|
11
27
|
if (props.class == undefined) {
|
|
12
28
|
return {};
|
|
13
29
|
}
|
|
@@ -19,42 +35,45 @@ export const Item = (props) => {
|
|
|
19
35
|
}
|
|
20
36
|
});
|
|
21
37
|
const itemClasses = createMemo(() => {
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
38
|
+
const stags = currentSTags();
|
|
39
|
+
const styler = currentStyler();
|
|
40
|
+
const rawClasses = [];
|
|
41
|
+
const stylerClasses = styler
|
|
42
|
+
? styler.classes(stags, props.vtags)
|
|
43
|
+
: undefined;
|
|
44
|
+
rawClasses.push(...(stylerClasses ?? []));
|
|
45
|
+
if (props.callback) {
|
|
29
46
|
rawClasses.push("select-none cursor-pointer");
|
|
30
47
|
}
|
|
31
|
-
const customClasses =
|
|
48
|
+
const customClasses = classProp();
|
|
32
49
|
if (customClasses.item) {
|
|
33
50
|
rawClasses.push(customClasses.item);
|
|
34
51
|
}
|
|
35
|
-
if (props.selected) {
|
|
36
|
-
rawClasses.push(
|
|
52
|
+
if (props.selected && customClasses.selected) {
|
|
53
|
+
rawClasses.push(customClasses.selected);
|
|
37
54
|
}
|
|
38
|
-
if (props.disabled) {
|
|
39
|
-
rawClasses.push(
|
|
55
|
+
if (props.disabled && customClasses.disabled) {
|
|
56
|
+
rawClasses.push(customClasses.disabled);
|
|
40
57
|
}
|
|
41
58
|
rawClasses.push("relative");
|
|
42
|
-
const r = twMerge(
|
|
59
|
+
const r = twMerge(rawClasses);
|
|
43
60
|
return r;
|
|
44
61
|
});
|
|
45
62
|
const disablerClasses = createMemo(() => {
|
|
46
63
|
const rawClasses = [];
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
64
|
+
if (currentStyler()) {
|
|
65
|
+
rawClasses.push(...currentStyler().classes("item/disabler", props.vtags));
|
|
66
|
+
}
|
|
67
|
+
if (classProp().disabler) {
|
|
68
|
+
rawClasses.push(classProp().disabler);
|
|
50
69
|
}
|
|
51
70
|
rawClasses.push("absolute inset-0");
|
|
52
|
-
const r = twMerge(
|
|
71
|
+
const r = twMerge(rawClasses);
|
|
53
72
|
return r;
|
|
54
73
|
});
|
|
55
74
|
function handleClick() {
|
|
56
|
-
if (props.
|
|
57
|
-
props.
|
|
75
|
+
if (props.callback != undefined) {
|
|
76
|
+
props.callback(itemData());
|
|
58
77
|
}
|
|
59
78
|
}
|
|
60
79
|
return (<div onClick={handleClick} class={itemClasses()}>
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { twMerge } from "tailwind-merge";
|
|
2
|
+
import { Block } from "../Block.jsx";
|
|
3
|
+
import { Item } from "./Item.js";
|
|
4
|
+
import { buildIdLabel } from "./IdLabel.js";
|
|
5
|
+
import { createMemo, For } from "solid-js";
|
|
6
|
+
import { normalizeTagListArgument } from "../stylers/tagRules.js";
|
|
7
|
+
export const ItemGroup = (props) => {
|
|
8
|
+
const items = () => props.items.map(buildIdLabel);
|
|
9
|
+
const currentVTags = createMemo(() => {
|
|
10
|
+
const item = [];
|
|
11
|
+
const group = [];
|
|
12
|
+
const _vtags = props.vtags;
|
|
13
|
+
if (Array.isArray(_vtags) || typeof _vtags == "string") {
|
|
14
|
+
group.push(...normalizeTagListArgument(_vtags));
|
|
15
|
+
}
|
|
16
|
+
else if (typeof _vtags == "object") {
|
|
17
|
+
group.push(...normalizeTagListArgument(_vtags.group));
|
|
18
|
+
item.push(...normalizeTagListArgument(_vtags.item));
|
|
19
|
+
}
|
|
20
|
+
return { group, item };
|
|
21
|
+
});
|
|
22
|
+
const classes = createMemo(() => {
|
|
23
|
+
let group = "";
|
|
24
|
+
let item = "";
|
|
25
|
+
if (typeof props.class == "string") {
|
|
26
|
+
group = props.class;
|
|
27
|
+
}
|
|
28
|
+
else if (props.class != undefined) {
|
|
29
|
+
props.class;
|
|
30
|
+
group = props.class.group ?? "";
|
|
31
|
+
item = props.class.item ?? "";
|
|
32
|
+
}
|
|
33
|
+
return { group, item };
|
|
34
|
+
});
|
|
35
|
+
const blockClasses = () => {
|
|
36
|
+
return twMerge("flex flex-row gap-1", classes().group);
|
|
37
|
+
};
|
|
38
|
+
const itemClasses = () => {
|
|
39
|
+
return classes().item;
|
|
40
|
+
};
|
|
41
|
+
const callCallback = (item) => {
|
|
42
|
+
if (props.callback) {
|
|
43
|
+
props.callback(item);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const itemSelected = (id) => {
|
|
47
|
+
if (typeof props.selection == "string") {
|
|
48
|
+
return id == props.selection;
|
|
49
|
+
}
|
|
50
|
+
else if (typeof props.selection == "object") {
|
|
51
|
+
return !!props.selection[id];
|
|
52
|
+
}
|
|
53
|
+
return false;
|
|
54
|
+
};
|
|
55
|
+
return (<Block class={blockClasses()} vtags={currentVTags().group}>
|
|
56
|
+
<For each={items()}>
|
|
57
|
+
{(item) => {
|
|
58
|
+
return (<Item idLabel={item} selected={itemSelected(item.id)} callback={() => callCallback(item)} class={itemClasses()} vtags={currentVTags().item}></Item>);
|
|
59
|
+
}}
|
|
60
|
+
</For>
|
|
61
|
+
</Block>);
|
|
62
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { normalizeTagListArgument, tagRuleMatches } from "./tagRules.js";
|
|
2
|
+
import { deduplicate } from "./utils.js";
|
|
3
|
+
export class SVTStyler {
|
|
4
|
+
_rules = [];
|
|
5
|
+
options;
|
|
6
|
+
constructor(rules, options = {}) {
|
|
7
|
+
for (const r of rules) {
|
|
8
|
+
this._rules.push(SVTStyler.normalizeRule(r));
|
|
9
|
+
}
|
|
10
|
+
this.options = { ...options };
|
|
11
|
+
}
|
|
12
|
+
with(rules, options = {}) {
|
|
13
|
+
const addedRules = [];
|
|
14
|
+
for (const r of rules) {
|
|
15
|
+
addedRules.push(SVTStyler.normalizeRule(r));
|
|
16
|
+
}
|
|
17
|
+
const styler = new SVTStyler([], { ...this.options });
|
|
18
|
+
styler._rules.push(...this._rules, ...addedRules);
|
|
19
|
+
return styler;
|
|
20
|
+
}
|
|
21
|
+
classes(stags, vtags) {
|
|
22
|
+
const r = [];
|
|
23
|
+
let stagsNormalized = normalizeTagListArgument(stags);
|
|
24
|
+
let vtagsNormalized = normalizeTagListArgument(vtags);
|
|
25
|
+
if (this.options.stagsNormaliser) {
|
|
26
|
+
stagsNormalized = this.options.stagsNormaliser(stagsNormalized);
|
|
27
|
+
}
|
|
28
|
+
if (this.options.vtagsNormaliser) {
|
|
29
|
+
vtagsNormalized = this.options.vtagsNormaliser(vtagsNormalized);
|
|
30
|
+
}
|
|
31
|
+
for (const rule of this._rules) {
|
|
32
|
+
if (this.ruleMatches(rule, stagsNormalized, vtagsNormalized)) {
|
|
33
|
+
r.push(...rule.classes);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return this.options.normalizer ? this.options.normalizer(r) : r;
|
|
37
|
+
}
|
|
38
|
+
static normalizeRule(rule) {
|
|
39
|
+
let stagMode = rule.stagMode ?? "or";
|
|
40
|
+
let vtagMode = rule.vtagMode ?? "or";
|
|
41
|
+
let stags = deduplicate(normalizeTagListArgument(rule.stags));
|
|
42
|
+
let vtags = deduplicate(normalizeTagListArgument(rule.vtags));
|
|
43
|
+
let classes = deduplicate(normalizeTagListArgument(rule.classes));
|
|
44
|
+
if (rule.stags == undefined && rule.stagMode == undefined) {
|
|
45
|
+
stagMode = "any";
|
|
46
|
+
}
|
|
47
|
+
if (rule.vtags == undefined && rule.vtagMode == undefined) {
|
|
48
|
+
vtagMode = "any";
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
stagRule: { mode: stagMode, tags: stags },
|
|
52
|
+
vtagRule: { mode: vtagMode, tags: vtags },
|
|
53
|
+
classes,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
ruleMatches(rule, stags, vtags) {
|
|
57
|
+
return (tagRuleMatches(rule.stagRule, stags) &&
|
|
58
|
+
tagRuleMatches(rule.vtagRule, vtags));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { baseStyler } from "./base.styler.js";
|
|
2
|
+
export class Stylers {
|
|
3
|
+
static _base;
|
|
4
|
+
static _stylersMap = new Map();
|
|
5
|
+
static get base() {
|
|
6
|
+
return this._base;
|
|
7
|
+
}
|
|
8
|
+
static setBase(base) {
|
|
9
|
+
return (this._base = base);
|
|
10
|
+
}
|
|
11
|
+
static {
|
|
12
|
+
this._stylersMap.set("default", baseStyler);
|
|
13
|
+
this.setBase(baseStyler);
|
|
14
|
+
}
|
|
15
|
+
static get(name) {
|
|
16
|
+
return this._stylersMap.get(name);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { mainTagNormalize, twMergeNormalize, exlusiveTagNormalize, } from "./stylersUtils.js";
|
|
2
|
+
import { SVTStyler } from "./SVTStyler.js";
|
|
3
|
+
export const baseStyler = new SVTStyler([
|
|
4
|
+
{
|
|
5
|
+
vtags: "A",
|
|
6
|
+
classes: "bg-slate-100 text-slate-800",
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
vtags: "B",
|
|
10
|
+
classes: "bg-slate-800 text-slate-100",
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
vtags: "C",
|
|
14
|
+
classes: "bg-stone-300 text-orange-950",
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
vtags: "D",
|
|
18
|
+
classes: "bg-orange-900 text-stone-100",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
vtags: "LG",
|
|
22
|
+
classes: "text-xl p-2",
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
vtags: "BASE",
|
|
26
|
+
classes: "text-base p-1",
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
vtags: "SM",
|
|
30
|
+
classes: "text-sm p-0.5",
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
vtags: "LG",
|
|
34
|
+
stags: "item",
|
|
35
|
+
classes: "text-xl px-2 py-1",
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
vtags: "BASE",
|
|
39
|
+
stags: "item",
|
|
40
|
+
classes: "text-base px-1 py-0.5",
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
vtags: "SM",
|
|
44
|
+
stags: "item",
|
|
45
|
+
classes: "text-sm p-0.5",
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
stags: "item:selected",
|
|
49
|
+
classes: "underline font-bold",
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
stags: "item:disabled",
|
|
53
|
+
classes: "blur-[1px]",
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
stags: "item/disabler",
|
|
57
|
+
classes: "bg-slate-300/85 cursor-not-allowed",
|
|
58
|
+
},
|
|
59
|
+
], {
|
|
60
|
+
normalizer: twMergeNormalize,
|
|
61
|
+
vtagsNormaliser: (tags) => exlusiveTagNormalize(mainTagNormalize(tags, "A"), new Set(["SM", "BASE", "LG"]), "BASE"),
|
|
62
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { twMerge } from "tailwind-merge";
|
|
2
|
+
import { splitCleanString } from "./utils.js";
|
|
3
|
+
export class SVTStylerNormalizer {
|
|
4
|
+
styler;
|
|
5
|
+
constructor(styler) {
|
|
6
|
+
this.styler = styler;
|
|
7
|
+
}
|
|
8
|
+
classes(stags, vtags) {
|
|
9
|
+
const r = this.styler.classes(stags, vtags);
|
|
10
|
+
return r ?? [];
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export function twMergeNormalize(raw) {
|
|
14
|
+
return splitCleanString(twMerge(...raw));
|
|
15
|
+
}
|
|
16
|
+
export function mainTagNormalize(rawTags, defaultTag) {
|
|
17
|
+
const rhead = [];
|
|
18
|
+
const rtail = [];
|
|
19
|
+
let rtag = undefined;
|
|
20
|
+
for (const tag of rawTags) {
|
|
21
|
+
if (tag.length == 1 && tag.toUpperCase() == tag) {
|
|
22
|
+
rtag = tag;
|
|
23
|
+
rhead.push(...rtail);
|
|
24
|
+
rtail.length = 0;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
if (rtag == undefined) {
|
|
28
|
+
rhead.push(tag);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
rtail.push(tag);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
rtag = rtag ?? defaultTag;
|
|
36
|
+
const r = rtag == undefined ? [...rhead, ...rtail] : [...rhead, rtag, ...rtail];
|
|
37
|
+
// console.log("MAIN TAGS NORM:", rawTags, r);
|
|
38
|
+
return r;
|
|
39
|
+
}
|
|
40
|
+
export function exlusiveTagNormalize(rawTags, tagSet, defaultTag) {
|
|
41
|
+
const rhead = [];
|
|
42
|
+
const rtail = [];
|
|
43
|
+
let rtag = undefined;
|
|
44
|
+
for (const tag of rawTags) {
|
|
45
|
+
if (tagSet.has(tag)) {
|
|
46
|
+
rtag = tag;
|
|
47
|
+
rhead.push(...rtail);
|
|
48
|
+
rtail.length = 0;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
if (rtag == undefined) {
|
|
52
|
+
rhead.push(tag);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
rtail.push(tag);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
rtag = rtag ?? defaultTag;
|
|
60
|
+
const r = rtag == undefined ? [...rhead, ...rtail] : [...rhead, rtag, ...rtail];
|
|
61
|
+
//console.log("EXCLU TAGS NORM:", rawTags, r);
|
|
62
|
+
return r;
|
|
63
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { splitCleanString } from "./utils.js";
|
|
2
|
+
export function normalizeTagListArgument(arg) {
|
|
3
|
+
if (typeof arg == "string") {
|
|
4
|
+
return splitCleanString(arg);
|
|
5
|
+
}
|
|
6
|
+
else if (Array.isArray(arg)) {
|
|
7
|
+
const r = [];
|
|
8
|
+
for (const a of arg) {
|
|
9
|
+
r.push(...normalizeTagListArgument(a));
|
|
10
|
+
}
|
|
11
|
+
return r;
|
|
12
|
+
}
|
|
13
|
+
return [];
|
|
14
|
+
}
|
|
15
|
+
export function tagRuleMatches(rule, candidateTags) {
|
|
16
|
+
if (rule.mode == "any") {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
else if (rule.mode == "or") {
|
|
20
|
+
for (const ctag of candidateTags) {
|
|
21
|
+
if (rule.tags.indexOf(ctag) >= 0) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
else if (rule.mode == "and") {
|
|
28
|
+
for (const rtag of rule.tags) {
|
|
29
|
+
if (candidateTags.indexOf(rtag) < 0) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function splitCleanString(s, options = {}) {
|
|
2
|
+
const separator = options.separator ?? /\s+/;
|
|
3
|
+
const filter = options.filter ?? ((s) => s.length > 0);
|
|
4
|
+
const r = s.split(separator).filter(filter);
|
|
5
|
+
return r;
|
|
6
|
+
}
|
|
7
|
+
export function deduplicate(items) {
|
|
8
|
+
const r = [];
|
|
9
|
+
const itemSet = new Set();
|
|
10
|
+
for (const item of items) {
|
|
11
|
+
if (!itemSet.has(item)) {
|
|
12
|
+
r.push(item);
|
|
13
|
+
itemSet.add(item);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return r;
|
|
17
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Component, ParentProps } from "solid-js";
|
|
2
|
+
import { type ISVTStyler, type TagListArgument } from "./stylers/index.js";
|
|
3
|
+
type TProps = ParentProps & {
|
|
4
|
+
vtags?: TagListArgument;
|
|
5
|
+
styler?: ISVTStyler;
|
|
6
|
+
class?: string;
|
|
7
|
+
element?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const Block: Component<TProps>;
|
|
10
|
+
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Component } from "solid-js";
|
|
2
|
+
import { type ISVTStyler, type TagListArgument } from "../stylers/index.js";
|
|
2
3
|
import { type IdLabel, type IdLabelArg } from "./IdLabel.js";
|
|
3
|
-
import type { IStyleBox } from "../theme/StyleBox.js";
|
|
4
4
|
export type TItemClass = {
|
|
5
5
|
item?: string;
|
|
6
6
|
selected?: string;
|
|
@@ -10,11 +10,12 @@ export type TItemClass = {
|
|
|
10
10
|
export type TItemClassArg = TItemClass | string;
|
|
11
11
|
export type TItemProps = {
|
|
12
12
|
idLabel: IdLabelArg;
|
|
13
|
-
|
|
13
|
+
callback?: (item: IdLabel) => void;
|
|
14
14
|
selected?: boolean;
|
|
15
15
|
disabled?: boolean;
|
|
16
16
|
clickableWhendisabled?: boolean;
|
|
17
|
+
styler?: ISVTStyler;
|
|
18
|
+
vtags?: TagListArgument;
|
|
17
19
|
class?: TItemClassArg;
|
|
18
|
-
theme?: IStyleBox;
|
|
19
20
|
};
|
|
20
21
|
export declare const Item: Component<TItemProps>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type TItemClassArg } from "./Item.js";
|
|
2
|
+
import { type IdLabel, type IdLabelArg } from "./IdLabel.js";
|
|
3
|
+
import { type Component } from "solid-js";
|
|
4
|
+
import { type TagListArgument } from "../stylers/types.js";
|
|
5
|
+
type TProps = {
|
|
6
|
+
items: IdLabelArg[];
|
|
7
|
+
callback?: (item: IdLabel) => void;
|
|
8
|
+
class?: string | {
|
|
9
|
+
group?: string;
|
|
10
|
+
item?: TItemClassArg;
|
|
11
|
+
};
|
|
12
|
+
selection?: string | {
|
|
13
|
+
[id: string]: boolean;
|
|
14
|
+
};
|
|
15
|
+
vtags?: TagListArgument | {
|
|
16
|
+
group?: TagListArgument;
|
|
17
|
+
item?: TagListArgument;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export declare const ItemGroup: Component<TProps>;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ISVTStyler, TagListArgument, TagRule, TagRuleMode } from "./types.js";
|
|
2
|
+
export type SVTRule = {
|
|
3
|
+
stagRule: TagRule;
|
|
4
|
+
vtagRule: TagRule;
|
|
5
|
+
classes: string[];
|
|
6
|
+
};
|
|
7
|
+
export type SVTRuleDef = {
|
|
8
|
+
stagMode?: TagRuleMode;
|
|
9
|
+
vtagMode?: TagRuleMode;
|
|
10
|
+
stags?: TagListArgument;
|
|
11
|
+
vtags?: TagListArgument;
|
|
12
|
+
classes?: TagListArgument;
|
|
13
|
+
};
|
|
14
|
+
type SVTStylerOptions = {
|
|
15
|
+
normalizer?: (rawClasses: string[]) => string[];
|
|
16
|
+
stagsNormaliser?: (rawTags: string[]) => string[];
|
|
17
|
+
vtagsNormaliser?: (rawTags: string[]) => string[];
|
|
18
|
+
};
|
|
19
|
+
export declare class SVTStyler implements ISVTStyler {
|
|
20
|
+
readonly _rules: SVTRule[];
|
|
21
|
+
readonly options: SVTStylerOptions;
|
|
22
|
+
constructor(rules: SVTRuleDef[], options?: SVTStylerOptions);
|
|
23
|
+
with(rules: SVTRuleDef[], options?: SVTStylerOptions): SVTStyler;
|
|
24
|
+
classes(stags: TagListArgument, vtags: TagListArgument): string[];
|
|
25
|
+
static normalizeRule(rule: SVTRuleDef): SVTRule;
|
|
26
|
+
ruleMatches(rule: SVTRule, stags: string[], vtags: string[]): boolean;
|
|
27
|
+
}
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ISVTStyler } from "./types.js";
|
|
2
|
+
export declare class Stylers {
|
|
3
|
+
private static _base;
|
|
4
|
+
private static _stylersMap;
|
|
5
|
+
static get base(): ISVTStyler | undefined;
|
|
6
|
+
static setBase(base: ISVTStyler | undefined): ISVTStyler;
|
|
7
|
+
static get(name: string): ISVTStyler | undefined;
|
|
8
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ISVTStyler, TagListArgument } from "./types.js";
|
|
2
|
+
export declare class SVTStylerNormalizer implements ISVTStyler {
|
|
3
|
+
private readonly styler;
|
|
4
|
+
constructor(styler: ISVTStyler);
|
|
5
|
+
classes(stags: TagListArgument, vtags: TagListArgument): string[];
|
|
6
|
+
}
|
|
7
|
+
export declare function twMergeNormalize(raw: string[]): string[];
|
|
8
|
+
export declare function mainTagNormalize(rawTags: string[], defaultTag?: string): string[];
|
|
9
|
+
export declare function exlusiveTagNormalize(rawTags: string[], tagSet: Set<String>, defaultTag?: string): string[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type TagListArgument = string | string[] | TagListArgument[] | undefined;
|
|
2
|
+
export type TagRuleMode = "or" | "and" | "any";
|
|
3
|
+
export type TagRule = {
|
|
4
|
+
mode: TagRuleMode;
|
|
5
|
+
tags: string[];
|
|
6
|
+
};
|
|
7
|
+
export interface ISVTStyler {
|
|
8
|
+
classes(stags: TagListArgument, vtags: TagListArgument): string[] | undefined;
|
|
9
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrts/soltw",
|
|
3
3
|
"description": "S O L T W : SolidJS + tailwindcss ui components",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
7
7
|
"module": "dist/esm/index.js",
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "e08b5c423be3441bea8cf8f2388201a19f2c6146"
|
|
38
38
|
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export const themeAlpha = {
|
|
2
|
-
"block": {
|
|
3
|
-
base: "bg-stone-100 text-stone-900",
|
|
4
|
-
selected: "bg-stone-100 text-orange-800 font-bold",
|
|
5
|
-
disabled: "bg-stone-100 text-stone-600 italic",
|
|
6
|
-
disabler: "bg-white/30"
|
|
7
|
-
},
|
|
8
|
-
"item": {
|
|
9
|
-
base: "bg-orange-900 text-stone-100",
|
|
10
|
-
selected: "bg-orange-800 text-stone-100 font-bold underline",
|
|
11
|
-
disabled: "bg-orange-900 text-stone-300 italic",
|
|
12
|
-
disabler: "bg-white/70"
|
|
13
|
-
},
|
|
14
|
-
};
|
|
File without changes
|