lism-css 0.13.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.
@@ -1,2 +1,9 @@
1
- import { DecoratorProps } from './getProps';
1
+ import { LismComponentProps } from '../../Lism/Lism';
2
+ import { CssValue } from '../../../lib/types/LayoutProps';
3
+ export interface DecoratorOwnProps {
4
+ size?: CssValue;
5
+ clipPath?: string;
6
+ boxSizing?: string;
7
+ }
8
+ export type DecoratorProps = LismComponentProps & DecoratorOwnProps;
2
9
  export default function Decorator(props: DecoratorProps): import("react").JSX.Element;
@@ -1,9 +1,8 @@
1
1
  import { jsx as o } from "react/jsx-runtime";
2
- import t from "./getProps.js";
3
- import m from "../../Lism/index.js";
4
- function p(r) {
5
- return /* @__PURE__ */ o(m, { ...t(r) });
2
+ import t from "../../Lism/index.js";
3
+ function i(r) {
4
+ return /* @__PURE__ */ o(t, { atomic: "decorator", "aria-hidden": "true", ...r });
6
5
  }
7
6
  export {
8
- p as default
7
+ i as default
9
8
  };
@@ -1,9 +1,8 @@
1
- import { jsx as i } from "react/jsx-runtime";
2
- import { getDividerProps as o } from "./getProps.js";
1
+ import { jsx as r } from "react/jsx-runtime";
3
2
  import t from "../../Lism/index.js";
4
- function p(r) {
5
- return /* @__PURE__ */ i(t, { ...o(r) });
3
+ function d(i) {
4
+ return /* @__PURE__ */ r(t, { atomic: "divider", "aria-hidden": "true", ...i });
6
5
  }
7
6
  export {
8
- p as default
7
+ d as default
9
8
  };
@@ -1,56 +1,55 @@
1
- import S from "./presets.js";
2
- import h from "../../../lib/helper/atts.js";
3
- function d(m) {
4
- const f = {}, s = m.match(/<svg([^>]*?)>([\s\S]*?)<\/svg>/i);
5
- if (s) {
6
- const [, c, t] = s, u = /([\w-]+)=["']([^"']*)["']/g;
1
+ import p from "./presets.js";
2
+ function S(m) {
3
+ const c = {}, e = m.match(/<svg([^>]*?)>([\s\S]*?)<\/svg>/i);
4
+ if (e) {
5
+ const [, f, t] = e, u = /([\w-]+)=["']([^"']*)["']/g;
7
6
  let a;
8
- for (; (a = u.exec(c)) !== null; ) {
9
- const [, i, o] = a;
10
- if (i === "style") {
11
- const g = {};
12
- o.split(";").forEach((l) => {
13
- const [n, r] = l.split(":").map((e) => e.trim());
14
- n && r && (g[n] = r);
15
- }), f[i] = g;
7
+ for (; (a = u.exec(f)) !== null; ) {
8
+ const [, n, g] = a;
9
+ if (n === "style") {
10
+ const o = {};
11
+ g.split(";").forEach((s) => {
12
+ const [r, i] = s.split(":").map((l) => l.trim());
13
+ r && i && (o[r] = i);
14
+ }), c[n] = o;
16
15
  } else
17
- f[i] = o;
16
+ c[n] = g;
18
17
  }
19
- return { svgProps: f, svgContent: t };
18
+ return { svgProps: c, svgContent: t };
20
19
  }
21
20
  return {};
22
21
  }
23
- function b({ lismClass: m, as: f, icon: s, label: c, exProps: t = {}, ...u }) {
24
- let a = f || "span", i = "";
22
+ function C({ lismClass: m, as: c, icon: e, label: f, exProps: t = {}, ...u }) {
23
+ let a = c || "span", n = "";
25
24
  const {
26
- style: o = {},
27
- className: g = "",
28
- ...l
25
+ style: g = {},
26
+ className: o = "",
27
+ ...s
29
28
  } = u;
30
- let n = o, r = g;
31
- if (l.viewBox) {
29
+ let r = g, i = o;
30
+ if (s.viewBox) {
32
31
  a = "svg";
33
- const e = l.size;
34
- e && delete l.size, l.width || (t.width = e || "1em"), l.height || (t.height = e || "1em");
35
- } else if (l.src)
32
+ const l = s.size;
33
+ l && delete s.size, s.width || (t.width = l || "1em"), s.height || (t.height = l || "1em");
34
+ } else if (s.src)
36
35
  a = "img";
37
- else if (s)
38
- if (typeof s == "string")
39
- if (s.startsWith("<svg")) {
36
+ else if (e)
37
+ if (typeof e == "string")
38
+ if (e.startsWith("<svg")) {
40
39
  a = "_SVG_";
41
- const { svgProps: e = {}, svgContent: v = "" } = d(s), { class: y, style: _, ...p } = e;
42
- r = h(r, y), n = { ...n, ..._ }, t = { ...t, ...p, fill: "currentColor" }, i = v;
40
+ const { svgProps: l = {}, svgContent: v = "" } = S(e), { class: h, style: y, ..._ } = l;
41
+ h && (i = i ? `${i} ${h}` : h), r = { ...r, ...y }, t = { ...t, ..._, fill: "currentColor" }, n = v;
43
42
  } else {
44
- const e = S[s] || null;
45
- e != null && (a = "_SVG_", t = { ...t, ...e });
43
+ const l = p[e] || null;
44
+ l != null && (a = "_SVG_", t = { ...t, ...l });
46
45
  }
47
- else if (typeof s == "object" && s.as) {
48
- const { as: e, ...v } = s;
49
- a = e, t = { ...t, ...v };
46
+ else if (typeof e == "object" && e.as) {
47
+ const { as: l, ...v } = e;
48
+ a = l, t = { ...t, ...v };
50
49
  } else
51
- a = s;
52
- return c ? (t["aria-label"] = c, t.role = "img") : t["aria-hidden"] = "true", l.lismClass = h(m, "a--icon", r), l.style = { ...n }, { Component: a, lismProps: l, exProps: t, content: i };
50
+ a = e;
51
+ return f ? (t["aria-label"] = f, t.role = "img") : t["aria-hidden"] = "true", s.lismClass = m, s.atomic = "icon", i && (s.className = i), s.style = { ...r }, { Component: a, lismProps: s, exProps: t, content: n };
53
52
  }
54
53
  export {
55
- b as default
54
+ C as default
56
55
  };
@@ -1,9 +1,8 @@
1
- import { jsx as o } from "react/jsx-runtime";
2
- import t from "./getProps.js";
3
- import m from "../../Lism/index.js";
4
- function i(r) {
5
- return /* @__PURE__ */ o(m, { ...t(r) });
1
+ import { jsx as t } from "react/jsx-runtime";
2
+ import a from "../../Lism/index.js";
3
+ function o(r) {
4
+ return /* @__PURE__ */ t(a, { atomic: "spacer", "aria-hidden": "true", ...r });
6
5
  }
7
6
  export {
8
- i as default
7
+ o as default
9
8
  };
@@ -1,12 +1,12 @@
1
1
  import r from "./default-config.js";
2
2
  import s from "lism-css/config.js";
3
- import { objDeepMerge as e, arrayConvertToSet as n } from "./helper.js";
4
- let t = e(r, s);
5
- typeof window < "u" && window._LISM_CSS_CONFIG_ && (t = e(t, window._LISM_CSS_CONFIG_));
3
+ import { arrayConvertToSet as e, objDeepMerge as n } from "./helper.js";
4
+ let t = n(r, s);
5
+ typeof window < "u" && window._LISM_CSS_CONFIG_ && (t = n(t, window._LISM_CSS_CONFIG_));
6
6
  const i = t, { tokens: o, props: c, traits: C } = i, S = {
7
7
  color: [...o.c.values, ...o.palette.values],
8
8
  ...o
9
- }, m = n(structuredClone(S)), p = n(structuredClone(c)), u = C, l = ["sm", "md", "lg", "xl"], a = ["base", ...l];
9
+ }, m = e(structuredClone(S)), p = e(structuredClone(c)), u = C, l = ["sm", "md", "lg", "xl"], a = ["base", ...l];
10
10
  export {
11
11
  l as BREAK_POINTS,
12
12
  a as BREAK_POINTS_ALL,
@@ -0,0 +1,27 @@
1
+ import { StyleWithCustomProps } from './types';
2
+ import { AtomicType } from './types/AtomicProps';
3
+ import { CssValue } from './types/LayoutProps';
4
+ export type { AtomicType };
5
+ interface PropConfig {
6
+ isVar?: number;
7
+ [key: string]: unknown;
8
+ }
9
+ interface AtomicOwnProps {
10
+ size?: CssValue;
11
+ clipPath?: string;
12
+ boxSizing?: string;
13
+ }
14
+ type AtomicSpecificKeys = keyof AtomicOwnProps;
15
+ export interface BaseProps {
16
+ lismClass?: string;
17
+ primitiveClass?: string[];
18
+ style?: StyleWithCustomProps;
19
+ _propConfig?: Record<string, PropConfig>;
20
+ w?: unknown;
21
+ h?: unknown;
22
+ ar?: unknown;
23
+ }
24
+ interface InputProps extends BaseProps, AtomicOwnProps {
25
+ [key: string]: unknown;
26
+ }
27
+ export default function getAtomicProps<P extends InputProps>(atomic: AtomicType | undefined, props: P): Omit<P, AtomicSpecificKeys> & BaseProps;
@@ -0,0 +1,32 @@
1
+ import c from "./getBpData.js";
2
+ import f from "./getMaybeCssVar.js";
3
+ function a(r, ...t) {
4
+ return [...r ?? [], ...t];
5
+ }
6
+ function u(r) {
7
+ const t = c(r), e = {};
8
+ return Object.entries(t).forEach(([n, i]) => {
9
+ e[n] = f(i, "space");
10
+ }), e;
11
+ }
12
+ function m(r, t) {
13
+ if (!r) return t;
14
+ const e = {
15
+ ...t,
16
+ primitiveClass: a(t.primitiveClass, `a--${r}`)
17
+ };
18
+ return r === "spacer" ? l(e) : r === "decorator" ? p(e) : e;
19
+ }
20
+ function l(r) {
21
+ const t = { ...r };
22
+ return t.w != null && (t.w = u(t.w)), t.h != null && (t.h = u(t.h)), t;
23
+ }
24
+ function p({ size: r, clipPath: t, boxSizing: e, style: n, ...i }) {
25
+ const o = { ...n };
26
+ t && (o.clipPath = t), e && (o.boxSizing = e);
27
+ const s = { ...i, style: o };
28
+ return r && (s.ar = "1/1", s.w = r), s;
29
+ }
30
+ export {
31
+ m as default
32
+ };
@@ -15,6 +15,7 @@ interface LayoutOwnProps {
15
15
  type LayoutSpecificKeys = keyof LayoutOwnProps;
16
16
  export interface BaseProps {
17
17
  lismClass?: string;
18
+ primitiveClass?: string[];
18
19
  style?: StyleWithCustomProps;
19
20
  _propConfig?: Record<string, PropConfig>;
20
21
  }
@@ -1,26 +1,36 @@
1
- import r from "./helper/atts.js";
2
- import f from "./isTokenValue.js";
3
- import t from "./getMaybeCssVar.js";
4
- function g(e, s) {
5
- if (!e) return s;
6
- const i = {
7
- ...s,
8
- lismClass: r(s.lismClass, `l--${e}`)
1
+ import s from "./isTokenValue.js";
2
+ import n from "./getMaybeCssVar.js";
3
+ function f(e, ...i) {
4
+ return [...e ?? [], ...i];
5
+ }
6
+ function g(e, i) {
7
+ if (!e) return i;
8
+ const r = {
9
+ ...i,
10
+ primitiveClass: f(i.primitiveClass, `l--${e}`)
9
11
  };
10
- return e === "flow" ? a(i) : e === "sideMain" ? u(i) : e === "fluidCols" ? o(i) : e === "switchCols" ? m(i) : i;
12
+ return e === "flow" ? c(r) : e === "sideMain" ? l(r) : e === "fluidCols" ? o(r) : e === "switchCols" ? a(r) : r;
11
13
  }
12
- function u({ sideW: e, mainW: s, style: i, ...l }) {
13
- const n = { ...i };
14
- return e != null && (n["--sideW"] = t(e, "sz")), s != null && (n["--mainW"] = t(s, "sz")), { ...l, style: n };
14
+ function l({ sideW: e, mainW: i, style: r, ...t }) {
15
+ const u = { ...r };
16
+ return e != null && (u["--sideW"] = n(e, "sz")), i != null && (u["--mainW"] = n(i, "sz")), { ...t, style: u };
15
17
  }
16
- function o({ autoFill: e, style: s, ...i }) {
17
- return e ? { ...i, style: { ...s, "--autoMode": "auto-fill" } } : { ...i, style: s };
18
+ function o({ autoFill: e, style: i, ...r }) {
19
+ return e ? { ...r, style: { ...i, "--autoMode": "auto-fill" } } : { ...r, style: i };
18
20
  }
19
- function a({ flow: e, style: s, ...i }) {
20
- return f("flow", e) ? i.lismClass = r(i.lismClass, `-flow:${e}`) : e && (i.lismClass = r(i.lismClass, "-flow:"), s = { ...s, "--flow": t(e, "space") }), { ...i, style: s };
21
+ function c({ flow: e, style: i, primitiveClass: r, ...t }) {
22
+ return s("flow", e) ? {
23
+ ...t,
24
+ primitiveClass: f(r, `-flow:${e}`),
25
+ style: i
26
+ } : e ? {
27
+ ...t,
28
+ primitiveClass: f(r, "-flow:"),
29
+ style: { ...i, "--flow": n(e, "space") }
30
+ } : { ...t, primitiveClass: r, style: i };
21
31
  }
22
- function m({ breakSize: e, style: s, ...i }) {
23
- return e ? { ...i, style: { ...s, "--breakSize": t(e, "sz") } } : { ...i, style: s };
32
+ function a({ breakSize: e, style: i, ...r }) {
33
+ return e ? { ...r, style: { ...i, "--breakSize": n(e, "sz") } } : { ...r, style: i };
24
34
  }
25
35
  export {
26
36
  g as default
@@ -2,7 +2,8 @@ import { StyleWithCustomProps } from './types';
2
2
  import { TraitProps, SetPropValue, UtilPropValue } from './types/TraitProps';
3
3
  import { PropValueTypes } from './types/PropValueTypes';
4
4
  import { LayoutType, LayoutProps } from './types/LayoutProps';
5
- export { type LayoutType };
5
+ import { AtomicType, AtomicProps } from './types/AtomicProps';
6
+ export { type LayoutType, type AtomicType };
6
7
  interface PropConfig {
7
8
  prop?: string;
8
9
  token?: string | null | undefined | false;
@@ -32,9 +33,14 @@ interface TraitPropDataObject {
32
33
  }
33
34
  export interface LismPropsBase extends TraitProps, PropValueTypes {
34
35
  forwardedRef?: React.Ref<any>;
35
- class?: string;
36
+ class?: string | null;
36
37
  className?: string;
37
38
  lismClass?: string;
39
+ /**
40
+ * a--* / l--* / is--* クラスを集約する内部スロット。
41
+ * 通常は getLayoutProps / getAtomicProps 経由で push される。
42
+ */
43
+ primitiveClass?: string[];
38
44
  variant?: string;
39
45
  style?: StyleWithCustomProps;
40
46
  _propConfig?: Record<string, PropConfig>;
@@ -48,13 +54,13 @@ export interface LismPropsBase extends TraitProps, PropValueTypes {
48
54
  export declare class LismPropsData {
49
55
  className: string;
50
56
  lismClass: string;
51
- lismTrait: string[];
57
+ primitiveClass: string[];
52
58
  uClasses: string[];
53
59
  styles: StyleWithCustomProps;
54
60
  attrs: Record<string, unknown>;
55
61
  _propConfig?: Record<string, PropConfig>;
56
62
  constructor(allProps: LismPropsBase & Record<string, unknown>);
57
- buildClassName(userClassName?: string, astroClassName?: string): string;
63
+ buildClassName(userClassName?: string, astroClassName?: string | null): string;
58
64
  analyzeTrait(traitPropData: TraitPropDataObject, propVal: unknown): void;
59
65
  analyzeProps(): void;
60
66
  analyzeLismProp(propName: string, propVal: unknown): void;
@@ -71,7 +77,7 @@ export declare class LismPropsData {
71
77
  setAttrs(propKey: string, val: unknown, propConfig?: PropConfig, bpKey?: string): void;
72
78
  setHovProps(hoverData: boolean | string | Record<string, unknown> | null): void;
73
79
  }
74
- export interface LismProps extends LismPropsBase, LayoutProps {
80
+ export interface LismProps extends LismPropsBase, LayoutProps, AtomicProps {
75
81
  }
76
82
  export interface LismOutputProps {
77
83
  className?: string;
@@ -1,133 +1,144 @@
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";
12
- import j from "./helper/splitWithComma.js";
13
- const _ = (n) => {
14
- const i = y[n];
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
- 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(" ");
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}`;
22
23
  }
23
- class L {
24
+ class T {
24
25
  // 最終出力 className
25
26
  className = "";
26
- // 出力順のためのクラスバケット: [lismClass] [lismTrait] [uClasses]
27
- // - lismClass : コンポーネント基底クラス + variant + l--{layout}(getLayoutProps 側で付与済み)
28
- // - lismTrait : is--* 等の trait クラス
29
- // - uClasses : set--* → u--* → -property の順で push される utility クラス
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 クラス
30
31
  lismClass = "";
31
- lismTrait = [];
32
+ primitiveClass = [];
32
33
  uClasses = [];
33
34
  styles = {};
34
35
  attrs = {};
35
36
  _propConfig;
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);
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);
39
50
  }
40
51
  // 最終クラス文字列の組み立て(出力順の唯一の確定地点)
41
- // 出力順: [user/astro className] [lismClass] [lismTrait] [uClasses]
42
- buildClassName(i, t) {
43
- return x(i || t, this.lismClass, this.lismTrait, this.uClasses);
52
+ // 出力順: [user/astro className] [lismClass] [primitiveClass] [uClasses]
53
+ buildClassName(s, t) {
54
+ return A(s || t || void 0, this.lismClass, this.primitiveClass, this.uClasses);
44
55
  }
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)));
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)));
48
59
  }
49
60
  // prop解析
50
61
  analyzeProps() {
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);
59
- } else if (s === "hov") {
60
- 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);
61
72
  this.setHovProps(e);
62
- } else if (s === "css") {
73
+ } else if (i === "css") {
63
74
  const e = this.extractProp("css");
64
75
  this.addStyles(e);
65
76
  }
66
77
  });
67
78
  }
68
79
  // Lism Prop 解析
69
- analyzeLismProp(i, t) {
80
+ analyzeLismProp(s, t) {
70
81
  if (t == null) return;
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);
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);
77
88
  });
78
89
  }
79
- addUtil(i) {
80
- this.uClasses.push(i);
90
+ addUtil(s) {
91
+ this.uClasses.push(s);
81
92
  }
82
- addUtils(i) {
83
- this.uClasses.push(...i);
93
+ addUtils(s) {
94
+ this.uClasses.push(...s);
84
95
  }
85
96
  // addState(state) {
86
97
  // this.stateClasses.push(state);
87
98
  // }
88
- addStyle(i, t) {
89
- this.styles[i] = t;
99
+ addStyle(s, t) {
100
+ this.styles[s] = t;
90
101
  }
91
- addStyles(i) {
92
- this.styles = { ...this.styles, ...i };
102
+ addStyles(s) {
103
+ this.styles = { ...this.styles, ...s };
93
104
  }
94
- addAttrs(i) {
95
- this.addStyles(i.styles || {}), this.addUtils(i.utils || []);
105
+ addAttrs(s) {
106
+ this.addStyles(s.styles || {}), this.addUtils(s.utils || []);
96
107
  }
97
- extractProp(i) {
98
- const t = this.attrs[i];
99
- 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);
100
111
  }
101
- extractProps(i) {
112
+ extractProps(s) {
102
113
  const t = {};
103
- return i.forEach((s) => {
104
- 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]);
105
116
  }), t;
106
117
  }
107
118
  // utilクラスを追加するか、styleにセットするかの分岐処理 @base
108
119
  // 値が null, undefined, '', false の時はスキップ
109
- setAttrs(i, t, s = {}, e = "") {
120
+ setAttrs(s, t, i = {}, e = "") {
110
121
  if (t == null || t === "" || t === !1) return;
111
- let l = `--${i}`, r = `-${String(s.utilKey || i)}`;
112
- 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(":")) {
113
124
  this.addUtil(`${r}:${t.replace(":", "")}`);
114
125
  return;
115
126
  }
116
127
  if (!e) {
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}`);
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}`);
121
132
  return;
122
133
  }
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}`);
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}`);
126
137
  return;
127
138
  }
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}`);
139
+ let h = "";
140
+ if ($ && typeof t == "string" && (h = p($, t)), !h && C && typeof t == "string" && (h = p(C, t, !0)), h) {
141
+ this.addUtil(`${r}:${h}`);
131
142
  return;
132
143
  }
133
144
  }
@@ -135,14 +146,14 @@ class L {
135
146
  this.addUtil(r);
136
147
  return;
137
148
  }
138
- const { prop: o, isVar: d, alwaysVar: u, token: m, bp: k } = s;
149
+ const { prop: n, isVar: c, alwaysVar: d, token: a, bp: k } = i;
139
150
  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);
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);
143
154
  return;
144
- } else if (!k && !u) {
145
- this.addStyle(o, f);
155
+ } else if (!k && !d) {
156
+ this.addStyle(n, f);
146
157
  return;
147
158
  }
148
159
  }
@@ -161,40 +172,40 @@ class L {
161
172
  // this.addStyle(`--pass_${propName}`, value);
162
173
  // });
163
174
  // }
164
- setHovProps(i) {
165
- 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) => {
166
177
  this.addUtil(`-hov:${t}`);
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)
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)
171
182
  this.addUtil(`-hov:${t}`);
172
183
  else if (t === "class")
173
- j(s).forEach((e) => {
184
+ O(i).forEach((e) => {
174
185
  this.addUtil(`-hov:${e}`);
175
186
  });
176
- else if (typeof s == "string" || typeof s == "number") {
177
- const e = c(s, _(t));
187
+ else if (typeof i == "string" || typeof i == "number") {
188
+ const e = y(i, _(t));
178
189
  this.addUtil(`-hov:${t}`), this.addStyle(`--hov-${t}`, e);
179
190
  }
180
191
  }
181
192
  }));
182
193
  }
183
194
  }
184
- function X(n) {
185
- if (Object.keys(n).length === 0)
195
+ function Z(o) {
196
+ if (Object.keys(o).length === 0)
186
197
  return {};
187
- const { layout: i, ...t } = n, s = new L(p(i, t));
198
+ const { atomic: s, layout: t, ...i } = o, e = V(s, i), l = E(t, e), r = new T(l);
188
199
  return {
189
- ...U({
190
- className: s.className,
191
- style: U(s.styles)
200
+ ...S({
201
+ className: r.className,
202
+ style: S(r.styles)
192
203
  }),
193
- ...s.attrs
204
+ ...r.attrs
194
205
  // data-* などHTMLの標準属性はそのまま渡す
195
206
  };
196
207
  }
197
208
  export {
198
- L as LismPropsData,
199
- X as default
209
+ T as LismPropsData,
210
+ Z as default
200
211
  };
@@ -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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lism-css",
3
- "version": "0.13.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} />
@@ -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,8 +0,0 @@
1
- import { LismProps } from '../../../lib/getLismProps';
2
- export interface DecoratorOwnProps {
3
- size?: string;
4
- clipPath?: string;
5
- boxSizing?: string;
6
- }
7
- export type DecoratorProps = LismProps & DecoratorOwnProps;
8
- export default function getDecoratorProps({ lismClass, size, clipPath, boxSizing, style: outerStyle, ...rest }: DecoratorProps): LismProps;
@@ -1,15 +0,0 @@
1
- import f from "../../../lib/helper/atts.js";
2
- function p({ lismClass: e, size: s, clipPath: o, boxSizing: a, style: i, ...n }) {
3
- const r = i ?? {};
4
- o && (r.clipPath = o), a && (r.boxSizing = a);
5
- const t = { ...n };
6
- s && (t.ar = "1/1", t.w = s), t.style = r;
7
- const c = {
8
- lismClass: f(e, "a--decorator"),
9
- "aria-hidden": "true"
10
- };
11
- return Object.assign(c, t);
12
- }
13
- export {
14
- p as default
15
- };
@@ -1,2 +0,0 @@
1
- import { LismProps } from '../../../lib/getLismProps';
2
- export declare function getDividerProps({ lismClass, ...props }: LismProps): LismProps;
@@ -1,11 +0,0 @@
1
- import t from "../../../lib/helper/atts.js";
2
- function a({ lismClass: r, ...i }) {
3
- return {
4
- lismClass: t(r, "a--divider"),
5
- "aria-hidden": "true",
6
- ...i
7
- };
8
- }
9
- export {
10
- a as getDividerProps
11
- };
@@ -1,2 +0,0 @@
1
- import { LismProps } from '../../../lib/getLismProps';
2
- export default function getSpacerProps({ lismClass, ...props }: LismProps): LismProps;
@@ -1,27 +0,0 @@
1
- import s from "../../../lib/helper/atts.js";
2
- import u from "../../../lib/getBpData.js";
3
- import c from "../../../lib/getMaybeCssVar.js";
4
- function h({ lismClass: l, ...e }) {
5
- const n = {
6
- lismClass: s(l, "a--spacer"),
7
- "aria-hidden": "true"
8
- };
9
- if (e.h != null) {
10
- let t = u(e.h);
11
- t = Object.entries(t).reduce(
12
- (r, [a, i]) => (r[a] = c(i, "space"), r),
13
- {}
14
- ), e.h = t;
15
- }
16
- if (e.w != null) {
17
- let t = u(e.w);
18
- t = Object.entries(t).reduce(
19
- (r, [a, i]) => (r[a] = c(i, "space"), r),
20
- {}
21
- ), e.w = t;
22
- }
23
- return { ...n, ...e };
24
- }
25
- export {
26
- h as default
27
- };