@mrts/soltw 0.3.0 → 0.3.1
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 +118 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +118 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/source/index.js +1 -0
- package/dist/source/items/IdLabel.js +15 -0
- package/dist/source/items/Item.jsx +70 -0
- package/dist/source/items/index.js +2 -0
- package/dist/source/theme/StyleBox.js +1 -0
- package/dist/source/theme/StyleBoxes.js +14 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/items/IdLabel.d.ts +12 -0
- package/dist/types/items/Item.d.ts +20 -0
- package/dist/types/items/index.d.ts +2 -0
- package/dist/types/theme/StyleBox.d.ts +6 -0
- package/dist/types/theme/StyleBoxes.d.ts +2 -0
- package/package.json +2 -2
package/dist/cjs/index.js
CHANGED
|
@@ -1,11 +1,127 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var web = require('solid-js/web');
|
|
4
|
+
var solidJs = require('solid-js');
|
|
5
|
+
var tailwindMerge = require('tailwind-merge');
|
|
4
6
|
|
|
5
|
-
var _tmpl
|
|
7
|
+
var _tmpl$$1 = /*#__PURE__*/web.template(`<div class=bg-red-600>- - S O L T W - -`);
|
|
6
8
|
const SolTw = props => {
|
|
7
|
-
return _tmpl
|
|
9
|
+
return _tmpl$$1();
|
|
8
10
|
};
|
|
9
11
|
|
|
12
|
+
function buildIdLabel(arg) {
|
|
13
|
+
if (typeof arg == "string") {
|
|
14
|
+
return {
|
|
15
|
+
id: arg,
|
|
16
|
+
label: arg
|
|
17
|
+
};
|
|
18
|
+
} else if (Array.isArray(arg)) {
|
|
19
|
+
return {
|
|
20
|
+
id: arg[0],
|
|
21
|
+
label: arg[1]
|
|
22
|
+
};
|
|
23
|
+
} else {
|
|
24
|
+
const r = Object.assign({}, arg);
|
|
25
|
+
if (r.label == undefined) {
|
|
26
|
+
r["label"] = r.id;
|
|
27
|
+
}
|
|
28
|
+
return r;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const themeAlpha = {
|
|
33
|
+
"item": {
|
|
34
|
+
base: "bg-orange-900 text-stone-100",
|
|
35
|
+
selected: "bg-orange-800 text-stone-100 font-bold underline",
|
|
36
|
+
disabled: "bg-orange-900 text-stone-300 italic",
|
|
37
|
+
disabler: "bg-white/70"
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
var _tmpl$ = /*#__PURE__*/web.template(`<div>`);
|
|
42
|
+
const Item = props => {
|
|
43
|
+
const itemData = () => buildIdLabel(props.idLabel);
|
|
44
|
+
const styleBox = () => {
|
|
45
|
+
return props.theme != undefined ? props.theme : themeAlpha["item"];
|
|
46
|
+
};
|
|
47
|
+
const propsClass = solidJs.createMemo(() => {
|
|
48
|
+
if (props.class == undefined) {
|
|
49
|
+
return {};
|
|
50
|
+
} else if (typeof props.class == "string") {
|
|
51
|
+
return {
|
|
52
|
+
item: props.class
|
|
53
|
+
};
|
|
54
|
+
} else {
|
|
55
|
+
return props.class;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
const itemClasses = solidJs.createMemo(() => {
|
|
59
|
+
const rawClasses = ["px-1"];
|
|
60
|
+
rawClasses.push(styleBox().base);
|
|
61
|
+
|
|
62
|
+
// const stylerClasses = styler
|
|
63
|
+
// ? styler.classes(stags, props.vtags)
|
|
64
|
+
// : undefined;
|
|
65
|
+
// rawClasses.push(...(stylerClasses ?? []));
|
|
66
|
+
|
|
67
|
+
if (props.action) {
|
|
68
|
+
rawClasses.push("select-none cursor-pointer");
|
|
69
|
+
}
|
|
70
|
+
const customClasses = propsClass();
|
|
71
|
+
if (customClasses.item) {
|
|
72
|
+
rawClasses.push(customClasses.item);
|
|
73
|
+
}
|
|
74
|
+
if (props.selected) {
|
|
75
|
+
rawClasses.push(styleBox().selected, customClasses.selected);
|
|
76
|
+
}
|
|
77
|
+
if (props.disabled) {
|
|
78
|
+
rawClasses.push(styleBox().disabled, customClasses.disabled);
|
|
79
|
+
}
|
|
80
|
+
rawClasses.push("relative");
|
|
81
|
+
const r = tailwindMerge.twMerge(...rawClasses);
|
|
82
|
+
return r;
|
|
83
|
+
});
|
|
84
|
+
const disablerClasses = solidJs.createMemo(() => {
|
|
85
|
+
const rawClasses = [];
|
|
86
|
+
rawClasses.push(styleBox().disabler);
|
|
87
|
+
if (propsClass().disabler) {
|
|
88
|
+
rawClasses.push(propsClass().disabler);
|
|
89
|
+
}
|
|
90
|
+
rawClasses.push("absolute inset-0");
|
|
91
|
+
const r = tailwindMerge.twMerge(...rawClasses);
|
|
92
|
+
return r;
|
|
93
|
+
});
|
|
94
|
+
function handleClick() {
|
|
95
|
+
if (props.action != undefined) {
|
|
96
|
+
props.action(itemData());
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return (() => {
|
|
100
|
+
var _el$ = _tmpl$();
|
|
101
|
+
_el$.$$click = handleClick;
|
|
102
|
+
web.insert(_el$, () => itemData().label, null);
|
|
103
|
+
web.insert(_el$, web.createComponent(solidJs.Show, {
|
|
104
|
+
get when() {
|
|
105
|
+
return props.disabled;
|
|
106
|
+
},
|
|
107
|
+
get children() {
|
|
108
|
+
var _el$2 = _tmpl$();
|
|
109
|
+
_el$2.$$click = e => {
|
|
110
|
+
if (!props.clickableWhendisabled) {
|
|
111
|
+
e.stopPropagation();
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
web.effect(() => web.className(_el$2, disablerClasses()));
|
|
115
|
+
return _el$2;
|
|
116
|
+
}
|
|
117
|
+
}), null);
|
|
118
|
+
web.effect(() => web.className(_el$, itemClasses()));
|
|
119
|
+
return _el$;
|
|
120
|
+
})();
|
|
121
|
+
};
|
|
122
|
+
web.delegateEvents(["click"]);
|
|
123
|
+
|
|
124
|
+
exports.Item = Item;
|
|
10
125
|
exports.SolTw = SolTw;
|
|
126
|
+
exports.buildIdLabel = buildIdLabel;
|
|
11
127
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/soltw.tsx"],"sourcesContent":["import type { Component } from \"solid-js\";\n\ntype TProps = {}\n\nexport const SolTw : Component<TProps> = (props) =>{\n return <div class=\"bg-red-600\">- - S O L T W - -</div>\n}\n\n\n"],"names":["SolTw","props","_tmpl$"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/soltw.tsx","../../src/items/IdLabel.ts","../../src/theme/StyleBoxes.ts","../../src/items/Item.tsx"],"sourcesContent":["import type { Component } from \"solid-js\";\n\ntype TProps = {}\n\nexport const SolTw : Component<TProps> = (props) =>{\n return <div class=\"bg-red-600\">- - S O L T W - -</div>\n}\n\n\n","export interface IdLabel {\n id: string;\n label: string;\n [x: string | symbol]: unknown;\n}\n\nexport type IdLabelDef = {\n id: string;\n label?: string;\n [x: string | symbol]: unknown;\n};\n\nexport type IdLabelArg = IdLabelDef | [string, string] | string;\n\nexport function buildIdLabel(arg: IdLabelArg): IdLabel {\n if (typeof arg == \"string\") {\n return { id: arg, label: arg };\n } else if (Array.isArray(arg)) {\n return { id: arg[0], label: arg[1] };\n } else {\n const r = Object.assign({}, arg);\n if (r.label == undefined) {\n r[\"label\"] = r.id;\n }\n return r as IdLabel;\n }\n}\n\n","import type { IStyleBox } from \"./StyleBox\";\n\nexport const themeAlpha :Record<string, IStyleBox> = {\n\n \"block\" : {\n base: \"bg-stone-100 text-stone-900\",\n selected: \"bg-stone-100 text-orange-800 font-bold\",\n disabled: \"bg-stone-100 text-stone-600 italic\",\n disabler: \"bg-white/30\"\n },\n \"item\" : {\n base: \"bg-orange-900 text-stone-100\",\n selected: \"bg-orange-800 text-stone-100 font-bold underline\",\n disabled: \"bg-orange-900 text-stone-300 italic\",\n disabler: \"bg-white/70\"\n },\n\n}\n","import { type Component, createMemo, Show } from \"solid-js\";\nimport { twMerge } from \"tailwind-merge\";\nimport { buildIdLabel, type IdLabel, type IdLabelArg } from \"./IdLabel.js\";\nimport { themeAlpha } from \"../theme/StyleBoxes.js\";\nimport type { IStyleBox } from \"../theme/StyleBox.js\";\n\nexport type TItemClass = {\n item?: string;\n selected?: string;\n disabled?: string;\n disabler?: string;\n};\nexport type TItemClassArg = TItemClass | string;\n\nexport type TItemProps = {\n idLabel: IdLabelArg;\n action?: (item: IdLabel) => void;\n selected?: boolean;\n disabled?: boolean;\n clickableWhendisabled?: boolean;\n class?: TItemClassArg;\n theme?: IStyleBox;\n};\n\nexport const Item: Component<TItemProps> = (props) => {\n const itemData = () => buildIdLabel(props.idLabel);\n\n const styleBox = () => {\n return props.theme !=undefined ? props.theme : themeAlpha[\"item\"]!;\n };\n\n const propsClass = createMemo<TItemClass>(() => {\n if (props.class == undefined) {\n return {};\n } else if (typeof props.class == \"string\") {\n return { item: props.class };\n } else {\n return props.class;\n }\n });\n\n const itemClasses = createMemo(() => {\n const rawClasses = [\"px-1\"] as (string | undefined)[];\n\n rawClasses.push(styleBox().base)\n\n\n // const stylerClasses = styler\n // ? styler.classes(stags, props.vtags)\n // : undefined;\n // rawClasses.push(...(stylerClasses ?? []));\n\n if (props.action) {\n rawClasses.push(\"select-none cursor-pointer\");\n }\n\n const customClasses = propsClass();\n if (customClasses.item) {\n rawClasses.push(customClasses.item);\n }\n if (props.selected) {\n rawClasses.push(styleBox().selected, customClasses.selected);\n }\n if (props.disabled ) {\n rawClasses.push(styleBox().disabled, customClasses.disabled);\n }\n\n rawClasses.push(\"relative\");\n const r = twMerge(...rawClasses);\n return r;\n });\n\n const disablerClasses = createMemo(() => {\n const rawClasses = [] as string[];\n\n rawClasses.push(styleBox().disabler)\n\n if (propsClass().disabler) {\n rawClasses.push(propsClass().disabler!);\n }\n rawClasses.push(\"absolute inset-0\");\n const r = twMerge(...rawClasses);\n return r;\n });\n\n function handleClick() {\n if (props.action != undefined) {\n props.action(itemData());\n }\n }\n\n return (\n <div onClick={handleClick} class={itemClasses()}>\n {itemData().label}\n <Show when={props.disabled}>\n <div\n class={disablerClasses()}\n onClick={(e) => {\n if (!props.clickableWhendisabled) {\n e.stopPropagation();\n }\n }}\n ></div>\n </Show>\n </div>\n );\n};\n"],"names":["SolTw","props","_tmpl$","buildIdLabel","arg","id","label","Array","isArray","r","Object","assign","undefined","themeAlpha","base","selected","disabled","disabler","Item","itemData","idLabel","styleBox","theme","propsClass","createMemo","class","item","itemClasses","rawClasses","push","action","customClasses","twMerge","disablerClasses","handleClick","_el$","$$click","_$insert","_$createComponent","Show","when","children","_el$2","e","clickableWhendisabled","stopPropagation","_$effect","_$className","_$delegateEvents"],"mappings":";;;;;;;AAIO,MAAMA,KAAyB,GAAIC,KAAK,IAAI;AACjD,EAAA,OAAAC,QAAA,EAAA;AACF;;ACQO,SAASC,YAAYA,CAACC,GAAe,EAAW;AACrD,EAAA,IAAI,OAAOA,GAAG,IAAI,QAAQ,EAAE;IAC1B,OAAO;AAAEC,MAAAA,EAAE,EAAED,GAAG;AAAEE,MAAAA,KAAK,EAAEF;KAAK;EAChC,CAAC,MAAM,IAAIG,KAAK,CAACC,OAAO,CAACJ,GAAG,CAAC,EAAE;IAC7B,OAAO;AAAEC,MAAAA,EAAE,EAAED,GAAG,CAAC,CAAC,CAAC;MAAEE,KAAK,EAAEF,GAAG,CAAC,CAAC;KAAG;AACtC,EAAA,CAAC,MAAM;IACL,MAAMK,CAAC,GAAGC,MAAM,CAACC,MAAM,CAAC,EAAE,EAAEP,GAAG,CAAC;AAChC,IAAA,IAAIK,CAAC,CAACH,KAAK,IAAIM,SAAS,EAAE;AACxBH,MAAAA,CAAC,CAAC,OAAO,CAAC,GAAGA,CAAC,CAACJ,EAAE;AACnB,IAAA;AACA,IAAA,OAAOI,CAAC;AACV,EAAA;AACF;;ACxBO,MAAMI,UAAqC,GAAG;AAEnD,EAMA,MAAM,EAAG;AACPC,IAAAA,IAAI,EAAE,8BAA8B;AACpCC,IAAAA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,CAAA;AAAA+B,IAAAA,UAAA,CAAAF,IAAA,EAAAG,mBAAA,CAChBC,YAAI,EAAA;AAAA,MAAA,IAACC,IAAIA,GAAA;QAAA,OAAEvC,KAAK,CAACe,QAAQ;AAAA,MAAA,CAAA;AAAA,MAAA,IAAAyB,QAAAA,GAAA;QAAA,IAAAC,KAAA,GAAAxC,MAAA,EAAA;AAAAwC,QAAAA,KAAA,CAAAN,OAAA,GAGZO,CAAC,IAAK;AACd,UAAA,IAAI,CAAC1C,KAAK,CAAC2C,qBAAqB,EAAE;YAChCD,CAAC,CAACE,eAAe,EAAE;AACrB,UAAA;QACF,CAAC;AAAAC,QAAAA,UAAA,OAAAC,aAAA,CAAAL,KAAA,EALMT,eAAe,EAAE,CAAA,CAAA;AAAA,QAAA,OAAAS,KAAA;AAAA,MAAA;AAAA,KAAA,CAAA,EAAA,IAAA,CAAA;AAAAI,IAAAA,UAAA,OAAAC,aAAA,CAAAZ,IAAA,EAJIR,WAAW,EAAE,CAAA,CAAA;AAAA,IAAA,OAAAQ,IAAA;AAAA,EAAA,CAAA,GAAA;AAcnD;AAAEa,kBAAA,CAAA,CAAA,OAAA,CAAA,CAAA;;;;;;"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,9 +1,123 @@
|
|
|
1
|
-
import { template } from 'solid-js/web';
|
|
1
|
+
import { template, delegateEvents, insert, createComponent, effect, className } from 'solid-js/web';
|
|
2
|
+
import { createMemo, Show } from 'solid-js';
|
|
3
|
+
import { twMerge } from 'tailwind-merge';
|
|
2
4
|
|
|
3
|
-
var _tmpl
|
|
5
|
+
var _tmpl$$1 = /*#__PURE__*/template(`<div class=bg-red-600>- - S O L T W - -`);
|
|
4
6
|
const SolTw = props => {
|
|
5
|
-
return _tmpl
|
|
7
|
+
return _tmpl$$1();
|
|
6
8
|
};
|
|
7
9
|
|
|
8
|
-
|
|
10
|
+
function buildIdLabel(arg) {
|
|
11
|
+
if (typeof arg == "string") {
|
|
12
|
+
return {
|
|
13
|
+
id: arg,
|
|
14
|
+
label: arg
|
|
15
|
+
};
|
|
16
|
+
} else if (Array.isArray(arg)) {
|
|
17
|
+
return {
|
|
18
|
+
id: arg[0],
|
|
19
|
+
label: arg[1]
|
|
20
|
+
};
|
|
21
|
+
} else {
|
|
22
|
+
const r = Object.assign({}, arg);
|
|
23
|
+
if (r.label == undefined) {
|
|
24
|
+
r["label"] = r.id;
|
|
25
|
+
}
|
|
26
|
+
return r;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const themeAlpha = {
|
|
31
|
+
"item": {
|
|
32
|
+
base: "bg-orange-900 text-stone-100",
|
|
33
|
+
selected: "bg-orange-800 text-stone-100 font-bold underline",
|
|
34
|
+
disabled: "bg-orange-900 text-stone-300 italic",
|
|
35
|
+
disabler: "bg-white/70"
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
var _tmpl$ = /*#__PURE__*/template(`<div>`);
|
|
40
|
+
const Item = props => {
|
|
41
|
+
const itemData = () => buildIdLabel(props.idLabel);
|
|
42
|
+
const styleBox = () => {
|
|
43
|
+
return props.theme != undefined ? props.theme : themeAlpha["item"];
|
|
44
|
+
};
|
|
45
|
+
const propsClass = createMemo(() => {
|
|
46
|
+
if (props.class == undefined) {
|
|
47
|
+
return {};
|
|
48
|
+
} else if (typeof props.class == "string") {
|
|
49
|
+
return {
|
|
50
|
+
item: props.class
|
|
51
|
+
};
|
|
52
|
+
} else {
|
|
53
|
+
return props.class;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
const itemClasses = createMemo(() => {
|
|
57
|
+
const rawClasses = ["px-1"];
|
|
58
|
+
rawClasses.push(styleBox().base);
|
|
59
|
+
|
|
60
|
+
// const stylerClasses = styler
|
|
61
|
+
// ? styler.classes(stags, props.vtags)
|
|
62
|
+
// : undefined;
|
|
63
|
+
// rawClasses.push(...(stylerClasses ?? []));
|
|
64
|
+
|
|
65
|
+
if (props.action) {
|
|
66
|
+
rawClasses.push("select-none cursor-pointer");
|
|
67
|
+
}
|
|
68
|
+
const customClasses = propsClass();
|
|
69
|
+
if (customClasses.item) {
|
|
70
|
+
rawClasses.push(customClasses.item);
|
|
71
|
+
}
|
|
72
|
+
if (props.selected) {
|
|
73
|
+
rawClasses.push(styleBox().selected, customClasses.selected);
|
|
74
|
+
}
|
|
75
|
+
if (props.disabled) {
|
|
76
|
+
rawClasses.push(styleBox().disabled, customClasses.disabled);
|
|
77
|
+
}
|
|
78
|
+
rawClasses.push("relative");
|
|
79
|
+
const r = twMerge(...rawClasses);
|
|
80
|
+
return r;
|
|
81
|
+
});
|
|
82
|
+
const disablerClasses = createMemo(() => {
|
|
83
|
+
const rawClasses = [];
|
|
84
|
+
rawClasses.push(styleBox().disabler);
|
|
85
|
+
if (propsClass().disabler) {
|
|
86
|
+
rawClasses.push(propsClass().disabler);
|
|
87
|
+
}
|
|
88
|
+
rawClasses.push("absolute inset-0");
|
|
89
|
+
const r = twMerge(...rawClasses);
|
|
90
|
+
return r;
|
|
91
|
+
});
|
|
92
|
+
function handleClick() {
|
|
93
|
+
if (props.action != undefined) {
|
|
94
|
+
props.action(itemData());
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return (() => {
|
|
98
|
+
var _el$ = _tmpl$();
|
|
99
|
+
_el$.$$click = handleClick;
|
|
100
|
+
insert(_el$, () => itemData().label, null);
|
|
101
|
+
insert(_el$, createComponent(Show, {
|
|
102
|
+
get when() {
|
|
103
|
+
return props.disabled;
|
|
104
|
+
},
|
|
105
|
+
get children() {
|
|
106
|
+
var _el$2 = _tmpl$();
|
|
107
|
+
_el$2.$$click = e => {
|
|
108
|
+
if (!props.clickableWhendisabled) {
|
|
109
|
+
e.stopPropagation();
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
effect(() => className(_el$2, disablerClasses()));
|
|
113
|
+
return _el$2;
|
|
114
|
+
}
|
|
115
|
+
}), null);
|
|
116
|
+
effect(() => className(_el$, itemClasses()));
|
|
117
|
+
return _el$;
|
|
118
|
+
})();
|
|
119
|
+
};
|
|
120
|
+
delegateEvents(["click"]);
|
|
121
|
+
|
|
122
|
+
export { Item, SolTw, buildIdLabel };
|
|
9
123
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/soltw.tsx"],"sourcesContent":["import type { Component } from \"solid-js\";\n\ntype TProps = {}\n\nexport const SolTw : Component<TProps> = (props) =>{\n return <div class=\"bg-red-600\">- - S O L T W - -</div>\n}\n\n\n"],"names":["SolTw","props","_tmpl$"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/soltw.tsx","../../src/items/IdLabel.ts","../../src/theme/StyleBoxes.ts","../../src/items/Item.tsx"],"sourcesContent":["import type { Component } from \"solid-js\";\n\ntype TProps = {}\n\nexport const SolTw : Component<TProps> = (props) =>{\n return <div class=\"bg-red-600\">- - S O L T W - -</div>\n}\n\n\n","export interface IdLabel {\n id: string;\n label: string;\n [x: string | symbol]: unknown;\n}\n\nexport type IdLabelDef = {\n id: string;\n label?: string;\n [x: string | symbol]: unknown;\n};\n\nexport type IdLabelArg = IdLabelDef | [string, string] | string;\n\nexport function buildIdLabel(arg: IdLabelArg): IdLabel {\n if (typeof arg == \"string\") {\n return { id: arg, label: arg };\n } else if (Array.isArray(arg)) {\n return { id: arg[0], label: arg[1] };\n } else {\n const r = Object.assign({}, arg);\n if (r.label == undefined) {\n r[\"label\"] = r.id;\n }\n return r as IdLabel;\n }\n}\n\n","import type { IStyleBox } from \"./StyleBox\";\n\nexport const themeAlpha :Record<string, IStyleBox> = {\n\n \"block\" : {\n base: \"bg-stone-100 text-stone-900\",\n selected: \"bg-stone-100 text-orange-800 font-bold\",\n disabled: \"bg-stone-100 text-stone-600 italic\",\n disabler: \"bg-white/30\"\n },\n \"item\" : {\n base: \"bg-orange-900 text-stone-100\",\n selected: \"bg-orange-800 text-stone-100 font-bold underline\",\n disabled: \"bg-orange-900 text-stone-300 italic\",\n disabler: \"bg-white/70\"\n },\n\n}\n","import { type Component, createMemo, Show } from \"solid-js\";\nimport { twMerge } from \"tailwind-merge\";\nimport { buildIdLabel, type IdLabel, type IdLabelArg } from \"./IdLabel.js\";\nimport { themeAlpha } from \"../theme/StyleBoxes.js\";\nimport type { IStyleBox } from \"../theme/StyleBox.js\";\n\nexport type TItemClass = {\n item?: string;\n selected?: string;\n disabled?: string;\n disabler?: string;\n};\nexport type TItemClassArg = TItemClass | string;\n\nexport type TItemProps = {\n idLabel: IdLabelArg;\n action?: (item: IdLabel) => void;\n selected?: boolean;\n disabled?: boolean;\n clickableWhendisabled?: boolean;\n class?: TItemClassArg;\n theme?: IStyleBox;\n};\n\nexport const Item: Component<TItemProps> = (props) => {\n const itemData = () => buildIdLabel(props.idLabel);\n\n const styleBox = () => {\n return props.theme !=undefined ? props.theme : themeAlpha[\"item\"]!;\n };\n\n const propsClass = createMemo<TItemClass>(() => {\n if (props.class == undefined) {\n return {};\n } else if (typeof props.class == \"string\") {\n return { item: props.class };\n } else {\n return props.class;\n }\n });\n\n const itemClasses = createMemo(() => {\n const rawClasses = [\"px-1\"] as (string | undefined)[];\n\n rawClasses.push(styleBox().base)\n\n\n // const stylerClasses = styler\n // ? styler.classes(stags, props.vtags)\n // : undefined;\n // rawClasses.push(...(stylerClasses ?? []));\n\n if (props.action) {\n rawClasses.push(\"select-none cursor-pointer\");\n }\n\n const customClasses = propsClass();\n if (customClasses.item) {\n rawClasses.push(customClasses.item);\n }\n if (props.selected) {\n rawClasses.push(styleBox().selected, customClasses.selected);\n }\n if (props.disabled ) {\n rawClasses.push(styleBox().disabled, customClasses.disabled);\n }\n\n rawClasses.push(\"relative\");\n const r = twMerge(...rawClasses);\n return r;\n });\n\n const disablerClasses = createMemo(() => {\n const rawClasses = [] as string[];\n\n rawClasses.push(styleBox().disabler)\n\n if (propsClass().disabler) {\n rawClasses.push(propsClass().disabler!);\n }\n rawClasses.push(\"absolute inset-0\");\n const r = twMerge(...rawClasses);\n return r;\n });\n\n function handleClick() {\n if (props.action != undefined) {\n props.action(itemData());\n }\n }\n\n return (\n <div onClick={handleClick} class={itemClasses()}>\n {itemData().label}\n <Show when={props.disabled}>\n <div\n class={disablerClasses()}\n onClick={(e) => {\n if (!props.clickableWhendisabled) {\n e.stopPropagation();\n }\n }}\n ></div>\n </Show>\n </div>\n );\n};\n"],"names":["SolTw","props","_tmpl$","buildIdLabel","arg","id","label","Array","isArray","r","Object","assign","undefined","themeAlpha","base","selected","disabled","disabler","Item","itemData","idLabel","styleBox","theme","propsClass","createMemo","class","item","itemClasses","rawClasses","push","action","customClasses","twMerge","disablerClasses","handleClick","_el$","$$click","_$insert","_$createComponent","Show","when","children","_el$2","e","clickableWhendisabled","stopPropagation","_$effect","_$className","_$delegateEvents"],"mappings":";;;;;AAIO,MAAMA,KAAyB,GAAIC,KAAK,IAAI;AACjD,EAAA,OAAAC,QAAA,EAAA;AACF;;ACQO,SAASC,YAAYA,CAACC,GAAe,EAAW;AACrD,EAAA,IAAI,OAAOA,GAAG,IAAI,QAAQ,EAAE;IAC1B,OAAO;AAAEC,MAAAA,EAAE,EAAED,GAAG;AAAEE,MAAAA,KAAK,EAAEF;KAAK;EAChC,CAAC,MAAM,IAAIG,KAAK,CAACC,OAAO,CAACJ,GAAG,CAAC,EAAE;IAC7B,OAAO;AAAEC,MAAAA,EAAE,EAAED,GAAG,CAAC,CAAC,CAAC;MAAEE,KAAK,EAAEF,GAAG,CAAC,CAAC;KAAG;AACtC,EAAA,CAAC,MAAM;IACL,MAAMK,CAAC,GAAGC,MAAM,CAACC,MAAM,CAAC,EAAE,EAAEP,GAAG,CAAC;AAChC,IAAA,IAAIK,CAAC,CAACH,KAAK,IAAIM,SAAS,EAAE;AACxBH,MAAAA,CAAC,CAAC,OAAO,CAAC,GAAGA,CAAC,CAACJ,EAAE;AACnB,IAAA;AACA,IAAA,OAAOI,CAAC;AACV,EAAA;AACF;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gBF,WAAW;AAAAG,IAAAA,MAAA,CAAAF,IAAA,EAAA,MACtBhB,QAAQ,EAAE,CAACb,KAAK,EAAA,IAAA,CAAA;AAAA+B,IAAAA,MAAA,CAAAF,IAAA,EAAAG,eAAA,CAChBC,IAAI,EAAA;AAAA,MAAA,IAACC,IAAIA,GAAA;QAAA,OAAEvC,KAAK,CAACe,QAAQ;AAAA,MAAA,CAAA;AAAA,MAAA,IAAAyB,QAAAA,GAAA;QAAA,IAAAC,KAAA,GAAAxC,MAAA,EAAA;AAAAwC,QAAAA,KAAA,CAAAN,OAAA,GAGZO,CAAC,IAAK;AACd,UAAA,IAAI,CAAC1C,KAAK,CAAC2C,qBAAqB,EAAE;YAChCD,CAAC,CAACE,eAAe,EAAE;AACrB,UAAA;QACF,CAAC;AAAAC,QAAAA,MAAA,OAAAC,SAAA,CAAAL,KAAA,EALMT,eAAe,EAAE,CAAA,CAAA;AAAA,QAAA,OAAAS,KAAA;AAAA,MAAA;AAAA,KAAA,CAAA,EAAA,IAAA,CAAA;AAAAI,IAAAA,MAAA,OAAAC,SAAA,CAAAZ,IAAA,EAJIR,WAAW,EAAE,CAAA,CAAA;AAAA,IAAA,OAAAQ,IAAA;AAAA,EAAA,CAAA,GAAA;AAcnD;AAAEa,cAAA,CAAA,CAAA,OAAA,CAAA,CAAA;;;;"}
|
package/dist/source/index.js
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function buildIdLabel(arg) {
|
|
2
|
+
if (typeof arg == "string") {
|
|
3
|
+
return { id: arg, label: arg };
|
|
4
|
+
}
|
|
5
|
+
else if (Array.isArray(arg)) {
|
|
6
|
+
return { id: arg[0], label: arg[1] };
|
|
7
|
+
}
|
|
8
|
+
else {
|
|
9
|
+
const r = Object.assign({}, arg);
|
|
10
|
+
if (r.label == undefined) {
|
|
11
|
+
r["label"] = r.id;
|
|
12
|
+
}
|
|
13
|
+
return r;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { createMemo, Show } from "solid-js";
|
|
2
|
+
import { twMerge } from "tailwind-merge";
|
|
3
|
+
import { buildIdLabel } from "./IdLabel.js";
|
|
4
|
+
import { themeAlpha } from "../theme/StyleBoxes.js";
|
|
5
|
+
export const Item = (props) => {
|
|
6
|
+
const itemData = () => buildIdLabel(props.idLabel);
|
|
7
|
+
const styleBox = () => {
|
|
8
|
+
return props.theme != undefined ? props.theme : themeAlpha["item"];
|
|
9
|
+
};
|
|
10
|
+
const propsClass = createMemo(() => {
|
|
11
|
+
if (props.class == undefined) {
|
|
12
|
+
return {};
|
|
13
|
+
}
|
|
14
|
+
else if (typeof props.class == "string") {
|
|
15
|
+
return { item: props.class };
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
return props.class;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
const itemClasses = createMemo(() => {
|
|
22
|
+
const rawClasses = ["px-1"];
|
|
23
|
+
rawClasses.push(styleBox().base);
|
|
24
|
+
// const stylerClasses = styler
|
|
25
|
+
// ? styler.classes(stags, props.vtags)
|
|
26
|
+
// : undefined;
|
|
27
|
+
// rawClasses.push(...(stylerClasses ?? []));
|
|
28
|
+
if (props.action) {
|
|
29
|
+
rawClasses.push("select-none cursor-pointer");
|
|
30
|
+
}
|
|
31
|
+
const customClasses = propsClass();
|
|
32
|
+
if (customClasses.item) {
|
|
33
|
+
rawClasses.push(customClasses.item);
|
|
34
|
+
}
|
|
35
|
+
if (props.selected) {
|
|
36
|
+
rawClasses.push(styleBox().selected, customClasses.selected);
|
|
37
|
+
}
|
|
38
|
+
if (props.disabled) {
|
|
39
|
+
rawClasses.push(styleBox().disabled, customClasses.disabled);
|
|
40
|
+
}
|
|
41
|
+
rawClasses.push("relative");
|
|
42
|
+
const r = twMerge(...rawClasses);
|
|
43
|
+
return r;
|
|
44
|
+
});
|
|
45
|
+
const disablerClasses = createMemo(() => {
|
|
46
|
+
const rawClasses = [];
|
|
47
|
+
rawClasses.push(styleBox().disabler);
|
|
48
|
+
if (propsClass().disabler) {
|
|
49
|
+
rawClasses.push(propsClass().disabler);
|
|
50
|
+
}
|
|
51
|
+
rawClasses.push("absolute inset-0");
|
|
52
|
+
const r = twMerge(...rawClasses);
|
|
53
|
+
return r;
|
|
54
|
+
});
|
|
55
|
+
function handleClick() {
|
|
56
|
+
if (props.action != undefined) {
|
|
57
|
+
props.action(itemData());
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return (<div onClick={handleClick} class={itemClasses()}>
|
|
61
|
+
{itemData().label}
|
|
62
|
+
<Show when={props.disabled}>
|
|
63
|
+
<div class={disablerClasses()} onClick={(e) => {
|
|
64
|
+
if (!props.clickableWhendisabled) {
|
|
65
|
+
e.stopPropagation();
|
|
66
|
+
}
|
|
67
|
+
}}></div>
|
|
68
|
+
</Show>
|
|
69
|
+
</div>);
|
|
70
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface IdLabel {
|
|
2
|
+
id: string;
|
|
3
|
+
label: string;
|
|
4
|
+
[x: string | symbol]: unknown;
|
|
5
|
+
}
|
|
6
|
+
export type IdLabelDef = {
|
|
7
|
+
id: string;
|
|
8
|
+
label?: string;
|
|
9
|
+
[x: string | symbol]: unknown;
|
|
10
|
+
};
|
|
11
|
+
export type IdLabelArg = IdLabelDef | [string, string] | string;
|
|
12
|
+
export declare function buildIdLabel(arg: IdLabelArg): IdLabel;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type Component } from "solid-js";
|
|
2
|
+
import { type IdLabel, type IdLabelArg } from "./IdLabel.js";
|
|
3
|
+
import type { IStyleBox } from "../theme/StyleBox.js";
|
|
4
|
+
export type TItemClass = {
|
|
5
|
+
item?: string;
|
|
6
|
+
selected?: string;
|
|
7
|
+
disabled?: string;
|
|
8
|
+
disabler?: string;
|
|
9
|
+
};
|
|
10
|
+
export type TItemClassArg = TItemClass | string;
|
|
11
|
+
export type TItemProps = {
|
|
12
|
+
idLabel: IdLabelArg;
|
|
13
|
+
action?: (item: IdLabel) => void;
|
|
14
|
+
selected?: boolean;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
clickableWhendisabled?: boolean;
|
|
17
|
+
class?: TItemClassArg;
|
|
18
|
+
theme?: IStyleBox;
|
|
19
|
+
};
|
|
20
|
+
export declare const Item: Component<TItemProps>;
|
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.1",
|
|
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": "dc5c746473031e764be23f5efb7271a33fb5a1a9"
|
|
38
38
|
}
|