lism-css 0.12.0 → 0.13.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/README.ja.md +5 -5
- package/README.md +6 -6
- package/config/default-config.ts +2 -2
- package/config/defaults/{states.ts → traits.ts} +2 -1
- package/config/index.ts +3 -3
- package/dist/components/atomic/Decorator/Decorator.d.ts +8 -1
- package/dist/components/atomic/Decorator/index.js +4 -5
- package/dist/components/atomic/Divider/index.js +4 -5
- package/dist/components/atomic/Icon/getProps.js +38 -39
- package/dist/components/atomic/Spacer/index.js +5 -6
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +38 -38
- package/dist/components/state/BoxLink/BoxLink.d.ts +5 -0
- package/dist/components/state/{LinkBox/LinkBox.stories.d.ts → BoxLink/BoxLink.stories.d.ts} +3 -3
- package/dist/components/state/BoxLink/index.d.ts +1 -0
- package/dist/components/state/{LinkBox → BoxLink}/index.js +1 -1
- package/dist/components/state/BoxLink/script.d.ts +4 -0
- package/dist/components/state/Container/Container.d.ts +1 -5
- package/dist/components/state/Container/Container.stories.d.ts +2 -2
- package/dist/components/state/Container/index.js +4 -4
- package/dist/config/default-config.d.ts +3 -2
- package/dist/config/default-config.js +4 -4
- package/dist/config/defaults/{states.d.ts → traits.d.ts} +2 -1
- package/dist/config/defaults/{states.js → traits.js} +4 -3
- package/dist/config/index.d.ts +6 -4
- package/dist/config/index.js +8 -8
- package/dist/css/main.css +1 -1
- package/dist/css/main_no_layer.css +1 -1
- package/dist/css/primitives/trait.css +1 -0
- package/dist/css/utility.css +1 -1
- package/dist/lib/getAtomicProps.d.ts +27 -0
- package/dist/lib/getAtomicProps.js +32 -0
- package/dist/lib/getLayoutProps.d.ts +1 -0
- package/dist/lib/getLayoutProps.js +28 -18
- package/dist/lib/getLismProps.d.ts +17 -9
- package/dist/lib/getLismProps.js +123 -102
- package/dist/lib/helper/mergeSet.d.ts +8 -3
- package/dist/lib/helper/mergeSet.js +10 -10
- package/dist/lib/types/AtomicProps.d.ts +24 -0
- package/dist/lib/types/TraitProps.d.ts +47 -0
- package/package.json +1 -1
- package/packages/astro/atomic/Decorator/Decorator.astro +4 -7
- package/packages/astro/atomic/Divider/Divider.astro +1 -2
- package/packages/astro/atomic/Spacer/Spacer.astro +1 -2
- package/packages/astro/index.ts +1 -1
- package/packages/astro/state/{LinkBox/LinkBox.astro → BoxLink/BoxLink.astro} +2 -2
- package/packages/astro/state/BoxLink/index.ts +1 -0
- package/packages/astro/state/Container/Container.astro +3 -6
- package/src/scss/_with_layer.scss +12 -5
- package/src/scss/base/tokens/_tokens.scss +1 -1
- package/src/scss/main_no_layer.scss +4 -4
- package/src/scss/{modules → primitives}/atomic/_icon.scss +2 -2
- package/src/scss/{modules → primitives}/layout/index.scss +1 -1
- package/src/scss/{modules/state/_linkbox.scss → primitives/trait/_boxLink.scss} +4 -4
- package/src/scss/{utility/_linkExpand.scss → primitives/trait/_coverLink.scss} +1 -1
- package/src/scss/primitives/trait/index.scss +7 -0
- package/src/scss/utility/index.scss +0 -1
- package/dist/components/atomic/Decorator/getProps.d.ts +0 -8
- package/dist/components/atomic/Decorator/getProps.js +0 -15
- package/dist/components/atomic/Divider/getProps.d.ts +0 -2
- package/dist/components/atomic/Divider/getProps.js +0 -11
- package/dist/components/atomic/Spacer/getProps.d.ts +0 -2
- package/dist/components/atomic/Spacer/getProps.js +0 -27
- package/dist/components/state/LinkBox/LinkBox.d.ts +0 -5
- package/dist/components/state/LinkBox/index.d.ts +0 -1
- package/dist/components/state/LinkBox/script.d.ts +0 -4
- package/dist/css/modules/state.css +0 -1
- package/dist/lib/types/StateProps.d.ts +0 -29
- package/packages/astro/state/LinkBox/index.ts +0 -1
- package/src/scss/modules/state/index.scss +0 -6
- /package/dist/css/{modules → primitives}/atomic.css +0 -0
- /package/dist/css/{modules → primitives}/layout.css +0 -0
- /package/dist/lib/types/{StateProps.spec-d.d.ts → TraitProps.spec-d.d.ts} +0 -0
- /package/src/scss/{modules → primitives}/atomic/_divider.scss +0 -0
- /package/src/scss/{modules → primitives}/atomic/_spacer.scss +0 -0
- /package/src/scss/{modules → primitives}/atomic/index.scss +0 -0
- /package/src/scss/{modules → primitives}/layout/_center.scss +0 -0
- /package/src/scss/{modules → primitives}/layout/_cluster.scss +0 -0
- /package/src/scss/{modules → primitives}/layout/_columns.scss +0 -0
- /package/src/scss/{modules → primitives}/layout/_flex.scss +0 -0
- /package/src/scss/{modules → primitives}/layout/_flow.scss +0 -0
- /package/src/scss/{modules → primitives}/layout/_fluidCols.scss +0 -0
- /package/src/scss/{modules → primitives}/layout/_frame.scss +0 -0
- /package/src/scss/{modules → primitives}/layout/_grid.scss +0 -0
- /package/src/scss/{modules → primitives}/layout/_sideMain.scss +0 -0
- /package/src/scss/{modules → primitives}/layout/_stack.scss +0 -0
- /package/src/scss/{modules → primitives}/layout/_switchCols.scss +0 -0
- /package/src/scss/{modules → primitives}/layout/_tileGrid.scss +0 -0
- /package/src/scss/{modules/state → primitives/trait}/_container.scss +0 -0
- /package/src/scss/{modules/state → primitives/trait}/_layer.scss +0 -0
- /package/src/scss/{modules/state → primitives/trait}/_vertical.scss +0 -0
- /package/src/scss/{modules/state → primitives/trait}/_wrapper.scss +0 -0
package/dist/lib/getLismProps.js
CHANGED
|
@@ -1,122 +1,143 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { TRAITS as P, PROPS as m } from "../config/index.js";
|
|
2
|
+
import E from "./getLayoutProps.js";
|
|
3
|
+
import V from "./getAtomicProps.js";
|
|
4
|
+
import b from "./isPresetValue.js";
|
|
5
|
+
import x from "./isTokenValue.js";
|
|
6
|
+
import p from "./getUtilKey.js";
|
|
7
|
+
import y from "./getMaybeCssVar.js";
|
|
8
|
+
import w from "./getBpData.js";
|
|
9
|
+
import A from "./helper/atts.js";
|
|
10
|
+
import L from "./helper/isEmptyObj.js";
|
|
11
|
+
import S from "./helper/filterEmptyObj.js";
|
|
12
|
+
import U from "./helper/mergeSet.js";
|
|
13
|
+
import O from "./helper/splitWithComma.js";
|
|
14
|
+
const _ = (o) => {
|
|
15
|
+
const s = m[o];
|
|
16
|
+
return s && s?.token || "";
|
|
16
17
|
};
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
function z(o, s) {
|
|
19
|
+
if (!o) return "";
|
|
20
|
+
if (!s) return o;
|
|
21
|
+
const t = o.split(" ")[0];
|
|
22
|
+
return `${o} ${t}--${s}`;
|
|
23
|
+
}
|
|
24
|
+
class T {
|
|
25
|
+
// 最終出力 className
|
|
19
26
|
className = "";
|
|
27
|
+
// 出力順のためのクラスバケット: [lismClass] [primitiveClass] [uClasses]
|
|
28
|
+
// - lismClass : c--* 基底クラス(variant BEM 展開の対象)
|
|
29
|
+
// - primitiveClass : a--* / l--* / is--* の primitive クラス(getAtomicProps → getLayoutProps → analyzeTrait の順で push)
|
|
30
|
+
// - uClasses : set--* → u--* → -property の順で push される utility クラス
|
|
31
|
+
lismClass = "";
|
|
32
|
+
primitiveClass = [];
|
|
20
33
|
uClasses = [];
|
|
21
|
-
lismState = [];
|
|
22
34
|
styles = {};
|
|
23
35
|
attrs = {};
|
|
24
36
|
_propConfig;
|
|
25
|
-
constructor(
|
|
26
|
-
const {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
37
|
+
constructor(s) {
|
|
38
|
+
const {
|
|
39
|
+
forwardedRef: t,
|
|
40
|
+
class: i,
|
|
41
|
+
className: e,
|
|
42
|
+
lismClass: l,
|
|
43
|
+
primitiveClass: r,
|
|
44
|
+
variant: n,
|
|
45
|
+
style: c = {},
|
|
46
|
+
_propConfig: d = {},
|
|
47
|
+
...a
|
|
48
|
+
} = s;
|
|
49
|
+
this.styles = { ...c }, this._propConfig = { ...d }, this.lismClass = z(l, n), r && r.length && (this.primitiveClass = [...r]), L(a) || (this.attrs = { ...a }, this.analyzeProps()), t && (this.attrs.ref = t), this.className = this.buildClassName(e, i);
|
|
34
50
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
51
|
+
// 最終クラス文字列の組み立て(出力順の唯一の確定地点)
|
|
52
|
+
// 出力順: [user/astro className] [lismClass] [primitiveClass] [uClasses]
|
|
53
|
+
buildClassName(s, t) {
|
|
54
|
+
return A(s || t || void 0, this.lismClass, this.primitiveClass, this.uClasses);
|
|
55
|
+
}
|
|
56
|
+
analyzeTrait(s, t) {
|
|
57
|
+
const { className: i, preset: e, presetClass: l, customVar: r, tokenKey: n } = s;
|
|
58
|
+
t === !0 ? this.primitiveClass.push(i) : e && b(e, t) ? this.primitiveClass.push(`${i} ${l}:${String(t)}`) : t && (this.primitiveClass.push(i), n && r && this.addStyle(r, y(t, n)));
|
|
38
59
|
}
|
|
39
60
|
// prop解析
|
|
40
61
|
analyzeProps() {
|
|
41
|
-
const
|
|
42
|
-
Object.keys(this.attrs).forEach((
|
|
43
|
-
if (Object.hasOwn(
|
|
44
|
-
const e = this.extractProp(
|
|
45
|
-
typeof l == "string" ? e && this.
|
|
46
|
-
} else if (Object.hasOwn(
|
|
47
|
-
const e = this.attrs[
|
|
48
|
-
delete this.attrs[
|
|
49
|
-
} else if (
|
|
50
|
-
const e = this.extractProp(
|
|
62
|
+
const s = this.extractProp("set"), t = this.extractProp("util");
|
|
63
|
+
U(void 0, s).forEach((i) => this.addUtil(`set--${i}`)), U(void 0, t).forEach((i) => this.addUtil(`u--${i}`)), Object.keys(this.attrs).forEach((i) => {
|
|
64
|
+
if (Object.hasOwn(P, i)) {
|
|
65
|
+
const e = this.extractProp(i), l = P[i];
|
|
66
|
+
typeof l == "string" ? e && this.primitiveClass.push(l) : this.analyzeTrait(l, e);
|
|
67
|
+
} else if (Object.hasOwn(m, i)) {
|
|
68
|
+
const e = this.attrs[i];
|
|
69
|
+
delete this.attrs[i], this.analyzeLismProp(i, e);
|
|
70
|
+
} else if (i === "hov") {
|
|
71
|
+
const e = this.extractProp(i);
|
|
51
72
|
this.setHovProps(e);
|
|
52
|
-
} else if (
|
|
73
|
+
} else if (i === "css") {
|
|
53
74
|
const e = this.extractProp("css");
|
|
54
75
|
this.addStyles(e);
|
|
55
76
|
}
|
|
56
|
-
})
|
|
77
|
+
});
|
|
57
78
|
}
|
|
58
79
|
// Lism Prop 解析
|
|
59
|
-
analyzeLismProp(
|
|
80
|
+
analyzeLismProp(s, t) {
|
|
60
81
|
if (t == null) return;
|
|
61
|
-
let
|
|
62
|
-
if (
|
|
63
|
-
this._propConfig?.[
|
|
64
|
-
const { base: e, ...l } =
|
|
65
|
-
this.setAttrs(
|
|
66
|
-
|
|
82
|
+
let i = m[s] || null;
|
|
83
|
+
if (i === null) return;
|
|
84
|
+
this._propConfig?.[s] && (i = Object.assign({}, i, this._propConfig[s]));
|
|
85
|
+
const { base: e, ...l } = w(t);
|
|
86
|
+
this.setAttrs(s, e, i), Object.keys(l).forEach((r) => {
|
|
87
|
+
i && this.setAttrs(s, l[r], i, r);
|
|
67
88
|
});
|
|
68
89
|
}
|
|
69
|
-
addUtil(
|
|
70
|
-
this.uClasses.push(
|
|
90
|
+
addUtil(s) {
|
|
91
|
+
this.uClasses.push(s);
|
|
71
92
|
}
|
|
72
|
-
addUtils(
|
|
73
|
-
this.uClasses.push(...
|
|
93
|
+
addUtils(s) {
|
|
94
|
+
this.uClasses.push(...s);
|
|
74
95
|
}
|
|
75
96
|
// addState(state) {
|
|
76
97
|
// this.stateClasses.push(state);
|
|
77
98
|
// }
|
|
78
|
-
addStyle(
|
|
79
|
-
this.styles[
|
|
99
|
+
addStyle(s, t) {
|
|
100
|
+
this.styles[s] = t;
|
|
80
101
|
}
|
|
81
|
-
addStyles(
|
|
82
|
-
this.styles = { ...this.styles, ...
|
|
102
|
+
addStyles(s) {
|
|
103
|
+
this.styles = { ...this.styles, ...s };
|
|
83
104
|
}
|
|
84
|
-
addAttrs(
|
|
85
|
-
this.addStyles(
|
|
105
|
+
addAttrs(s) {
|
|
106
|
+
this.addStyles(s.styles || {}), this.addUtils(s.utils || []);
|
|
86
107
|
}
|
|
87
|
-
extractProp(
|
|
88
|
-
const t = this.attrs[
|
|
89
|
-
return this.attrs[
|
|
108
|
+
extractProp(s) {
|
|
109
|
+
const t = this.attrs[s];
|
|
110
|
+
return this.attrs[s] === void 0 ? null : (delete this.attrs[s], t);
|
|
90
111
|
}
|
|
91
|
-
extractProps(
|
|
112
|
+
extractProps(s) {
|
|
92
113
|
const t = {};
|
|
93
|
-
return
|
|
94
|
-
this.attrs[
|
|
114
|
+
return s.forEach((i) => {
|
|
115
|
+
this.attrs[i] !== void 0 && (t[i] = this.attrs[i], delete this.attrs[i]);
|
|
95
116
|
}), t;
|
|
96
117
|
}
|
|
97
118
|
// utilクラスを追加するか、styleにセットするかの分岐処理 @base
|
|
98
119
|
// 値が null, undefined, '', false の時はスキップ
|
|
99
|
-
setAttrs(
|
|
120
|
+
setAttrs(s, t, i = {}, e = "") {
|
|
100
121
|
if (t == null || t === "" || t === !1) return;
|
|
101
|
-
let l = `--${
|
|
102
|
-
if (e && (l = `--${
|
|
122
|
+
let l = `--${s}`, r = `-${String(i.utilKey || s)}`;
|
|
123
|
+
if (e && (l = `--${s}_${e}`, r += `_${e}`), typeof t == "string" && t.startsWith(":")) {
|
|
103
124
|
this.addUtil(`${r}:${t.replace(":", "")}`);
|
|
104
125
|
return;
|
|
105
126
|
}
|
|
106
127
|
if (!e) {
|
|
107
|
-
const { presets:
|
|
108
|
-
if (
|
|
109
|
-
const
|
|
110
|
-
|
|
128
|
+
const { presets: g, tokenClass: j, utils: $, shorthands: C } = i;
|
|
129
|
+
if (g && b(g, t)) {
|
|
130
|
+
const u = typeof t == "string" || typeof t == "number" ? String(t) : "";
|
|
131
|
+
u && this.addUtil(`${r}:${u}`);
|
|
111
132
|
return;
|
|
112
133
|
}
|
|
113
|
-
if (
|
|
114
|
-
const
|
|
115
|
-
|
|
134
|
+
if (j && i.token && x(i.token, t)) {
|
|
135
|
+
const u = typeof t == "string" || typeof t == "number" ? String(t) : "";
|
|
136
|
+
u && this.addUtil(`${r}:${u}`);
|
|
116
137
|
return;
|
|
117
138
|
}
|
|
118
139
|
let h = "";
|
|
119
|
-
if ($ && typeof t == "string" && (h =
|
|
140
|
+
if ($ && typeof t == "string" && (h = p($, t)), !h && C && typeof t == "string" && (h = p(C, t, !0)), h) {
|
|
120
141
|
this.addUtil(`${r}:${h}`);
|
|
121
142
|
return;
|
|
122
143
|
}
|
|
@@ -125,18 +146,18 @@ class z {
|
|
|
125
146
|
this.addUtil(r);
|
|
126
147
|
return;
|
|
127
148
|
}
|
|
128
|
-
const { prop:
|
|
129
|
-
let
|
|
130
|
-
if (a && (typeof t == "string" || typeof t == "number") ?
|
|
131
|
-
if (
|
|
132
|
-
this.addStyle(`--${
|
|
149
|
+
const { prop: n, isVar: c, alwaysVar: d, token: a, bp: k } = i;
|
|
150
|
+
let f;
|
|
151
|
+
if (a && (typeof t == "string" || typeof t == "number") ? f = y(t, a) : typeof t == "string" || typeof t == "number" ? f = t : f = JSON.stringify(t), !e) {
|
|
152
|
+
if (c) {
|
|
153
|
+
this.addStyle(`--${s}`, f);
|
|
133
154
|
return;
|
|
134
|
-
} else if (!
|
|
135
|
-
this.addStyle(
|
|
155
|
+
} else if (!k && !d) {
|
|
156
|
+
this.addStyle(n, f);
|
|
136
157
|
return;
|
|
137
158
|
}
|
|
138
159
|
}
|
|
139
|
-
this.addUtil(r), this.addStyle(l,
|
|
160
|
+
this.addUtil(r), this.addStyle(l, f);
|
|
140
161
|
}
|
|
141
162
|
// setPassProps(passVars) {
|
|
142
163
|
// let dataList = [];
|
|
@@ -151,40 +172,40 @@ class z {
|
|
|
151
172
|
// this.addStyle(`--pass_${propName}`, value);
|
|
152
173
|
// });
|
|
153
174
|
// }
|
|
154
|
-
setHovProps(
|
|
155
|
-
|
|
175
|
+
setHovProps(s) {
|
|
176
|
+
s && (s === "-" || s === !0 ? this.addUtil("-hov") : typeof s == "string" ? O(s).forEach((t) => {
|
|
156
177
|
this.addUtil(`-hov:${t}`);
|
|
157
|
-
}) : typeof
|
|
158
|
-
const
|
|
159
|
-
if (!(
|
|
160
|
-
if (
|
|
178
|
+
}) : typeof s == "object" && Object.keys(s).forEach((t) => {
|
|
179
|
+
const i = s[t];
|
|
180
|
+
if (!(i == null || i === "" || i === !1)) {
|
|
181
|
+
if (i === "-" || i === !0)
|
|
161
182
|
this.addUtil(`-hov:${t}`);
|
|
162
183
|
else if (t === "class")
|
|
163
|
-
|
|
184
|
+
O(i).forEach((e) => {
|
|
164
185
|
this.addUtil(`-hov:${e}`);
|
|
165
186
|
});
|
|
166
|
-
else if (typeof
|
|
167
|
-
const e =
|
|
187
|
+
else if (typeof i == "string" || typeof i == "number") {
|
|
188
|
+
const e = y(i, _(t));
|
|
168
189
|
this.addUtil(`-hov:${t}`), this.addStyle(`--hov-${t}`, e);
|
|
169
190
|
}
|
|
170
191
|
}
|
|
171
192
|
}));
|
|
172
193
|
}
|
|
173
194
|
}
|
|
174
|
-
function
|
|
175
|
-
if (Object.keys(
|
|
195
|
+
function Z(o) {
|
|
196
|
+
if (Object.keys(o).length === 0)
|
|
176
197
|
return {};
|
|
177
|
-
const { layout:
|
|
198
|
+
const { atomic: s, layout: t, ...i } = o, e = V(s, i), l = E(t, e), r = new T(l);
|
|
178
199
|
return {
|
|
179
|
-
...
|
|
180
|
-
className:
|
|
181
|
-
style:
|
|
200
|
+
...S({
|
|
201
|
+
className: r.className,
|
|
202
|
+
style: S(r.styles)
|
|
182
203
|
}),
|
|
183
|
-
...
|
|
204
|
+
...r.attrs
|
|
184
205
|
// data-* などHTMLの標準属性はそのまま渡す
|
|
185
206
|
};
|
|
186
207
|
}
|
|
187
208
|
export {
|
|
188
|
-
|
|
189
|
-
|
|
209
|
+
T as LismPropsData,
|
|
210
|
+
Z as default
|
|
190
211
|
};
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* base /
|
|
3
|
-
*
|
|
2
|
+
* base / value を合成し、最終的なクラス識別子の配列を返す。
|
|
3
|
+
* 値内の `-` prefix は除外マーカーとして扱われ、その識別子は base + value から除外される。
|
|
4
|
+
*
|
|
5
|
+
* `set` / `util` のいずれの prop でも共用できる汎用処理。
|
|
6
|
+
*
|
|
7
|
+
* 入力は空白区切りを基本とし、カンマ区切りも互換のため受け付ける。
|
|
8
|
+
* 内部 API 用途として文字列配列も受け付けるが、配列形式はユーザー向けドキュメントでは紹介していない。
|
|
4
9
|
*/
|
|
5
|
-
export default function mergeSet(base: unknown,
|
|
10
|
+
export default function mergeSet(base: unknown, value: unknown): string[];
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
function
|
|
2
|
-
return t ? Array.isArray(t) ? t.flatMap((e) =>
|
|
1
|
+
function i(t) {
|
|
2
|
+
return t ? Array.isArray(t) ? t.flatMap((e) => i(e)) : typeof t != "string" ? [] : t.split(/[,\s]+/).map((e) => e.trim()).filter(Boolean) : [];
|
|
3
3
|
}
|
|
4
|
-
function
|
|
5
|
-
const
|
|
6
|
-
if (
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return n.filter((
|
|
4
|
+
function o(t, e) {
|
|
5
|
+
const s = [...i(t), ...i(e)];
|
|
6
|
+
if (s.length === 0) return [];
|
|
7
|
+
const n = [], f = /* @__PURE__ */ new Set();
|
|
8
|
+
for (const r of s)
|
|
9
|
+
r.startsWith("-") ? f.add(r.slice(1)) : n.includes(r) || n.push(r);
|
|
10
|
+
return n.filter((r) => !f.has(r));
|
|
11
11
|
}
|
|
12
12
|
export {
|
|
13
|
-
|
|
13
|
+
o as default
|
|
14
14
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { CssValue } from './LayoutProps';
|
|
2
|
+
export interface NoAtomicProps {
|
|
3
|
+
atomic?: undefined;
|
|
4
|
+
}
|
|
5
|
+
export interface DividerAtomicProps {
|
|
6
|
+
atomic: 'divider';
|
|
7
|
+
}
|
|
8
|
+
export interface SpacerAtomicProps {
|
|
9
|
+
atomic: 'spacer';
|
|
10
|
+
}
|
|
11
|
+
export interface DecoratorAtomicProps {
|
|
12
|
+
atomic: 'decorator';
|
|
13
|
+
size?: CssValue;
|
|
14
|
+
clipPath?: string;
|
|
15
|
+
boxSizing?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface IconAtomicProps {
|
|
18
|
+
atomic: 'icon';
|
|
19
|
+
}
|
|
20
|
+
export type AtomicSpecificProps = NoAtomicProps | DividerAtomicProps | SpacerAtomicProps | DecoratorAtomicProps | IconAtomicProps;
|
|
21
|
+
export type AtomicType = Exclude<AtomicSpecificProps, NoAtomicProps>['atomic'];
|
|
22
|
+
export interface AtomicProps {
|
|
23
|
+
atomic?: AtomicType;
|
|
24
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { TRAITS } from '../../../config/index';
|
|
2
|
+
import { WithArbitraryString, ArrayElement } from './utils';
|
|
3
|
+
/**
|
|
4
|
+
* config/index.ts から TRAITS の型を取得
|
|
5
|
+
* objDeepMerge の DeepMergeResult 型により literal types が保持される
|
|
6
|
+
*/
|
|
7
|
+
type TraitsConfig = typeof TRAITS;
|
|
8
|
+
/** preset を持つ Trait の値の型を抽出 */
|
|
9
|
+
type PresetElement<T> = T extends {
|
|
10
|
+
preset: readonly unknown[];
|
|
11
|
+
} ? ArrayElement<T['preset']> : never;
|
|
12
|
+
/**
|
|
13
|
+
* Trait 設定から Props の値の型を抽出するユーティリティ型
|
|
14
|
+
*/
|
|
15
|
+
type ExtractTraitValue<T> = T extends string ? boolean : T extends {
|
|
16
|
+
preset: readonly unknown[];
|
|
17
|
+
} ? WithArbitraryString<PresetElement<T>> | boolean : never;
|
|
18
|
+
/**
|
|
19
|
+
* config/index.ts の TRAITS から自動生成される Trait Props の型
|
|
20
|
+
* config/index.ts の TRAITS に新しいトレイトを追加すると自動的に反映される
|
|
21
|
+
*/
|
|
22
|
+
export type TraitProps = {
|
|
23
|
+
[K in keyof TraitsConfig]?: ExtractTraitValue<TraitsConfig[K]>;
|
|
24
|
+
};
|
|
25
|
+
/** set prop で使われるプリセット値(エディタ補完用) */
|
|
26
|
+
type SetPreset = 'gutter' | 'shadow' | 'hov' | 'transition' | 'mask' | 'plain' | 'innerRs' | 'bp';
|
|
27
|
+
/**
|
|
28
|
+
* set prop の値の型。プリセット値がサジェストされつつ、任意の文字列も受け付ける。
|
|
29
|
+
*
|
|
30
|
+
* - 値はスペース区切りで複数指定可能
|
|
31
|
+
* - 先頭に `-` を付けると、その識別子を除外する(例: `set="card -bd"`)
|
|
32
|
+
* - 文字列配列も受け付けるが、これは内部 API 用途(lism-ui など)であり、
|
|
33
|
+
* ユーザー向けドキュメントでは紹介していない
|
|
34
|
+
*/
|
|
35
|
+
export type SetPropValue = WithArbitraryString<SetPreset> | WithArbitraryString<SetPreset>[];
|
|
36
|
+
/** util prop で使われるプリセット値(既知の `u--` クラス名・エディタ補完用) */
|
|
37
|
+
type UtilPreset = 'cbox' | 'trim' | 'trimChildren' | 'srOnly' | 'clipText' | 'collapseGrid' | 'snap';
|
|
38
|
+
/**
|
|
39
|
+
* util prop の値の型。既知の `u--` クラス名がサジェストされつつ、任意の文字列も受け付ける。
|
|
40
|
+
*
|
|
41
|
+
* - 値はスペース区切りで複数指定可能
|
|
42
|
+
* - 先頭に `-` を付けると、その識別子を除外する(例: `util="cbox -trim"`)
|
|
43
|
+
* - 文字列配列も受け付けるが、これは内部 API 用途であり、
|
|
44
|
+
* ユーザー向けドキュメントでは紹介していない
|
|
45
|
+
*/
|
|
46
|
+
export type UtilPropValue = WithArbitraryString<UtilPreset> | WithArbitraryString<UtilPreset>[];
|
|
47
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
import type { HTMLTag, Polymorphic } from 'astro/types';
|
|
3
|
-
import type {
|
|
3
|
+
import type { AstroLismFixedLayoutProps } from '../../types';
|
|
4
|
+
import type { DecoratorOwnProps } from 'lism-css/react/atomic/Decorator/Decorator';
|
|
4
5
|
import { Lism } from '../../Lism';
|
|
5
|
-
import getProps from 'lism-css/react/atomic/Decorator/getProps';
|
|
6
6
|
|
|
7
|
-
type Props<Tag extends HTMLTag = 'div'> = Polymorphic<{ as: Tag }> &
|
|
8
|
-
DecoratorProps & {
|
|
9
|
-
exProps?: Record<string, unknown>;
|
|
10
|
-
};
|
|
7
|
+
type Props<Tag extends HTMLTag = 'div'> = Polymorphic<{ as: Tag }> & AstroLismFixedLayoutProps & DecoratorOwnProps;
|
|
11
8
|
|
|
12
9
|
const { as: Tag = 'div', exProps, ...props } = Astro.props;
|
|
13
10
|
---
|
|
14
11
|
|
|
15
|
-
<Lism as={Tag} {...
|
|
12
|
+
<Lism as={Tag} atomic="decorator" aria-hidden="true" {...props} {...exProps}><slot /></Lism>
|
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
import type { HTMLTag, Polymorphic } from 'astro/types';
|
|
3
3
|
import type { AstroLismBaseProps } from '../../types';
|
|
4
4
|
import { Lism } from '../../Lism';
|
|
5
|
-
import { getDividerProps } from 'lism-css/react/atomic/Divider/getProps';
|
|
6
5
|
|
|
7
6
|
type Props<Tag extends HTMLTag = 'div'> = Polymorphic<{ as: Tag }> & AstroLismBaseProps;
|
|
8
7
|
|
|
9
8
|
const { as: Tag = 'div', exProps, ...props } = Astro.props;
|
|
10
9
|
---
|
|
11
10
|
|
|
12
|
-
<Lism as={Tag} {...
|
|
11
|
+
<Lism as={Tag} atomic="divider" aria-hidden="true" {...props} {...exProps} />
|
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
import type { HTMLTag, Polymorphic } from 'astro/types';
|
|
3
3
|
import type { AstroLismBaseProps } from '../../types';
|
|
4
4
|
import { Lism } from '../../Lism';
|
|
5
|
-
import getProps from 'lism-css/react/atomic/Spacer/getProps';
|
|
6
5
|
|
|
7
6
|
type Props<Tag extends HTMLTag = 'div'> = Polymorphic<{ as: Tag }> & AstroLismBaseProps;
|
|
8
7
|
|
|
9
8
|
const { as: Tag = 'div', exProps, ...props } = Astro.props;
|
|
10
9
|
---
|
|
11
10
|
|
|
12
|
-
<Lism as={Tag} {...
|
|
11
|
+
<Lism as={Tag} atomic="spacer" aria-hidden="true" {...props} {...exProps} />
|
package/packages/astro/index.ts
CHANGED
|
@@ -8,9 +8,9 @@ type Props<Tag extends HTMLTag = 'a'> = Polymorphic<{ as: Tag }> & AstroLismBase
|
|
|
8
8
|
const { as, exProps, ...props } = Astro.props;
|
|
9
9
|
|
|
10
10
|
const hasHref = !!props.href;
|
|
11
|
-
//
|
|
11
|
+
// BoxLinkは基本的にリンク要素(aタグ)として機能するため、
|
|
12
12
|
// hrefがないかつ、aタグとしてレンダリングする場合はdivタグに置き換える
|
|
13
13
|
const tag: HTMLTag = !hasHref && (as ?? 'a') === 'a' ? 'div' : (as ?? 'a');
|
|
14
14
|
---
|
|
15
15
|
|
|
16
|
-
<Lism
|
|
16
|
+
<Lism isBoxLink as={tag} {...props} {...exProps}><slot /></Lism>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as BoxLink } from './BoxLink.astro';
|
|
@@ -3,12 +3,9 @@ import type { HTMLTag, Polymorphic } from 'astro/types';
|
|
|
3
3
|
import type { AstroLismBaseProps } from '../../types';
|
|
4
4
|
import { Lism } from '../../Lism';
|
|
5
5
|
|
|
6
|
-
type Props<Tag extends HTMLTag = 'div'> = Polymorphic<{ as: Tag }> &
|
|
7
|
-
AstroLismBaseProps & {
|
|
8
|
-
size?: string;
|
|
9
|
-
};
|
|
6
|
+
type Props<Tag extends HTMLTag = 'div'> = Polymorphic<{ as: Tag }> & AstroLismBaseProps;
|
|
10
7
|
|
|
11
|
-
const
|
|
8
|
+
const props = Astro.props;
|
|
12
9
|
---
|
|
13
10
|
|
|
14
|
-
<Lism isContainer
|
|
11
|
+
<Lism isContainer {...props}><slot /></Lism>
|
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
*/
|
|
4
4
|
@use 'sass:meta';
|
|
5
5
|
|
|
6
|
+
// レイヤー順序を明示的に宣言(詳細度: 上ほど弱い)
|
|
7
|
+
@layer lism-base, lism-primitive, lism-component, lism-custom, lism-utility;
|
|
8
|
+
|
|
6
9
|
@layer lism-base {
|
|
7
10
|
// resetは中でも layer定義済み。 lism-base.reset となる
|
|
8
11
|
@include meta.load-css('reset');
|
|
@@ -10,18 +13,22 @@
|
|
|
10
13
|
@include meta.load-css('base');
|
|
11
14
|
}
|
|
12
15
|
|
|
13
|
-
@layer lism-
|
|
14
|
-
@layer
|
|
15
|
-
@include meta.load-css('
|
|
16
|
+
@layer lism-primitive {
|
|
17
|
+
@layer trait {
|
|
18
|
+
@include meta.load-css('primitives/trait');
|
|
16
19
|
}
|
|
17
20
|
@layer layout {
|
|
18
|
-
@include meta.load-css('
|
|
21
|
+
@include meta.load-css('primitives/layout');
|
|
19
22
|
}
|
|
20
23
|
@layer atomic {
|
|
21
|
-
@include meta.load-css('
|
|
24
|
+
@include meta.load-css('primitives/atomic');
|
|
22
25
|
}
|
|
23
26
|
}
|
|
24
27
|
|
|
28
|
+
/* stylelint-disable-next-line block-no-empty -- BEM 構造を持つ UI コンポーネント(c--)用レイヤー。コアでは空、@lism-css/ui やユーザー定義クラスがここに配置される。 */
|
|
29
|
+
@layer lism-component {
|
|
30
|
+
}
|
|
31
|
+
|
|
25
32
|
/* stylelint-disable-next-line block-no-empty -- ユーザーの独自分類クラス用レイヤー */
|
|
26
33
|
@layer lism-custom {
|
|
27
34
|
}
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
// base
|
|
12
12
|
@use './base/index' as base;
|
|
13
13
|
|
|
14
|
-
//
|
|
15
|
-
@use './
|
|
16
|
-
@use './
|
|
17
|
-
@use './
|
|
14
|
+
// Primitives
|
|
15
|
+
@use './primitives/trait/index' as trait;
|
|
16
|
+
@use './primitives/layout/index' as layout;
|
|
17
|
+
@use './primitives/atomic/index' as atomic;
|
|
18
18
|
|
|
19
19
|
// @use './component/index' as component;
|
|
20
20
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
.a--icon {
|
|
2
|
-
flex-shrink: 0; //
|
|
2
|
+
flex-shrink: 0; // アイコンはflex直下の子要素にしたい場合が多いのでデフォルトで適用する
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
/* fill指定のない svg にテキストカラーを継承させる */
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
fill: currentcolor;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
/*
|
|
10
|
+
/* 属性によるサイズ指定がない場合は 1em サイズが基本 */
|
|
11
11
|
.a--icon:where(:not([width])) {
|
|
12
12
|
width: 1em;
|
|
13
13
|
height: 1em;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
@use '../../_mixin' as mixin;
|
|
2
2
|
|
|
3
|
-
.is--
|
|
3
|
+
.is--boxLink {
|
|
4
4
|
position: relative;
|
|
5
5
|
display: block;
|
|
6
6
|
color: inherit;
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
// リンクをクリック可能にするためにz-indexあげる
|
|
14
|
-
.is--
|
|
14
|
+
.is--boxLink a {
|
|
15
15
|
position: relative;
|
|
16
|
-
z-index: 2; // .
|
|
16
|
+
z-index: 2; // .is--coverLink::before + 1
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
/* これをしてしまうと z-index 関係がややこしくなる。リンク以外のz-indexはデフォのままにする。 */
|
|
20
|
-
// .is--
|
|
20
|
+
// .is--boxLink > * {
|
|
21
21
|
// z-index: 0;
|
|
22
22
|
// }
|