lism-css 0.14.0 → 0.16.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 (102) hide show
  1. package/README.ja.md +6 -6
  2. package/README.md +8 -7
  3. package/bin/build-config.js +1 -4
  4. package/bin/cli.mjs +13 -3
  5. package/config/defaults/props.ts +11 -14
  6. package/config/defaults/tokens.ts +2 -2
  7. package/config/defaults/traits.ts +4 -0
  8. package/dist/components/Lism/Lism.d.ts +2 -1
  9. package/dist/components/index.d.ts +3 -3
  10. package/dist/components/index.js +57 -54
  11. package/dist/components/layout/AutoColumns/AutoColumns.d.ts +4 -0
  12. package/dist/components/layout/{FluidCols/FluidCols.stories.d.ts → AutoColumns/AutoColumns.stories.d.ts} +3 -3
  13. package/dist/components/layout/AutoColumns/index.d.ts +3 -0
  14. package/dist/components/layout/AutoColumns/index.js +8 -0
  15. package/dist/components/layout/SwitchColumns/SwitchColumns.d.ts +4 -0
  16. package/dist/components/layout/{SwitchCols/SwitchCols.stories.d.ts → SwitchColumns/SwitchColumns.stories.d.ts} +3 -3
  17. package/dist/components/layout/SwitchColumns/index.d.ts +3 -0
  18. package/dist/components/layout/SwitchColumns/index.js +8 -0
  19. package/dist/components/layout/WithSide/WithSide.d.ts +4 -0
  20. package/dist/components/layout/{SideMain/SideMain.stories.d.ts → WithSide/WithSide.stories.d.ts} +3 -3
  21. package/dist/components/layout/WithSide/index.d.ts +3 -0
  22. package/dist/components/layout/WithSide/index.js +8 -0
  23. package/dist/config/default-config.d.ts +6 -13
  24. package/dist/config/defaults/props.d.ts +5 -14
  25. package/dist/config/defaults/props.js +7 -12
  26. package/dist/config/defaults/tokens.d.ts +2 -2
  27. package/dist/config/defaults/tokens.js +2 -2
  28. package/dist/config/defaults/traits.d.ts +4 -0
  29. package/dist/config/defaults/traits.js +5 -1
  30. package/dist/config/index.d.ts +12 -26
  31. package/dist/css/base/set.css +1 -1
  32. package/dist/css/base.css +1 -1
  33. package/dist/css/main.css +1 -1
  34. package/dist/css/main_no_layer.css +1 -1
  35. package/dist/css/primitives/layout.css +1 -1
  36. package/dist/css/props.css +1 -1
  37. package/dist/css/trait.css +1 -0
  38. package/dist/css/utility.css +1 -1
  39. package/dist/lib/getLayoutProps.js +25 -25
  40. package/dist/lib/getLismProps.d.ts +5 -5
  41. package/dist/lib/getLismProps.js +101 -102
  42. package/dist/lib/types/LayoutProps.d.ts +7 -7
  43. package/dist/lib/types/TraitProps.d.ts +2 -2
  44. package/package.json +1 -1
  45. package/packages/astro/index.ts +6 -3
  46. package/packages/astro/layout/{FluidCols/FluidCols.astro → AutoColumns/AutoColumns.astro} +3 -3
  47. package/packages/astro/layout/AutoColumns/index.ts +4 -0
  48. package/packages/astro/layout/Flex/Flex.astro +3 -2
  49. package/packages/astro/layout/Flow/Flow.astro +2 -2
  50. package/packages/astro/layout/{SwitchCols/SwitchCols.astro → SwitchColumns/SwitchColumns.astro} +3 -3
  51. package/packages/astro/layout/SwitchColumns/index.ts +4 -0
  52. package/packages/astro/layout/{SideMain/SideMain.astro → WithSide/WithSide.astro} +3 -3
  53. package/packages/astro/layout/WithSide/index.ts +4 -0
  54. package/packages/astro/types.ts +3 -0
  55. package/src/scss/_auto_output.scss +12 -11
  56. package/src/scss/_prop-config.scss +5 -14
  57. package/src/scss/_with_layer.scss +8 -4
  58. package/src/scss/base/_html.scss +4 -4
  59. package/src/scss/base/set/{_innerRs.scss → _bdrsInner.scss} +1 -1
  60. package/src/scss/base/set/_hov.scss +4 -4
  61. package/src/scss/base/set/_revert.scss +6 -0
  62. package/src/scss/base/set/index.scss +2 -4
  63. package/src/scss/base/tokens/_shadow.scss +18 -12
  64. package/src/scss/base/tokens/_tokens.scss +7 -16
  65. package/src/scss/main_no_layer.scss +4 -1
  66. package/src/scss/primitives/layout/{_fluidCols.scss → _autoColumns.scss} +1 -1
  67. package/src/scss/primitives/layout/_flow.scss +1 -2
  68. package/src/scss/primitives/layout/{_switchCols.scss → _switchColumns.scss} +2 -2
  69. package/src/scss/primitives/layout/{_sideMain.scss → _withSide.scss} +1 -1
  70. package/src/scss/primitives/layout/index.scss +3 -3
  71. package/src/scss/props/_hover.scss +28 -17
  72. package/src/scss/props/_size.scss +1 -1
  73. package/src/scss/{base/set → trait/has}/_gutter.scss +1 -1
  74. package/src/scss/trait/has/_mask.scss +6 -0
  75. package/src/scss/trait/has/_snap.scss +11 -0
  76. package/src/scss/trait/has/_transition.scss +8 -0
  77. package/src/scss/trait/index.scss +12 -0
  78. package/src/scss/{primitives/trait → trait/is}/_container.scss +2 -2
  79. package/src/scss/utility/{_itemDivider.scss → _divide.scss} +10 -2
  80. package/src/scss/utility/_trimHL.scss +3 -29
  81. package/src/scss/utility/index.scss +1 -2
  82. package/dist/components/layout/FluidCols/FluidCols.d.ts +0 -4
  83. package/dist/components/layout/FluidCols/index.d.ts +0 -1
  84. package/dist/components/layout/FluidCols/index.js +0 -8
  85. package/dist/components/layout/SideMain/SideMain.d.ts +0 -4
  86. package/dist/components/layout/SideMain/index.d.ts +0 -1
  87. package/dist/components/layout/SideMain/index.js +0 -8
  88. package/dist/components/layout/SwitchCols/SwitchCols.d.ts +0 -4
  89. package/dist/components/layout/SwitchCols/index.d.ts +0 -1
  90. package/dist/components/layout/SwitchCols/index.js +0 -8
  91. package/dist/css/primitives/trait.css +0 -1
  92. package/packages/astro/layout/FluidCols/index.ts +0 -1
  93. package/packages/astro/layout/SideMain/index.ts +0 -1
  94. package/packages/astro/layout/SwitchCols/index.ts +0 -1
  95. package/src/scss/base/set/_mask.scss +0 -6
  96. package/src/scss/base/set/_transition.scss +0 -11
  97. package/src/scss/primitives/trait/index.scss +0 -6
  98. package/src/scss/utility/_snap.scss +0 -8
  99. /package/src/scss/{primitives/trait → trait/is}/_boxLink.scss +0 -0
  100. /package/src/scss/{primitives/trait → trait/is}/_coverLink.scss +0 -0
  101. /package/src/scss/{primitives/trait → trait/is}/_layer.scss +0 -0
  102. /package/src/scss/{primitives/trait → trait/is}/_wrapper.scss +0 -0
@@ -1,146 +1,149 @@
1
- import { TRAITS as C, PROPS as d } from "../config/index.js";
2
- import E from "./getLayoutProps.js";
3
- import V from "./getAtomicProps.js";
4
- import P from "./isPresetValue.js";
1
+ import { TRAITS as C, PROPS as c } from "../config/index.js";
2
+ import V from "./getLayoutProps.js";
3
+ import E from "./getAtomicProps.js";
4
+ import g from "./isPresetValue.js";
5
5
  import x from "./isTokenValue.js";
6
- import S from "./getUtilKey.js";
7
- import u from "./getMaybeCssVar.js";
6
+ import $ from "./getUtilKey.js";
7
+ import d from "./getMaybeCssVar.js";
8
8
  import w from "./getBpData.js";
9
9
  import A from "./helper/atts.js";
10
10
  import _ from "./helper/isEmptyObj.js";
11
- import p from "./helper/filterEmptyObj.js";
11
+ import S from "./helper/filterEmptyObj.js";
12
12
  import b from "./helper/mergeSet.js";
13
- import U from "./helper/splitWithComma.js";
14
- const z = (n) => {
15
- const i = d[n];
16
- return i && i?.token || "";
13
+ import z from "./helper/splitWithComma.js";
14
+ const L = (n) => {
15
+ const s = c[n];
16
+ return s && s?.token || "";
17
17
  };
18
- class L {
18
+ class T {
19
19
  // 最終出力 className
20
20
  className = "";
21
- // 出力順のためのクラスバケット: [primitiveClass] [uClasses]
22
- // - primitiveClass : a--* / l--* / is--* の primitive クラス(getAtomicProps → getLayoutProps → analyzeTrait の順で push)
23
- // - uClasses : set--* → u--* → -property の順で push される utility クラス
24
21
  primitiveClass = [];
22
+ setClasses = [];
23
+ traitClasses = [];
25
24
  uClasses = [];
25
+ propClasses = [];
26
26
  styles = {};
27
27
  attrs = {};
28
28
  _propConfig;
29
- constructor(i) {
30
- const { forwardedRef: t, class: s, className: e, primitiveClass: l, style: r = {}, _propConfig: o = {}, ...c } = i;
31
- this.styles = { ...r }, this._propConfig = { ...o }, l && l.length && (this.primitiveClass = [...l]), _(c) || (this.attrs = { ...c }, this.analyzeProps()), t && (this.attrs.ref = t), this.className = this.buildClassName(e, s);
29
+ constructor(s) {
30
+ const { forwardedRef: t, class: i, className: e, primitiveClass: o, style: r = {}, _propConfig: a = {}, ...u } = s;
31
+ this.styles = { ...r }, this._propConfig = { ...a }, o && o.length && (this.primitiveClass = [...o]), _(u) || (this.attrs = { ...u }, this.analyzeProps()), t && (this.attrs.ref = t), this.className = this.buildClassName(e, i);
32
32
  }
33
33
  // 最終クラス文字列の組み立て(出力順の唯一の確定地点)
34
- // 出力順: [className&class] [primitiveClass] [uClasses]
34
+ // 出力順: [className&class] [primitiveClass] [setClasses] [traitClasses] [uClasses] [propClasses]
35
35
  // className と class が両方来た場合は両方マージする(atts 内で重複は除去される)。
36
- buildClassName(i, t) {
37
- return A(i, t, this.primitiveClass, this.uClasses);
36
+ buildClassName(s, t) {
37
+ return A(s, t, this.primitiveClass, this.setClasses, this.traitClasses, this.uClasses, this.propClasses);
38
38
  }
39
- analyzeTrait(i, t) {
40
- const { className: s, preset: e, presetClass: l, customVar: r, tokenKey: o } = i;
41
- t === !0 ? this.primitiveClass.push(s) : e && P(e, t) ? this.primitiveClass.push(`${s} ${l}:${String(t)}`) : t && (this.primitiveClass.push(s), o && r && this.addStyle(r, u(t, o)));
39
+ analyzeTrait(s, t) {
40
+ const { className: i, preset: e, presetClass: o, customVar: r, tokenKey: a } = s;
41
+ t === !0 ? this.traitClasses.push(i) : e && g(e, t) ? this.traitClasses.push(`${i} ${o}:${String(t)}`) : t && (this.traitClasses.push(i), a && r && this.addStyle(r, d(t, a)));
42
42
  }
43
43
  // prop解析
44
44
  analyzeProps() {
45
- const i = this.extractProp("set"), t = this.extractProp("util");
46
- b(void 0, i).forEach((s) => this.addUtil(`set--${s}`)), b(void 0, t).forEach((s) => this.addUtil(`u--${s}`)), Object.keys(this.attrs).forEach((s) => {
47
- if (Object.hasOwn(C, s)) {
48
- const e = this.extractProp(s), l = C[s];
49
- typeof l == "string" ? e && this.primitiveClass.push(l) : this.analyzeTrait(l, e);
50
- } else if (Object.hasOwn(d, s)) {
51
- const e = this.attrs[s];
52
- delete this.attrs[s], this.analyzeLismProp(s, e);
53
- } else if (s === "hov") {
54
- const e = this.extractProp(s);
45
+ const s = this.extractProp("set"), t = this.extractProp("util");
46
+ b(void 0, s).forEach((i) => this.addSet(i)), b(void 0, t).forEach((i) => this.addUtil(`u--${i}`)), Object.keys(this.attrs).forEach((i) => {
47
+ if (Object.hasOwn(C, i)) {
48
+ const e = this.extractProp(i), o = C[i];
49
+ typeof o == "string" ? e && this.traitClasses.push(o) : this.analyzeTrait(o, e);
50
+ } else if (Object.hasOwn(c, i)) {
51
+ const e = this.attrs[i];
52
+ delete this.attrs[i], this.analyzeLismProp(i, e);
53
+ } else if (i === "hov") {
54
+ const e = this.extractProp(i);
55
55
  this.setHovProps(e);
56
- } else if (s === "css") {
56
+ } else if (i === "css") {
57
57
  const e = this.extractProp("css");
58
58
  this.addStyles(e);
59
59
  }
60
60
  });
61
61
  }
62
62
  // Lism Prop 解析
63
- analyzeLismProp(i, t) {
63
+ analyzeLismProp(s, t) {
64
64
  if (t == null) return;
65
- let s = d[i] || null;
66
- if (s === null) return;
67
- this._propConfig?.[i] && (s = Object.assign({}, s, this._propConfig[i]));
68
- const { base: e, ...l } = w(t);
69
- this.setAttrs(i, e, s), Object.keys(l).forEach((r) => {
70
- s && this.setAttrs(i, l[r], s, r);
65
+ let i = c[s] || null;
66
+ if (i === null) return;
67
+ this._propConfig?.[s] && (i = Object.assign({}, i, this._propConfig[s]));
68
+ const { base: e, ...o } = w(t);
69
+ this.setAttrs(s, e, i), Object.keys(o).forEach((r) => {
70
+ i && this.setAttrs(s, o[r], i, r);
71
71
  });
72
72
  }
73
- addUtil(i) {
74
- this.uClasses.push(i);
73
+ addSet(s) {
74
+ this.setClasses.push(`set--${s}`);
75
75
  }
76
- addUtils(i) {
77
- this.uClasses.push(...i);
76
+ addUtil(s) {
77
+ this.uClasses.push(s);
78
78
  }
79
- // addState(state) {
80
- // this.stateClasses.push(state);
81
- // }
82
- addStyle(i, t) {
83
- this.styles[i] = t;
79
+ addUtils(s) {
80
+ this.uClasses.push(...s);
81
+ }
82
+ addProp(s) {
83
+ this.propClasses.push(s);
84
+ }
85
+ addStyle(s, t) {
86
+ this.styles[s] = t;
84
87
  }
85
- addStyles(i) {
86
- this.styles = { ...this.styles, ...i };
88
+ addStyles(s) {
89
+ this.styles = { ...this.styles, ...s };
87
90
  }
88
- addAttrs(i) {
89
- this.addStyles(i.styles || {}), this.addUtils(i.utils || []);
91
+ addAttrs(s) {
92
+ this.addStyles(s.styles || {}), this.addUtils(s.utils || []);
90
93
  }
91
- extractProp(i) {
92
- const t = this.attrs[i];
93
- return this.attrs[i] === void 0 ? null : (delete this.attrs[i], t);
94
+ extractProp(s) {
95
+ const t = this.attrs[s];
96
+ return this.attrs[s] === void 0 ? null : (delete this.attrs[s], t);
94
97
  }
95
- extractProps(i) {
98
+ extractProps(s) {
96
99
  const t = {};
97
- return i.forEach((s) => {
98
- this.attrs[s] !== void 0 && (t[s] = this.attrs[s], delete this.attrs[s]);
100
+ return s.forEach((i) => {
101
+ this.attrs[i] !== void 0 && (t[i] = this.attrs[i], delete this.attrs[i]);
99
102
  }), t;
100
103
  }
101
- // utilクラスを追加するか、styleにセットするかの分岐処理 @base
104
+ // propertyクラスを追加するか、styleにセットするかの分岐処理 @base
102
105
  // 値が null, undefined, '', false の時はスキップ
103
- setAttrs(i, t, s = {}, e = "") {
106
+ setAttrs(s, t, i = {}, e = "") {
104
107
  if (t == null || t === "" || t === !1) return;
105
- let l = `--${i}`, r = `-${String(s.utilKey || i)}`;
106
- if (e && (l = `--${i}_${e}`, r += `_${e}`), typeof t == "string" && t.startsWith(":")) {
107
- this.addUtil(`${r}:${t.replace(":", "")}`);
108
+ let o = `--${s}`, r = `-${String(i.utilKey || s)}`;
109
+ if (e && (o = `--${s}_${e}`, r += `_${e}`), typeof t == "string" && t.startsWith(":")) {
110
+ this.addProp(`${r}:${t.replace(":", "")}`);
108
111
  return;
109
112
  }
110
113
  if (!e) {
111
- const { presets: m, tokenClass: j, utils: g, shorthands: $ } = s;
112
- if (m && P(m, t)) {
114
+ const { presets: m, tokenClass: j, utils: p, shorthands: P } = i;
115
+ if (m && g(m, t)) {
113
116
  const h = typeof t == "string" || typeof t == "number" ? String(t) : "";
114
- h && this.addUtil(`${r}:${h}`);
117
+ h && this.addProp(`${r}:${h}`);
115
118
  return;
116
119
  }
117
- if (j && s.token && x(s.token, t)) {
120
+ if (j && i.token && x(i.token, t)) {
118
121
  const h = typeof t == "string" || typeof t == "number" ? String(t) : "";
119
- h && this.addUtil(`${r}:${h}`);
122
+ h && this.addProp(`${r}:${h}`);
120
123
  return;
121
124
  }
122
- let a = "";
123
- if (g && typeof t == "string" && (a = S(g, t)), !a && $ && typeof t == "string" && (a = S($, t, !0)), a) {
124
- this.addUtil(`${r}:${a}`);
125
+ let f = "";
126
+ if (p && typeof t == "string" && (f = $(p, t)), !f && P && typeof t == "string" && (f = $(P, t, !0)), f) {
127
+ this.addProp(`${r}:${f}`);
125
128
  return;
126
129
  }
127
130
  }
128
- if (t === !0 || t === "-") {
129
- this.addUtil(r);
131
+ if (t === !0) {
132
+ this.addProp(r);
130
133
  return;
131
134
  }
132
- const { prop: o, isVar: c, alwaysVar: O, token: y, bp: k } = s;
133
- let f;
134
- if (y && (typeof t == "string" || typeof t == "number") ? f = u(t, y) : typeof t == "string" || typeof t == "number" ? f = t : f = JSON.stringify(t), !e) {
135
- if (c) {
136
- this.addStyle(`--${i}`, f);
135
+ const { prop: a, isVar: u, alwaysVar: O, token: y, bp: k } = i;
136
+ let l;
137
+ if (y && (typeof t == "string" || typeof t == "number") ? l = d(t, y) : typeof t == "string" || typeof t == "number" ? l = t : l = JSON.stringify(t), !e) {
138
+ if (u) {
139
+ this.addStyle(`--${s}`, l);
137
140
  return;
138
141
  } else if (!k && !O) {
139
- this.addStyle(o, f);
142
+ this.addStyle(a, l);
140
143
  return;
141
144
  }
142
145
  }
143
- this.addUtil(r), this.addStyle(l, f);
146
+ this.addProp(r), this.addStyle(o, l);
144
147
  }
145
148
  // setPassProps(passVars) {
146
149
  // let dataList = [];
@@ -155,21 +158,17 @@ class L {
155
158
  // this.addStyle(`--pass_${propName}`, value);
156
159
  // });
157
160
  // }
158
- setHovProps(i) {
159
- i && (i === "-" || i === !0 ? this.addUtil("-hov") : typeof i == "string" ? U(i).forEach((t) => {
160
- this.addUtil(`-hov:${t}`);
161
- }) : typeof i == "object" && Object.keys(i).forEach((t) => {
162
- const s = i[t];
163
- if (!(s == null || s === "" || s === !1)) {
164
- if (s === "-" || s === !0)
165
- this.addUtil(`-hov:${t}`);
166
- else if (t === "class")
167
- U(s).forEach((e) => {
168
- this.addUtil(`-hov:${e}`);
169
- });
170
- else if (typeof s == "string" || typeof s == "number") {
171
- const e = u(s, z(t));
172
- this.addUtil(`-hov:${t}`), this.addStyle(`--hov-${t}`, e);
161
+ setHovProps(s) {
162
+ s && (s === !0 ? this.addProp("-hov") : typeof s == "string" ? z(s).forEach((t) => {
163
+ this.addProp(`-hov:${t}`);
164
+ }) : typeof s == "object" && Object.keys(s).forEach((t) => {
165
+ const i = s[t];
166
+ if (!(i == null || i === "" || i === !1)) {
167
+ if (i === !0)
168
+ this.addProp(`-hov:${t}`);
169
+ else if (typeof i == "string" || typeof i == "number") {
170
+ const e = d(i, L(t));
171
+ this.addProp(`-hov:-${t}`), this.addStyle(`--hov-${t}`, e);
173
172
  }
174
173
  }
175
174
  }));
@@ -178,17 +177,17 @@ class L {
178
177
  function Y(n) {
179
178
  if (Object.keys(n).length === 0)
180
179
  return {};
181
- const { atomic: i, layout: t, ...s } = n, e = V(i, s), l = E(t, e), r = new L(l);
180
+ const { atomic: s, layout: t, ...i } = n, e = E(s, i), o = V(t, e), r = new T(o);
182
181
  return {
183
- ...p({
182
+ ...S({
184
183
  className: r.className,
185
- style: p(r.styles)
184
+ style: S(r.styles)
186
185
  }),
187
186
  ...r.attrs
188
187
  // data-* などHTMLの標準属性はそのまま渡す
189
188
  };
190
189
  }
191
190
  export {
192
- L as LismPropsData,
191
+ T as LismPropsData,
193
192
  Y as default
194
193
  };
@@ -33,20 +33,20 @@ export interface FlowLayoutProps {
33
33
  layout: 'flow';
34
34
  flow?: CssValue;
35
35
  }
36
- export interface FluidColsProps {
37
- layout: 'fluidCols';
36
+ export interface AutoColumnsProps {
37
+ layout: 'autoColumns';
38
38
  autoFill?: boolean;
39
39
  }
40
- export interface SideMainProps {
41
- layout: 'sideMain';
40
+ export interface WithSideProps {
41
+ layout: 'withSide';
42
42
  sideW?: CssValue;
43
43
  mainW?: CssValue;
44
44
  }
45
- export interface SwitchColsProps {
46
- layout: 'switchCols';
45
+ export interface SwitchColumnsProps {
46
+ layout: 'switchColumns';
47
47
  breakSize?: CssValue;
48
48
  }
49
- export type LayoutSpecificProps = NoLayoutProps | BoxProps | CenterProps | ClusterProps | ColumnsProps | FlexProps | FlowLayoutProps | FluidColsProps | FrameProps | GridLayoutProps | StackProps | SideMainProps | SwitchColsProps | TileGridProps;
49
+ export type LayoutSpecificProps = NoLayoutProps | BoxProps | CenterProps | ClusterProps | ColumnsProps | FlexProps | FlowLayoutProps | AutoColumnsProps | FrameProps | GridLayoutProps | StackProps | WithSideProps | SwitchColumnsProps | TileGridProps;
50
50
  export type LayoutType = Exclude<LayoutSpecificProps, NoLayoutProps>['layout'];
51
51
  export interface LayoutProps {
52
52
  layout?: LayoutType;
@@ -23,7 +23,7 @@ export type TraitProps = {
23
23
  [K in keyof TraitsConfig]?: ExtractTraitValue<TraitsConfig[K]>;
24
24
  };
25
25
  /** set prop で使われるプリセット値(エディタ補完用) */
26
- type SetPreset = 'gutter' | 'shadow' | 'hov' | 'transition' | 'mask' | 'plain' | 'innerRs';
26
+ type SetPreset = 'plain' | 'revert' | 'var:hov' | 'var:bxsh' | 'var:bdrsInner';
27
27
  /**
28
28
  * set prop の値の型。プリセット値がサジェストされつつ、任意の文字列も受け付ける。
29
29
  *
@@ -34,7 +34,7 @@ type SetPreset = 'gutter' | 'shadow' | 'hov' | 'transition' | 'mask' | 'plain' |
34
34
  */
35
35
  export type SetPropValue = WithArbitraryString<SetPreset> | WithArbitraryString<SetPreset>[];
36
36
  /** util prop で使われるプリセット値(既知の `u--` クラス名・エディタ補完用) */
37
- type UtilPreset = 'cbox' | 'trim' | 'trimChildren' | 'srOnly' | 'clipText' | 'collapseGrid' | 'snap';
37
+ type UtilPreset = 'cbox' | 'trim' | 'trimAll' | 'srOnly' | 'clipText' | 'divide' | 'cells';
38
38
  /**
39
39
  * util prop の値の型。既知の `u--` クラス名がサジェストされつつ、任意の文字列も受け付ける。
40
40
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lism-css",
3
- "version": "0.14.0",
3
+ "version": "0.16.0",
4
4
  "description": "Lism CSS is a layout-first CSS framework for websites.",
5
5
  "author": {
6
6
  "name": "ddryo",
@@ -22,12 +22,12 @@ export * from './layout/Cluster';
22
22
  export * from './layout/Columns';
23
23
  export * from './layout/Flex';
24
24
  export * from './layout/Flow';
25
- export * from './layout/FluidCols';
25
+ export * from './layout/AutoColumns';
26
26
  export * from './layout/Frame';
27
27
  export * from './layout/Grid';
28
- export * from './layout/SideMain';
28
+ export * from './layout/WithSide';
29
29
  export * from './layout/Stack';
30
- export * from './layout/SwitchCols';
30
+ export * from './layout/SwitchColumns';
31
31
  export * from './layout/TileGrid';
32
32
 
33
33
  // state (is--)
@@ -41,3 +41,6 @@ export * from './atomic/Decorator';
41
41
  export * from './atomic/Divider';
42
42
  export * from './atomic/Icon';
43
43
  export * from './atomic/Spacer';
44
+
45
+ // Type exports for Astro components
46
+ export type { AstroLismBaseProps, AstroLismFixedLayoutProps, AstroLayoutProps } from './types';
@@ -1,12 +1,12 @@
1
1
  ---
2
2
  import type { HTMLTag, Polymorphic } from 'astro/types';
3
3
  import type { AstroLismFixedLayoutProps } from '../../types';
4
- import type { FluidColsProps } from 'lism-css/lib/types/LayoutProps';
4
+ import type { AutoColumnsProps } from 'lism-css/lib/types/LayoutProps';
5
5
  import { Lism } from '../../Lism';
6
6
 
7
- type Props<Tag extends HTMLTag = 'div'> = Polymorphic<{ as: Tag }> & AstroLismFixedLayoutProps & Omit<FluidColsProps, 'layout'>;
7
+ type Props<Tag extends HTMLTag = 'div'> = Polymorphic<{ as: Tag }> & AstroLismFixedLayoutProps & Omit<AutoColumnsProps, 'layout'>;
8
8
 
9
9
  const props = Astro.props;
10
10
  ---
11
11
 
12
- <Lism layout="fluidCols" {...props}><slot /></Lism>
12
+ <Lism layout="autoColumns" {...props}><slot /></Lism>
@@ -0,0 +1,4 @@
1
+ export { default as AutoColumns } from './AutoColumns.astro';
2
+
3
+ /** @deprecated `AutoColumns` に名称変更されました。 */
4
+ export { default as FluidCols } from './AutoColumns.astro';
@@ -1,9 +1,10 @@
1
1
  ---
2
2
  import type { HTMLTag, Polymorphic } from 'astro/types';
3
- import type { AstroLismFixedLayoutProps } from '../../types';
3
+ import type { AstroLayoutProps } from '../../types';
4
+ import type { FlexProps } from 'lism-css/lib/types/LayoutProps';
4
5
  import { Lism } from '../../Lism';
5
6
 
6
- type Props<Tag extends HTMLTag = 'div'> = Polymorphic<{ as: Tag }> & AstroLismFixedLayoutProps;
7
+ type Props<Tag extends HTMLTag = 'div'> = Polymorphic<{ as: Tag }> & AstroLayoutProps<FlexProps>;
7
8
 
8
9
  const props = Astro.props;
9
10
  ---
@@ -1,10 +1,10 @@
1
1
  ---
2
2
  import type { HTMLTag, Polymorphic } from 'astro/types';
3
- import type { AstroLismFixedLayoutProps } from '../../types';
3
+ import type { AstroLayoutProps } from '../../types';
4
4
  import type { FlowLayoutProps } from 'lism-css/lib/types/LayoutProps';
5
5
  import { Lism } from '../../Lism';
6
6
 
7
- type Props<Tag extends HTMLTag = 'div'> = Polymorphic<{ as: Tag }> & AstroLismFixedLayoutProps & Omit<FlowLayoutProps, 'layout'>;
7
+ type Props<Tag extends HTMLTag = 'div'> = Polymorphic<{ as: Tag }> & AstroLayoutProps<FlowLayoutProps>;
8
8
 
9
9
  const props = Astro.props;
10
10
  ---
@@ -1,12 +1,12 @@
1
1
  ---
2
2
  import type { HTMLTag, Polymorphic } from 'astro/types';
3
3
  import type { AstroLismFixedLayoutProps } from '../../types';
4
- import type { SwitchColsProps } from 'lism-css/lib/types/LayoutProps';
4
+ import type { SwitchColumnsProps } from 'lism-css/lib/types/LayoutProps';
5
5
  import { Lism } from '../../Lism';
6
6
 
7
- type Props<Tag extends HTMLTag = 'div'> = Polymorphic<{ as: Tag }> & AstroLismFixedLayoutProps & Omit<SwitchColsProps, 'layout'>;
7
+ type Props<Tag extends HTMLTag = 'div'> = Polymorphic<{ as: Tag }> & AstroLismFixedLayoutProps & Omit<SwitchColumnsProps, 'layout'>;
8
8
 
9
9
  const props = Astro.props;
10
10
  ---
11
11
 
12
- <Lism layout="switchCols" {...props}><slot /></Lism>
12
+ <Lism layout="switchColumns" {...props}><slot /></Lism>
@@ -0,0 +1,4 @@
1
+ export { default as SwitchColumns } from './SwitchColumns.astro';
2
+
3
+ /** @deprecated `SwitchColumns` に名称変更されました。 */
4
+ export { default as SwitchCols } from './SwitchColumns.astro';
@@ -1,12 +1,12 @@
1
1
  ---
2
2
  import type { HTMLTag, Polymorphic } from 'astro/types';
3
3
  import type { AstroLismFixedLayoutProps } from '../../types';
4
- import type { SideMainProps } from 'lism-css/lib/types/LayoutProps';
4
+ import type { WithSideProps } from 'lism-css/lib/types/LayoutProps';
5
5
  import { Lism } from '../../Lism';
6
6
 
7
- type Props<Tag extends HTMLTag = 'div'> = Polymorphic<{ as: Tag }> & AstroLismFixedLayoutProps & Omit<SideMainProps, 'layout'>;
7
+ type Props<Tag extends HTMLTag = 'div'> = Polymorphic<{ as: Tag }> & AstroLismFixedLayoutProps & Omit<WithSideProps, 'layout'>;
8
8
 
9
9
  const props = Astro.props;
10
10
  ---
11
11
 
12
- <Lism layout="sideMain" {...props}><slot /></Lism>
12
+ <Lism layout="withSide" {...props}><slot /></Lism>
@@ -0,0 +1,4 @@
1
+ export { default as WithSide } from './WithSide.astro';
2
+
3
+ /** @deprecated `WithSide` に名称変更されました。 */
4
+ export { default as SideMain } from './WithSide.astro';
@@ -17,3 +17,6 @@ export type AstroLismBaseProps = LismProps &
17
17
  export type AstroLismFixedLayoutProps = Omit<LismProps, 'layout'> & {
18
18
  exProps?: Record<string, unknown>;
19
19
  };
20
+
21
+ /** レイアウトコンポーネント向けベース型(React の LayoutComponentProps<T, L> に対応) */
22
+ export type AstroLayoutProps<L = object> = AstroLismFixedLayoutProps & Omit<L, 'layout'>;
@@ -6,15 +6,15 @@
6
6
  @use './query' as query;
7
7
  @use './setting' as setting;
8
8
 
9
- /*
9
+ /*
10
10
  base_type:
11
11
  0 → なし(ユーティリティクラス以外は普通のインラインスタイルのみ)
12
12
  1 → .-d{display: var(--d)}  (メリット:importantなしでbp対応できる)
13
- 2 → .-p, [class*='-p\:'] {padding: var(--p);} の形式で、BPクラス含めて全て変数にセットするもの。
14
- 常に変数で管理されるようになるので、他の処理と絡ませることがしやすい。
15
- デメリット: *= は処理負荷が高い。また、途中のBPから使えるようにするにはCSS記述増える)
16
-
17
- 3 → BPクラスには変数使わないが、文字数省略のため baseのProperty Classだけ変数化して *= セレクタ使う
13
+ 2 → alwaysVar 対象。 .-p, [class*='-p\:'] {padding: var(--p);} の形式で、
14
+ ユーティリティクラスは --p をセットする形になる(state 変数として扱う)。
15
+ BPクラスも .-p_$bp { padding: var(--p); --p: var(--p_$bp) !important; } を出力し、
16
+ --p が常に現在値を参照できるようになる。
17
+ デメリット: *= は処理負荷が高い。
18
18
  */
19
19
 
20
20
  // マップから値を取得し、nullの場合はデフォルト値を返す
@@ -218,7 +218,7 @@ $bp_outputs: (
218
218
  $prop_data: map.get(setting.$props, $key);
219
219
  $prop_name: map.get($prop_data, prop);
220
220
  $isVar: map_get_with_default($prop_data, isVar, 0);
221
- $overwriteBaseVar: map_get_with_default($prop_data, overwriteBaseVar, 0);
221
+ $alwaysVar: map_get_with_default($prop_data, alwaysVar, 0);
222
222
  $important: map_get_with_default($prop_data, important, setting.$default_important);
223
223
 
224
224
  @if $isVar == 1 {
@@ -226,11 +226,12 @@ $bp_outputs: (
226
226
  }
227
227
 
228
228
  .-#{$key}_#{$bp} {
229
- #{$prop_name}: var(--#{$key}_#{$bp}) #{get_important_str($important)};
230
-
231
- // 常に --prop でそのBPの値を取得できるように
232
- @if $overwriteBaseVar == 1 {
229
+ @if $alwaysVar == 1 {
230
+ // state 変数扱い: --prop を単一情報源にし、--prop を上書きして property は var(--prop) を読む
231
+ #{$prop_name}: var(--#{$key}) #{get_important_str($important)};
233
232
  --#{$key}: var(--#{$key}_#{$bp}) !important;
233
+ } @else {
234
+ #{$prop_name}: var(--#{$key}_#{$bp}) #{get_important_str($important)};
234
235
  }
235
236
  }
236
237
  }
@@ -22,7 +22,6 @@ $props: (
22
22
  '2xs': 'var(--fz--2xs)',
23
23
  ),
24
24
  bp: 1,
25
- alwaysVar: 1,
26
25
  ),
27
26
  'fw': (
28
27
  prop: 'font-weight',
@@ -114,9 +113,10 @@ $props: (
114
113
  prop: 'opacity',
115
114
  utilities: (
116
115
  '0': '0',
117
- '-10': 'var(--o---10)',
118
- '-20': 'var(--o---20)',
119
- '-30': 'var(--o---30)',
116
+ 'mp': 'var(--o--mp)',
117
+ 'p': 'var(--o--p)',
118
+ 'pp': 'var(--o--pp)',
119
+ 'ppp': 'var(--o--ppp)',
120
120
  ),
121
121
  ),
122
122
  'v': (
@@ -317,7 +317,6 @@ $props: (
317
317
  ),
318
318
  bp: 1,
319
319
  alwaysVar: 1,
320
- overwriteBaseVar: 1,
321
320
  ),
322
321
  'bxsh': (
323
322
  prop: 'box-shadow',
@@ -327,9 +326,9 @@ $props: (
327
326
  '20': 'var(--bxsh--20)',
328
327
  '30': 'var(--bxsh--30)',
329
328
  '40': 'var(--bxsh--40)',
329
+ '50': 'var(--bxsh--50)',
330
330
  ),
331
331
  bp: 1,
332
- alwaysVar: 1,
333
332
  ),
334
333
  'pos': (
335
334
  prop: 'position',
@@ -405,7 +404,6 @@ $props: (
405
404
  ),
406
405
  bp: 1,
407
406
  alwaysVar: 1,
408
- overwriteBaseVar: 1,
409
407
  ),
410
408
  'px': (
411
409
  prop: 'padding-inline',
@@ -423,7 +421,6 @@ $props: (
423
421
  '80': 'var(--s80)',
424
422
  ),
425
423
  bp: 1,
426
- alwaysVar: 1,
427
424
  ),
428
425
  'py': (
429
426
  prop: 'padding-block',
@@ -441,7 +438,6 @@ $props: (
441
438
  '80': 'var(--s80)',
442
439
  ),
443
440
  bp: 1,
444
- alwaysVar: 1,
445
441
  ),
446
442
  'px-s': (
447
443
  prop: 'padding-inline-start',
@@ -493,7 +489,6 @@ $props: (
493
489
  ),
494
490
  bp: 1,
495
491
  alwaysVar: 1,
496
- overwriteBaseVar: 1,
497
492
  ),
498
493
  'mx': (
499
494
  prop: 'margin-inline',
@@ -512,7 +507,6 @@ $props: (
512
507
  'auto': 'auto',
513
508
  ),
514
509
  bp: 1,
515
- alwaysVar: 1,
516
510
  ),
517
511
  'my': (
518
512
  prop: 'margin-block',
@@ -531,7 +525,6 @@ $props: (
531
525
  'auto': 'auto',
532
526
  ),
533
527
  bp: 1,
534
- alwaysVar: 1,
535
528
  ),
536
529
  'mx-s': (
537
530
  prop: 'margin-inline-start',
@@ -609,8 +602,6 @@ $props: (
609
602
  ),
610
603
  ),
611
604
  bp: 1,
612
- alwaysVar: 1,
613
- overwriteBaseVar: 1,
614
605
  ),
615
606
  'cg': (
616
607
  prop: 'column-gap',
@@ -4,7 +4,7 @@
4
4
  @use 'sass:meta';
5
5
 
6
6
  // レイヤー順序を明示的に宣言(詳細度: 上ほど弱い)
7
- @layer lism-base, lism-primitive, lism-component, lism-custom, lism-utility;
7
+ @layer lism-base, lism-trait, lism-primitive, lism-component, lism-custom, lism-utility;
8
8
 
9
9
  @layer lism-base {
10
10
  // resetは中でも layer定義済み。 lism-base.reset となる
@@ -13,10 +13,14 @@
13
13
  @include meta.load-css('base');
14
14
  }
15
15
 
16
+ // ユーザーが明示的に宣言する trait クラス(is--* / has--*)用レイヤー。
17
+ // primitive より弱い位置に配置し、is--boxLink の display: block 等の
18
+ // 初期化的な宣言がレイアウトプリミティブ(l--stack の display: flex 等)に負けるようにする。
19
+ @layer lism-trait {
20
+ @include meta.load-css('trait');
21
+ }
22
+
16
23
  @layer lism-primitive {
17
- @layer trait {
18
- @include meta.load-css('primitives/trait');
19
- }
20
24
  @layer layout {
21
25
  @include meta.load-css('primitives/layout');
22
26
  }