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.
- package/dist/components/atomic/Decorator/Decorator.d.ts +8 -1
- package/dist/components/atomic/Decorator/index.js +4 -5
- package/dist/components/atomic/Divider/index.js +4 -5
- package/dist/components/atomic/Icon/getProps.js +38 -39
- package/dist/components/atomic/Spacer/index.js +5 -6
- package/dist/config/index.js +4 -4
- package/dist/lib/getAtomicProps.d.ts +27 -0
- package/dist/lib/getAtomicProps.js +32 -0
- package/dist/lib/getLayoutProps.d.ts +1 -0
- package/dist/lib/getLayoutProps.js +28 -18
- package/dist/lib/getLismProps.d.ts +11 -5
- package/dist/lib/getLismProps.js +117 -106
- package/dist/lib/types/AtomicProps.d.ts +24 -0
- package/package.json +1 -1
- package/packages/astro/atomic/Decorator/Decorator.astro +4 -7
- package/packages/astro/atomic/Divider/Divider.astro +1 -2
- package/packages/astro/atomic/Spacer/Spacer.astro +1 -2
- package/src/scss/primitives/atomic/_icon.scss +2 -2
- package/dist/components/atomic/Decorator/getProps.d.ts +0 -8
- package/dist/components/atomic/Decorator/getProps.js +0 -15
- package/dist/components/atomic/Divider/getProps.d.ts +0 -2
- package/dist/components/atomic/Divider/getProps.js +0 -11
- package/dist/components/atomic/Spacer/getProps.d.ts +0 -2
- package/dist/components/atomic/Spacer/getProps.js +0 -27
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
import {
|
|
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 "
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
7
|
+
i as default
|
|
9
8
|
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { jsx as
|
|
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
|
|
5
|
-
return /* @__PURE__ */
|
|
3
|
+
function d(i) {
|
|
4
|
+
return /* @__PURE__ */ r(t, { atomic: "divider", "aria-hidden": "true", ...i });
|
|
6
5
|
}
|
|
7
6
|
export {
|
|
8
|
-
|
|
7
|
+
d as default
|
|
9
8
|
};
|
|
@@ -1,56 +1,55 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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(
|
|
9
|
-
const [,
|
|
10
|
-
if (
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
const [
|
|
14
|
-
|
|
15
|
-
}),
|
|
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
|
-
|
|
16
|
+
c[n] = g;
|
|
18
17
|
}
|
|
19
|
-
return { svgProps:
|
|
18
|
+
return { svgProps: c, svgContent: t };
|
|
20
19
|
}
|
|
21
20
|
return {};
|
|
22
21
|
}
|
|
23
|
-
function
|
|
24
|
-
let a =
|
|
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:
|
|
27
|
-
className:
|
|
28
|
-
...
|
|
25
|
+
style: g = {},
|
|
26
|
+
className: o = "",
|
|
27
|
+
...s
|
|
29
28
|
} = u;
|
|
30
|
-
let
|
|
31
|
-
if (
|
|
29
|
+
let r = g, i = o;
|
|
30
|
+
if (s.viewBox) {
|
|
32
31
|
a = "svg";
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
} else if (
|
|
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 (
|
|
38
|
-
if (typeof
|
|
39
|
-
if (
|
|
36
|
+
else if (e)
|
|
37
|
+
if (typeof e == "string")
|
|
38
|
+
if (e.startsWith("<svg")) {
|
|
40
39
|
a = "_SVG_";
|
|
41
|
-
const { svgProps:
|
|
42
|
-
|
|
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
|
|
45
|
-
|
|
43
|
+
const l = p[e] || null;
|
|
44
|
+
l != null && (a = "_SVG_", t = { ...t, ...l });
|
|
46
45
|
}
|
|
47
|
-
else if (typeof
|
|
48
|
-
const { as:
|
|
49
|
-
a =
|
|
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 =
|
|
52
|
-
return
|
|
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
|
-
|
|
54
|
+
C as default
|
|
56
55
|
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
7
|
+
o as default
|
|
9
8
|
};
|
package/dist/config/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import r from "./default-config.js";
|
|
2
2
|
import s from "lism-css/config.js";
|
|
3
|
-
import {
|
|
4
|
-
let t =
|
|
5
|
-
typeof window < "u" && window._LISM_CSS_CONFIG_ && (t =
|
|
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 =
|
|
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
|
+
};
|
|
@@ -1,26 +1,36 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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" ?
|
|
12
|
+
return e === "flow" ? c(r) : e === "sideMain" ? l(r) : e === "fluidCols" ? o(r) : e === "switchCols" ? a(r) : r;
|
|
11
13
|
}
|
|
12
|
-
function
|
|
13
|
-
const
|
|
14
|
-
return e != null && (
|
|
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:
|
|
17
|
-
return e ? { ...
|
|
18
|
+
function o({ autoFill: e, style: i, ...r }) {
|
|
19
|
+
return e ? { ...r, style: { ...i, "--autoMode": "auto-fill" } } : { ...r, style: i };
|
|
18
20
|
}
|
|
19
|
-
function
|
|
20
|
-
return
|
|
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
|
|
23
|
-
return e ? { ...
|
|
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
|
-
|
|
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
|
-
|
|
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;
|
package/dist/lib/getLismProps.js
CHANGED
|
@@ -1,133 +1,144 @@
|
|
|
1
|
-
import { TRAITS as P, PROPS as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { TRAITS as P, PROPS as m } from "../config/index.js";
|
|
2
|
+
import E from "./getLayoutProps.js";
|
|
3
|
+
import V from "./getAtomicProps.js";
|
|
4
|
+
import b from "./isPresetValue.js";
|
|
5
|
+
import x from "./isTokenValue.js";
|
|
6
|
+
import p from "./getUtilKey.js";
|
|
7
|
+
import y from "./getMaybeCssVar.js";
|
|
8
|
+
import w from "./getBpData.js";
|
|
9
|
+
import A from "./helper/atts.js";
|
|
10
|
+
import L from "./helper/isEmptyObj.js";
|
|
11
|
+
import S from "./helper/filterEmptyObj.js";
|
|
12
|
+
import U from "./helper/mergeSet.js";
|
|
13
|
+
import O from "./helper/splitWithComma.js";
|
|
14
|
+
const _ = (o) => {
|
|
15
|
+
const s = m[o];
|
|
16
|
+
return s && s?.token || "";
|
|
16
17
|
};
|
|
17
|
-
function z(
|
|
18
|
-
if (!
|
|
19
|
-
if (!
|
|
20
|
-
const t =
|
|
21
|
-
return
|
|
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
|
|
24
|
+
class T {
|
|
24
25
|
// 最終出力 className
|
|
25
26
|
className = "";
|
|
26
|
-
// 出力順のためのクラスバケット: [lismClass] [
|
|
27
|
-
// - lismClass
|
|
28
|
-
// -
|
|
29
|
-
// - uClasses
|
|
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
|
-
|
|
32
|
+
primitiveClass = [];
|
|
32
33
|
uClasses = [];
|
|
33
34
|
styles = {};
|
|
34
35
|
attrs = {};
|
|
35
36
|
_propConfig;
|
|
36
|
-
constructor(
|
|
37
|
-
const {
|
|
38
|
-
|
|
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] [
|
|
42
|
-
buildClassName(
|
|
43
|
-
return
|
|
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(
|
|
46
|
-
const { className:
|
|
47
|
-
t === !0 ? this.
|
|
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
|
|
52
|
-
|
|
53
|
-
if (Object.hasOwn(P,
|
|
54
|
-
const e = this.extractProp(
|
|
55
|
-
typeof l == "string" ? e && this.
|
|
56
|
-
} else if (Object.hasOwn(
|
|
57
|
-
const e = this.attrs[
|
|
58
|
-
delete this.attrs[
|
|
59
|
-
} else if (
|
|
60
|
-
const e = this.extractProp(
|
|
62
|
+
const s = this.extractProp("set"), t = this.extractProp("util");
|
|
63
|
+
U(void 0, s).forEach((i) => this.addUtil(`set--${i}`)), U(void 0, t).forEach((i) => this.addUtil(`u--${i}`)), Object.keys(this.attrs).forEach((i) => {
|
|
64
|
+
if (Object.hasOwn(P, i)) {
|
|
65
|
+
const e = this.extractProp(i), l = P[i];
|
|
66
|
+
typeof l == "string" ? e && this.primitiveClass.push(l) : this.analyzeTrait(l, e);
|
|
67
|
+
} else if (Object.hasOwn(m, i)) {
|
|
68
|
+
const e = this.attrs[i];
|
|
69
|
+
delete this.attrs[i], this.analyzeLismProp(i, e);
|
|
70
|
+
} else if (i === "hov") {
|
|
71
|
+
const e = this.extractProp(i);
|
|
61
72
|
this.setHovProps(e);
|
|
62
|
-
} else if (
|
|
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(
|
|
80
|
+
analyzeLismProp(s, t) {
|
|
70
81
|
if (t == null) return;
|
|
71
|
-
let
|
|
72
|
-
if (
|
|
73
|
-
this._propConfig?.[
|
|
74
|
-
const { base: e, ...l } =
|
|
75
|
-
this.setAttrs(
|
|
76
|
-
|
|
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(
|
|
80
|
-
this.uClasses.push(
|
|
90
|
+
addUtil(s) {
|
|
91
|
+
this.uClasses.push(s);
|
|
81
92
|
}
|
|
82
|
-
addUtils(
|
|
83
|
-
this.uClasses.push(...
|
|
93
|
+
addUtils(s) {
|
|
94
|
+
this.uClasses.push(...s);
|
|
84
95
|
}
|
|
85
96
|
// addState(state) {
|
|
86
97
|
// this.stateClasses.push(state);
|
|
87
98
|
// }
|
|
88
|
-
addStyle(
|
|
89
|
-
this.styles[
|
|
99
|
+
addStyle(s, t) {
|
|
100
|
+
this.styles[s] = t;
|
|
90
101
|
}
|
|
91
|
-
addStyles(
|
|
92
|
-
this.styles = { ...this.styles, ...
|
|
102
|
+
addStyles(s) {
|
|
103
|
+
this.styles = { ...this.styles, ...s };
|
|
93
104
|
}
|
|
94
|
-
addAttrs(
|
|
95
|
-
this.addStyles(
|
|
105
|
+
addAttrs(s) {
|
|
106
|
+
this.addStyles(s.styles || {}), this.addUtils(s.utils || []);
|
|
96
107
|
}
|
|
97
|
-
extractProp(
|
|
98
|
-
const t = this.attrs[
|
|
99
|
-
return this.attrs[
|
|
108
|
+
extractProp(s) {
|
|
109
|
+
const t = this.attrs[s];
|
|
110
|
+
return this.attrs[s] === void 0 ? null : (delete this.attrs[s], t);
|
|
100
111
|
}
|
|
101
|
-
extractProps(
|
|
112
|
+
extractProps(s) {
|
|
102
113
|
const t = {};
|
|
103
|
-
return
|
|
104
|
-
this.attrs[
|
|
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(
|
|
120
|
+
setAttrs(s, t, i = {}, e = "") {
|
|
110
121
|
if (t == null || t === "" || t === !1) return;
|
|
111
|
-
let l = `--${
|
|
112
|
-
if (e && (l = `--${
|
|
122
|
+
let l = `--${s}`, r = `-${String(i.utilKey || s)}`;
|
|
123
|
+
if (e && (l = `--${s}_${e}`, r += `_${e}`), typeof t == "string" && t.startsWith(":")) {
|
|
113
124
|
this.addUtil(`${r}:${t.replace(":", "")}`);
|
|
114
125
|
return;
|
|
115
126
|
}
|
|
116
127
|
if (!e) {
|
|
117
|
-
const { presets: g, tokenClass:
|
|
118
|
-
if (g &&
|
|
119
|
-
const
|
|
120
|
-
|
|
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 (
|
|
124
|
-
const
|
|
125
|
-
|
|
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
|
|
129
|
-
if ($ && typeof t == "string" && (
|
|
130
|
-
this.addUtil(`${r}:${
|
|
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:
|
|
149
|
+
const { prop: n, isVar: c, alwaysVar: d, token: a, bp: k } = i;
|
|
139
150
|
let f;
|
|
140
|
-
if (
|
|
141
|
-
if (
|
|
142
|
-
this.addStyle(`--${
|
|
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 && !
|
|
145
|
-
this.addStyle(
|
|
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(
|
|
165
|
-
|
|
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
|
|
168
|
-
const
|
|
169
|
-
if (!(
|
|
170
|
-
if (
|
|
178
|
+
}) : typeof s == "object" && Object.keys(s).forEach((t) => {
|
|
179
|
+
const i = s[t];
|
|
180
|
+
if (!(i == null || i === "" || i === !1)) {
|
|
181
|
+
if (i === "-" || i === !0)
|
|
171
182
|
this.addUtil(`-hov:${t}`);
|
|
172
183
|
else if (t === "class")
|
|
173
|
-
|
|
184
|
+
O(i).forEach((e) => {
|
|
174
185
|
this.addUtil(`-hov:${e}`);
|
|
175
186
|
});
|
|
176
|
-
else if (typeof
|
|
177
|
-
const e =
|
|
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
|
|
185
|
-
if (Object.keys(
|
|
195
|
+
function Z(o) {
|
|
196
|
+
if (Object.keys(o).length === 0)
|
|
186
197
|
return {};
|
|
187
|
-
const { layout:
|
|
198
|
+
const { atomic: s, layout: t, ...i } = o, e = V(s, i), l = E(t, e), r = new T(l);
|
|
188
199
|
return {
|
|
189
|
-
...
|
|
190
|
-
className:
|
|
191
|
-
style:
|
|
200
|
+
...S({
|
|
201
|
+
className: r.className,
|
|
202
|
+
style: S(r.styles)
|
|
192
203
|
}),
|
|
193
|
-
...
|
|
204
|
+
...r.attrs
|
|
194
205
|
// data-* などHTMLの標準属性はそのまま渡す
|
|
195
206
|
};
|
|
196
207
|
}
|
|
197
208
|
export {
|
|
198
|
-
|
|
199
|
-
|
|
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,15 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
import type { HTMLTag, Polymorphic } from 'astro/types';
|
|
3
|
-
import type {
|
|
3
|
+
import type { AstroLismFixedLayoutProps } from '../../types';
|
|
4
|
+
import type { DecoratorOwnProps } from 'lism-css/react/atomic/Decorator/Decorator';
|
|
4
5
|
import { Lism } from '../../Lism';
|
|
5
|
-
import getProps from 'lism-css/react/atomic/Decorator/getProps';
|
|
6
6
|
|
|
7
|
-
type Props<Tag extends HTMLTag = 'div'> = Polymorphic<{ as: Tag }> &
|
|
8
|
-
DecoratorProps & {
|
|
9
|
-
exProps?: Record<string, unknown>;
|
|
10
|
-
};
|
|
7
|
+
type Props<Tag extends HTMLTag = 'div'> = Polymorphic<{ as: Tag }> & AstroLismFixedLayoutProps & DecoratorOwnProps;
|
|
11
8
|
|
|
12
9
|
const { as: Tag = 'div', exProps, ...props } = Astro.props;
|
|
13
10
|
---
|
|
14
11
|
|
|
15
|
-
<Lism as={Tag} {...
|
|
12
|
+
<Lism as={Tag} atomic="decorator" aria-hidden="true" {...props} {...exProps}><slot /></Lism>
|
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
import type { HTMLTag, Polymorphic } from 'astro/types';
|
|
3
3
|
import type { AstroLismBaseProps } from '../../types';
|
|
4
4
|
import { Lism } from '../../Lism';
|
|
5
|
-
import { getDividerProps } from 'lism-css/react/atomic/Divider/getProps';
|
|
6
5
|
|
|
7
6
|
type Props<Tag extends HTMLTag = 'div'> = Polymorphic<{ as: Tag }> & AstroLismBaseProps;
|
|
8
7
|
|
|
9
8
|
const { as: Tag = 'div', exProps, ...props } = Astro.props;
|
|
10
9
|
---
|
|
11
10
|
|
|
12
|
-
<Lism as={Tag} {...
|
|
11
|
+
<Lism as={Tag} atomic="divider" aria-hidden="true" {...props} {...exProps} />
|
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
import type { HTMLTag, Polymorphic } from 'astro/types';
|
|
3
3
|
import type { AstroLismBaseProps } from '../../types';
|
|
4
4
|
import { Lism } from '../../Lism';
|
|
5
|
-
import getProps from 'lism-css/react/atomic/Spacer/getProps';
|
|
6
5
|
|
|
7
6
|
type Props<Tag extends HTMLTag = 'div'> = Polymorphic<{ as: Tag }> & AstroLismBaseProps;
|
|
8
7
|
|
|
9
8
|
const { as: Tag = 'div', exProps, ...props } = Astro.props;
|
|
10
9
|
---
|
|
11
10
|
|
|
12
|
-
<Lism as={Tag} {...
|
|
11
|
+
<Lism as={Tag} atomic="spacer" aria-hidden="true" {...props} {...exProps} />
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
.a--icon {
|
|
2
|
-
flex-shrink: 0; //
|
|
2
|
+
flex-shrink: 0; // アイコンはflex直下の子要素にしたい場合が多いのでデフォルトで適用する
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
/* fill指定のない svg にテキストカラーを継承させる */
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
fill: currentcolor;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
/*
|
|
10
|
+
/* 属性によるサイズ指定がない場合は 1em サイズが基本 */
|
|
11
11
|
.a--icon:where(:not([width])) {
|
|
12
12
|
width: 1em;
|
|
13
13
|
height: 1em;
|
|
@@ -1,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,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
|
-
};
|