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.
Files changed (92) hide show
  1. package/README.ja.md +5 -5
  2. package/README.md +6 -6
  3. package/config/default-config.ts +2 -2
  4. package/config/defaults/{states.ts → traits.ts} +2 -1
  5. package/config/index.ts +3 -3
  6. package/dist/components/atomic/Decorator/Decorator.d.ts +8 -1
  7. package/dist/components/atomic/Decorator/index.js +4 -5
  8. package/dist/components/atomic/Divider/index.js +4 -5
  9. package/dist/components/atomic/Icon/getProps.js +38 -39
  10. package/dist/components/atomic/Spacer/index.js +5 -6
  11. package/dist/components/index.d.ts +1 -1
  12. package/dist/components/index.js +38 -38
  13. package/dist/components/state/BoxLink/BoxLink.d.ts +5 -0
  14. package/dist/components/state/{LinkBox/LinkBox.stories.d.ts → BoxLink/BoxLink.stories.d.ts} +3 -3
  15. package/dist/components/state/BoxLink/index.d.ts +1 -0
  16. package/dist/components/state/{LinkBox → BoxLink}/index.js +1 -1
  17. package/dist/components/state/BoxLink/script.d.ts +4 -0
  18. package/dist/components/state/Container/Container.d.ts +1 -5
  19. package/dist/components/state/Container/Container.stories.d.ts +2 -2
  20. package/dist/components/state/Container/index.js +4 -4
  21. package/dist/config/default-config.d.ts +3 -2
  22. package/dist/config/default-config.js +4 -4
  23. package/dist/config/defaults/{states.d.ts → traits.d.ts} +2 -1
  24. package/dist/config/defaults/{states.js → traits.js} +4 -3
  25. package/dist/config/index.d.ts +6 -4
  26. package/dist/config/index.js +8 -8
  27. package/dist/css/main.css +1 -1
  28. package/dist/css/main_no_layer.css +1 -1
  29. package/dist/css/primitives/trait.css +1 -0
  30. package/dist/css/utility.css +1 -1
  31. package/dist/lib/getAtomicProps.d.ts +27 -0
  32. package/dist/lib/getAtomicProps.js +32 -0
  33. package/dist/lib/getLayoutProps.d.ts +1 -0
  34. package/dist/lib/getLayoutProps.js +28 -18
  35. package/dist/lib/getLismProps.d.ts +17 -9
  36. package/dist/lib/getLismProps.js +123 -102
  37. package/dist/lib/helper/mergeSet.d.ts +8 -3
  38. package/dist/lib/helper/mergeSet.js +10 -10
  39. package/dist/lib/types/AtomicProps.d.ts +24 -0
  40. package/dist/lib/types/TraitProps.d.ts +47 -0
  41. package/package.json +1 -1
  42. package/packages/astro/atomic/Decorator/Decorator.astro +4 -7
  43. package/packages/astro/atomic/Divider/Divider.astro +1 -2
  44. package/packages/astro/atomic/Spacer/Spacer.astro +1 -2
  45. package/packages/astro/index.ts +1 -1
  46. package/packages/astro/state/{LinkBox/LinkBox.astro → BoxLink/BoxLink.astro} +2 -2
  47. package/packages/astro/state/BoxLink/index.ts +1 -0
  48. package/packages/astro/state/Container/Container.astro +3 -6
  49. package/src/scss/_with_layer.scss +12 -5
  50. package/src/scss/base/tokens/_tokens.scss +1 -1
  51. package/src/scss/main_no_layer.scss +4 -4
  52. package/src/scss/{modules → primitives}/atomic/_icon.scss +2 -2
  53. package/src/scss/{modules → primitives}/layout/index.scss +1 -1
  54. package/src/scss/{modules/state/_linkbox.scss → primitives/trait/_boxLink.scss} +4 -4
  55. package/src/scss/{utility/_linkExpand.scss → primitives/trait/_coverLink.scss} +1 -1
  56. package/src/scss/primitives/trait/index.scss +7 -0
  57. package/src/scss/utility/index.scss +0 -1
  58. package/dist/components/atomic/Decorator/getProps.d.ts +0 -8
  59. package/dist/components/atomic/Decorator/getProps.js +0 -15
  60. package/dist/components/atomic/Divider/getProps.d.ts +0 -2
  61. package/dist/components/atomic/Divider/getProps.js +0 -11
  62. package/dist/components/atomic/Spacer/getProps.d.ts +0 -2
  63. package/dist/components/atomic/Spacer/getProps.js +0 -27
  64. package/dist/components/state/LinkBox/LinkBox.d.ts +0 -5
  65. package/dist/components/state/LinkBox/index.d.ts +0 -1
  66. package/dist/components/state/LinkBox/script.d.ts +0 -4
  67. package/dist/css/modules/state.css +0 -1
  68. package/dist/lib/types/StateProps.d.ts +0 -29
  69. package/packages/astro/state/LinkBox/index.ts +0 -1
  70. package/src/scss/modules/state/index.scss +0 -6
  71. /package/dist/css/{modules → primitives}/atomic.css +0 -0
  72. /package/dist/css/{modules → primitives}/layout.css +0 -0
  73. /package/dist/lib/types/{StateProps.spec-d.d.ts → TraitProps.spec-d.d.ts} +0 -0
  74. /package/src/scss/{modules → primitives}/atomic/_divider.scss +0 -0
  75. /package/src/scss/{modules → primitives}/atomic/_spacer.scss +0 -0
  76. /package/src/scss/{modules → primitives}/atomic/index.scss +0 -0
  77. /package/src/scss/{modules → primitives}/layout/_center.scss +0 -0
  78. /package/src/scss/{modules → primitives}/layout/_cluster.scss +0 -0
  79. /package/src/scss/{modules → primitives}/layout/_columns.scss +0 -0
  80. /package/src/scss/{modules → primitives}/layout/_flex.scss +0 -0
  81. /package/src/scss/{modules → primitives}/layout/_flow.scss +0 -0
  82. /package/src/scss/{modules → primitives}/layout/_fluidCols.scss +0 -0
  83. /package/src/scss/{modules → primitives}/layout/_frame.scss +0 -0
  84. /package/src/scss/{modules → primitives}/layout/_grid.scss +0 -0
  85. /package/src/scss/{modules → primitives}/layout/_sideMain.scss +0 -0
  86. /package/src/scss/{modules → primitives}/layout/_stack.scss +0 -0
  87. /package/src/scss/{modules → primitives}/layout/_switchCols.scss +0 -0
  88. /package/src/scss/{modules → primitives}/layout/_tileGrid.scss +0 -0
  89. /package/src/scss/{modules/state → primitives/trait}/_container.scss +0 -0
  90. /package/src/scss/{modules/state → primitives/trait}/_layer.scss +0 -0
  91. /package/src/scss/{modules/state → primitives/trait}/_vertical.scss +0 -0
  92. /package/src/scss/{modules/state → primitives/trait}/_wrapper.scss +0 -0
@@ -1,122 +1,143 @@
1
- import { STATES as b, PROPS as g } from "../config/index.js";
2
- import p from "./getLayoutProps.js";
3
- import U from "./isPresetValue.js";
4
- import E from "./isTokenValue.js";
5
- import C from "./getUtilKey.js";
6
- import S from "./getMaybeCssVar.js";
7
- import V from "./getBpData.js";
8
- import x from "./helper/atts.js";
9
- import _ from "./helper/isEmptyObj.js";
10
- import O from "./helper/filterEmptyObj.js";
11
- import w from "./helper/mergeSet.js";
12
- import j from "./helper/splitWithComma.js";
13
- const A = (f) => {
14
- const i = g[f];
15
- return i && i?.token || "";
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
- class z {
18
- // propList = {};
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(i) {
26
- const { forwardedRef: t, class: s, className: e, lismClass: l, variant: r, style: o = {}, _propConfig: m = {}, ...u } = i;
27
- this.styles = { ...o }, this._propConfig = { ...m };
28
- let a = l || "";
29
- if (r && l) {
30
- const d = l.split(" "), n = d[0], y = `${n}--${r}`;
31
- a = [n, y, ...d.slice(1)].join(" ");
32
- }
33
- _(u) || (this.attrs = { ...u }, this.analyzeProps()), t && (this.attrs.ref = t), this.className = x(e || s, a, this.lismState, this.uClasses);
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
- analyzeState(i, t) {
36
- const { className: s, preset: e, presetClass: l, customVar: r, tokenKey: o } = i;
37
- t === !0 ? this.lismState.push(s) : e && U(e, t) ? this.lismState.push(`${s} ${l}:${String(t)}`) : t && (this.lismState.push(s), o && r && this.addStyle(r, S(t, o)));
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 i = this.extractProp("set"), t = this.extractProp("unset");
42
- Object.keys(this.attrs).forEach((s) => {
43
- if (Object.hasOwn(b, s)) {
44
- const e = this.extractProp(s), l = b[s];
45
- typeof l == "string" ? e && this.lismState.push(l) : this.analyzeState(l, e);
46
- } else if (Object.hasOwn(g, s)) {
47
- const e = this.attrs[s];
48
- delete this.attrs[s], this.analyzeLismProp(s, e);
49
- } else if (s === "hov") {
50
- const e = this.extractProp(s);
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 (s === "css") {
73
+ } else if (i === "css") {
53
74
  const e = this.extractProp("css");
54
75
  this.addStyles(e);
55
76
  }
56
- }), w(void 0, i, t).forEach((s) => this.lismState.push(`set--${s}`));
77
+ });
57
78
  }
58
79
  // Lism Prop 解析
59
- analyzeLismProp(i, t) {
80
+ analyzeLismProp(s, t) {
60
81
  if (t == null) return;
61
- let s = g[i] || null;
62
- if (s === null) return;
63
- this._propConfig?.[i] && (s = Object.assign({}, s, this._propConfig[i]));
64
- const { base: e, ...l } = V(t);
65
- this.setAttrs(i, e, s), Object.keys(l).forEach((r) => {
66
- s && this.setAttrs(i, l[r], s, r);
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(i) {
70
- this.uClasses.push(i);
90
+ addUtil(s) {
91
+ this.uClasses.push(s);
71
92
  }
72
- addUtils(i) {
73
- this.uClasses.push(...i);
93
+ addUtils(s) {
94
+ this.uClasses.push(...s);
74
95
  }
75
96
  // addState(state) {
76
97
  // this.stateClasses.push(state);
77
98
  // }
78
- addStyle(i, t) {
79
- this.styles[i] = t;
99
+ addStyle(s, t) {
100
+ this.styles[s] = t;
80
101
  }
81
- addStyles(i) {
82
- this.styles = { ...this.styles, ...i };
102
+ addStyles(s) {
103
+ this.styles = { ...this.styles, ...s };
83
104
  }
84
- addAttrs(i) {
85
- this.addStyles(i.styles || {}), this.addUtils(i.utils || []);
105
+ addAttrs(s) {
106
+ this.addStyles(s.styles || {}), this.addUtils(s.utils || []);
86
107
  }
87
- extractProp(i) {
88
- const t = this.attrs[i];
89
- return this.attrs[i] === void 0 ? null : (delete this.attrs[i], t);
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(i) {
112
+ extractProps(s) {
92
113
  const t = {};
93
- return i.forEach((s) => {
94
- this.attrs[s] !== void 0 && (t[s] = this.attrs[s], delete this.attrs[s]);
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(i, t, s = {}, e = "") {
120
+ setAttrs(s, t, i = {}, e = "") {
100
121
  if (t == null || t === "" || t === !1) return;
101
- let l = `--${i}`, r = `-${String(s.utilKey || i)}`;
102
- if (e && (l = `--${i}_${e}`, r += `_${e}`), typeof t == "string" && t.startsWith(":")) {
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: y, tokenClass: k, utils: $, shorthands: P } = s;
108
- if (y && U(y, t)) {
109
- const c = typeof t == "string" || typeof t == "number" ? String(t) : "";
110
- c && this.addUtil(`${r}:${c}`);
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 (k && s.token && E(s.token, t)) {
114
- const c = typeof t == "string" || typeof t == "number" ? String(t) : "";
115
- c && this.addUtil(`${r}:${c}`);
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 = C($, t)), !h && P && typeof t == "string" && (h = C(P, t, !0)), 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: o, isVar: m, alwaysVar: u, token: a, bp: d } = s;
129
- let n;
130
- if (a && (typeof t == "string" || typeof t == "number") ? n = S(t, a) : typeof t == "string" || typeof t == "number" ? n = t : n = JSON.stringify(t), !e) {
131
- if (m) {
132
- this.addStyle(`--${i}`, n);
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 (!d && !u) {
135
- this.addStyle(o, n);
155
+ } else if (!k && !d) {
156
+ this.addStyle(n, f);
136
157
  return;
137
158
  }
138
159
  }
139
- this.addUtil(r), this.addStyle(l, n);
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(i) {
155
- i && (i === "-" || i === !0 ? this.addUtil("-hov") : typeof i == "string" ? j(i).forEach((t) => {
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 i == "object" && Object.keys(i).forEach((t) => {
158
- const s = i[t];
159
- if (!(s == null || s === "" || s === !1)) {
160
- if (s === "-" || s === !0)
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
- j(s).forEach((e) => {
184
+ O(i).forEach((e) => {
164
185
  this.addUtil(`-hov:${e}`);
165
186
  });
166
- else if (typeof s == "string" || typeof s == "number") {
167
- const e = S(s, A(t));
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 Q(f) {
175
- if (Object.keys(f).length === 0)
195
+ function Z(o) {
196
+ if (Object.keys(o).length === 0)
176
197
  return {};
177
- const { layout: i, ...t } = f, s = new z(p(i, t));
198
+ const { atomic: s, layout: t, ...i } = o, e = V(s, i), l = E(t, e), r = new T(l);
178
199
  return {
179
- ...O({
180
- className: s.className,
181
- style: O(s.styles)
200
+ ...S({
201
+ className: r.className,
202
+ style: S(r.styles)
182
203
  }),
183
- ...s.attrs
204
+ ...r.attrs
184
205
  // data-* などHTMLの標準属性はそのまま渡す
185
206
  };
186
207
  }
187
208
  export {
188
- z as LismPropsData,
189
- Q as default
209
+ T as LismPropsData,
210
+ Z as default
190
211
  };
@@ -1,5 +1,10 @@
1
1
  /**
2
- * base / set / unset を合成し、最終的な set 値の配列を返す。
3
- * unset に含まれる値は base + set から除外される。
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, set: unknown, unset: unknown): string[];
10
+ export default function mergeSet(base: unknown, value: unknown): string[];
@@ -1,14 +1,14 @@
1
- function r(t) {
2
- return t ? Array.isArray(t) ? t.flatMap((e) => r(e)) : typeof t == "string" ? t.split(/[,\s]+/).map((e) => e.trim()).filter(Boolean) : [] : [];
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 u(t, e, f) {
5
- const n = [.../* @__PURE__ */ new Set([...r(t), ...r(e)])];
6
- if (n.length === 0) return [];
7
- const i = r(f);
8
- if (i.length === 0) return n;
9
- const s = new Set(i);
10
- return n.filter((o) => !s.has(o));
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
- u as default
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,6 +1,6 @@
1
1
  {
2
2
  "name": "lism-css",
3
- "version": "0.12.0",
3
+ "version": "0.13.1",
4
4
  "description": "Lism CSS is a layout-first CSS framework for websites.",
5
5
  "author": {
6
6
  "name": "ddryo",
@@ -1,15 +1,12 @@
1
1
  ---
2
2
  import type { HTMLTag, Polymorphic } from 'astro/types';
3
- import type { DecoratorProps } from 'lism-css/react/atomic/Decorator/getProps';
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} {...getProps(props)} {...exProps}><slot /></Lism>
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} {...getDividerProps(props)} {...exProps} />
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} {...getProps(props)} {...exProps} />
11
+ <Lism as={Tag} atomic="spacer" aria-hidden="true" {...props} {...exProps} />
@@ -33,7 +33,7 @@ export * from './layout/TileGrid';
33
33
  // state (is--)
34
34
  export * from './state/Container';
35
35
  export * from './state/Layer';
36
- export * from './state/LinkBox';
36
+ export * from './state/BoxLink';
37
37
  export * from './state/Wrapper';
38
38
 
39
39
  // atomic (a--)
@@ -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
- // LinkBoxは基本的にリンク要素(aタグ)として機能するため、
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 isLinkBox as={tag} {...props} {...exProps}><slot /></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 { size, ...props } = Astro.props;
8
+ const props = Astro.props;
12
9
  ---
13
10
 
14
- <Lism isContainer isWrapper={size} {...props}><slot /></Lism>
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-modules {
14
- @layer state {
15
- @include meta.load-css('modules/state');
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('modules/layout');
21
+ @include meta.load-css('primitives/layout');
19
22
  }
20
23
  @layer atomic {
21
- @include meta.load-css('modules/atomic');
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
  }
@@ -95,7 +95,7 @@
95
95
  --ar--og: 1.91/1;
96
96
 
97
97
  /**
98
- * State Module用の初期値
98
+ * Trait Primitive用の初期値
99
99
  */
100
100
  --gutter-size: var(--s30); // サイトコンテンツの左右につける余白
101
101
  --vertical-mode: vertical-rl; // 縦書きモード
@@ -11,10 +11,10 @@
11
11
  // base
12
12
  @use './base/index' as base;
13
13
 
14
- // Modules
15
- @use './modules/state/index' as state;
16
- @use './modules/layout/index' as layout;
17
- @use './modules/atomic/index' as atomic;
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; // Callout など、アイコンはflex直下の子要素にしたい場合も多いので、指定しておく
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,4 +1,4 @@
1
- // modules
1
+ // layout primitives
2
2
  @forward './flow';
3
3
  @forward './flex';
4
4
  @forward './cluster';
@@ -1,6 +1,6 @@
1
1
  @use '../../_mixin' as mixin;
2
2
 
3
- .is--linkBox {
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--linkBox a {
14
+ .is--boxLink a {
15
15
  position: relative;
16
- z-index: 2; // .u-linkExpand::before + 1
16
+ z-index: 2; // .is--coverLink::before + 1
17
17
  }
18
18
 
19
19
  /* これをしてしまうと z-index 関係がややこしくなる。リンク以外のz-indexはデフォのままにする。 */
20
- // .is--linkBox > * {
20
+ // .is--boxLink > * {
21
21
  // z-index: 0;
22
22
  // }
@@ -1,4 +1,4 @@
1
- .u--expandedLink {
1
+ .is--coverLink {
2
2
  position: static;
3
3
  text-decoration: none;
4
4
  color: inherit;