@namroodinc/liquid-editorial 0.6.2 → 0.6.4
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/README.md +36 -3
- package/UPGRADING.md +83 -0
- package/dist/chunks/{Board-BPA6mVhf.cjs → Board-CUt4j2-8.cjs} +2 -2
- package/dist/chunks/{Board-BPA6mVhf.cjs.map → Board-CUt4j2-8.cjs.map} +1 -1
- package/dist/chunks/{Board-CcIF7jS0.js → Board-z688-51u.js} +2 -2
- package/dist/chunks/{Board-CcIF7jS0.js.map → Board-z688-51u.js.map} +1 -1
- package/dist/chunks/{ColourField-DWdc4d9E.cjs → ColourField-Bk5O632x.cjs} +2 -2
- package/dist/chunks/{ColourField-DWdc4d9E.cjs.map → ColourField-Bk5O632x.cjs.map} +1 -1
- package/dist/chunks/{ColourField-BmHHxU6T.js → ColourField-BwDb7ydB.js} +2 -2
- package/dist/chunks/{ColourField-BmHHxU6T.js.map → ColourField-BwDb7ydB.js.map} +1 -1
- package/dist/chunks/{DatePicker-D5-LzTXS.cjs → DatePicker-BVsloqVY.cjs} +2 -2
- package/dist/chunks/{DatePicker-D5-LzTXS.cjs.map → DatePicker-BVsloqVY.cjs.map} +1 -1
- package/dist/chunks/{DatePicker-CFYwk6eA.js → DatePicker-C1zcScC3.js} +2 -2
- package/dist/chunks/{DatePicker-CFYwk6eA.js.map → DatePicker-C1zcScC3.js.map} +1 -1
- package/dist/chunks/{FormEditor-_gqfxL_g.js → FormEditor-C4PJu7ZF.js} +3 -3
- package/dist/chunks/{FormEditor-_gqfxL_g.js.map → FormEditor-C4PJu7ZF.js.map} +1 -1
- package/dist/chunks/{FormEditor-B-XLNrub.cjs → FormEditor-Dd44EMp_.cjs} +2 -2
- package/dist/chunks/{FormEditor-B-XLNrub.cjs.map → FormEditor-Dd44EMp_.cjs.map} +1 -1
- package/dist/chunks/Icon-WOhlu6Rp.cjs +2 -0
- package/dist/chunks/Icon-WOhlu6Rp.cjs.map +1 -0
- package/dist/chunks/Icon-spaFBU4S.js +85 -0
- package/dist/chunks/Icon-spaFBU4S.js.map +1 -0
- package/dist/components/AssetCard/index.cjs +1 -1
- package/dist/components/AssetCard/index.cjs.map +1 -1
- package/dist/components/AssetCard/index.d.cts +11 -1
- package/dist/components/AssetCard/index.d.cts.map +1 -1
- package/dist/components/AssetCard/index.d.ts +11 -1
- package/dist/components/AssetCard/index.d.ts.map +1 -1
- package/dist/components/AssetCard/index.js +93 -57
- package/dist/components/AssetCard/index.js.map +1 -1
- package/dist/components/AssetCard/style.css +22 -5
- package/dist/components/AssetGrid/index.cjs +1 -1
- package/dist/components/AssetGrid/index.js +1 -1
- package/dist/components/AssetGrid/style.css +2 -1
- package/dist/components/Board/index.cjs +1 -1
- package/dist/components/Board/index.js +1 -1
- package/dist/components/Button/index.cjs +1 -1
- package/dist/components/Button/index.js +1 -1
- package/dist/components/ColourField/index.cjs +1 -1
- package/dist/components/ColourField/index.js +1 -1
- package/dist/components/DatePicker/index.cjs +1 -1
- package/dist/components/DatePicker/index.js +1 -1
- package/dist/components/EditLayout/index.cjs +1 -1
- package/dist/components/EditLayout/index.cjs.map +1 -1
- package/dist/components/EditLayout/index.d.cts +6 -0
- package/dist/components/EditLayout/index.d.cts.map +1 -1
- package/dist/components/EditLayout/index.d.ts +6 -0
- package/dist/components/EditLayout/index.d.ts.map +1 -1
- package/dist/components/EditLayout/index.js +104 -97
- package/dist/components/EditLayout/index.js.map +1 -1
- package/dist/components/EditLayout/style.css +8 -1
- package/dist/components/EntryPicker/index.cjs +1 -1
- package/dist/components/EntryPicker/index.js +1 -1
- package/dist/components/FormEditor/index.cjs +1 -1
- package/dist/components/FormEditor/index.js +1 -1
- package/dist/components/Grid/style.css +8 -6
- package/dist/components/Icon/icons.d.cts +4 -0
- package/dist/components/Icon/icons.d.cts.map +1 -1
- package/dist/components/Icon/icons.d.ts +4 -0
- package/dist/components/Icon/icons.d.ts.map +1 -1
- package/dist/components/Icon/index.cjs +1 -1
- package/dist/components/Icon/index.js +1 -1
- package/dist/components/SearchField/index.cjs +1 -1
- package/dist/components/SearchField/index.js +1 -1
- package/dist/components/Select/index.cjs +1 -1
- package/dist/components/Select/index.js +1 -1
- package/dist/components/SideNav/index.cjs +1 -1
- package/dist/components/SideNav/index.js +1 -1
- package/dist/components/SortableList/index.cjs +1 -1
- package/dist/components/SortableList/index.js +1 -1
- package/dist/components/Stepper/index.cjs +1 -1
- package/dist/components/Stepper/index.js +1 -1
- package/dist/components/SubNav/index.cjs +1 -1
- package/dist/components/SubNav/index.js +1 -1
- package/dist/components/Table/index.cjs +1 -1
- package/dist/components/Table/index.js +1 -1
- package/dist/components/Toast/index.cjs +1 -1
- package/dist/components/Toast/index.js +1 -1
- package/dist/components/TopNav/index.cjs +1 -1
- package/dist/components/TopNav/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +5 -5
- package/package.json +1 -1
- package/dist/chunks/Icon-D1kx7-1c.js +0 -81
- package/dist/chunks/Icon-D1kx7-1c.js.map +0 -1
- package/dist/chunks/Icon-D38lQXNe.cjs +0 -2
- package/dist/chunks/Icon-D38lQXNe.cjs.map +0 -1
|
@@ -1,147 +1,183 @@
|
|
|
1
|
-
import { t as e } from "../../chunks/Icon-
|
|
1
|
+
import { t as e } from "../../chunks/Icon-spaFBU4S.js";
|
|
2
2
|
import { Button as t } from "../Button/index.js";
|
|
3
3
|
import { Skeleton as n } from "../Skeleton/index.js";
|
|
4
|
-
import { forwardRef as r, useCallback as i,
|
|
5
|
-
import { Fragment as
|
|
4
|
+
import { forwardRef as r, useCallback as i, useEffect as a, useId as o, useState as s } from "react";
|
|
5
|
+
import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
6
6
|
//#region src/components/AssetCard/index.tsx
|
|
7
|
-
function
|
|
8
|
-
return /* @__PURE__ */
|
|
7
|
+
function d({ icon: t, label: n }) {
|
|
8
|
+
return /* @__PURE__ */ l("span", {
|
|
9
9
|
className: "ds-asset-card__placeholder ds-asset-tile__placeholder",
|
|
10
|
-
children: /* @__PURE__ */
|
|
10
|
+
children: /* @__PURE__ */ l(e, {
|
|
11
11
|
name: t,
|
|
12
12
|
size: 24,
|
|
13
13
|
"aria-label": n
|
|
14
14
|
})
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
|
-
function
|
|
18
|
-
let [r,
|
|
19
|
-
|
|
17
|
+
function f({ src: e, alt: t }) {
|
|
18
|
+
let [r, a] = s("loading"), [o, f] = s(), p = i((e) => {
|
|
19
|
+
a("loaded"), e.naturalWidth && e.naturalHeight && f(e.naturalWidth / e.naturalHeight);
|
|
20
20
|
}, []), m = i((e) => {
|
|
21
21
|
e?.complete && (e.naturalWidth > 0 ? p(e) : e.decode().then(() => p(e), () => {}));
|
|
22
22
|
}, [p]);
|
|
23
|
-
return r === "failed" ? /* @__PURE__ */
|
|
23
|
+
return r === "failed" ? /* @__PURE__ */ l(d, {
|
|
24
24
|
icon: "alert-triangle",
|
|
25
25
|
label: t ? `${t} (preview unavailable)` : "Preview unavailable"
|
|
26
|
-
}) : /* @__PURE__ */ c
|
|
26
|
+
}) : /* @__PURE__ */ u(c, { children: [r === "loading" && /* @__PURE__ */ l(n, {
|
|
27
27
|
shape: "block",
|
|
28
28
|
className: "ds-asset-card__thumb-skeleton ds-asset-tile__thumb-skeleton"
|
|
29
|
-
}), /* @__PURE__ */
|
|
29
|
+
}), /* @__PURE__ */ l("img", {
|
|
30
30
|
ref: m,
|
|
31
31
|
src: e,
|
|
32
32
|
alt: t,
|
|
33
33
|
loading: "lazy",
|
|
34
34
|
"data-loaded": r === "loaded" || void 0,
|
|
35
|
-
style:
|
|
35
|
+
style: o ? { "--asset-ratio": o } : void 0,
|
|
36
36
|
onLoad: (e) => p(e.currentTarget),
|
|
37
|
-
onError: () =>
|
|
37
|
+
onError: () => a("failed")
|
|
38
38
|
})] });
|
|
39
39
|
}
|
|
40
|
-
var
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
var p = (e) => /^on[A-Z]/.test(e), m = !1;
|
|
41
|
+
function h(e) {
|
|
42
|
+
a(() => {
|
|
43
|
+
e && !m && process.env.NODE_ENV !== "production" && (m = !0, console.warn("AssetCard: `linkProps` replaces `onSelect`, so the thumbnail navigates and `onSelect` is never called. Pass one of them, and put selection on an `actions` control."));
|
|
44
|
+
}, [e]);
|
|
45
|
+
}
|
|
46
|
+
function g({ name: e, linkProps: { href: t, tabIndex: n, className: r, ...i }, isPending: a, isSelected: s }) {
|
|
47
|
+
let d = o(), f = a ? Object.fromEntries(Object.entries(i).filter(([e]) => !p(e))) : i, m = [i["aria-describedby"], s && d].filter(Boolean).join(" ");
|
|
48
|
+
return /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("a", {
|
|
49
|
+
...f,
|
|
50
|
+
href: a ? void 0 : t,
|
|
51
|
+
tabIndex: a ? void 0 : n,
|
|
52
|
+
role: a ? "link" : i.role,
|
|
53
|
+
"aria-label": i["aria-label"] ?? e,
|
|
54
|
+
"aria-disabled": a || i["aria-disabled"],
|
|
55
|
+
"aria-describedby": m || void 0,
|
|
56
|
+
className: ["ds-asset-card__hit ds-asset-tile__hit ds-asset-card__link ds-asset-tile__link", r].filter(Boolean).join(" ")
|
|
57
|
+
}), s ? /* @__PURE__ */ l("span", {
|
|
58
|
+
id: d,
|
|
59
|
+
hidden: !0,
|
|
60
|
+
children: "Selected"
|
|
61
|
+
}) : null] });
|
|
62
|
+
}
|
|
63
|
+
function _({ linkProps: e, onSelect: n, ...r }) {
|
|
64
|
+
let { name: i, isPending: a, isSelected: o } = r;
|
|
65
|
+
return h(!!(e && n)), e ? /* @__PURE__ */ l(g, {
|
|
66
|
+
...r,
|
|
67
|
+
linkProps: e
|
|
68
|
+
}) : n ? /* @__PURE__ */ l(t, {
|
|
69
|
+
variant: "simple",
|
|
70
|
+
className: "ds-asset-card__hit ds-asset-tile__hit",
|
|
71
|
+
"aria-pressed": o,
|
|
72
|
+
"aria-label": i,
|
|
73
|
+
isDisabled: a,
|
|
74
|
+
onClick: n
|
|
75
|
+
}) : null;
|
|
76
|
+
}
|
|
77
|
+
var v = r(function({ name: t, src: n, alt: r = "", icon: i = "image", fit: a = "cover", meta: o, description: s, isSelected: c = !1, isPending: p = !1, onSelect: m, linkProps: h, actions: g, footer: v, className: y, ...b }, x) {
|
|
78
|
+
return /* @__PURE__ */ u("div", {
|
|
79
|
+
ref: x,
|
|
43
80
|
className: [
|
|
44
81
|
"ds-asset-card",
|
|
45
82
|
"ds-asset-tile",
|
|
46
|
-
|
|
83
|
+
y
|
|
47
84
|
].filter(Boolean).join(" "),
|
|
48
|
-
"data-fit":
|
|
49
|
-
"data-selected":
|
|
50
|
-
"data-pending":
|
|
51
|
-
...
|
|
85
|
+
"data-fit": a,
|
|
86
|
+
"data-selected": c || void 0,
|
|
87
|
+
"data-pending": p || void 0,
|
|
88
|
+
...b,
|
|
52
89
|
children: [
|
|
53
|
-
/* @__PURE__ */
|
|
90
|
+
/* @__PURE__ */ u("div", {
|
|
54
91
|
className: "ds-asset-card__thumb ds-asset-tile__thumb",
|
|
55
92
|
children: [
|
|
56
|
-
|
|
57
|
-
src:
|
|
58
|
-
alt:
|
|
59
|
-
},
|
|
60
|
-
|
|
93
|
+
n ? /* @__PURE__ */ l(f, {
|
|
94
|
+
src: n,
|
|
95
|
+
alt: r
|
|
96
|
+
}, n) : /* @__PURE__ */ l(d, { icon: i }),
|
|
97
|
+
p && /* @__PURE__ */ u("span", {
|
|
61
98
|
className: "ds-asset-card__pending ds-asset-tile__pending",
|
|
62
99
|
role: "status",
|
|
63
|
-
children: [/* @__PURE__ */
|
|
100
|
+
children: [/* @__PURE__ */ l(e, {
|
|
64
101
|
name: "spinner",
|
|
65
102
|
size: 20,
|
|
66
103
|
className: "ds-asset-card__spinner ds-asset-tile__spinner ds-icon--spin"
|
|
67
|
-
}), /* @__PURE__ */
|
|
104
|
+
}), /* @__PURE__ */ l("span", {
|
|
68
105
|
className: "ds-asset-card__pending-label ds-asset-tile__pending-label",
|
|
69
106
|
children: "Uploading"
|
|
70
107
|
})]
|
|
71
108
|
}),
|
|
72
|
-
g ? /* @__PURE__ */
|
|
109
|
+
g ? /* @__PURE__ */ l("div", {
|
|
73
110
|
className: "ds-asset-card__actions ds-asset-tile__actions",
|
|
74
111
|
children: g
|
|
75
112
|
}) : null,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
onClick: h
|
|
113
|
+
/* @__PURE__ */ l(_, {
|
|
114
|
+
name: t,
|
|
115
|
+
linkProps: h,
|
|
116
|
+
onSelect: m,
|
|
117
|
+
isPending: p,
|
|
118
|
+
isSelected: c
|
|
83
119
|
})
|
|
84
120
|
]
|
|
85
121
|
}),
|
|
86
|
-
/* @__PURE__ */
|
|
122
|
+
/* @__PURE__ */ u("div", {
|
|
87
123
|
className: "ds-asset-card__text ds-asset-tile__text",
|
|
88
124
|
children: [
|
|
89
|
-
/* @__PURE__ */
|
|
125
|
+
/* @__PURE__ */ l("span", {
|
|
90
126
|
className: "ds-asset-card__name ds-asset-tile__name",
|
|
91
|
-
children:
|
|
127
|
+
children: t
|
|
92
128
|
}),
|
|
93
|
-
|
|
129
|
+
o ? /* @__PURE__ */ l("div", {
|
|
94
130
|
className: "ds-asset-card__meta ds-asset-tile__meta",
|
|
95
|
-
children:
|
|
131
|
+
children: o
|
|
96
132
|
}) : null,
|
|
97
|
-
|
|
133
|
+
s ? /* @__PURE__ */ l("div", {
|
|
98
134
|
className: "ds-asset-card__description",
|
|
99
|
-
children:
|
|
135
|
+
children: s
|
|
100
136
|
}) : null
|
|
101
137
|
]
|
|
102
138
|
}),
|
|
103
|
-
|
|
139
|
+
v ? /* @__PURE__ */ l("div", {
|
|
104
140
|
className: "ds-asset-card__footer",
|
|
105
|
-
children:
|
|
141
|
+
children: v
|
|
106
142
|
}) : null
|
|
107
143
|
]
|
|
108
144
|
});
|
|
109
145
|
});
|
|
110
|
-
function
|
|
146
|
+
function y({ index: e = 0, description: t = !1, footer: r = !1 }) {
|
|
111
147
|
let i = { animationDelay: `calc(var(--skeleton-stagger) * ${e})` };
|
|
112
|
-
return /* @__PURE__ */
|
|
148
|
+
return /* @__PURE__ */ u("div", {
|
|
113
149
|
className: "ds-asset-card ds-asset-tile",
|
|
114
150
|
"data-loading": "true",
|
|
115
151
|
"aria-hidden": "true",
|
|
116
152
|
children: [
|
|
117
|
-
/* @__PURE__ */
|
|
153
|
+
/* @__PURE__ */ l(n, {
|
|
118
154
|
shape: "block",
|
|
119
155
|
className: "ds-asset-card__thumb ds-asset-tile__thumb",
|
|
120
156
|
style: i
|
|
121
157
|
}),
|
|
122
|
-
/* @__PURE__ */
|
|
158
|
+
/* @__PURE__ */ u("div", {
|
|
123
159
|
className: "ds-asset-card__text ds-asset-tile__text",
|
|
124
160
|
children: [
|
|
125
|
-
/* @__PURE__ */
|
|
161
|
+
/* @__PURE__ */ l(n, {
|
|
126
162
|
shape: "text",
|
|
127
163
|
width: "80%",
|
|
128
164
|
style: i
|
|
129
165
|
}),
|
|
130
|
-
/* @__PURE__ */
|
|
166
|
+
/* @__PURE__ */ l(n, {
|
|
131
167
|
shape: "text",
|
|
132
168
|
width: "45%",
|
|
133
169
|
style: i
|
|
134
170
|
}),
|
|
135
|
-
t && /* @__PURE__ */
|
|
171
|
+
t && /* @__PURE__ */ l(n, {
|
|
136
172
|
shape: "text",
|
|
137
173
|
width: "65%",
|
|
138
174
|
style: i
|
|
139
175
|
})
|
|
140
176
|
]
|
|
141
177
|
}),
|
|
142
|
-
r && /* @__PURE__ */
|
|
178
|
+
r && /* @__PURE__ */ l("div", {
|
|
143
179
|
className: "ds-asset-card__footer",
|
|
144
|
-
children: /* @__PURE__ */
|
|
180
|
+
children: /* @__PURE__ */ l(n, {
|
|
145
181
|
shape: "block",
|
|
146
182
|
width: "45%",
|
|
147
183
|
style: {
|
|
@@ -154,6 +190,6 @@ function f({ index: e = 0, description: t = !1, footer: r = !1 }) {
|
|
|
154
190
|
});
|
|
155
191
|
}
|
|
156
192
|
//#endregion
|
|
157
|
-
export {
|
|
193
|
+
export { v as AssetCard, y as AssetCardSkeleton };
|
|
158
194
|
|
|
159
195
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_Fragment","Icon","Fragment$1","Placeholder","icon","label","AssetImage","status","setStatus","useState","ratio","setRatio","adopt","useCallback","image","imageRef","alt","Skeleton","event","AssetCard","forwardRef","rest","className","fit","isSelected","isPending","src","actions","onSelect","Button","name","meta","description","footer","AssetCardSkeleton","delay","index"],"sources":["../../../src/components/AssetCard/index.tsx"],"sourcesContent":["import {\n forwardRef,\n useCallback,\n useState,\n type CSSProperties,\n type HTMLAttributes,\n type ReactNode,\n} from \"react\";\nimport { Button } from \"../Button\";\nimport { Icon } from \"../Icon\";\nimport type { IconName } from \"../Icon/icons\";\nimport { Skeleton } from \"../Skeleton\";\nimport \"./style.css\";\n\nexport interface AssetCardProps extends Omit<HTMLAttributes<HTMLDivElement>, \"onSelect\" | \"title\"> {\n /** File name or crop label, displayed in full. */\n name: string;\n /** Thumbnail source. Omit to display the fallback icon. */\n src?: string;\n /** Alternative text for the preview; empty when the image is decorative. */\n alt?: string;\n /** Fallback for assets without a thumbnail, such as videos and PDFs. */\n icon?: IconName;\n /** Fill the frame, or show the complete image on an inset preview stage. */\n fit?: \"cover\" | \"contain\";\n /** Dimensions, size, ratio, or other metadata below the name. */\n meta?: ReactNode;\n /** Supporting content below the metadata, such as a source file name. */\n description?: ReactNode;\n /** Paint the selection fill and rail without changing the card's size. */\n isSelected?: boolean;\n /** Show an uploading overlay and disable the thumbnail action. */\n isPending?: boolean;\n /** Makes the thumbnail a selection toggle, independent of overlay and footer controls. */\n onSelect?: () => void;\n /** Badges, buttons, or menus pinned across the top of the thumbnail. */\n actions?: ReactNode;\n /** Actions or content below the card's text. */\n footer?: ReactNode;\n}\n\nfunction Placeholder({ icon, label }: { icon: IconName; label?: string }) {\n return (\n <span className=\"ds-asset-card__placeholder ds-asset-tile__placeholder\">\n <Icon\n name={icon}\n size={24}\n aria-label={label}\n />\n </span>\n );\n}\n\n/** Remount for each source so failed and loaded states cannot leak to another image. */\nfunction AssetImage({ src, alt }: { src: string; alt: string }) {\n const [status, setStatus] = useState<\"loading\" | \"loaded\" | \"failed\">(\"loading\");\n // The picture's own shape lets a contained preview fill the stage exactly.\n const [ratio, setRatio] = useState<number>();\n const adopt = useCallback((image: HTMLImageElement) => {\n setStatus(\"loaded\");\n if (image.naturalWidth && image.naturalHeight) {\n setRatio(image.naturalWidth / image.naturalHeight);\n }\n }, []);\n // A cached image can finish before onLoad is attached. Only success is read\n // here: an SVG without intrinsic size and a deferred lazy image also report\n // a zero naturalWidth, so failure is left to the error event.\n const imageRef = useCallback(\n (image: HTMLImageElement | null) => {\n if (!image?.complete) {\n return;\n }\n if (image.naturalWidth > 0) {\n adopt(image);\n } else {\n image.decode().then(\n () => adopt(image),\n () => {},\n );\n }\n },\n [adopt],\n );\n\n if (status === \"failed\") {\n return (\n <Placeholder\n icon=\"alert-triangle\"\n label={alt ? `${alt} (preview unavailable)` : \"Preview unavailable\"}\n />\n );\n }\n\n return (\n <>\n {status === \"loading\" && (\n <Skeleton\n shape=\"block\"\n className=\"ds-asset-card__thumb-skeleton ds-asset-tile__thumb-skeleton\"\n />\n )}\n <img\n ref={imageRef}\n src={src}\n alt={alt}\n loading=\"lazy\"\n data-loaded={status === \"loaded\" || undefined}\n style={ratio ? ({ \"--asset-ratio\": ratio } as CSSProperties) : undefined}\n onLoad={(event) => adopt(event.currentTarget)}\n onError={() => setStatus(\"failed\")}\n />\n </>\n );\n}\n\n/** Shared presentation for assets, source files, and crop variants. */\nexport const AssetCard = forwardRef<HTMLDivElement, AssetCardProps>(function AssetCard(\n {\n name,\n src,\n alt = \"\",\n icon = \"image\",\n fit = \"cover\",\n meta,\n description,\n isSelected = false,\n isPending = false,\n onSelect,\n actions,\n footer,\n className,\n ...rest\n },\n ref,\n) {\n return (\n <div\n ref={ref}\n className={[\"ds-asset-card\", \"ds-asset-tile\", className].filter(Boolean).join(\" \")}\n data-fit={fit}\n data-selected={isSelected || undefined}\n data-pending={isPending || undefined}\n {...rest}\n >\n <div className=\"ds-asset-card__thumb ds-asset-tile__thumb\">\n {src ? (\n <AssetImage\n key={src}\n src={src}\n alt={alt}\n />\n ) : (\n <Placeholder icon={icon} />\n )}\n {isPending && (\n <span\n className=\"ds-asset-card__pending ds-asset-tile__pending\"\n role=\"status\"\n >\n <Icon\n name=\"spinner\"\n size={20}\n className=\"ds-asset-card__spinner ds-asset-tile__spinner ds-icon--spin\"\n />\n <span className=\"ds-asset-card__pending-label ds-asset-tile__pending-label\">\n Uploading\n </span>\n </span>\n )}\n {/* Slots render only for truthy content, so `count && …` never leaves a stray 0. */}\n {actions ? (\n <div className=\"ds-asset-card__actions ds-asset-tile__actions\">{actions}</div>\n ) : null}\n {onSelect && (\n <Button\n variant=\"simple\"\n className=\"ds-asset-card__hit ds-asset-tile__hit\"\n aria-pressed={isSelected}\n aria-label={name}\n isDisabled={isPending}\n onClick={onSelect}\n />\n )}\n </div>\n <div className=\"ds-asset-card__text ds-asset-tile__text\">\n <span className=\"ds-asset-card__name ds-asset-tile__name\">{name}</span>\n {meta ? <div className=\"ds-asset-card__meta ds-asset-tile__meta\">{meta}</div> : null}\n {description ? <div className=\"ds-asset-card__description\">{description}</div> : null}\n </div>\n {footer ? <div className=\"ds-asset-card__footer\">{footer}</div> : null}\n </div>\n );\n});\n\nexport interface AssetCardSkeletonProps {\n /** Position in the collection, used for the skeleton stagger. */\n index?: number;\n /** Reserve the description line, for cards that pass `description`. */\n description?: boolean;\n /** Reserve a footer row the height of a small Button, for cards that pass `footer`. */\n footer?: boolean;\n}\n\n/** A loading card. Match its slots to the real cards so nothing moves when they arrive. */\nexport function AssetCardSkeleton({\n index = 0,\n description = false,\n footer = false,\n}: AssetCardSkeletonProps) {\n const delay = { animationDelay: `calc(var(--skeleton-stagger) * ${index})` };\n return (\n <div\n className=\"ds-asset-card ds-asset-tile\"\n data-loading=\"true\"\n aria-hidden=\"true\"\n >\n <Skeleton\n shape=\"block\"\n className=\"ds-asset-card__thumb ds-asset-tile__thumb\"\n style={delay}\n />\n <div className=\"ds-asset-card__text ds-asset-tile__text\">\n <Skeleton\n shape=\"text\"\n width=\"80%\"\n style={delay}\n />\n <Skeleton\n shape=\"text\"\n width=\"45%\"\n style={delay}\n />\n {description && (\n <Skeleton\n shape=\"text\"\n width=\"65%\"\n style={delay}\n />\n )}\n </div>\n {footer && (\n <div className=\"ds-asset-card__footer\">\n <Skeleton\n shape=\"block\"\n width=\"45%\"\n style={{ ...delay, blockSize: \"var(--field-height-sm)\" }}\n />\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;AAyCA,SAASG,EAAY,EAAE,SAAM,YAA6C;CACxE,OACE,kBAAC,QAAD;EAAM,WAAU;EACd,UAAA,kBAACF,GAAD;GACE,MAAMG;GACN,MAAM;GACN,cAAYC;EACb,CAAA;CACG,CAAA;AAEV;AAGA,SAASC,EAAW,EAAE,QAAK,UAAqC;CAC9D,IAAM,CAACC,GAAQC,KAAaC,EAA0C,SAAS,GAEzE,CAACC,GAAOC,KAAYF,EAAiB,GACrCG,IAAQC,GAAa,MAA4B;EAErD,AADAL,EAAU,QAAQ,GACdM,EAAM,gBAAgBA,EAAM,iBAC9BH,EAASG,EAAM,eAAeA,EAAM,aAAa;CAErD,GAAG,CAAC,CAAC,GAICC,IAAWF,GACd,MAAmC;EAClC,AAAKC,GAAO,aAGRA,EAAM,eAAe,IACvBF,EAAME,CAAK,IAEXA,EAAM,OAAO,CAAC,CAAC,WACPF,EAAME,CAAK,SACX,CAAC,CACT;CAEJ,GACA,CAACF,CAAK,CACR;CAWA,OATIL,MAAW,WAEX,kBAACJ,GAAD;EACE,MAAK;EACL,OAAOa,IAAM,GAAGA,EAAI,0BAA0B;CAC/C,CAAA,IAKH,kBAAAhB,GAAA,EAA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AAC,QAAD;MAAM,WAAU;MAA2C,UAAAE;KAAW,CAAA;KACrEC,IAAO,kBAAC,OAAD;MAAK,WAAU;MAA2C,UAAAA;KAAU,CAAA,IAAI;KAC/EC,IAAc,kBAAC,OAAD;MAAK,WAAU;MAA8B,UAAAA;KAAiB,CAAA,IAAI;IAC9E;;GACJC,IAAS,kBAAC,OAAD;IAAK,WAAU;IAAyB,UAAAA;GAAY,CAAA,IAAI;EAC/D;;AAET,CAAC;AAYD,SAAgBC,EAAkB,EAChC,WAAQ,GACR,iBAAc,IACd,YAAS,MACgB;CACzB,IAAMC,IAAQ,EAAE,gBAAgB,kCAAkCC,EAAM,GAAG;CAC3E,OACE,kBAAC,OAAD;EACE,WAAU;EACV,gBAAa;EACb,eAAY;EAHd,UAAA;GAKE,kBAACnB,GAAD;IACE,OAAM;IACN,WAAU;IACV,OAAOkB;GACR,CAAA;GACD,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA;KACE,kBAAClB,GAAD;MACE,OAAM;MACN,OAAM;MACN,OAAOkB;KACR,CAAA;KACD,kBAAClB,GAAD;MACE,OAAM;MACN,OAAM;MACN,OAAOkB;KACR,CAAA;KACAH,KACC,kBAACf,GAAD;MACE,OAAM;MACN,OAAM;MACN,OAAOkB;KACR,CAAA;IAEA;;GACJF,KACC,kBAAC,OAAD;IAAK,WAAU;IACb,UAAA,kBAAChB,GAAD;KACE,OAAM;KACN,OAAM;KACN,OAAO;MAAE,GAAGkB;MAAO,WAAW;KAAyB;IACxD,CAAA;GACE,CAAA;EAEJ;;AAET"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_Fragment","Icon","Fragment$1","Placeholder","icon","label","AssetImage","status","setStatus","useState","ratio","setRatio","adopt","useCallback","image","imageRef","alt","Skeleton","event","isHandler","key","warnedLinkAndSelect","useLinkAndSelectWarning","isConflicting","ThumbnailLink","anchorProps","selectedId","useId","props","isPending","describedBy","isSelected","href","tabIndex","name","className","ThumbnailAction","linkProps","onSelect","Button","AssetCard","forwardRef","rest","fit","src","actions","meta","description","footer","AssetCardSkeleton","delay","index"],"sources":["../../../src/components/AssetCard/index.tsx"],"sourcesContent":["import {\n forwardRef,\n useCallback,\n useEffect,\n useId,\n useState,\n type AnchorHTMLAttributes,\n type CSSProperties,\n type HTMLAttributes,\n type ReactNode,\n} from \"react\";\nimport { Button } from \"../Button\";\nimport { Icon } from \"../Icon\";\nimport type { IconName } from \"../Icon/icons\";\nimport { Skeleton } from \"../Skeleton\";\nimport \"./style.css\";\n\nexport interface AssetCardProps extends Omit<HTMLAttributes<HTMLDivElement>, \"onSelect\" | \"title\"> {\n /** File name or crop label, displayed in full. */\n name: string;\n /** Thumbnail source. Omit to display the fallback icon. */\n src?: string;\n /** Alternative text for the preview; empty when the image is decorative. */\n alt?: string;\n /** Fallback for assets without a thumbnail, such as videos and PDFs. */\n icon?: IconName;\n /** Fill the frame, or show the complete image on an inset preview stage. */\n fit?: \"cover\" | \"contain\";\n /** Dimensions, size, ratio, or other metadata below the name. */\n meta?: ReactNode;\n /** Supporting content below the metadata, such as a source file name. */\n description?: ReactNode;\n /** Paint the selection fill and rail without changing the card's size. */\n isSelected?: boolean;\n /** Show an uploading overlay and disable the thumbnail action. */\n isPending?: boolean;\n /** Makes the thumbnail a selection toggle, independent of overlay and footer controls. */\n onSelect?: () => void;\n /**\n * Makes the thumbnail a link, independent of overlay and footer controls.\n * Replaces `onSelect`, which is then never called (development builds warn);\n * put selection on an `actions` control instead. While `isPending`, the link\n * has no `href`, is `aria-disabled`, leaves the tab order, and drops every\n * `on*` handler.\n */\n linkProps?: Omit<AnchorHTMLAttributes<HTMLAnchorElement>, \"children\"> & { href: string };\n /** Badges, buttons, or menus pinned across the top of the thumbnail. */\n actions?: ReactNode;\n /** Actions or content below the card's text. */\n footer?: ReactNode;\n}\n\nfunction Placeholder({ icon, label }: { icon: IconName; label?: string }) {\n return (\n <span className=\"ds-asset-card__placeholder ds-asset-tile__placeholder\">\n <Icon\n name={icon}\n size={24}\n aria-label={label}\n />\n </span>\n );\n}\n\n/** Remount for each source so failed and loaded states cannot leak to another image. */\nfunction AssetImage({ src, alt }: { src: string; alt: string }) {\n const [status, setStatus] = useState<\"loading\" | \"loaded\" | \"failed\">(\"loading\");\n // The picture's own shape lets a contained preview fill the stage exactly.\n const [ratio, setRatio] = useState<number>();\n const adopt = useCallback((image: HTMLImageElement) => {\n setStatus(\"loaded\");\n if (image.naturalWidth && image.naturalHeight) {\n setRatio(image.naturalWidth / image.naturalHeight);\n }\n }, []);\n // A cached image can finish before onLoad is attached. Only success is read\n // here: an SVG without intrinsic size and a deferred lazy image also report\n // a zero naturalWidth, so failure is left to the error event.\n const imageRef = useCallback(\n (image: HTMLImageElement | null) => {\n if (!image?.complete) {\n return;\n }\n if (image.naturalWidth > 0) {\n adopt(image);\n } else {\n image.decode().then(\n () => adopt(image),\n () => {},\n );\n }\n },\n [adopt],\n );\n\n if (status === \"failed\") {\n return (\n <Placeholder\n icon=\"alert-triangle\"\n label={alt ? `${alt} (preview unavailable)` : \"Preview unavailable\"}\n />\n );\n }\n\n return (\n <>\n {status === \"loading\" && (\n <Skeleton\n shape=\"block\"\n className=\"ds-asset-card__thumb-skeleton ds-asset-tile__thumb-skeleton\"\n />\n )}\n <img\n ref={imageRef}\n src={src}\n alt={alt}\n loading=\"lazy\"\n data-loaded={status === \"loaded\" || undefined}\n style={ratio ? ({ \"--asset-ratio\": ratio } as CSSProperties) : undefined}\n onLoad={(event) => adopt(event.currentTarget)}\n onError={() => setStatus(\"failed\")}\n />\n </>\n );\n}\n\ntype ThumbnailActionProps = Pick<\n AssetCardProps,\n \"name\" | \"linkProps\" | \"onSelect\" | \"isPending\" | \"isSelected\"\n>;\n\n/** Event handler props, such as `onClick`, `onPointerDown` or a router's `onMouseEnter`. */\nconst isHandler = (key: string) => /^on[A-Z]/.test(key);\n\nlet warnedLinkAndSelect = false;\n\n/** Development-only: `onSelect` is unreachable once the thumbnail is a link. */\nfunction useLinkAndSelectWarning(isConflicting: boolean) {\n useEffect(() => {\n if (isConflicting && !warnedLinkAndSelect && process.env.NODE_ENV !== \"production\") {\n warnedLinkAndSelect = true;\n console.warn(\n \"AssetCard: `linkProps` replaces `onSelect`, so the thumbnail navigates and `onSelect` \" +\n \"is never called. Pass one of them, and put selection on an `actions` control.\",\n );\n }\n }, [isConflicting]);\n}\n\n/**\n * A link has no pressed state, so selection is its description. While pending\n * it matches a disabled Button: no `href`, no tab stop, and no handlers, with\n * an explicit role so its name and disabled state still reach assistive tech.\n */\nfunction ThumbnailLink({\n name,\n linkProps: { href, tabIndex, className, ...anchorProps },\n isPending,\n isSelected,\n}: Omit<ThumbnailActionProps, \"linkProps\" | \"onSelect\"> & {\n linkProps: NonNullable<AssetCardProps[\"linkProps\"]>;\n}) {\n const selectedId = useId();\n const props = isPending\n ? Object.fromEntries(Object.entries(anchorProps).filter(([key]) => !isHandler(key)))\n : anchorProps;\n const describedBy = [anchorProps[\"aria-describedby\"], isSelected && selectedId]\n .filter(Boolean)\n .join(\" \");\n return (\n <>\n <a\n {...props}\n href={isPending ? undefined : href}\n tabIndex={isPending ? undefined : tabIndex}\n role={isPending ? \"link\" : anchorProps.role}\n aria-label={anchorProps[\"aria-label\"] ?? name}\n aria-disabled={isPending || anchorProps[\"aria-disabled\"]}\n aria-describedby={describedBy || undefined}\n className={[\n \"ds-asset-card__hit ds-asset-tile__hit ds-asset-card__link ds-asset-tile__link\",\n className,\n ]\n .filter(Boolean)\n .join(\" \")}\n />\n {isSelected ? (\n <span\n id={selectedId}\n hidden\n >\n Selected\n </span>\n ) : null}\n </>\n );\n}\n\nfunction ThumbnailAction({ linkProps, onSelect, ...props }: ThumbnailActionProps) {\n const { name, isPending, isSelected } = props;\n useLinkAndSelectWarning(Boolean(linkProps && onSelect));\n if (linkProps) {\n return (\n <ThumbnailLink\n {...props}\n linkProps={linkProps}\n />\n );\n }\n return onSelect ? (\n <Button\n variant=\"simple\"\n className=\"ds-asset-card__hit ds-asset-tile__hit\"\n aria-pressed={isSelected}\n aria-label={name}\n isDisabled={isPending}\n onClick={onSelect}\n />\n ) : null;\n}\n\n/** Shared presentation for assets, source files, and crop variants. */\nexport const AssetCard = forwardRef<HTMLDivElement, AssetCardProps>(function AssetCard(\n {\n name,\n src,\n alt = \"\",\n icon = \"image\",\n fit = \"cover\",\n meta,\n description,\n isSelected = false,\n isPending = false,\n onSelect,\n linkProps,\n actions,\n footer,\n className,\n ...rest\n },\n ref,\n) {\n return (\n <div\n ref={ref}\n className={[\"ds-asset-card\", \"ds-asset-tile\", className].filter(Boolean).join(\" \")}\n data-fit={fit}\n data-selected={isSelected || undefined}\n data-pending={isPending || undefined}\n {...rest}\n >\n <div className=\"ds-asset-card__thumb ds-asset-tile__thumb\">\n {src ? (\n <AssetImage\n key={src}\n src={src}\n alt={alt}\n />\n ) : (\n <Placeholder icon={icon} />\n )}\n {isPending && (\n <span\n className=\"ds-asset-card__pending ds-asset-tile__pending\"\n role=\"status\"\n >\n <Icon\n name=\"spinner\"\n size={20}\n className=\"ds-asset-card__spinner ds-asset-tile__spinner ds-icon--spin\"\n />\n <span className=\"ds-asset-card__pending-label ds-asset-tile__pending-label\">\n Uploading\n </span>\n </span>\n )}\n {/* Slots render only for truthy content, so `count && …` never leaves a stray 0. */}\n {actions ? (\n <div className=\"ds-asset-card__actions ds-asset-tile__actions\">{actions}</div>\n ) : null}\n <ThumbnailAction\n name={name}\n linkProps={linkProps}\n onSelect={onSelect}\n isPending={isPending}\n isSelected={isSelected}\n />\n </div>\n <div className=\"ds-asset-card__text ds-asset-tile__text\">\n <span className=\"ds-asset-card__name ds-asset-tile__name\">{name}</span>\n {meta ? <div className=\"ds-asset-card__meta ds-asset-tile__meta\">{meta}</div> : null}\n {description ? <div className=\"ds-asset-card__description\">{description}</div> : null}\n </div>\n {footer ? <div className=\"ds-asset-card__footer\">{footer}</div> : null}\n </div>\n );\n});\n\nexport interface AssetCardSkeletonProps {\n /** Position in the collection, used for the skeleton stagger. */\n index?: number;\n /** Reserve the description line, for cards that pass `description`. */\n description?: boolean;\n /** Reserve a footer row the height of a small Button, for cards that pass `footer`. */\n footer?: boolean;\n}\n\n/** A loading card. Match its slots to the real cards so nothing moves when they arrive. */\nexport function AssetCardSkeleton({\n index = 0,\n description = false,\n footer = false,\n}: AssetCardSkeletonProps) {\n const delay = { animationDelay: `calc(var(--skeleton-stagger) * ${index})` };\n return (\n <div\n className=\"ds-asset-card ds-asset-tile\"\n data-loading=\"true\"\n aria-hidden=\"true\"\n >\n <Skeleton\n shape=\"block\"\n className=\"ds-asset-card__thumb ds-asset-tile__thumb\"\n style={delay}\n />\n <div className=\"ds-asset-card__text ds-asset-tile__text\">\n <Skeleton\n shape=\"text\"\n width=\"80%\"\n style={delay}\n />\n <Skeleton\n shape=\"text\"\n width=\"45%\"\n style={delay}\n />\n {description && (\n <Skeleton\n shape=\"text\"\n width=\"65%\"\n style={delay}\n />\n )}\n </div>\n {footer && (\n <div className=\"ds-asset-card__footer\">\n <Skeleton\n shape=\"block\"\n width=\"45%\"\n style={{ ...delay, blockSize: \"var(--field-height-sm)\" }}\n />\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;AAoDA,SAASG,EAAY,EAAE,SAAM,YAA6C;CACxE,OACE,kBAAC,QAAD;EAAM,WAAU;EACd,UAAA,kBAACF,GAAD;GACE,MAAMG;GACN,MAAM;GACN,cAAYC;EACb,CAAA;CACG,CAAA;AAEV;AAGA,SAASC,EAAW,EAAE,QAAK,UAAqC;CAC9D,IAAM,CAACC,GAAQC,KAAaC,EAA0C,SAAS,GAEzE,CAACC,GAAOC,KAAYF,EAAiB,GACrCG,IAAQC,GAAa,MAA4B;EAErD,AADAL,EAAU,QAAQ,GACdM,EAAM,gBAAgBA,EAAM,iBAC9BH,EAASG,EAAM,eAAeA,EAAM,aAAa;CAErD,GAAG,CAAC,CAAC,GAICC,IAAWF,GACd,MAAmC;EAClC,AAAKC,GAAO,aAGRA,EAAM,eAAe,IACvBF,EAAME,CAAK,IAEXA,EAA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
121
121
|
pointer-events: auto;
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
/* The whole thumbnail is the selection target; the name stays
|
|
125
|
-
* underneath rather than being swallowed by the
|
|
126
|
-
:is(.ds-asset-card, .ds-asset-tile) :is(.ds-asset-card__hit, .ds-asset-tile__hit)
|
|
124
|
+
/* The whole thumbnail is the selection or link target; the name stays
|
|
125
|
+
* readable text underneath rather than being swallowed by the control. */
|
|
126
|
+
:is(.ds-asset-card, .ds-asset-tile) :is(.ds-asset-card__hit, .ds-asset-tile__hit) {
|
|
127
127
|
position: absolute;
|
|
128
128
|
inset: 0;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
:is(.ds-asset-card, .ds-asset-tile) :is(.ds-asset-card__hit, .ds-asset-tile__hit):focus-visible {
|
|
132
|
+
outline-offset: -2px;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/* Button sizes and pads itself; the hit area spans the frame instead. */
|
|
136
|
+
:is(.ds-asset-card, .ds-asset-tile) :is(.ds-asset-card__hit, .ds-asset-tile__hit).ds-button {
|
|
129
137
|
inline-size: 100%;
|
|
130
138
|
height: 100%;
|
|
131
139
|
padding: 0;
|
|
132
140
|
}
|
|
133
141
|
|
|
134
|
-
|
|
135
|
-
|
|
142
|
+
/* The link takes Button's focus ring and disabled cursor, not its fills. */
|
|
143
|
+
:is(.ds-asset-card__link, .ds-asset-tile__link) {
|
|
144
|
+
border-radius: inherit;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
:is(.ds-asset-card__link, .ds-asset-tile__link):focus-visible {
|
|
148
|
+
outline: var(--control-border-width) solid var(--color-focus);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
:is(.ds-asset-card__link, .ds-asset-tile__link)[aria-disabled="true"] {
|
|
152
|
+
cursor: not-allowed;
|
|
136
153
|
}
|
|
137
154
|
|
|
138
155
|
/* Selection reads on the tile, so Button's hover and pressed fills never
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/Icon-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/Icon-WOhlu6Rp.cjs"),t=require("../Grid/index.cjs"),n=require("../AssetCard/index.cjs");let r=require("react"),i=require("react/jsx-runtime");function a(...e){return e.filter(Boolean).join(` `)}var o=(0,r.forwardRef)(function({isLoading:e=!1,loadingCount:r=8,loadingCard:o,className:s,children:c,...l},u){return(0,i.jsx)(t.Grid,{ref:u,columns:`auto`,gap:`md`,minColumnWidth:`var(--asset-tile-min-width)`,className:a(`ds-asset-grid`,s),"aria-busy":e||void 0,...l,children:e?Array.from({length:r},(e,t)=>(0,i.jsx)(n.AssetCardSkeleton,{...o,index:t},t)):c})});function s({title:t,description:n,action:r}){return(0,i.jsxs)(`div`,{className:`ds-asset-empty`,children:[(0,i.jsx)(e.t,{name:`image`,size:24}),(0,i.jsx)(`span`,{className:`ds-asset-empty__title`,children:t}),n&&(0,i.jsx)(`span`,{className:`ds-asset-empty__description`,children:n}),r]})}exports.AssetGrid=o,exports.AssetGridEmpty=s,exports.AssetTile=n.AssetCard,exports.AssetTileSkeleton=n.AssetCardSkeleton;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as e } from "../../chunks/Icon-
|
|
1
|
+
import { t as e } from "../../chunks/Icon-spaFBU4S.js";
|
|
2
2
|
import { Grid as t } from "../Grid/index.js";
|
|
3
3
|
import { AssetCard as n, AssetCardSkeleton as r } from "../AssetCard/index.js";
|
|
4
4
|
import { forwardRef as i } from "react";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
@layer components {
|
|
2
|
-
/* Columns and gap come from Grid; the grid only adds its own inset.
|
|
2
|
+
/* Columns and gap come from Grid; the grid only adds its own inset. Grid's
|
|
3
|
+
* list reset has no specificity, so this wins in any load order. */
|
|
3
4
|
.ds-asset-grid {
|
|
4
5
|
padding: var(--space-4);
|
|
5
6
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/Board-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/Board-CUt4j2-8.cjs");exports.Board=e.t,exports.BoardCard=e.n,exports.BoardColumn=e.r;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as Board, n as BoardCard, r as BoardColumn } from "../../chunks/Board-
|
|
1
|
+
export { t as Board, n as BoardCard, r as BoardColumn } from "../../chunks/Board-z688-51u.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/Icon-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/Icon-WOhlu6Rp.cjs");let t=require("react"),n=require("react/jsx-runtime");var r=(0,t.forwardRef)(function({variant:t=`neutral`,size:r=`md`,iconStart:i,iconEnd:a,isIconOnly:o=!1,isDisabled:s=!1,isPending:c=!1,isFocusableWhenDisabled:l=!1,className:u,children:d,type:f=`button`,onClick:p,...m},h){let g=r===`lg`?20:16,_=s||c,v=_&&l;return(0,n.jsxs)(`button`,{ref:h,type:f,disabled:_&&!l,"aria-disabled":v||void 0,"data-variant":t,"data-size":r,"data-icon-only":o||void 0,"data-pending":c||void 0,className:[`ds-button`,u].filter(Boolean).join(` `),...m,onClick:v?e=>e.preventDefault():p,children:[c?(0,n.jsx)(e.t,{name:`spinner`,size:g,className:`ds-button__spinner ds-icon--spin`}):i&&(0,n.jsx)(e.t,{name:i,size:g}),(!o||!i&&!c)&&d,a&&!o&&(0,n.jsx)(e.t,{name:a,size:g})]})});exports.Button=r;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/ColourField-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/ColourField-Bk5O632x.cjs");exports.ColourField=e.t,exports.ColourPanel=e.n;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as ColourField, n as ColourPanel } from "../../chunks/ColourField-
|
|
1
|
+
export { t as ColourField, n as ColourPanel } from "../../chunks/ColourField-BwDb7ydB.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/DatePicker-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/DatePicker-BVsloqVY.cjs");exports.Calendar=e.t,exports.DateField=e.n,exports.DateRangeField=e.r,exports.formatIsoDate=e.i;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as Calendar, n as DateField, r as DateRangeField, i as formatIsoDate } from "../../chunks/DatePicker-
|
|
1
|
+
export { t as Calendar, n as DateField, r as DateRangeField, i as formatIsoDate } from "../../chunks/DatePicker-C1zcScC3.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/Icon-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/Icon-WOhlu6Rp.cjs"),t=require("../Button/index.cjs"),n=require("../../chunks/mergeRefs-Bc3qS0Tt.cjs"),r=require("../../chunks/portalScope-BVA1-Ypu.cjs"),i=require("../Drawer/index.cjs"),a=require("../../chunks/observeElementWidth-BCJM2FAw.cjs"),o=require("../../chunks/movableHost-CajG9_5Z.cjs");let s=require("react"),c=require("react-dom"),l=require("react/jsx-runtime");var u=360,d=600,f=900;function ee(e){return e<u?`tight`:e<d?`compact`:e<f?`narrow`:`wide`}var p={clean:`No changes`,dirty:`Unsaved changes`,saving:`Saving…`,saved:`Saved`,error:`Couldn't save`,offline:`Offline · kept in this tab`},m={clean:void 0,dirty:void 0,saving:`spinner`,saved:`check`,error:`alert-triangle`,offline:`clock`},h=new Set([`clean`,`dirty`]);function g(e){return typeof e==`string`?e.trim()!==``:e!=null&&typeof e!=`boolean`}function _({saveState:t,savedAgo:n,statusLabel:r}){let i=m[t],a=h.has(t)&&g(r)?r:void 0;return(0,l.jsxs)(`div`,{className:`ds-edit-layout__status`,"data-state":t,role:`status`,"aria-live":`polite`,children:[i&&(0,l.jsx)(e.t,{name:i,className:t===`saving`?`ds-icon--spin`:void 0}),t===`dirty`&&(0,l.jsx)(`span`,{className:`ds-edit-layout__dirty`,"aria-hidden":`true`}),(0,l.jsxs)(`span`,{title:typeof a==`string`?a:void 0,children:[a??p[t],t===`saved`&&n?(0,l.jsxs)(l.Fragment,{children:[` `,n]}):null]})]})}function v({text:e,bodyRef:n,onKeepEditing:r}){let i=(0,s.useRef)(null),a=(0,s.useRef)(null);return(0,s.useEffect)(()=>{a.current=document.activeElement;let e=requestAnimationFrame(()=>i.current?.focus({preventScroll:!0}));return()=>cancelAnimationFrame(e)},[]),(0,l.jsxs)(`div`,{className:`ds-edit-layout__confirmation`,children:[(0,l.jsx)(`strong`,{children:e}),(0,l.jsx)(t.Button,{ref:i,size:`xs`,onClick:()=>{r?.(),requestAnimationFrame(()=>{(a.current?.isConnected?a.current:n.current?.querySelector(`input, textarea, button, [contenteditable='true']`))?.focus({preventScroll:!0})})},children:`Keep editing`})]})}function y({backLabel:e,onBack:n,compact:r,status:i,actions:a,confirmLeave:o,confirmation:s,onLeave:c,detailsToggle:u}){return(0,l.jsxs)(`header`,{className:`ds-edit-layout__bar`,children:[(0,l.jsx)(t.Button,{variant:`simple`,size:`sm`,iconStart:`arrow-left`,isIconOnly:r,"aria-label":`Back to ${e}`,onClick:n,children:e}),o?s:i,(0,l.jsxs)(`div`,{className:`ds-edit-layout__actions`,children:[o?(0,l.jsx)(t.Button,{variant:`danger`,size:`sm`,onClick:c,children:`Leave anyway`}):a,r&&u]})]})}function b({label:e,detailsId:n,expanded:r,opensSheet:i,sheetOpen:a,toggleRef:o,contentRef:s,collapsed:c,onToggle:u}){return(0,l.jsxs)(`aside`,{className:`ds-edit-layout__rail`,"aria-label":e,children:[(0,l.jsxs)(`header`,{className:`ds-edit-layout__rail-head`,children:[r&&(0,l.jsx)(`span`,{children:e}),(0,l.jsx)(t.Button,{ref:o,variant:`simple`,size:`sm`,isIconOnly:!0,iconStart:r?`chevrons-right`:`chevrons-left`,className:`ds-edit-layout__toggle`,"aria-label":`${r?`Collapse`:`Expand`} ${e}`,"aria-expanded":r||a,"aria-controls":n,"aria-haspopup":i?`dialog`:void 0,onClick:u})]}),r?(0,l.jsx)(`div`,{id:n,ref:s,className:`ds-edit-layout__rail-content`}):(0,l.jsx)(`div`,{className:`ds-edit-layout__rail-icons`,children:c?c(u):(0,l.jsx)(t.Button,{variant:`simple`,size:`sm`,isIconOnly:!0,iconStart:`info`,"aria-label":`Show ${e}`,onClick:u})})]})}var x=(0,s.forwardRef)(function({backLabel:e,onBack:u,saveState:d=`clean`,statusLabel:f,savedAgo:p,actions:m,rail:h,railCollapsed:g,railLabel:x=`Details`,railOpen:S,defaultRailOpen:C=!0,onRailToggle:w,confirmLeave:T=!1,confirmText:E=`Leave without saving?`,onKeepEditing:D,onLeave:O,children:k,className:A,onFocus:j,...M},N){let P=(0,s.useRef)(null),te=(0,s.useMemo)(()=>n.t(P,N),[N]),F=(0,s.useRef)(null),I=(0,s.useRef)(null),L=(0,s.useRef)(null),R=(0,s.useRef)(null),z=(0,s.useRef)(null),[B]=(0,s.useState)(()=>o.t(`ds-edit-layout__rail-host`)),[V,H]=(0,s.useState)(`wide`),[U,W]=(0,s.useState)(C),[G,K]=(0,s.useState)(!1),[q,J]=(0,s.useState)(!1),Y=(0,s.useId)(),X=V===`tight`||V===`compact`,Z=V!==`wide`,Q=!Z&&(S??U);G&&(T||!Z)&&K(!1),(0,s.useLayoutEffect)(()=>{let e;return a.t(P.current,t=>{let n=ee(t);n!==e&&(e=n,J(!1),H(n))})},[]),(0,s.useLayoutEffect)(()=>{B&&o.n(B,L.current??R.current,z.current)}),(0,s.useEffect)(()=>{let e=z.current;e&&r.i(e)&&r.i(document.activeElement)&&I.current?.focus({preventScroll:!0})},[V,Q,G]);let $=()=>{Z?K(!0):(J(!0),W(!Q),w?.(!Q))},ne=typeof h==`function`?h(()=>(0,c.flushSync)(()=>K(!1))):h;return(0,l.jsxs)(`div`,{...M,ref:te,className:[`ds-edit-layout`,A].filter(Boolean).join(` `),"data-compact":X||void 0,"data-tight":V===`tight`||void 0,"data-expanded":Q||void 0,"data-animate":q||void 0,onFocus:e=>{z.current=e.target,j?.(e)},children:[(0,l.jsxs)(`div`,{className:`ds-edit-layout__main`,children:[(0,l.jsx)(y,{backLabel:e,onBack:u,compact:X,status:(0,l.jsx)(_,{saveState:d,statusLabel:f,savedAgo:p}),actions:m,confirmLeave:T,confirmation:(0,l.jsx)(v,{text:E,bodyRef:F,onKeepEditing:D}),onLeave:O,detailsToggle:(0,l.jsx)(t.Button,{ref:I,variant:`simple`,size:`sm`,isIconOnly:!0,iconStart:`info`,"aria-label":x,"aria-haspopup":`dialog`,"aria-expanded":G,"aria-controls":Y,onClick:$})}),(0,l.jsx)(`div`,{ref:F,className:`ds-edit-layout__body`,children:(0,l.jsx)(`div`,{className:`ds-edit-layout__content`,children:k})})]}),!X&&(0,l.jsx)(b,{label:x,detailsId:Y,expanded:Q,opensSheet:Z,sheetOpen:G,toggleRef:I,contentRef:L,collapsed:g,onToggle:$}),(0,l.jsx)(i.Drawer,{id:Z?Y:void 0,dir:M.dir,isOpen:G,onClose:()=>K(!1),side:`end`,size:`md`,title:x,closeLabel:`Close ${x}`,className:`ds-edit-layout__sheet`,children:Z&&(0,l.jsx)(`div`,{ref:R,className:`ds-edit-layout__rail-content`})}),B&&(0,c.createPortal)(ne,B)]})});exports.EditLayout=x;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["Icon","_Fragment","useRef","Button","forwardRef","useMemo","mergeRefs","useState","createMovableHost","useId","observeElementWidth","cannotHoldFocus","flushSync","Drawer","createPortal","require_Icon","require_components_Button_index","require_mergeRefs","require_portalScope","require_components_Drawer_index","require_observeElementWidth","require_movableHost","react","react_dom","react_jsx_runtime","TIGHT_WIDTH","COMPACT_WIDTH","WIDE_WIDTH","layoutMode","width","statusLabels","statusIcons","SaveStatus","icon","saveState","savedAgo","LeaveConfirmation","keepRef","origin","frame","text","onKeepEditing","bodyRef","EditActionBar","compact","backLabel","onBack","confirmLeave","confirmation","status","onLeave","actions","detailsToggle","DetailsRail","label","expanded","toggleRef","sheetOpen","detailsId","opensSheet","onToggle","contentRef","collapsed","EditLayout","rest","rootRef","mergedRef","ref","railSlotRef","sheetSlotRef","lastFocus","railHost","mode","setMode","localOpen","setLocalOpen","defaultRailOpen","sheet","setSheet","animate","setAnimate","narrow","railOpen","current","next","last","toggle","onRailToggle","railContent","rail","className","event","onFocus","confirmText","railLabel","railCollapsed"],"sources":["../../../src/components/EditLayout/index.tsx"],"sourcesContent":["import {\n forwardRef,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type HTMLAttributes,\n type ReactNode,\n type RefObject,\n} from \"react\";\nimport { createPortal, flushSync } from \"react-dom\";\nimport { Button } from \"../Button\";\nimport { Drawer } from \"../Drawer\";\nimport { Icon } from \"../Icon\";\nimport type { IconName } from \"../Icon/icons\";\nimport { mergeRefs } from \"../../internal/mergeRefs\";\nimport { observeElementWidth } from \"../../internal/observeElementWidth\";\nimport { cannotHoldFocus } from \"../../internal/dialogFocus\";\nimport { createMovableHost, moveHost } from \"../../internal/movableHost\";\nimport \"./style.css\";\n\nexport type EditSaveState = \"clean\" | \"dirty\" | \"saving\" | \"saved\" | \"error\" | \"offline\";\n\nexport interface EditLayoutProps extends HTMLAttributes<HTMLDivElement> {\n backLabel: string;\n onBack: () => void;\n saveState?: EditSaveState;\n savedAgo?: ReactNode;\n actions?: ReactNode;\n /** A render slot can close the Details sheet before opening another dialog. */\n rail: ReactNode | ((closeDetails: () => void) => ReactNode);\n /** Custom collapsed controls receive the accessible expand action. */\n railCollapsed?: (expand: () => void) => ReactNode;\n railLabel?: string;\n railOpen?: boolean;\n defaultRailOpen?: boolean;\n onRailToggle?: (open: boolean) => void;\n confirmLeave?: boolean;\n confirmText?: string;\n onKeepEditing?: () => void;\n onLeave?: () => void;\n children?: ReactNode;\n}\n\n/** Below this width, the action bar's gaps and padding contract. */\nconst TIGHT_WIDTH = 360;\n/** Below this width, Details opens from the action bar. */\nconst COMPACT_WIDTH = 600;\n/** From this width, the rail follows the open/closed preference. */\nconst WIDE_WIDTH = 900;\n\ntype LayoutMode = \"tight\" | \"compact\" | \"narrow\" | \"wide\";\n\nfunction layoutMode(width: number): LayoutMode {\n if (width < TIGHT_WIDTH) {\n return \"tight\";\n }\n if (width < COMPACT_WIDTH) {\n return \"compact\";\n }\n if (width < WIDE_WIDTH) {\n return \"narrow\";\n }\n return \"wide\";\n}\n\nconst statusLabels: Record<EditSaveState, string> = {\n clean: \"No changes\",\n dirty: \"Unsaved changes\",\n saving: \"Saving…\",\n saved: \"Saved\",\n error: \"Couldn't save\",\n offline: \"Offline · kept in this tab\",\n};\n\nconst statusIcons: Record<EditSaveState, IconName | undefined> = {\n clean: undefined,\n dirty: undefined,\n saving: \"spinner\",\n saved: \"check\",\n error: \"alert-triangle\",\n offline: \"clock\",\n};\n\ninterface SaveStatusProps {\n saveState: EditSaveState;\n savedAgo?: ReactNode;\n}\n\nfunction SaveStatus({ saveState, savedAgo }: SaveStatusProps) {\n const icon = statusIcons[saveState];\n return (\n <div\n className=\"ds-edit-layout__status\"\n data-state={saveState}\n role=\"status\"\n aria-live=\"polite\"\n >\n {icon && (\n <Icon\n name={icon}\n className={saveState === \"saving\" ? \"ds-icon--spin\" : undefined}\n />\n )}\n {saveState === \"dirty\" && (\n <span\n className=\"ds-edit-layout__dirty\"\n aria-hidden=\"true\"\n />\n )}\n <span>\n {statusLabels[saveState]}\n {saveState === \"saved\" && savedAgo ? <> {savedAgo}</> : null}\n </span>\n </div>\n );\n}\n\ninterface LeaveConfirmationProps {\n text: string;\n /** Keep editing falls back to the first control here when its origin is gone. */\n bodyRef: RefObject<HTMLDivElement | null>;\n onKeepEditing?: () => void;\n}\n\n/** Takes focus while shown; Keep editing returns it to where the user was. */\nfunction LeaveConfirmation({ text, bodyRef, onKeepEditing }: LeaveConfirmationProps) {\n const keepRef = useRef<HTMLButtonElement>(null);\n const origin = useRef<HTMLElement | null>(null);\n\n useEffect(() => {\n origin.current = document.activeElement as HTMLElement | null;\n const frame = requestAnimationFrame(() => keepRef.current?.focus({ preventScroll: true }));\n return () => cancelAnimationFrame(frame);\n }, []);\n\n const keepEditing = () => {\n onKeepEditing?.();\n requestAnimationFrame(() => {\n const destination = origin.current?.isConnected\n ? origin.current\n : bodyRef.current?.querySelector<HTMLElement>(\n \"input, textarea, button, [contenteditable='true']\",\n );\n destination?.focus({ preventScroll: true });\n });\n };\n\n return (\n <div className=\"ds-edit-layout__confirmation\">\n <strong>{text}</strong>\n <Button\n ref={keepRef}\n size=\"xs\"\n onClick={keepEditing}\n >\n Keep editing\n </Button>\n </div>\n );\n}\n\ninterface EditActionBarProps {\n backLabel: string;\n onBack: () => void;\n compact: boolean;\n status: ReactNode;\n actions?: ReactNode;\n /** Replaces the status and actions while set. */\n confirmLeave: boolean;\n confirmation: ReactNode;\n onLeave?: () => void;\n /** Shown only in compact layouts, where Details opens as a sheet. */\n detailsToggle: ReactNode;\n}\n\nfunction EditActionBar({\n backLabel,\n onBack,\n compact,\n status,\n actions,\n confirmLeave,\n confirmation,\n onLeave,\n detailsToggle,\n}: EditActionBarProps) {\n return (\n <header className=\"ds-edit-layout__bar\">\n <Button\n variant=\"simple\"\n size=\"sm\"\n iconStart=\"arrow-left\"\n isIconOnly={compact}\n aria-label={`Back to ${backLabel}`}\n onClick={onBack}\n >\n {backLabel}\n </Button>\n {confirmLeave ? confirmation : status}\n <div className=\"ds-edit-layout__actions\">\n {confirmLeave ? (\n <Button\n variant=\"danger\"\n size=\"sm\"\n onClick={onLeave}\n >\n Leave anyway\n </Button>\n ) : (\n actions\n )}\n {compact && detailsToggle}\n </div>\n </header>\n );\n}\n\ninterface DetailsRailProps {\n label: string;\n detailsId: string;\n expanded: boolean;\n /** Below the wide breakpoint, the toggle opens the Details sheet instead. */\n opensSheet: boolean;\n sheetOpen: boolean;\n toggleRef: RefObject<HTMLButtonElement | null>;\n /** Receives the rail content while the rail is expanded. */\n contentRef: RefObject<HTMLDivElement | null>;\n collapsed?: (expand: () => void) => ReactNode;\n onToggle: () => void;\n}\n\nfunction DetailsRail({\n label,\n detailsId,\n expanded,\n opensSheet,\n sheetOpen,\n toggleRef,\n contentRef,\n collapsed,\n onToggle,\n}: DetailsRailProps) {\n return (\n <aside\n className=\"ds-edit-layout__rail\"\n aria-label={label}\n >\n <header className=\"ds-edit-layout__rail-head\">\n {expanded && <span>{label}</span>}\n <Button\n ref={toggleRef}\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart={expanded ? \"chevrons-right\" : \"chevrons-left\"}\n className=\"ds-edit-layout__toggle\"\n aria-label={`${expanded ? \"Collapse\" : \"Expand\"} ${label}`}\n aria-expanded={expanded || sheetOpen}\n aria-controls={detailsId}\n aria-haspopup={opensSheet ? \"dialog\" : undefined}\n onClick={onToggle}\n />\n </header>\n {expanded ? (\n <div\n id={detailsId}\n ref={contentRef}\n className=\"ds-edit-layout__rail-content\"\n />\n ) : (\n <div className=\"ds-edit-layout__rail-icons\">\n {collapsed ? (\n collapsed(onToggle)\n ) : (\n <Button\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"info\"\n aria-label={`Show ${label}`}\n onClick={onToggle}\n />\n )}\n </div>\n )}\n </aside>\n );\n}\n\n/** Presentation only: the consumer owns saving, routing and persisted preferences. */\nexport const EditLayout = forwardRef<HTMLDivElement, EditLayoutProps>(function EditLayout(\n {\n backLabel,\n onBack,\n saveState = \"clean\",\n savedAgo,\n actions,\n rail,\n railCollapsed,\n railLabel = \"Details\",\n railOpen,\n defaultRailOpen = true,\n onRailToggle,\n confirmLeave = false,\n confirmText = \"Leave without saving?\",\n onKeepEditing,\n onLeave,\n children,\n className,\n onFocus,\n ...rest\n },\n ref,\n) {\n const rootRef = useRef<HTMLDivElement>(null);\n const mergedRef = useMemo(() => mergeRefs(rootRef, ref), [ref]);\n const bodyRef = useRef<HTMLDivElement>(null);\n const toggleRef = useRef<HTMLButtonElement>(null);\n const railSlotRef = useRef<HTMLDivElement>(null);\n const sheetSlotRef = useRef<HTMLDivElement>(null);\n const lastFocus = useRef<Element | null>(null);\n // Rail content renders once, into a node that moves between the rail and\n // the sheet, so uncontrolled fields keep their values across modes.\n const [railHost] = useState(() => createMovableHost(\"ds-edit-layout__rail-host\"));\n const [mode, setMode] = useState<LayoutMode>(\"wide\");\n const [localOpen, setLocalOpen] = useState(defaultRailOpen);\n const [sheet, setSheet] = useState(false);\n const [animate, setAnimate] = useState(false);\n const detailsId = useId();\n const compact = mode === \"tight\" || mode === \"compact\";\n const narrow = mode !== \"wide\";\n const expanded = !narrow && (railOpen ?? localOpen);\n\n // Leave confirmation and the wide rail both replace the Details sheet.\n if (sheet && (confirmLeave || !narrow)) {\n setSheet(false);\n }\n\n // Measure before the first paint, then re-render only when a breakpoint is crossed.\n useLayoutEffect(() => {\n let current: LayoutMode | undefined;\n return observeElementWidth(rootRef.current!, (width) => {\n const next = layoutMode(width);\n if (next === current) {\n return;\n }\n current = next;\n // Crossing a breakpoint is not a deliberate toggle, so it doesn't animate.\n setAnimate(false);\n setMode(next);\n });\n }, []);\n\n // Moving a node drops its focus; keep the user in the field they were in.\n useLayoutEffect(() => {\n if (railHost) {\n moveHost(railHost, railSlotRef.current ?? sheetSlotRef.current, lastFocus.current);\n }\n });\n\n // A breakpoint, a collapse or a closing sheet can remove the focused control.\n // Hand focus to the Details toggle that replaced it.\n useEffect(() => {\n const last = lastFocus.current;\n if (last && cannotHoldFocus(last) && cannotHoldFocus(document.activeElement)) {\n toggleRef.current?.focus({ preventScroll: true });\n }\n }, [mode, expanded, sheet]);\n\n const toggle = () => {\n if (narrow) {\n setSheet(true);\n return;\n }\n setAnimate(true);\n setLocalOpen(!expanded);\n onRailToggle?.(!expanded);\n };\n const closeDetails = () => flushSync(() => setSheet(false));\n const railContent = typeof rail === \"function\" ? rail(closeDetails) : rail;\n\n return (\n <div\n {...rest}\n ref={mergedRef}\n className={[\"ds-edit-layout\", className].filter(Boolean).join(\" \")}\n data-compact={compact || undefined}\n data-tight={mode === \"tight\" || undefined}\n data-expanded={expanded || undefined}\n data-animate={animate || undefined}\n onFocus={(event) => {\n lastFocus.current = event.target;\n onFocus?.(event);\n }}\n >\n <div className=\"ds-edit-layout__main\">\n <EditActionBar\n backLabel={backLabel}\n onBack={onBack}\n compact={compact}\n status={\n <SaveStatus\n saveState={saveState}\n savedAgo={savedAgo}\n />\n }\n actions={actions}\n confirmLeave={confirmLeave}\n confirmation={\n <LeaveConfirmation\n text={confirmText}\n bodyRef={bodyRef}\n onKeepEditing={onKeepEditing}\n />\n }\n onLeave={onLeave}\n detailsToggle={\n <Button\n ref={toggleRef}\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"info\"\n aria-label={railLabel}\n aria-haspopup=\"dialog\"\n aria-expanded={sheet}\n aria-controls={detailsId}\n onClick={toggle}\n />\n }\n />\n <div\n ref={bodyRef}\n className=\"ds-edit-layout__body\"\n >\n <div className=\"ds-edit-layout__content\">{children}</div>\n </div>\n </div>\n {!compact && (\n <DetailsRail\n label={railLabel}\n detailsId={detailsId}\n expanded={expanded}\n opensSheet={narrow}\n sheetOpen={sheet}\n toggleRef={toggleRef}\n contentRef={railSlotRef}\n collapsed={railCollapsed}\n onToggle={toggle}\n />\n )}\n <Drawer\n id={narrow ? detailsId : undefined}\n dir={rest.dir}\n isOpen={sheet}\n onClose={() => setSheet(false)}\n side=\"end\"\n size=\"md\"\n title={railLabel}\n closeLabel={`Close ${railLabel}`}\n className=\"ds-edit-layout__sheet\"\n >\n {narrow && (\n <div\n ref={sheetSlotRef}\n className=\"ds-edit-layout__rail-content\"\n />\n )}\n </Drawer>\n {railHost && createPortal(railContent, railHost)}\n </div>\n );\n});\n"],"mappings":"A,sdA+CA,IAAMyB,EAAc,IAEdC,EAAgB,IAEhBC,EAAa,IAInB,SAASC,EAAW,EAA2B,CAU7C,OATIC,EAAQJ,EACH,QAELI,EAAQH,EACH,UAELG,EAAQF,EACH,SAEF,MACT,CAEA,IAAMG,EAA8C,CAClD,MAAO,aACP,MAAO,kBACP,OAAQ,UACR,MAAO,QACP,MAAO,gBACP,QAAS,4BACX,EAEMC,EAA2D,CAC/D,MAAO,IAAA,GACP,MAAO,IAAA,GACP,OAAQ,UACR,MAAO,QACP,MAAO,iBACP,QAAS,OACX,EAOA,SAASC,EAAW,CAAE,YAAW,YAA6B,CAC5D,IAAMC,EAAOF,EAAYG,GACzB,OACE,EAAAV,EAAA,KAAA,CAAC,MAAD,CACE,UAAU,yBACV,aAAYU,EACZ,KAAK,SACL,YAAU,SAJZ,SAAA,CAMGD,IACC,EAAAT,EAAA,IAAA,CAACxB,EAAAA,EAAD,CACE,KAAMiC,EACN,UAAWC,IAAc,SAAW,gBAAkB,IAAA,EACvD,CAAA,EAEFA,IAAc,UACb,EAAAV,EAAA,IAAA,CAAC,OAAD,CACE,UAAU,wBACV,cAAY,MACb,CAAA,GAEH,EAAAA,EAAA,KAAA,CAAC,OAAD,CAAA,SAAA,CACGM,EAAaI,GACbA,IAAc,SAAWC,GAAW,EAAAX,EAAA,KAAA,CAAAvB,EAAAA,SAAA,CAAA,SAAA,CAAE,IAAEkC,CAAW,CAAA,CAAA,EAAI,IACpD,CAAA,CAAA,CACH,C,EAET,CAUA,SAASC,EAAkB,CAAE,OAAM,UAAS,iBAAyC,CACnF,IAAMC,GAAA,EAAUnC,EAAAA,OAAAA,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V,UAAA,EAAAlB,EAAA,IAAA,CAAC,MAAD,CAAK,UAAU,0BAA2B,UAAc,CAAA,CACrD,CAAA,CACF,C,GACJ,CAACoB,IACA,EAAApB,EAAA,IAAA,CAAC6B,EAAD,CACE,MAAOyC,EACI,YACD,WACV,WAAYb,EACZ,UAAWJ,EACA,YACX,WAAYT,EACZ,UAAW2B,EACX,SAAUT,CACX,CAAA,GAEH,EAAA9D,EAAA,IAAA,CAACX,EAAAA,OAAD,CACE,GAAIoE,EAASvB,EAAY,IAAA,GACzB,IAAKM,EAAK,IACV,OAAQa,EACR,YAAeC,EAAS,EAAK,EAC7B,KAAK,MACL,KAAK,KACL,MAAOgB,EACP,WAAY,SAASA,IACrB,UAAU,wBAET,SAAAb,IACC,EAAAzD,EAAA,IAAA,CAAC,MAAD,CACE,IAAK6C,EACL,UAAU,8BACX,CAAA,CAEG,CAAA,EACPE,IAAA,EAAYzD,EAAAA,aAAAA,CAAa0E,GAAajB,CAAQ,CAC5C,C,EAET,CAAC,E"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["Icon","_Fragment","useRef","Button","forwardRef","useMemo","mergeRefs","useState","createMovableHost","useId","observeElementWidth","cannotHoldFocus","flushSync","Drawer","createPortal","require_Icon","require_components_Button_index","require_mergeRefs","require_portalScope","require_components_Drawer_index","require_observeElementWidth","require_movableHost","react","react_dom","react_jsx_runtime","TIGHT_WIDTH","COMPACT_WIDTH","WIDE_WIDTH","layoutMode","width","statusLabels","statusIcons","relabelledStates","hasContent","node","SaveStatus","icon","saveState","custom","statusLabel","savedAgo","LeaveConfirmation","keepRef","origin","frame","text","onKeepEditing","bodyRef","EditActionBar","compact","backLabel","onBack","confirmLeave","confirmation","status","onLeave","actions","detailsToggle","DetailsRail","label","expanded","toggleRef","sheetOpen","detailsId","opensSheet","onToggle","contentRef","collapsed","EditLayout","rest","rootRef","mergedRef","ref","railSlotRef","sheetSlotRef","lastFocus","railHost","mode","setMode","localOpen","setLocalOpen","defaultRailOpen","sheet","setSheet","animate","setAnimate","narrow","railOpen","current","next","last","toggle","onRailToggle","railContent","rail","className","event","onFocus","confirmText","railLabel","railCollapsed"],"sources":["../../../src/components/EditLayout/index.tsx"],"sourcesContent":["import {\n forwardRef,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type HTMLAttributes,\n type ReactNode,\n type RefObject,\n} from \"react\";\nimport { createPortal, flushSync } from \"react-dom\";\nimport { Button } from \"../Button\";\nimport { Drawer } from \"../Drawer\";\nimport { Icon } from \"../Icon\";\nimport type { IconName } from \"../Icon/icons\";\nimport { mergeRefs } from \"../../internal/mergeRefs\";\nimport { observeElementWidth } from \"../../internal/observeElementWidth\";\nimport { cannotHoldFocus } from \"../../internal/dialogFocus\";\nimport { createMovableHost, moveHost } from \"../../internal/movableHost\";\nimport \"./style.css\";\n\nexport type EditSaveState = \"clean\" | \"dirty\" | \"saving\" | \"saved\" | \"error\" | \"offline\";\n\nexport interface EditLayoutProps extends HTMLAttributes<HTMLDivElement> {\n backLabel: string;\n onBack: () => void;\n saveState?: EditSaveState;\n /**\n * Replaces the `clean` or `dirty` message, for example on a read-only record.\n * Saving, saved, error and offline keep their standard messages, and\n * `saveState` always controls the indicator and colour. Empty values are ignored.\n */\n statusLabel?: ReactNode;\n savedAgo?: ReactNode;\n actions?: ReactNode;\n /** A render slot can close the Details sheet before opening another dialog. */\n rail: ReactNode | ((closeDetails: () => void) => ReactNode);\n /** Custom collapsed controls receive the accessible expand action. */\n railCollapsed?: (expand: () => void) => ReactNode;\n railLabel?: string;\n railOpen?: boolean;\n defaultRailOpen?: boolean;\n onRailToggle?: (open: boolean) => void;\n confirmLeave?: boolean;\n confirmText?: string;\n onKeepEditing?: () => void;\n onLeave?: () => void;\n children?: ReactNode;\n}\n\n/** Below this width, the action bar's gaps and padding contract. */\nconst TIGHT_WIDTH = 360;\n/** Below this width, Details opens from the action bar. */\nconst COMPACT_WIDTH = 600;\n/** From this width, the rail follows the open/closed preference. */\nconst WIDE_WIDTH = 900;\n\ntype LayoutMode = \"tight\" | \"compact\" | \"narrow\" | \"wide\";\n\nfunction layoutMode(width: number): LayoutMode {\n if (width < TIGHT_WIDTH) {\n return \"tight\";\n }\n if (width < COMPACT_WIDTH) {\n return \"compact\";\n }\n if (width < WIDE_WIDTH) {\n return \"narrow\";\n }\n return \"wide\";\n}\n\nconst statusLabels: Record<EditSaveState, string> = {\n clean: \"No changes\",\n dirty: \"Unsaved changes\",\n saving: \"Saving…\",\n saved: \"Saved\",\n error: \"Couldn't save\",\n offline: \"Offline · kept in this tab\",\n};\n\nconst statusIcons: Record<EditSaveState, IconName | undefined> = {\n clean: undefined,\n dirty: undefined,\n saving: \"spinner\",\n saved: \"check\",\n error: \"alert-triangle\",\n offline: \"clock\",\n};\n\n/** Save progress, outcomes and connection loss always keep their standard messages. */\nconst relabelledStates: ReadonlySet<EditSaveState> = new Set([\"clean\", \"dirty\"]);\n\nfunction hasContent(node: ReactNode) {\n if (typeof node === \"string\") {\n return node.trim() !== \"\";\n }\n return node !== null && node !== undefined && typeof node !== \"boolean\";\n}\n\ninterface SaveStatusProps {\n saveState: EditSaveState;\n statusLabel?: ReactNode;\n savedAgo?: ReactNode;\n}\n\nfunction SaveStatus({ saveState, savedAgo, statusLabel }: SaveStatusProps) {\n const icon = statusIcons[saveState];\n const custom =\n relabelledStates.has(saveState) && hasContent(statusLabel) ? statusLabel : undefined;\n return (\n <div\n className=\"ds-edit-layout__status\"\n data-state={saveState}\n role=\"status\"\n aria-live=\"polite\"\n >\n {icon && (\n <Icon\n name={icon}\n className={saveState === \"saving\" ? \"ds-icon--spin\" : undefined}\n />\n )}\n {saveState === \"dirty\" && (\n <span\n className=\"ds-edit-layout__dirty\"\n aria-hidden=\"true\"\n />\n )}\n {/* The title recovers a custom string clipped beyond two lines. */}\n <span title={typeof custom === \"string\" ? custom : undefined}>\n {custom ?? statusLabels[saveState]}\n {saveState === \"saved\" && savedAgo ? <> {savedAgo}</> : null}\n </span>\n </div>\n );\n}\n\ninterface LeaveConfirmationProps {\n text: string;\n /** Keep editing falls back to the first control here when its origin is gone. */\n bodyRef: RefObject<HTMLDivElement | null>;\n onKeepEditing?: () => void;\n}\n\n/** Takes focus while shown; Keep editing returns it to where the user was. */\nfunction LeaveConfirmation({ text, bodyRef, onKeepEditing }: LeaveConfirmationProps) {\n const keepRef = useRef<HTMLButtonElement>(null);\n const origin = useRef<HTMLElement | null>(null);\n\n useEffect(() => {\n origin.current = document.activeElement as HTMLElement | null;\n const frame = requestAnimationFrame(() => keepRef.current?.focus({ preventScroll: true }));\n return () => cancelAnimationFrame(frame);\n }, []);\n\n const keepEditing = () => {\n onKeepEditing?.();\n requestAnimationFrame(() => {\n const destination = origin.current?.isConnected\n ? origin.current\n : bodyRef.current?.querySelector<HTMLElement>(\n \"input, textarea, button, [contenteditable='true']\",\n );\n destination?.focus({ preventScroll: true });\n });\n };\n\n return (\n <div className=\"ds-edit-layout__confirmation\">\n <strong>{text}</strong>\n <Button\n ref={keepRef}\n size=\"xs\"\n onClick={keepEditing}\n >\n Keep editing\n </Button>\n </div>\n );\n}\n\ninterface EditActionBarProps {\n backLabel: string;\n onBack: () => void;\n compact: boolean;\n status: ReactNode;\n actions?: ReactNode;\n /** Replaces the status and actions while set. */\n confirmLeave: boolean;\n confirmation: ReactNode;\n onLeave?: () => void;\n /** Shown only in compact layouts, where Details opens as a sheet. */\n detailsToggle: ReactNode;\n}\n\nfunction EditActionBar({\n backLabel,\n onBack,\n compact,\n status,\n actions,\n confirmLeave,\n confirmation,\n onLeave,\n detailsToggle,\n}: EditActionBarProps) {\n return (\n <header className=\"ds-edit-layout__bar\">\n <Button\n variant=\"simple\"\n size=\"sm\"\n iconStart=\"arrow-left\"\n isIconOnly={compact}\n aria-label={`Back to ${backLabel}`}\n onClick={onBack}\n >\n {backLabel}\n </Button>\n {confirmLeave ? confirmation : status}\n <div className=\"ds-edit-layout__actions\">\n {confirmLeave ? (\n <Button\n variant=\"danger\"\n size=\"sm\"\n onClick={onLeave}\n >\n Leave anyway\n </Button>\n ) : (\n actions\n )}\n {compact && detailsToggle}\n </div>\n </header>\n );\n}\n\ninterface DetailsRailProps {\n label: string;\n detailsId: string;\n expanded: boolean;\n /** Below the wide breakpoint, the toggle opens the Details sheet instead. */\n opensSheet: boolean;\n sheetOpen: boolean;\n toggleRef: RefObject<HTMLButtonElement | null>;\n /** Receives the rail content while the rail is expanded. */\n contentRef: RefObject<HTMLDivElement | null>;\n collapsed?: (expand: () => void) => ReactNode;\n onToggle: () => void;\n}\n\nfunction DetailsRail({\n label,\n detailsId,\n expanded,\n opensSheet,\n sheetOpen,\n toggleRef,\n contentRef,\n collapsed,\n onToggle,\n}: DetailsRailProps) {\n return (\n <aside\n className=\"ds-edit-layout__rail\"\n aria-label={label}\n >\n <header className=\"ds-edit-layout__rail-head\">\n {expanded && <span>{label}</span>}\n <Button\n ref={toggleRef}\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart={expanded ? \"chevrons-right\" : \"chevrons-left\"}\n className=\"ds-edit-layout__toggle\"\n aria-label={`${expanded ? \"Collapse\" : \"Expand\"} ${label}`}\n aria-expanded={expanded || sheetOpen}\n aria-controls={detailsId}\n aria-haspopup={opensSheet ? \"dialog\" : undefined}\n onClick={onToggle}\n />\n </header>\n {expanded ? (\n <div\n id={detailsId}\n ref={contentRef}\n className=\"ds-edit-layout__rail-content\"\n />\n ) : (\n <div className=\"ds-edit-layout__rail-icons\">\n {collapsed ? (\n collapsed(onToggle)\n ) : (\n <Button\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"info\"\n aria-label={`Show ${label}`}\n onClick={onToggle}\n />\n )}\n </div>\n )}\n </aside>\n );\n}\n\n/** Presentation only: the consumer owns saving, routing and persisted preferences. */\nexport const EditLayout = forwardRef<HTMLDivElement, EditLayoutProps>(function EditLayout(\n {\n backLabel,\n onBack,\n saveState = \"clean\",\n statusLabel,\n savedAgo,\n actions,\n rail,\n railCollapsed,\n railLabel = \"Details\",\n railOpen,\n defaultRailOpen = true,\n onRailToggle,\n confirmLeave = false,\n confirmText = \"Leave without saving?\",\n onKeepEditing,\n onLeave,\n children,\n className,\n onFocus,\n ...rest\n },\n ref,\n) {\n const rootRef = useRef<HTMLDivElement>(null);\n const mergedRef = useMemo(() => mergeRefs(rootRef, ref), [ref]);\n const bodyRef = useRef<HTMLDivElement>(null);\n const toggleRef = useRef<HTMLButtonElement>(null);\n const railSlotRef = useRef<HTMLDivElement>(null);\n const sheetSlotRef = useRef<HTMLDivElement>(null);\n const lastFocus = useRef<Element | null>(null);\n // Rail content renders once, into a node that moves between the rail and\n // the sheet, so uncontrolled fields keep their values across modes.\n const [railHost] = useState(() => createMovableHost(\"ds-edit-layout__rail-host\"));\n const [mode, setMode] = useState<LayoutMode>(\"wide\");\n const [localOpen, setLocalOpen] = useState(defaultRailOpen);\n const [sheet, setSheet] = useState(false);\n const [animate, setAnimate] = useState(false);\n const detailsId = useId();\n const compact = mode === \"tight\" || mode === \"compact\";\n const narrow = mode !== \"wide\";\n const expanded = !narrow && (railOpen ?? localOpen);\n\n // Leave confirmation and the wide rail both replace the Details sheet.\n if (sheet && (confirmLeave || !narrow)) {\n setSheet(false);\n }\n\n // Measure before the first paint, then re-render only when a breakpoint is crossed.\n useLayoutEffect(() => {\n let current: LayoutMode | undefined;\n return observeElementWidth(rootRef.current!, (width) => {\n const next = layoutMode(width);\n if (next === current) {\n return;\n }\n current = next;\n // Crossing a breakpoint is not a deliberate toggle, so it doesn't animate.\n setAnimate(false);\n setMode(next);\n });\n }, []);\n\n // Moving a node drops its focus; keep the user in the field they were in.\n useLayoutEffect(() => {\n if (railHost) {\n moveHost(railHost, railSlotRef.current ?? sheetSlotRef.current, lastFocus.current);\n }\n });\n\n // A breakpoint, a collapse or a closing sheet can remove the focused control.\n // Hand focus to the Details toggle that replaced it.\n useEffect(() => {\n const last = lastFocus.current;\n if (last && cannotHoldFocus(last) && cannotHoldFocus(document.activeElement)) {\n toggleRef.current?.focus({ preventScroll: true });\n }\n }, [mode, expanded, sheet]);\n\n const toggle = () => {\n if (narrow) {\n setSheet(true);\n return;\n }\n setAnimate(true);\n setLocalOpen(!expanded);\n onRailToggle?.(!expanded);\n };\n const closeDetails = () => flushSync(() => setSheet(false));\n const railContent = typeof rail === \"function\" ? rail(closeDetails) : rail;\n\n return (\n <div\n {...rest}\n ref={mergedRef}\n className={[\"ds-edit-layout\", className].filter(Boolean).join(\" \")}\n data-compact={compact || undefined}\n data-tight={mode === \"tight\" || undefined}\n data-expanded={expanded || undefined}\n data-animate={animate || undefined}\n onFocus={(event) => {\n lastFocus.current = event.target;\n onFocus?.(event);\n }}\n >\n <div className=\"ds-edit-layout__main\">\n <EditActionBar\n backLabel={backLabel}\n onBack={onBack}\n compact={compact}\n status={\n <SaveStatus\n saveState={saveState}\n statusLabel={statusLabel}\n savedAgo={savedAgo}\n />\n }\n actions={actions}\n confirmLeave={confirmLeave}\n confirmation={\n <LeaveConfirmation\n text={confirmText}\n bodyRef={bodyRef}\n onKeepEditing={onKeepEditing}\n />\n }\n onLeave={onLeave}\n detailsToggle={\n <Button\n ref={toggleRef}\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"info\"\n aria-label={railLabel}\n aria-haspopup=\"dialog\"\n aria-expanded={sheet}\n aria-controls={detailsId}\n onClick={toggle}\n />\n }\n />\n <div\n ref={bodyRef}\n className=\"ds-edit-layout__body\"\n >\n <div className=\"ds-edit-layout__content\">{children}</div>\n </div>\n </div>\n {!compact && (\n <DetailsRail\n label={railLabel}\n detailsId={detailsId}\n expanded={expanded}\n opensSheet={narrow}\n sheetOpen={sheet}\n toggleRef={toggleRef}\n contentRef={railSlotRef}\n collapsed={railCollapsed}\n onToggle={toggle}\n />\n )}\n <Drawer\n id={narrow ? detailsId : undefined}\n dir={rest.dir}\n isOpen={sheet}\n onClose={() => setSheet(false)}\n side=\"end\"\n size=\"md\"\n title={railLabel}\n closeLabel={`Close ${railLabel}`}\n className=\"ds-edit-layout__sheet\"\n >\n {narrow && (\n <div\n ref={sheetSlotRef}\n className=\"ds-edit-layout__rail-content\"\n />\n )}\n </Drawer>\n {railHost && createPortal(railContent, railHost)}\n </div>\n );\n});\n"],"mappings":"A,sdAqDA,IAAMyB,EAAc,IAEdC,EAAgB,IAEhBC,EAAa,IAInB,SAASC,GAAW,EAA2B,CAU7C,OATIC,EAAQJ,EACH,QAELI,EAAQH,EACH,UAELG,EAAQF,EACH,SAEF,MACT,CAEA,IAAMG,EAA8C,CAClD,MAAO,aACP,MAAO,kBACP,OAAQ,UACR,MAAO,QACP,MAAO,gBACP,QAAS,4BACX,EAEMC,EAA2D,CAC/D,MAAO,IAAA,GACP,MAAO,IAAA,GACP,OAAQ,UACR,MAAO,QACP,MAAO,iBACP,QAAS,OACX,EAGMC,EAA+C,IAAI,IAAI,CAAC,QAAS,OAAO,CAAC,EAE/E,SAASC,EAAW,EAAiB,CAInC,OAHI,OAAOC,GAAS,SACXA,EAAK,KAAK,IAAM,GAElBA,GAAS,MAA8B,OAAOA,GAAS,SAChE,CAQA,SAASC,EAAW,CAAE,YAAW,WAAU,eAAgC,CACzE,IAAMC,EAAOL,EAAYM,GACnBC,EACJN,EAAiB,IAAIK,CAAS,GAAKJ,EAAWM,CAAW,EAAIA,EAAc,IAAA,GAC7E,OACE,EAAAf,EAAA,KAAA,CAAC,MAAD,CACE,UAAU,yBACV,aAAYa,EACZ,KAAK,SACL,YAAU,SAJZ,SAAA,CAMGD,IACC,EAAAZ,EAAA,IAAA,CAACxB,EAAAA,EAAD,CACE,KAAMoC,EACN,UAAWC,IAAc,SAAW,gBAAkB,IAAA,EACvD,CAAA,EAEFA,IAAc,UACb,EAAAb,EAAA,IAAA,CAAC,OAAD,CACE,UAAU,wBACV,cAAY,MACb,CAAA,GAGH,EAAAA,EAAA,KAAA,CAAC,OAAD,CAAM,MAAO,OAAOc,GAAW,SAAWA,EAAS,IAAA,GAAnD,SAAA,CACGA,GAAUR,EAAaO,GACvBA,IA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B,EAAAA,OAAD,CACE,IAAK0D,EACL,QAAQ,SACR,KAAK,KACL,WAAA,GACA,UAAU,OACV,aAAYsC,EACZ,gBAAc,SACd,gBAAejB,EACf,gBAAenB,EACf,QAAS4B,CACV,CAAA,CAEJ,CAAA,GACD,EAAAnE,EAAA,IAAA,CAAC,MAAD,CACE,IAAKuB,EACL,UAAU,uBAEV,UAAA,EAAAvB,EAAA,IAAA,CAAC,MAAD,CAAK,UAAU,0BAA2B,UAAc,CAAA,CACrD,CAAA,CACF,C,GACJ,CAACyB,IACA,EAAAzB,EAAA,IAAA,CAACkC,EAAD,CACE,MAAOyC,EACI,YACD,WACV,WAAYb,EACZ,UAAWJ,EACA,YACX,WAAYT,EACZ,UAAW2B,EACX,SAAUT,CACX,CAAA,GAEH,EAAAnE,EAAA,IAAA,CAACX,EAAAA,OAAD,CACE,GAAIyE,EAASvB,EAAY,IAAA,GACzB,IAAKM,EAAK,IACV,OAAQa,EACR,YAAeC,EAAS,EAAK,EAC7B,KAAK,MACL,KAAK,KACL,MAAOgB,EACP,WAAY,SAASA,IACrB,UAAU,wBAET,SAAAb,IACC,EAAA9D,EAAA,IAAA,CAAC,MAAD,CACE,IAAKkD,EACL,UAAU,8BACX,CAAA,CAEG,CAAA,EACPE,IAAA,EAAY9D,EAAAA,aAAAA,CAAa+E,GAAajB,CAAQ,CAC5C,C,EAET,CAAC,E"}
|
|
@@ -4,6 +4,12 @@ export interface EditLayoutProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
4
4
|
backLabel: string;
|
|
5
5
|
onBack: () => void;
|
|
6
6
|
saveState?: EditSaveState;
|
|
7
|
+
/**
|
|
8
|
+
* Replaces the `clean` or `dirty` message, for example on a read-only record.
|
|
9
|
+
* Saving, saved, error and offline keep their standard messages, and
|
|
10
|
+
* `saveState` always controls the indicator and colour. Empty values are ignored.
|
|
11
|
+
*/
|
|
12
|
+
statusLabel?: ReactNode;
|
|
7
13
|
savedAgo?: ReactNode;
|
|
8
14
|
actions?: ReactNode;
|
|
9
15
|
/** A render slot can close the Details sheet before opening another dialog. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/components/EditLayout/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,cAAc,EACnB,KAAK,SAAS,EAEf,MAAM,OAAO,CAAC;AAUf,OAAO,aAAa,CAAC;AAErB,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS,CAAC;AAEzF,MAAM,WAAW,eAAgB,SAAQ,cAAc,CAAC,cAAc,CAAC;IACrE,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,+EAA+E;IAC/E,IAAI,EAAE,SAAS,GAAG,CAAC,CAAC,YAAY,EAAE,MAAM,IAAI,KAAK,SAAS,CAAC,CAAC;IAC5D,sEAAsE;IACtE,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,IAAI,KAAK,SAAS,CAAC;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/components/EditLayout/index.ts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