lism-css 0.11.0 → 0.13.0

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 (220) hide show
  1. package/README.ja.md +9 -9
  2. package/README.md +12 -12
  3. package/config/default-config.ts +2 -2
  4. package/config/defaults/props.ts +16 -26
  5. package/config/defaults/traits.ts +16 -0
  6. package/config/index.ts +3 -3
  7. package/dist/components/{atomic/Media → Media}/Media.d.ts +2 -2
  8. package/dist/components/{atomic/Media → Media}/index.js +1 -1
  9. package/dist/components/atomic/Icon/getProps.d.ts +1 -1
  10. package/dist/components/atomic/Icon/index.d.ts +1 -1
  11. package/dist/components/index.d.ts +18 -18
  12. package/dist/components/index.js +45 -45
  13. package/dist/components/{Box → layout/Box}/Box.d.ts +2 -2
  14. package/dist/components/{Box → layout/Box}/index.js +1 -1
  15. package/dist/components/{Center → layout/Center}/Center.d.ts +2 -2
  16. package/dist/components/{Center → layout/Center}/index.js +1 -1
  17. package/dist/components/{Cluster → layout/Cluster}/Cluster.d.ts +2 -2
  18. package/dist/components/{Cluster → layout/Cluster}/index.js +1 -1
  19. package/dist/components/{Columns → layout/Columns}/Columns.d.ts +2 -2
  20. package/dist/components/{Columns → layout/Columns}/index.js +1 -1
  21. package/dist/components/{Flex → layout/Flex}/Flex.d.ts +2 -2
  22. package/dist/components/{Flex → layout/Flex}/index.js +1 -1
  23. package/dist/components/{Flow → layout/Flow}/Flow.d.ts +2 -2
  24. package/dist/components/{Flow → layout/Flow}/index.js +1 -1
  25. package/dist/components/{FluidCols → layout/FluidCols}/FluidCols.d.ts +2 -2
  26. package/dist/components/{FluidCols → layout/FluidCols}/index.js +1 -1
  27. package/dist/components/{Frame → layout/Frame}/Frame.d.ts +2 -2
  28. package/dist/components/{Frame → layout/Frame}/index.js +1 -1
  29. package/dist/components/{Grid → layout/Grid}/Grid.d.ts +2 -2
  30. package/dist/components/{Grid → layout/Grid}/index.js +1 -1
  31. package/dist/components/{SideMain → layout/SideMain}/SideMain.d.ts +2 -2
  32. package/dist/components/{SideMain → layout/SideMain}/index.js +1 -1
  33. package/dist/components/{Stack → layout/Stack}/Stack.d.ts +2 -2
  34. package/dist/components/{Stack → layout/Stack}/index.js +1 -1
  35. package/dist/components/{SwitchCols → layout/SwitchCols}/SwitchCols.d.ts +2 -2
  36. package/dist/components/{SwitchCols → layout/SwitchCols}/index.js +1 -1
  37. package/dist/components/layout/TileGrid/TileGrid.d.ts +4 -0
  38. package/dist/components/layout/TileGrid/index.d.ts +1 -0
  39. package/dist/components/layout/TileGrid/index.js +8 -0
  40. package/dist/components/state/BoxLink/BoxLink.d.ts +5 -0
  41. package/dist/components/{LinkBox/LinkBox.stories.d.ts → state/BoxLink/BoxLink.stories.d.ts} +3 -3
  42. package/dist/components/state/BoxLink/index.d.ts +1 -0
  43. package/dist/components/{LinkBox → state/BoxLink}/index.js +2 -2
  44. package/dist/components/state/BoxLink/script.d.ts +4 -0
  45. package/dist/components/state/Container/Container.d.ts +2 -0
  46. package/dist/components/{Container → state/Container}/Container.stories.d.ts +2 -2
  47. package/dist/components/state/Container/index.js +8 -0
  48. package/dist/components/{Layer → state/Layer}/Layer.d.ts +1 -1
  49. package/dist/components/{Layer → state/Layer}/index.js +1 -1
  50. package/dist/components/{Wrapper → state/Wrapper}/Wrapper.d.ts +1 -1
  51. package/dist/components/{Wrapper → state/Wrapper}/index.js +1 -1
  52. package/dist/config/default-config.d.ts +27 -73
  53. package/dist/config/default-config.js +4 -4
  54. package/dist/config/defaults/props.d.ts +24 -58
  55. package/dist/config/defaults/props.js +16 -26
  56. package/dist/config/defaults/{states.d.ts → traits.d.ts} +2 -14
  57. package/dist/config/defaults/traits.js +19 -0
  58. package/dist/config/index.d.ts +54 -146
  59. package/dist/config/index.js +5 -5
  60. package/dist/css/base.css +1 -1
  61. package/dist/css/main.css +1 -1
  62. package/dist/css/main_no_layer.css +1 -1
  63. package/dist/css/primitives/layout.css +1 -0
  64. package/dist/css/primitives/trait.css +1 -0
  65. package/dist/css/props.css +1 -1
  66. package/dist/css/utility.css +1 -1
  67. package/dist/lib/getLayoutProps.js +12 -15
  68. package/dist/lib/getLismProps.d.ts +9 -6
  69. package/dist/lib/getLismProps.js +113 -101
  70. package/dist/lib/helper/mergeSet.d.ts +10 -0
  71. package/dist/lib/helper/mergeSet.js +14 -0
  72. package/dist/lib/types/LayoutProps.d.ts +4 -1
  73. package/dist/lib/types/TraitProps.d.ts +47 -0
  74. package/dist/lib/types/TraitProps.spec-d.d.ts +1 -0
  75. package/package.json +1 -1
  76. package/packages/astro/{Decorator → atomic/Decorator}/Decorator.astro +1 -1
  77. package/packages/astro/{Divider → atomic/Divider}/Divider.astro +2 -2
  78. package/packages/astro/{Icon → atomic/Icon}/Icon.astro +1 -1
  79. package/packages/astro/{Spacer → atomic/Spacer}/Spacer.astro +2 -2
  80. package/packages/astro/index.ts +26 -22
  81. package/packages/astro/{Box → layout/Box}/Box.astro +2 -2
  82. package/packages/astro/{Center → layout/Center}/Center.astro +2 -2
  83. package/packages/astro/{Cluster → layout/Cluster}/Cluster.astro +2 -2
  84. package/packages/astro/{Columns → layout/Columns}/Columns.astro +2 -2
  85. package/packages/astro/{Flex → layout/Flex}/Flex.astro +2 -2
  86. package/packages/astro/{Flow → layout/Flow}/Flow.astro +2 -2
  87. package/packages/astro/{FluidCols → layout/FluidCols}/FluidCols.astro +2 -2
  88. package/packages/astro/{Frame → layout/Frame}/Frame.astro +2 -2
  89. package/packages/astro/{Grid → layout/Grid}/Grid.astro +2 -2
  90. package/packages/astro/{SideMain → layout/SideMain}/SideMain.astro +2 -2
  91. package/packages/astro/{Stack → layout/Stack}/Stack.astro +2 -2
  92. package/packages/astro/{SwitchCols → layout/SwitchCols}/SwitchCols.astro +2 -2
  93. package/packages/astro/layout/TileGrid/TileGrid.astro +11 -0
  94. package/packages/astro/layout/TileGrid/index.ts +1 -0
  95. package/packages/astro/{LinkBox/LinkBox.astro → state/BoxLink/BoxLink.astro} +4 -4
  96. package/packages/astro/state/BoxLink/index.ts +1 -0
  97. package/packages/astro/state/Container/Container.astro +11 -0
  98. package/packages/astro/{Layer → state/Layer}/Layer.astro +2 -2
  99. package/packages/astro/{Wrapper → state/Wrapper}/Wrapper.astro +2 -2
  100. package/src/scss/_auto_output.scss +1 -1
  101. package/src/scss/_prop-config.scss +24 -26
  102. package/src/scss/_with_layer.scss +15 -8
  103. package/src/scss/base/_html.scss +8 -8
  104. package/src/scss/base/tokens/_tokens.scss +1 -3
  105. package/src/scss/main_no_layer.scss +4 -4
  106. package/src/scss/primitives/layout/_grid.scss +7 -0
  107. package/src/scss/primitives/layout/_tileGrid.scss +4 -0
  108. package/src/scss/{modules → primitives}/layout/index.scss +2 -1
  109. package/src/scss/{modules/state/_linkbox.scss → primitives/trait/_boxLink.scss} +4 -4
  110. package/src/scss/{utility/_linkExpand.scss → primitives/trait/_coverLink.scss} +1 -1
  111. package/src/scss/primitives/trait/index.scss +7 -0
  112. package/src/scss/props/index.scss +1 -1
  113. package/src/scss/utility/_cbox.scss +1 -1
  114. package/src/scss/utility/_clipText.scss +1 -1
  115. package/src/scss/utility/index.scss +0 -1
  116. package/config/defaults/states.ts +0 -43
  117. package/config/helper/getSvgUrl.ts +0 -26
  118. package/dist/components/Container/Container.d.ts +0 -6
  119. package/dist/components/Container/index.js +0 -8
  120. package/dist/components/HTML/HTML.d.ts +0 -26
  121. package/dist/components/HTML/index.d.ts +0 -14
  122. package/dist/components/HTML/index.js +0 -5
  123. package/dist/components/HTML/index2.js +0 -45
  124. package/dist/components/LinkBox/LinkBox.d.ts +0 -5
  125. package/dist/components/LinkBox/index.d.ts +0 -1
  126. package/dist/components/LinkBox/script.d.ts +0 -4
  127. package/dist/config/defaults/states.js +0 -38
  128. package/dist/config/helper/getSvgUrl.d.ts +0 -5
  129. package/dist/config/helper/getSvgUrl.js +0 -4
  130. package/dist/css/modules/layout.css +0 -1
  131. package/dist/css/modules/state.css +0 -1
  132. package/dist/lib/types/StateProps.d.ts +0 -27
  133. package/packages/astro/Container/Container.astro +0 -14
  134. package/packages/astro/HTML/_index_memo.js +0 -29
  135. package/packages/astro/HTML/a.astro +0 -10
  136. package/packages/astro/HTML/button.astro +0 -10
  137. package/packages/astro/HTML/div.astro +0 -10
  138. package/packages/astro/HTML/h.astro +0 -13
  139. package/packages/astro/HTML/img.astro +0 -10
  140. package/packages/astro/HTML/index.ts +0 -12
  141. package/packages/astro/HTML/li.astro +0 -10
  142. package/packages/astro/HTML/ol.astro +0 -10
  143. package/packages/astro/HTML/p.astro +0 -10
  144. package/packages/astro/HTML/span.astro +0 -10
  145. package/packages/astro/HTML/ul.astro +0 -10
  146. package/packages/astro/LinkBox/index.ts +0 -1
  147. package/src/scss/modules/layout/_grid.scss +0 -12
  148. package/src/scss/modules/state/index.scss +0 -6
  149. /package/dist/components/{atomic/Media → Media}/Media.stories.d.ts +0 -0
  150. /package/dist/components/{atomic/Media → Media}/index.d.ts +0 -0
  151. /package/dist/components/{Box → layout/Box}/Box.stories.d.ts +0 -0
  152. /package/dist/components/{Box → layout/Box}/index.d.ts +0 -0
  153. /package/dist/components/{Center → layout/Center}/Center.stories.d.ts +0 -0
  154. /package/dist/components/{Center → layout/Center}/index.d.ts +0 -0
  155. /package/dist/components/{Cluster → layout/Cluster}/Cluster.stories.d.ts +0 -0
  156. /package/dist/components/{Cluster → layout/Cluster}/index.d.ts +0 -0
  157. /package/dist/components/{Columns → layout/Columns}/Columns.stories.d.ts +0 -0
  158. /package/dist/components/{Columns → layout/Columns}/index.d.ts +0 -0
  159. /package/dist/components/{Flex → layout/Flex}/Flex.stories.d.ts +0 -0
  160. /package/dist/components/{Flex → layout/Flex}/index.d.ts +0 -0
  161. /package/dist/components/{Flow → layout/Flow}/Flow.stories.d.ts +0 -0
  162. /package/dist/components/{Flow → layout/Flow}/index.d.ts +0 -0
  163. /package/dist/components/{FluidCols → layout/FluidCols}/FluidCols.stories.d.ts +0 -0
  164. /package/dist/components/{FluidCols → layout/FluidCols}/index.d.ts +0 -0
  165. /package/dist/components/{Frame → layout/Frame}/Frame.stories.d.ts +0 -0
  166. /package/dist/components/{Frame → layout/Frame}/index.d.ts +0 -0
  167. /package/dist/components/{Grid → layout/Grid}/Grid.stories.d.ts +0 -0
  168. /package/dist/components/{Grid → layout/Grid}/index.d.ts +0 -0
  169. /package/dist/components/{SideMain → layout/SideMain}/SideMain.stories.d.ts +0 -0
  170. /package/dist/components/{SideMain → layout/SideMain}/index.d.ts +0 -0
  171. /package/dist/components/{Stack → layout/Stack}/Stack.stories.d.ts +0 -0
  172. /package/dist/components/{Stack → layout/Stack}/index.d.ts +0 -0
  173. /package/dist/components/{SwitchCols → layout/SwitchCols}/SwitchCols.stories.d.ts +0 -0
  174. /package/dist/components/{SwitchCols → layout/SwitchCols}/index.d.ts +0 -0
  175. /package/dist/components/{Container → state/Container}/index.d.ts +0 -0
  176. /package/dist/components/{Layer → state/Layer}/Layer.stories.d.ts +0 -0
  177. /package/dist/components/{Layer → state/Layer}/Layer.test.d.ts +0 -0
  178. /package/dist/components/{Layer → state/Layer}/index.d.ts +0 -0
  179. /package/dist/components/{Wrapper → state/Wrapper}/Wrapper.stories.d.ts +0 -0
  180. /package/dist/components/{Wrapper → state/Wrapper}/index.d.ts +0 -0
  181. /package/dist/css/{modules → primitives}/atomic.css +0 -0
  182. /package/dist/lib/{types/StateProps.spec-d.d.ts → helper/mergeSet.test.d.ts} +0 -0
  183. /package/packages/astro/{Decorator → atomic/Decorator}/index.ts +0 -0
  184. /package/packages/astro/{Divider → atomic/Divider}/index.ts +0 -0
  185. /package/packages/astro/{Icon → atomic/Icon}/SVG.astro +0 -0
  186. /package/packages/astro/{Icon → atomic/Icon}/index.ts +0 -0
  187. /package/packages/astro/{Spacer → atomic/Spacer}/index.ts +0 -0
  188. /package/packages/astro/{Box → layout/Box}/index.ts +0 -0
  189. /package/packages/astro/{Center → layout/Center}/index.ts +0 -0
  190. /package/packages/astro/{Cluster → layout/Cluster}/index.ts +0 -0
  191. /package/packages/astro/{Columns → layout/Columns}/index.ts +0 -0
  192. /package/packages/astro/{Flex → layout/Flex}/index.ts +0 -0
  193. /package/packages/astro/{Flow → layout/Flow}/index.ts +0 -0
  194. /package/packages/astro/{FluidCols → layout/FluidCols}/index.ts +0 -0
  195. /package/packages/astro/{Frame → layout/Frame}/index.ts +0 -0
  196. /package/packages/astro/{Grid → layout/Grid}/index.ts +0 -0
  197. /package/packages/astro/{SideMain → layout/SideMain}/index.ts +0 -0
  198. /package/packages/astro/{Stack → layout/Stack}/index.ts +0 -0
  199. /package/packages/astro/{SwitchCols → layout/SwitchCols}/index.ts +0 -0
  200. /package/packages/astro/{Container → state/Container}/index.ts +0 -0
  201. /package/packages/astro/{Layer → state/Layer}/index.ts +0 -0
  202. /package/packages/astro/{Wrapper → state/Wrapper}/index.ts +0 -0
  203. /package/src/scss/{modules → primitives}/atomic/_divider.scss +0 -0
  204. /package/src/scss/{modules → primitives}/atomic/_icon.scss +0 -0
  205. /package/src/scss/{modules → primitives}/atomic/_spacer.scss +0 -0
  206. /package/src/scss/{modules → primitives}/atomic/index.scss +0 -0
  207. /package/src/scss/{modules → primitives}/layout/_center.scss +0 -0
  208. /package/src/scss/{modules → primitives}/layout/_cluster.scss +0 -0
  209. /package/src/scss/{modules → primitives}/layout/_columns.scss +0 -0
  210. /package/src/scss/{modules → primitives}/layout/_flex.scss +0 -0
  211. /package/src/scss/{modules → primitives}/layout/_flow.scss +0 -0
  212. /package/src/scss/{modules → primitives}/layout/_fluidCols.scss +0 -0
  213. /package/src/scss/{modules → primitives}/layout/_frame.scss +0 -0
  214. /package/src/scss/{modules → primitives}/layout/_sideMain.scss +0 -0
  215. /package/src/scss/{modules → primitives}/layout/_stack.scss +0 -0
  216. /package/src/scss/{modules → primitives}/layout/_switchCols.scss +0 -0
  217. /package/src/scss/{modules/state → primitives/trait}/_container.scss +0 -0
  218. /package/src/scss/{modules/state → primitives/trait}/_layer.scss +0 -0
  219. /package/src/scss/{modules/state → primitives/trait}/_vertical.scss +0 -0
  220. /package/src/scss/{modules/state → primitives/trait}/_wrapper.scss +0 -0
@@ -1,121 +1,133 @@
1
- import { STATES as b, PROPS as g } from "../config/index.js";
2
- import E from "./getLayoutProps.js";
3
- import C from "./isPresetValue.js";
4
- import V from "./isTokenValue.js";
5
- import U from "./getUtilKey.js";
6
- import S from "./getMaybeCssVar.js";
7
- import _ from "./getBpData.js";
8
- import A from "./helper/atts.js";
9
- import x from "./helper/isEmptyObj.js";
10
- import O from "./helper/filterEmptyObj.js";
1
+ import { TRAITS as P, PROPS as y } from "../config/index.js";
2
+ import p from "./getLayoutProps.js";
3
+ import S from "./isPresetValue.js";
4
+ import E from "./isTokenValue.js";
5
+ import C from "./getUtilKey.js";
6
+ import c from "./getMaybeCssVar.js";
7
+ import V from "./getBpData.js";
8
+ import x from "./helper/atts.js";
9
+ import w from "./helper/isEmptyObj.js";
10
+ import U from "./helper/filterEmptyObj.js";
11
+ import O from "./helper/mergeSet.js";
11
12
  import j from "./helper/splitWithComma.js";
12
- const z = (a) => {
13
- const s = g[a];
14
- return s && s?.token || "";
13
+ const _ = (n) => {
14
+ const i = y[n];
15
+ return i && i?.token || "";
15
16
  };
16
- class w {
17
- // propList = {};
17
+ function z(n, i) {
18
+ if (!n) return "";
19
+ if (!i) return n;
20
+ const t = n.split(" "), s = t[0];
21
+ return [s, `${s}--${i}`, ...t.slice(1)].join(" ");
22
+ }
23
+ class L {
24
+ // 最終出力 className
18
25
  className = "";
26
+ // 出力順のためのクラスバケット: [lismClass] [lismTrait] [uClasses]
27
+ // - lismClass : コンポーネント基底クラス + variant + l--{layout}(getLayoutProps 側で付与済み)
28
+ // - lismTrait : is--* 等の trait クラス
29
+ // - uClasses : set--* → u--* → -property の順で push される utility クラス
30
+ lismClass = "";
31
+ lismTrait = [];
19
32
  uClasses = [];
20
- lismState = [];
21
33
  styles = {};
22
34
  attrs = {};
23
35
  _propConfig;
24
- constructor(s) {
25
- const { forwardedRef: t, class: i, className: e, lismClass: l, variant: r, style: f = {}, _propConfig: o = {}, ...u } = s;
26
- this.styles = { ...f }, this._propConfig = { ...o };
27
- let h = l || "";
28
- if (r && l) {
29
- const y = l.split(" "), n = y[0], m = `${n}--${r}`;
30
- h = [n, m, ...y.slice(1)].join(" ");
31
- }
32
- x(u) || (this.attrs = { ...u }, this.analyzeProps()), t && (this.attrs.ref = t), this.className = A(e || i, h, this.lismState, this.uClasses);
36
+ constructor(i) {
37
+ const { forwardedRef: t, class: s, className: e, lismClass: l, variant: r, style: o = {}, _propConfig: d = {}, ...u } = i;
38
+ this.styles = { ...o }, this._propConfig = { ...d }, this.lismClass = z(l, r), w(u) || (this.attrs = { ...u }, this.analyzeProps()), t && (this.attrs.ref = t), this.className = this.buildClassName(e, s);
39
+ }
40
+ // 最終クラス文字列の組み立て(出力順の唯一の確定地点)
41
+ // 出力順: [user/astro className] [lismClass] [lismTrait] [uClasses]
42
+ buildClassName(i, t) {
43
+ return x(i || t, this.lismClass, this.lismTrait, this.uClasses);
33
44
  }
34
- analyzeState(s, t) {
35
- const { className: i, preset: e, presetClass: l, customVar: r, tokenKey: f, setStyles: o } = s;
36
- t === !0 ? this.lismState.push(i) : e && C(e, t) ? this.lismState.push(`${i} ${l}:${String(t)}`) : t && (this.lismState.push(i), f && r ? this.addStyle(r, S(t, f)) : o && typeof t == "string" && this.addStyles(o(t)));
45
+ analyzeTrait(i, t) {
46
+ const { className: s, preset: e, presetClass: l, customVar: r, tokenKey: o } = i;
47
+ t === !0 ? this.lismTrait.push(s) : e && S(e, t) ? this.lismTrait.push(`${s} ${l}:${String(t)}`) : t && (this.lismTrait.push(s), o && r && this.addStyle(r, c(t, o)));
37
48
  }
38
49
  // prop解析
39
50
  analyzeProps() {
40
- Object.keys(this.attrs).forEach((s) => {
41
- if (Object.hasOwn(b, s)) {
42
- const t = this.extractProp(s), i = b[s];
43
- typeof i == "string" ? t && this.lismState.push(i) : this.analyzeState(i, t);
44
- } else if (Object.hasOwn(g, s)) {
45
- const t = this.attrs[s];
46
- delete this.attrs[s], this.analyzeLismProp(s, t);
51
+ const i = this.extractProp("set"), t = this.extractProp("util");
52
+ O(void 0, i).forEach((s) => this.addUtil(`set--${s}`)), O(void 0, t).forEach((s) => this.addUtil(`u--${s}`)), Object.keys(this.attrs).forEach((s) => {
53
+ if (Object.hasOwn(P, s)) {
54
+ const e = this.extractProp(s), l = P[s];
55
+ typeof l == "string" ? e && this.lismTrait.push(l) : this.analyzeTrait(l, e);
56
+ } else if (Object.hasOwn(y, s)) {
57
+ const e = this.attrs[s];
58
+ delete this.attrs[s], this.analyzeLismProp(s, e);
47
59
  } else if (s === "hov") {
48
- const t = this.extractProp(s);
49
- this.setHovProps(t);
60
+ const e = this.extractProp(s);
61
+ this.setHovProps(e);
50
62
  } else if (s === "css") {
51
- const t = this.extractProp("css");
52
- this.addStyles(t);
63
+ const e = this.extractProp("css");
64
+ this.addStyles(e);
53
65
  }
54
66
  });
55
67
  }
56
68
  // Lism Prop 解析
57
- analyzeLismProp(s, t) {
69
+ analyzeLismProp(i, t) {
58
70
  if (t == null) return;
59
- let i = g[s] || null;
60
- if (i === null) return;
61
- this._propConfig?.[s] && (i = Object.assign({}, i, this._propConfig[s]));
62
- const { base: e, ...l } = _(t);
63
- this.setAttrs(s, e, i), Object.keys(l).forEach((r) => {
64
- i && this.setAttrs(s, l[r], i, r);
71
+ let s = y[i] || null;
72
+ if (s === null) return;
73
+ this._propConfig?.[i] && (s = Object.assign({}, s, this._propConfig[i]));
74
+ const { base: e, ...l } = V(t);
75
+ this.setAttrs(i, e, s), Object.keys(l).forEach((r) => {
76
+ s && this.setAttrs(i, l[r], s, r);
65
77
  });
66
78
  }
67
- addUtil(s) {
68
- this.uClasses.push(s);
79
+ addUtil(i) {
80
+ this.uClasses.push(i);
69
81
  }
70
- addUtils(s) {
71
- this.uClasses.push(...s);
82
+ addUtils(i) {
83
+ this.uClasses.push(...i);
72
84
  }
73
85
  // addState(state) {
74
86
  // this.stateClasses.push(state);
75
87
  // }
76
- addStyle(s, t) {
77
- this.styles[s] = t;
88
+ addStyle(i, t) {
89
+ this.styles[i] = t;
78
90
  }
79
- addStyles(s) {
80
- this.styles = { ...this.styles, ...s };
91
+ addStyles(i) {
92
+ this.styles = { ...this.styles, ...i };
81
93
  }
82
- addAttrs(s) {
83
- this.addStyles(s.styles || {}), this.addUtils(s.utils || []);
94
+ addAttrs(i) {
95
+ this.addStyles(i.styles || {}), this.addUtils(i.utils || []);
84
96
  }
85
- extractProp(s) {
86
- const t = this.attrs[s];
87
- return this.attrs[s] === void 0 ? null : (delete this.attrs[s], t);
97
+ extractProp(i) {
98
+ const t = this.attrs[i];
99
+ return this.attrs[i] === void 0 ? null : (delete this.attrs[i], t);
88
100
  }
89
- extractProps(s) {
101
+ extractProps(i) {
90
102
  const t = {};
91
- return s.forEach((i) => {
92
- this.attrs[i] !== void 0 && (t[i] = this.attrs[i], delete this.attrs[i]);
103
+ return i.forEach((s) => {
104
+ this.attrs[s] !== void 0 && (t[s] = this.attrs[s], delete this.attrs[s]);
93
105
  }), t;
94
106
  }
95
107
  // utilクラスを追加するか、styleにセットするかの分岐処理 @base
96
108
  // 値が null, undefined, '', false の時はスキップ
97
- setAttrs(s, t, i = {}, e = "") {
109
+ setAttrs(i, t, s = {}, e = "") {
98
110
  if (t == null || t === "" || t === !1) return;
99
- let l = `--${s}`, r = `-${String(i.utilKey || s)}`;
100
- if (e && (l = `--${s}_${e}`, r += `_${e}`), typeof t == "string" && t.startsWith(":")) {
111
+ let l = `--${i}`, r = `-${String(s.utilKey || i)}`;
112
+ if (e && (l = `--${i}_${e}`, r += `_${e}`), typeof t == "string" && t.startsWith(":")) {
101
113
  this.addUtil(`${r}:${t.replace(":", "")}`);
102
114
  return;
103
115
  }
104
116
  if (!e) {
105
- const { presets: m, tokenClass: k, utils: $, shorthands: P } = i;
106
- if (m && C(m, t)) {
107
- const d = typeof t == "string" || typeof t == "number" ? String(t) : "";
108
- d && this.addUtil(`${r}:${d}`);
117
+ const { presets: g, tokenClass: T, utils: $, shorthands: b } = s;
118
+ if (g && S(g, t)) {
119
+ const h = typeof t == "string" || typeof t == "number" ? String(t) : "";
120
+ h && this.addUtil(`${r}:${h}`);
109
121
  return;
110
122
  }
111
- if (k && i.token && V(i.token, t)) {
112
- const d = typeof t == "string" || typeof t == "number" ? String(t) : "";
113
- d && this.addUtil(`${r}:${d}`);
123
+ if (T && s.token && E(s.token, t)) {
124
+ const h = typeof t == "string" || typeof t == "number" ? String(t) : "";
125
+ h && this.addUtil(`${r}:${h}`);
114
126
  return;
115
127
  }
116
- let c = "";
117
- if ($ && typeof t == "string" && (c = U($, t)), !c && P && typeof t == "string" && (c = U(P, t, !0)), c) {
118
- this.addUtil(`${r}:${c}`);
128
+ let a = "";
129
+ if ($ && typeof t == "string" && (a = C($, t)), !a && b && typeof t == "string" && (a = C(b, t, !0)), a) {
130
+ this.addUtil(`${r}:${a}`);
119
131
  return;
120
132
  }
121
133
  }
@@ -123,18 +135,18 @@ class w {
123
135
  this.addUtil(r);
124
136
  return;
125
137
  }
126
- const { prop: f, isVar: o, alwaysVar: u, token: h, bp: y } = i;
127
- let n;
128
- if (h && (typeof t == "string" || typeof t == "number") ? n = S(t, h) : typeof t == "string" || typeof t == "number" ? n = t : n = JSON.stringify(t), !e) {
129
- if (o) {
130
- this.addStyle(`--${s}`, n);
138
+ const { prop: o, isVar: d, alwaysVar: u, token: m, bp: k } = s;
139
+ let f;
140
+ if (m && (typeof t == "string" || typeof t == "number") ? f = c(t, m) : typeof t == "string" || typeof t == "number" ? f = t : f = JSON.stringify(t), !e) {
141
+ if (d) {
142
+ this.addStyle(`--${i}`, f);
131
143
  return;
132
- } else if (!y && !u) {
133
- this.addStyle(f, n);
144
+ } else if (!k && !u) {
145
+ this.addStyle(o, f);
134
146
  return;
135
147
  }
136
148
  }
137
- this.addUtil(r), this.addStyle(l, n);
149
+ this.addUtil(r), this.addStyle(l, f);
138
150
  }
139
151
  // setPassProps(passVars) {
140
152
  // let dataList = [];
@@ -149,40 +161,40 @@ class w {
149
161
  // this.addStyle(`--pass_${propName}`, value);
150
162
  // });
151
163
  // }
152
- setHovProps(s) {
153
- s && (s === "-" || s === !0 ? this.addUtil("-hov") : typeof s == "string" ? j(s).forEach((t) => {
164
+ setHovProps(i) {
165
+ i && (i === "-" || i === !0 ? this.addUtil("-hov") : typeof i == "string" ? j(i).forEach((t) => {
154
166
  this.addUtil(`-hov:${t}`);
155
- }) : typeof s == "object" && Object.keys(s).forEach((t) => {
156
- const i = s[t];
157
- if (!(i == null || i === "" || i === !1)) {
158
- if (i === "-" || i === !0)
167
+ }) : typeof i == "object" && Object.keys(i).forEach((t) => {
168
+ const s = i[t];
169
+ if (!(s == null || s === "" || s === !1)) {
170
+ if (s === "-" || s === !0)
159
171
  this.addUtil(`-hov:${t}`);
160
172
  else if (t === "class")
161
- j(i).forEach((e) => {
173
+ j(s).forEach((e) => {
162
174
  this.addUtil(`-hov:${e}`);
163
175
  });
164
- else if (typeof i == "string" || typeof i == "number") {
165
- const e = S(i, z(t));
176
+ else if (typeof s == "string" || typeof s == "number") {
177
+ const e = c(s, _(t));
166
178
  this.addUtil(`-hov:${t}`), this.addStyle(`--hov-${t}`, e);
167
179
  }
168
180
  }
169
181
  }));
170
182
  }
171
183
  }
172
- function G(a) {
173
- if (Object.keys(a).length === 0)
184
+ function X(n) {
185
+ if (Object.keys(n).length === 0)
174
186
  return {};
175
- const { layout: s, ...t } = a, i = new w(E(s, t));
187
+ const { layout: i, ...t } = n, s = new L(p(i, t));
176
188
  return {
177
- ...O({
178
- className: i.className,
179
- style: O(i.styles)
189
+ ...U({
190
+ className: s.className,
191
+ style: U(s.styles)
180
192
  }),
181
- ...i.attrs
193
+ ...s.attrs
182
194
  // data-* などHTMLの標準属性はそのまま渡す
183
195
  };
184
196
  }
185
197
  export {
186
- w as LismPropsData,
187
- G as default
198
+ L as LismPropsData,
199
+ X as default
188
200
  };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * base / value を合成し、最終的なクラス識別子の配列を返す。
3
+ * 値内の `-` prefix は除外マーカーとして扱われ、その識別子は base + value から除外される。
4
+ *
5
+ * `set` / `util` のいずれの prop でも共用できる汎用処理。
6
+ *
7
+ * 入力は空白区切りを基本とし、カンマ区切りも互換のため受け付ける。
8
+ * 内部 API 用途として文字列配列も受け付けるが、配列形式はユーザー向けドキュメントでは紹介していない。
9
+ */
10
+ export default function mergeSet(base: unknown, value: unknown): string[];
@@ -0,0 +1,14 @@
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
+ }
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
+ }
12
+ export {
13
+ o as default
14
+ };
@@ -26,6 +26,9 @@ export interface StackProps {
26
26
  export interface ColumnsProps {
27
27
  layout: 'columns';
28
28
  }
29
+ export interface TileGridProps {
30
+ layout: 'tileGrid';
31
+ }
29
32
  export interface FlowLayoutProps {
30
33
  layout: 'flow';
31
34
  flow?: CssValue;
@@ -43,7 +46,7 @@ export interface SwitchColsProps {
43
46
  layout: 'switchCols';
44
47
  breakSize?: CssValue;
45
48
  }
46
- export type LayoutSpecificProps = NoLayoutProps | BoxProps | CenterProps | ClusterProps | ColumnsProps | FlexProps | FlowLayoutProps | FluidColsProps | FrameProps | GridLayoutProps | StackProps | SideMainProps | SwitchColsProps;
49
+ export type LayoutSpecificProps = NoLayoutProps | BoxProps | CenterProps | ClusterProps | ColumnsProps | FlexProps | FlowLayoutProps | FluidColsProps | FrameProps | GridLayoutProps | StackProps | SideMainProps | SwitchColsProps | TileGridProps;
47
50
  export type LayoutType = Exclude<LayoutSpecificProps, NoLayoutProps>['layout'];
48
51
  export interface LayoutProps {
49
52
  layout?: LayoutType;
@@ -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 {};
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lism-css",
3
- "version": "0.11.0",
3
+ "version": "0.13.0",
4
4
  "description": "Lism CSS is a layout-first CSS framework for websites.",
5
5
  "author": {
6
6
  "name": "ddryo",
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  import type { HTMLTag, Polymorphic } from 'astro/types';
3
3
  import type { DecoratorProps } from 'lism-css/react/atomic/Decorator/getProps';
4
- import { Lism } from '../Lism';
4
+ import { Lism } from '../../Lism';
5
5
  import getProps from 'lism-css/react/atomic/Decorator/getProps';
6
6
 
7
7
  type Props<Tag extends HTMLTag = 'div'> = Polymorphic<{ as: Tag }> &
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  import type { HTMLTag, Polymorphic } from 'astro/types';
3
- import type { AstroLismBaseProps } from '../types';
4
- import { Lism } from '../Lism';
3
+ import type { AstroLismBaseProps } from '../../types';
4
+ import { Lism } from '../../Lism';
5
5
  import { getDividerProps } from 'lism-css/react/atomic/Divider/getProps';
6
6
 
7
7
  type Props<Tag extends HTMLTag = 'div'> = Polymorphic<{ as: Tag }> & AstroLismBaseProps;
@@ -2,7 +2,7 @@
2
2
  import type { HTMLTag, Polymorphic } from 'astro/types';
3
3
  import type { ElementType } from 'react';
4
4
  import type { IconProps, IconOwnProps } from 'lism-css/react/atomic/Icon/getProps';
5
- import type { AstroLismBaseProps } from '../types';
5
+ import type { AstroLismBaseProps } from '../../types';
6
6
  import getLismProps from 'lism-css/lib/getLismProps';
7
7
  import getProps from 'lism-css/react/atomic/Icon/getProps';
8
8
  import SVG from './SVG.astro';
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  import type { HTMLTag, Polymorphic } from 'astro/types';
3
- import type { AstroLismBaseProps } from '../types';
4
- import { Lism } from '../Lism';
3
+ import type { AstroLismBaseProps } from '../../types';
4
+ import { Lism } from '../../Lism';
5
5
  import getProps from 'lism-css/react/atomic/Spacer/getProps';
6
6
 
7
7
  type Props<Tag extends HTMLTag = 'div'> = Polymorphic<{ as: Tag }> & AstroLismBaseProps;
@@ -3,7 +3,6 @@
3
3
  */
4
4
 
5
5
  export * from './Lism';
6
- export { default as HTML } from './HTML';
7
6
  /** @deprecated DummyText / DummyImage (@lism-css/ui) を使用してください */
8
7
  export * from './Dummy';
9
8
 
@@ -14,26 +13,31 @@ export * from './Group';
14
13
  export * from './Heading';
15
14
  export * from './Link';
16
15
  export * from './List';
17
- export * from './Box';
18
- export * from './Flow';
19
- export * from './Flex';
20
- export * from './Cluster';
21
- export * from './Stack';
22
- export * from './Grid';
23
- export * from './FluidCols';
24
- export * from './SwitchCols';
25
- export * from './Columns';
26
- export * from './Center';
27
- export * from './SideMain';
28
- export * from './Frame';
16
+ export * from './Media';
29
17
 
30
- export * from './Container';
31
- export * from './Wrapper';
32
- export * from './Layer';
33
- export * from './LinkBox';
18
+ // layout (l--)
19
+ export * from './layout/Box';
20
+ export * from './layout/Center';
21
+ export * from './layout/Cluster';
22
+ export * from './layout/Columns';
23
+ export * from './layout/Flex';
24
+ export * from './layout/Flow';
25
+ export * from './layout/FluidCols';
26
+ export * from './layout/Frame';
27
+ export * from './layout/Grid';
28
+ export * from './layout/SideMain';
29
+ export * from './layout/Stack';
30
+ export * from './layout/SwitchCols';
31
+ export * from './layout/TileGrid';
34
32
 
35
- export * from './Decorator';
36
- export * from './Divider';
37
- export * from './Icon';
38
- export * from './Media';
39
- export * from './Spacer';
33
+ // state (is--)
34
+ export * from './state/Container';
35
+ export * from './state/Layer';
36
+ export * from './state/BoxLink';
37
+ export * from './state/Wrapper';
38
+
39
+ // atomic (a--)
40
+ export * from './atomic/Decorator';
41
+ export * from './atomic/Divider';
42
+ export * from './atomic/Icon';
43
+ export * from './atomic/Spacer';
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  import type { HTMLTag, Polymorphic } from 'astro/types';
3
- import type { AstroLismFixedLayoutProps } from '../types';
4
- import { Lism } from '../Lism';
3
+ import type { AstroLismFixedLayoutProps } from '../../types';
4
+ import { Lism } from '../../Lism';
5
5
 
6
6
  type Props<Tag extends HTMLTag = 'div'> = Polymorphic<{ as: Tag }> & AstroLismFixedLayoutProps;
7
7
 
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  import type { HTMLTag, Polymorphic } from 'astro/types';
3
- import type { AstroLismFixedLayoutProps } from '../types';
4
- import { Lism } from '../Lism';
3
+ import type { AstroLismFixedLayoutProps } from '../../types';
4
+ import { Lism } from '../../Lism';
5
5
 
6
6
  type Props<Tag extends HTMLTag = 'div'> = Polymorphic<{ as: Tag }> & AstroLismFixedLayoutProps;
7
7
 
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  import type { HTMLTag, Polymorphic } from 'astro/types';
3
- import type { AstroLismFixedLayoutProps } from '../types';
4
- import { Lism } from '../Lism';
3
+ import type { AstroLismFixedLayoutProps } from '../../types';
4
+ import { Lism } from '../../Lism';
5
5
 
6
6
  type Props<Tag extends HTMLTag = 'div'> = Polymorphic<{ as: Tag }> & AstroLismFixedLayoutProps;
7
7
 
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  import type { HTMLTag, Polymorphic } from 'astro/types';
3
- import type { AstroLismFixedLayoutProps } from '../types';
4
- import { Lism } from '../Lism';
3
+ import type { AstroLismFixedLayoutProps } from '../../types';
4
+ import { Lism } from '../../Lism';
5
5
 
6
6
  type Props<Tag extends HTMLTag = 'div'> = Polymorphic<{ as: Tag }> & AstroLismFixedLayoutProps;
7
7
 
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  import type { HTMLTag, Polymorphic } from 'astro/types';
3
- import type { AstroLismFixedLayoutProps } from '../types';
4
- import { Lism } from '../Lism';
3
+ import type { AstroLismFixedLayoutProps } from '../../types';
4
+ import { Lism } from '../../Lism';
5
5
 
6
6
  type Props<Tag extends HTMLTag = 'div'> = Polymorphic<{ as: Tag }> & AstroLismFixedLayoutProps;
7
7
 
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  import type { HTMLTag, Polymorphic } from 'astro/types';
3
- import type { AstroLismFixedLayoutProps } from '../types';
3
+ import type { AstroLismFixedLayoutProps } from '../../types';
4
4
  import type { FlowLayoutProps } from 'lism-css/lib/types/LayoutProps';
5
- import { Lism } from '../Lism';
5
+ import { Lism } from '../../Lism';
6
6
 
7
7
  type Props<Tag extends HTMLTag = 'div'> = Polymorphic<{ as: Tag }> & AstroLismFixedLayoutProps & Omit<FlowLayoutProps, 'layout'>;
8
8
 
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  import type { HTMLTag, Polymorphic } from 'astro/types';
3
- import type { AstroLismFixedLayoutProps } from '../types';
3
+ import type { AstroLismFixedLayoutProps } from '../../types';
4
4
  import type { FluidColsProps } from 'lism-css/lib/types/LayoutProps';
5
- import { Lism } from '../Lism';
5
+ import { Lism } from '../../Lism';
6
6
 
7
7
  type Props<Tag extends HTMLTag = 'div'> = Polymorphic<{ as: Tag }> & AstroLismFixedLayoutProps & Omit<FluidColsProps, 'layout'>;
8
8
 
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  import type { HTMLTag, Polymorphic } from 'astro/types';
3
- import type { AstroLismFixedLayoutProps } from '../types';
4
- import { Lism } from '../Lism';
3
+ import type { AstroLismFixedLayoutProps } from '../../types';
4
+ import { Lism } from '../../Lism';
5
5
 
6
6
  type Props<Tag extends HTMLTag = 'div'> = Polymorphic<{ as: Tag }> & AstroLismFixedLayoutProps;
7
7
 
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  import type { HTMLTag, Polymorphic } from 'astro/types';
3
- import type { AstroLismFixedLayoutProps } from '../types';
4
- import { Lism } from '../Lism';
3
+ import type { AstroLismFixedLayoutProps } from '../../types';
4
+ import { Lism } from '../../Lism';
5
5
 
6
6
  type Props<Tag extends HTMLTag = 'div'> = Polymorphic<{ as: Tag }> & AstroLismFixedLayoutProps;
7
7
 
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  import type { HTMLTag, Polymorphic } from 'astro/types';
3
- import type { AstroLismFixedLayoutProps } from '../types';
3
+ import type { AstroLismFixedLayoutProps } from '../../types';
4
4
  import type { SideMainProps } from 'lism-css/lib/types/LayoutProps';
5
- import { Lism } from '../Lism';
5
+ import { Lism } from '../../Lism';
6
6
 
7
7
  type Props<Tag extends HTMLTag = 'div'> = Polymorphic<{ as: Tag }> & AstroLismFixedLayoutProps & Omit<SideMainProps, 'layout'>;
8
8
 
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  import type { HTMLTag, Polymorphic } from 'astro/types';
3
- import type { AstroLismFixedLayoutProps } from '../types';
4
- import { Lism } from '../Lism';
3
+ import type { AstroLismFixedLayoutProps } from '../../types';
4
+ import { Lism } from '../../Lism';
5
5
 
6
6
  type Props<Tag extends HTMLTag = 'div'> = Polymorphic<{ as: Tag }> & AstroLismFixedLayoutProps;
7
7