@eui/eds-react 22.0.0-alpha.14 → 22.0.0-alpha.16
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/eds-datepicker/eds-date-adapter.d.ts +56 -0
- package/eds-datepicker/eds-date-adapter.d.ts.map +1 -0
- package/eds-datepicker/eds-date-adapter.js +69 -0
- package/eds-datepicker/eds-date-adapter.js.map +1 -0
- package/eds-datepicker/eds-datepicker.css +137 -0
- package/eds-datepicker/eds-datepicker.d.ts +67 -0
- package/eds-datepicker/eds-datepicker.d.ts.map +1 -0
- package/eds-datepicker/eds-datepicker.js +203 -0
- package/eds-datepicker/eds-datepicker.js.map +1 -0
- package/eds-datepicker/eds-luxon-date-adapter.d.ts +33 -0
- package/eds-datepicker/eds-luxon-date-adapter.d.ts.map +1 -0
- package/eds-datepicker/eds-luxon-date-adapter.js +90 -0
- package/eds-datepicker/eds-luxon-date-adapter.js.map +1 -0
- package/eds-datepicker/eds-timepicker.css +69 -0
- package/eds-datepicker/eds-timepicker.d.ts +44 -0
- package/eds-datepicker/eds-timepicker.d.ts.map +1 -0
- package/eds-datepicker/eds-timepicker.js +122 -0
- package/eds-datepicker/eds-timepicker.js.map +1 -0
- package/eds-datepicker/index.d.ts +8 -0
- package/eds-datepicker/index.d.ts.map +1 -0
- package/eds-datepicker/index.js +5 -0
- package/eds-datepicker/index.js.map +1 -0
- package/eds-label/eds-label.css +19 -0
- package/eds-label/eds-label.d.ts +22 -0
- package/eds-label/eds-label.d.ts.map +1 -0
- package/eds-label/eds-label.js +15 -0
- package/eds-label/eds-label.js.map +1 -0
- package/eds-label/index.d.ts +3 -0
- package/eds-label/index.d.ts.map +1 -0
- package/eds-label/index.js +2 -0
- package/eds-label/index.js.map +1 -0
- package/eds-shell/eds-shell-sidebar.css +1 -0
- package/eds-shell/eds-shell.css +2 -1
- package/eds-table/eds-table-context.d.ts +56 -0
- package/eds-table/eds-table-context.d.ts.map +1 -0
- package/eds-table/eds-table-context.js +12 -0
- package/eds-table/eds-table-context.js.map +1 -0
- package/eds-table/eds-table-expandable-row.d.ts +22 -0
- package/eds-table/eds-table-expandable-row.d.ts.map +1 -0
- package/eds-table/eds-table-expandable-row.js +25 -0
- package/eds-table/eds-table-expandable-row.js.map +1 -0
- package/eds-table/eds-table-filter.d.ts +38 -0
- package/eds-table/eds-table-filter.d.ts.map +1 -0
- package/eds-table/eds-table-filter.js +66 -0
- package/eds-table/eds-table-filter.js.map +1 -0
- package/eds-table/eds-table-highlight.d.ts +38 -0
- package/eds-table/eds-table-highlight.d.ts.map +1 -0
- package/eds-table/eds-table-highlight.js +81 -0
- package/eds-table/eds-table-highlight.js.map +1 -0
- package/eds-table/eds-table-selectable-header.d.ts +19 -0
- package/eds-table/eds-table-selectable-header.d.ts.map +1 -0
- package/eds-table/eds-table-selectable-header.js +38 -0
- package/eds-table/eds-table-selectable-header.js.map +1 -0
- package/eds-table/eds-table-selectable-row.d.ts +21 -0
- package/eds-table/eds-table-selectable-row.d.ts.map +1 -0
- package/eds-table/eds-table-selectable-row.js +92 -0
- package/eds-table/eds-table-selectable-row.js.map +1 -0
- package/eds-table/eds-table-sort.model.d.ts +11 -0
- package/eds-table/eds-table-sort.model.d.ts.map +1 -0
- package/eds-table/eds-table-sort.model.js +5 -0
- package/eds-table/eds-table-sort.model.js.map +1 -0
- package/eds-table/eds-table-sortable-col.d.ts +32 -0
- package/eds-table/eds-table-sortable-col.d.ts.map +1 -0
- package/eds-table/eds-table-sortable-col.js +65 -0
- package/eds-table/eds-table-sortable-col.js.map +1 -0
- package/eds-table/eds-table-sticky-col.d.ts +25 -0
- package/eds-table/eds-table-sticky-col.d.ts.map +1 -0
- package/eds-table/eds-table-sticky-col.js +23 -0
- package/eds-table/eds-table-sticky-col.js.map +1 -0
- package/eds-table/eds-table.css +410 -0
- package/eds-table/eds-table.d.ts +92 -0
- package/eds-table/eds-table.d.ts.map +1 -0
- package/eds-table/eds-table.js +353 -0
- package/eds-table/eds-table.js.map +1 -0
- package/eds-table/index.d.ts +20 -0
- package/eds-table/index.d.ts.map +1 -0
- package/eds-table/index.js +10 -0
- package/eds-table/index.js.map +1 -0
- package/index.d.ts +6 -0
- package/index.d.ts.map +1 -1
- package/index.js +3 -0
- package/index.js.map +1 -1
- package/package.json +22 -2
- package/showcase/doc-page.d.ts +56 -0
- package/showcase/doc-page.d.ts.map +1 -0
- package/showcase/doc-page.js +104 -0
- package/showcase/doc-page.js.map +1 -0
- package/showcase/index.d.ts +7 -0
- package/showcase/index.d.ts.map +1 -0
- package/showcase/index.js +7 -0
- package/showcase/index.js.map +1 -0
- package/showcase/jsx-to-string.d.ts +15 -0
- package/showcase/jsx-to-string.d.ts.map +1 -0
- package/showcase/jsx-to-string.js +98 -0
- package/showcase/jsx-to-string.js.map +1 -0
- package/showcase/shared.d.ts +64 -0
- package/showcase/shared.d.ts.map +1 -0
- package/showcase/shared.js +43 -0
- package/showcase/shared.js.map +1 -0
- package/showcase/showcase.css +407 -0
- package/styles.css +4 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type JsxToStringOptions } from './jsx-to-string.js';
|
|
3
|
+
/**
|
|
4
|
+
* Shared port of the Angular showcase `doc-page` primitives
|
|
5
|
+
* (`packages/eui/packages/showcase/src/lib/components/doc-page`), reused by BOTH standalone
|
|
6
|
+
* showcase hosts (`eui-showcase-react` and `eui-showcase-webcomponents`). Two pieces:
|
|
7
|
+
*
|
|
8
|
+
* - `ShowcaseDocPage` — the page frame: a title header plus a right-hand "On this page"
|
|
9
|
+
* navigation generated from the samples projected inside it (a flat list, deduped by
|
|
10
|
+
* label, in registration order), with click-to-scroll.
|
|
11
|
+
* - `ShowcaseDocSample` — one sample block: a title, a copy-link button, and a per-sample
|
|
12
|
+
* **Code / Hide Code** toggle that reveals the auto-generated code snippet beneath the
|
|
13
|
+
* live preview (mirrors the Angular per-sample code button).
|
|
14
|
+
*
|
|
15
|
+
* Samples register themselves with the page through `DocPageContext` (the React analog of
|
|
16
|
+
* the Angular `contentChildren(DocSampleComponent)` query) so the nav can list them without
|
|
17
|
+
* the author hand-maintaining a second list.
|
|
18
|
+
*
|
|
19
|
+
* The two hosts differ only in the snippet dialect (React JSX vs. HTML custom elements); a
|
|
20
|
+
* host sets it once via `ShowcaseDocPage`'s `codeDialect` prop, which flows to every sample.
|
|
21
|
+
*/
|
|
22
|
+
/** Preview layout for a sample. `bare`/`block` both mean "no flex wrapper" (host owns layout). */
|
|
23
|
+
export type ShowcaseSampleLayout = 'row' | 'column' | 'bare' | 'block';
|
|
24
|
+
/**
|
|
25
|
+
* `ShowcaseDocPage` — the doc-page frame. Renders the component title, the projected samples
|
|
26
|
+
* (its `children`), and a sticky "On this page" nav built from the samples that registered
|
|
27
|
+
* themselves. Clicking a nav item scrolls to that sample.
|
|
28
|
+
*/
|
|
29
|
+
export declare function ShowcaseDocPage({ id, label, subLabel, codeDialect, children }: {
|
|
30
|
+
id: string;
|
|
31
|
+
label?: string;
|
|
32
|
+
subLabel?: string;
|
|
33
|
+
/** Snippet dialect for this page's samples: `'jsx'` (React) or `'html'` (WC). */
|
|
34
|
+
codeDialect?: NonNullable<JsxToStringOptions['dialect']>;
|
|
35
|
+
children: React.ReactNode;
|
|
36
|
+
}): React.JSX.Element;
|
|
37
|
+
/**
|
|
38
|
+
* `ShowcaseDocSample` — one titled sample with a per-sample **Code / Hide Code** toggle.
|
|
39
|
+
*
|
|
40
|
+
* The code snippet is auto-generated by serializing `children` back to source (see
|
|
41
|
+
* `jsxToString`, in the enclosing page's dialect); pass `code` to override it (e.g. to show a
|
|
42
|
+
* `.map(...)` loop instead of its expanded elements). `layout` toggles the preview between a
|
|
43
|
+
* wrapping row (default), a column, or `bare`/`block` (no flex wrapper at all — the sample's
|
|
44
|
+
* own top-level element controls the layout, mirroring the Angular doc-sample's bare
|
|
45
|
+
* `<ng-content/>`). `category` groups the sample in the page nav (matching the Angular
|
|
46
|
+
* `category` input); omit it or use `Base` for the primary group.
|
|
47
|
+
*/
|
|
48
|
+
export declare function ShowcaseDocSample({ id, label, category, code, layout, children }: {
|
|
49
|
+
id?: string;
|
|
50
|
+
label?: string;
|
|
51
|
+
category?: string;
|
|
52
|
+
code?: string;
|
|
53
|
+
layout?: ShowcaseSampleLayout;
|
|
54
|
+
children: React.ReactNode;
|
|
55
|
+
}): React.JSX.Element;
|
|
56
|
+
//# sourceMappingURL=doc-page.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doc-page.d.ts","sourceRoot":"","sources":["../../src/showcase/doc-page.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAe,KAAK,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE1E;;;;;;;;;;;;;;;;;;GAkBG;AAEH,kGAAkG;AAClG,MAAM,MAAM,oBAAoB,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;AAoCvE;;;;GAIG;AACH,wBAAgB,eAAe,CAC3B,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAmB,EAAE,QAAQ,EAAE,EAAE;IACpD,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iFAAiF;IACjF,WAAW,CAAC,EAAE,WAAW,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC,CAAC;IACzD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC7B,GACF,KAAK,CAAC,GAAG,CAAC,OAAO,CAsEnB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAC7B,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAc,EAAE,QAAQ,EAAE,EAAE;IACrD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC7B,GACF,KAAK,CAAC,GAAG,CAAC,OAAO,CAuEnB"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { createContext, useContext, useId, useMemo, useRef, useState, useCallback } from 'react';
|
|
4
|
+
import { jsxToString } from './jsx-to-string.js';
|
|
5
|
+
const DocPageContext = createContext(null);
|
|
6
|
+
/**
|
|
7
|
+
* Collapse repeated labels to a single nav entry (the first sample with that label) — a
|
|
8
|
+
* section with several untitled sub-samples should show one nav item per label, not one per
|
|
9
|
+
* block. The nav item scrolls to the first occurrence.
|
|
10
|
+
*/
|
|
11
|
+
function dedupeByLabel(list) {
|
|
12
|
+
const seen = new Set();
|
|
13
|
+
return list.filter((s) => {
|
|
14
|
+
const key = s.label || s.id;
|
|
15
|
+
if (seen.has(key))
|
|
16
|
+
return false;
|
|
17
|
+
seen.add(key);
|
|
18
|
+
return true;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* `ShowcaseDocPage` — the doc-page frame. Renders the component title, the projected samples
|
|
23
|
+
* (its `children`), and a sticky "On this page" nav built from the samples that registered
|
|
24
|
+
* themselves. Clicking a nav item scrolls to that sample.
|
|
25
|
+
*/
|
|
26
|
+
export function ShowcaseDocPage({ id, label, subLabel, codeDialect = 'jsx', children }) {
|
|
27
|
+
const [samples, setSamples] = useState([]);
|
|
28
|
+
const [activeId, setActiveId] = useState(undefined);
|
|
29
|
+
const orderRef = useRef([]);
|
|
30
|
+
const register = useCallback((sample) => {
|
|
31
|
+
setSamples((prev) => {
|
|
32
|
+
if (prev.some(s => s.id === sample.id)) {
|
|
33
|
+
return prev.map(s => (s.id === sample.id ? sample : s));
|
|
34
|
+
}
|
|
35
|
+
if (!orderRef.current.includes(sample.id))
|
|
36
|
+
orderRef.current.push(sample.id);
|
|
37
|
+
return [...prev, sample];
|
|
38
|
+
});
|
|
39
|
+
}, []);
|
|
40
|
+
const unregister = useCallback((sampleId) => {
|
|
41
|
+
setSamples(prev => prev.filter(s => s.id !== sampleId));
|
|
42
|
+
orderRef.current = orderRef.current.filter(x => x !== sampleId);
|
|
43
|
+
}, []);
|
|
44
|
+
const ctx = useMemo(() => ({ register, unregister, activeId, setActiveId, codeDialect }), [register, unregister, activeId, codeDialect]);
|
|
45
|
+
// Flat nav list in registration order (no category grouping), deduped by label.
|
|
46
|
+
const navSamples = useMemo(() => {
|
|
47
|
+
const order = orderRef.current;
|
|
48
|
+
const ordered = [...samples].sort((a, b) => order.indexOf(a.id) - order.indexOf(b.id));
|
|
49
|
+
return dedupeByLabel(ordered);
|
|
50
|
+
}, [samples]);
|
|
51
|
+
const onNavClick = (sampleId) => {
|
|
52
|
+
setActiveId(sampleId);
|
|
53
|
+
document.getElementById(sampleId)?.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
54
|
+
};
|
|
55
|
+
return (_jsx(DocPageContext.Provider, { value: ctx, children: _jsxs("div", { className: "doc-page", children: [_jsxs("div", { className: "doc-page__main", children: [_jsxs("header", { className: "doc-page__header", children: [_jsx("h1", { className: "doc-page__title", children: label || id }), subLabel ? _jsx("p", { className: "doc-page__sublabel", children: subLabel }) : null] }), _jsx("div", { className: "doc-page__samples", children: children })] }), _jsxs("nav", { className: "doc-page__nav", "aria-label": "On this page", children: [_jsx("div", { className: "doc-page__nav-heading", children: "On this page" }), _jsx("ul", { className: "doc-page__nav-list", children: navSamples.map(s => (_jsx("li", { children: _jsx("button", { type: "button", className: 'doc-page__nav-item' +
|
|
56
|
+
(activeId === s.id ? ' doc-page__nav-item--selected' : ''), onClick: () => onNavClick(s.id), children: s.label || s.id }) }, s.id))) })] })] }) }));
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* `ShowcaseDocSample` — one titled sample with a per-sample **Code / Hide Code** toggle.
|
|
60
|
+
*
|
|
61
|
+
* The code snippet is auto-generated by serializing `children` back to source (see
|
|
62
|
+
* `jsxToString`, in the enclosing page's dialect); pass `code` to override it (e.g. to show a
|
|
63
|
+
* `.map(...)` loop instead of its expanded elements). `layout` toggles the preview between a
|
|
64
|
+
* wrapping row (default), a column, or `bare`/`block` (no flex wrapper at all — the sample's
|
|
65
|
+
* own top-level element controls the layout, mirroring the Angular doc-sample's bare
|
|
66
|
+
* `<ng-content/>`). `category` groups the sample in the page nav (matching the Angular
|
|
67
|
+
* `category` input); omit it or use `Base` for the primary group.
|
|
68
|
+
*/
|
|
69
|
+
export function ShowcaseDocSample({ id, label, category, code, layout = 'row', children }) {
|
|
70
|
+
const ctx = useContext(DocPageContext);
|
|
71
|
+
const reactId = useId();
|
|
72
|
+
// Stable, collision-free dom id: a slug of the id/label plus the React-generated id.
|
|
73
|
+
const slug = (id ?? label ?? 'sample').replace(/[^\w-]+/g, '-').replace(/^-+|-+$/g, '').toLowerCase() || 'sample';
|
|
74
|
+
const domId = `${slug}-${reactId.replace(/[^\w-]+/g, '')}`;
|
|
75
|
+
const [expanded, setExpanded] = useState(false);
|
|
76
|
+
const displayLabel = label ?? id ?? '';
|
|
77
|
+
const snippet = code ?? jsxToString(children, { dialect: ctx?.codeDialect ?? 'jsx' });
|
|
78
|
+
// Register with the page so it appears in the "On this page" nav.
|
|
79
|
+
React.useEffect(() => {
|
|
80
|
+
if (!ctx)
|
|
81
|
+
return;
|
|
82
|
+
ctx.register({ id: domId, label: displayLabel, category });
|
|
83
|
+
return () => ctx.unregister(domId);
|
|
84
|
+
}, [ctx, domId, displayLabel, category]);
|
|
85
|
+
// `bare`/`block` apply no flex layout — the sample's own top-level element (a flex/grid
|
|
86
|
+
// wrapper, matching the Angular sample template) owns the layout. `row`/`column` keep the
|
|
87
|
+
// convenience flex wrapper for simple samples that render their variants as direct children.
|
|
88
|
+
const previewClass = layout === 'bare' || layout === 'block'
|
|
89
|
+
? ''
|
|
90
|
+
: layout === 'column'
|
|
91
|
+
? 'eds-u-d-flex eds-u-flex-column eds-u-flex-align-items-start eds-u-flex-gap-s'
|
|
92
|
+
: 'eds-u-d-flex eds-u-flex-wrap eds-u-flex-align-items-center eds-u-flex-gap-m';
|
|
93
|
+
const copyLink = () => {
|
|
94
|
+
try {
|
|
95
|
+
const url = `${window.location.origin}${window.location.pathname}${window.location.hash.split('#').slice(0, 2).join('#')}#${domId}`;
|
|
96
|
+
void navigator.clipboard?.writeText(url);
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
/* clipboard unavailable — non-critical */
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
return (_jsxs("section", { id: domId, className: "doc-sample", onMouseEnter: () => ctx?.setActiveId(domId), children: [_jsxs("div", { className: "doc-sample__title", children: [_jsx("span", { className: "doc-sample__label", children: displayLabel }), displayLabel ? (_jsx("button", { type: "button", className: "doc-sample__link", "aria-label": "Copy link to this sample", onClick: copyLink, children: "#" })) : null, _jsx("span", { className: "doc-sample__spacer" }), _jsx("button", { type: "button", className: "doc-sample__code-toggle", "aria-expanded": expanded, onClick: () => setExpanded(v => !v), children: expanded ? 'Hide code' : 'Code' })] }), _jsx("div", { className: previewClass ? `${previewClass} sample-preview` : 'sample-preview', children: children }), expanded ? (_jsx("pre", { className: "sample-code", children: _jsx("code", { children: snippet }) })) : null] }));
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=doc-page.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doc-page.js","sourceRoot":"","sources":["../../src/showcase/doc-page.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAA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AAE,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,YAElC,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,GAC3B,IACP,EAEN,cAAK,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,YAAY,iBAAiB,CAAC,CAAC,CAAC,gBAAgB,YAAG,QAAQ,GAAO,EAEnG,QAAQ,CAAC,CAAC,CAAC,CACR,cAAK,SAAS,EAAC,aAAa,YACxB,yBAAO,OAAO,GAAQ,GACpB,CACT,CAAC,CAAC,CAAC,IAAI,IACF,CACb,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { ShowcaseDocPage, ShowcaseDocSample } from './doc-page.js';
|
|
2
|
+
export type { ShowcaseSampleLayout } from './doc-page.js';
|
|
3
|
+
export { Section, Sample, DEMO_GROUPS } from './shared.js';
|
|
4
|
+
export type { DemoEntry, DemoGroup } from './shared.js';
|
|
5
|
+
export { jsxToString, registerComponentName } from './jsx-to-string.js';
|
|
6
|
+
export type { JsxToStringOptions } from './jsx-to-string.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/showcase/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACnE,YAAY,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC3D,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AACxE,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Shared showcase doc-page scaffolding, reused by both standalone showcase hosts
|
|
2
|
+
// (eui-showcase-react and eui-showcase-webcomponents). Import the component styles alongside:
|
|
3
|
+
// import '@eui/eds-react/showcase/showcase.css';
|
|
4
|
+
export { ShowcaseDocPage, ShowcaseDocSample } from './doc-page.js';
|
|
5
|
+
export { Section, Sample, DEMO_GROUPS } from './shared.js';
|
|
6
|
+
export { jsxToString, registerComponentName } from './jsx-to-string.js';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/showcase/index.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,8FAA8F;AAC9F,mDAAmD;AACnD,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEnE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE3D,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/** Register a component's tag name so the serializer prints it (not `Unknown`). */
|
|
3
|
+
export declare function registerComponentName(type: unknown, name: string): void;
|
|
4
|
+
/** Output conventions that differ between the JSX (React) and HTML (Web Component) hosts. */
|
|
5
|
+
export interface JsxToStringOptions {
|
|
6
|
+
/**
|
|
7
|
+
* How to close an element with no children:
|
|
8
|
+
* - `'jsx'` (default) → `<tag />`, numeric props as `{n}`, empty-string prop omitted.
|
|
9
|
+
* - `'html'` → `<tag></tag>`, numeric props as `"n"`, empty-string prop as a bare `name`.
|
|
10
|
+
*/
|
|
11
|
+
dialect?: 'jsx' | 'html';
|
|
12
|
+
}
|
|
13
|
+
/** Serialize a node (typically a `<Sample>`'s children) to a source string. */
|
|
14
|
+
export declare function jsxToString(node: React.ReactNode, options?: JsxToStringOptions): string;
|
|
15
|
+
//# sourceMappingURL=jsx-to-string.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx-to-string.d.ts","sourceRoot":"","sources":["../../src/showcase/jsx-to-string.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAqB/B,mFAAmF;AACnF,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAEvE;AAED,6FAA6F;AAC7F,MAAM,WAAW,kBAAkB;IAC/B;;;;OAIG;IACH,OAAO,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;CAC5B;AAsED,+EAA+E;AAC/E,wBAAgB,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,SAAS,EAAE,OAAO,GAAE,kBAAuB,GAAG,MAAM,CAG3F"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Serializes a React node tree back into readable source, so a `<Sample>` can display the
|
|
4
|
+
* exact code that produced its live rendering — no hand-maintained `code` string.
|
|
5
|
+
*
|
|
6
|
+
* Scope: this handles the subset used by showcase samples (intrinsic tags like `span` /
|
|
7
|
+
* `eds-wc-icon`, components like `EdsBadge`, string/number/boolean props, and text / element
|
|
8
|
+
* children). It is a documentation aid, not a general-purpose serializer.
|
|
9
|
+
*
|
|
10
|
+
* Both showcase hosts share this serializer; they differ only in cosmetic output conventions
|
|
11
|
+
* (React JSX prints self-closing `<tag />` and numeric props as `{n}`; the Web Component host
|
|
12
|
+
* prints HTML `<tag></tag>` and numeric props as `"n"`). Pass {@link JsxToStringOptions} to
|
|
13
|
+
* select the convention.
|
|
14
|
+
*/
|
|
15
|
+
const INDENT = ' ';
|
|
16
|
+
/** Explicit component → tag names, for components without a stable runtime name. */
|
|
17
|
+
const NAME_REGISTRY = new Map();
|
|
18
|
+
/** Register a component's tag name so the serializer prints it (not `Unknown`). */
|
|
19
|
+
export function registerComponentName(type, name) {
|
|
20
|
+
NAME_REGISTRY.set(type, name);
|
|
21
|
+
}
|
|
22
|
+
/** Component display name → tag (e.g. EdsBadge → "EdsBadge", 'span' → "span"). */
|
|
23
|
+
function tagName(type) {
|
|
24
|
+
if (typeof type === 'string')
|
|
25
|
+
return type;
|
|
26
|
+
const registered = NAME_REGISTRY.get(type);
|
|
27
|
+
if (registered)
|
|
28
|
+
return registered;
|
|
29
|
+
if (typeof type === 'function') {
|
|
30
|
+
const fn = type;
|
|
31
|
+
if (fn.displayName || fn.name)
|
|
32
|
+
return fn.displayName || fn.name || 'Unknown';
|
|
33
|
+
}
|
|
34
|
+
// React.forwardRef components are objects with a render fn — read its name.
|
|
35
|
+
if (type && typeof type === 'object') {
|
|
36
|
+
const obj = type;
|
|
37
|
+
if (obj.displayName)
|
|
38
|
+
return obj.displayName;
|
|
39
|
+
if (obj.render?.name)
|
|
40
|
+
return obj.render.name;
|
|
41
|
+
}
|
|
42
|
+
return 'Unknown';
|
|
43
|
+
}
|
|
44
|
+
/** Render one prop as ` name`, ` name="v"`, or ` name={expr}`. `key`/`ref` are dropped. */
|
|
45
|
+
function serializeProp(name, value, dialect) {
|
|
46
|
+
if (name === 'children' || name === 'key' || name === 'ref')
|
|
47
|
+
return '';
|
|
48
|
+
if (value === true)
|
|
49
|
+
return ` ${name}`;
|
|
50
|
+
// HTML treats an empty-string attribute as a bare boolean-style attribute (` name`).
|
|
51
|
+
if (dialect === 'html' && value === '')
|
|
52
|
+
return ` ${name}`;
|
|
53
|
+
if (value === false || value === null || value === undefined)
|
|
54
|
+
return '';
|
|
55
|
+
if (typeof value === 'string')
|
|
56
|
+
return ` ${name}="${value}"`;
|
|
57
|
+
if (typeof value === 'number')
|
|
58
|
+
return dialect === 'html' ? ` ${name}="${value}"` : ` ${name}={${value}}`;
|
|
59
|
+
return ` ${name}={${String(value)}}`;
|
|
60
|
+
}
|
|
61
|
+
function serializeNode(node, depth, dialect) {
|
|
62
|
+
const pad = INDENT.repeat(depth);
|
|
63
|
+
if (node === null || node === undefined || node === false || node === true)
|
|
64
|
+
return '';
|
|
65
|
+
if (typeof node === 'string' || typeof node === 'number') {
|
|
66
|
+
const text = String(node).trim();
|
|
67
|
+
return text ? pad + text : '';
|
|
68
|
+
}
|
|
69
|
+
if (Array.isArray(node)) {
|
|
70
|
+
return node.map(n => serializeNode(n, depth, dialect)).filter(Boolean).join('\n');
|
|
71
|
+
}
|
|
72
|
+
if (React.isValidElement(node)) {
|
|
73
|
+
const el = node;
|
|
74
|
+
const tag = tagName(el.type);
|
|
75
|
+
const props = el.props ?? {};
|
|
76
|
+
const attrs = Object.keys(props)
|
|
77
|
+
.map(k => serializeProp(k, props[k], dialect))
|
|
78
|
+
.join('');
|
|
79
|
+
const children = props.children;
|
|
80
|
+
const hasChildren = children !== undefined && children !== null && children !== false;
|
|
81
|
+
if (!hasChildren) {
|
|
82
|
+
return dialect === 'html' ? `${pad}<${tag}${attrs}></${tag}>` : `${pad}<${tag}${attrs} />`;
|
|
83
|
+
}
|
|
84
|
+
const inner = serializeNode(children, depth + 1, dialect);
|
|
85
|
+
// Inline a single short text child (e.g. <EdsBadge>9</EdsBadge>).
|
|
86
|
+
if ((typeof children === 'string' || typeof children === 'number') && inner.trim().length <= 20) {
|
|
87
|
+
return `${pad}<${tag}${attrs}>${String(children).trim()}</${tag}>`;
|
|
88
|
+
}
|
|
89
|
+
return `${pad}<${tag}${attrs}>\n${inner}\n${pad}</${tag}>`;
|
|
90
|
+
}
|
|
91
|
+
return '';
|
|
92
|
+
}
|
|
93
|
+
/** Serialize a node (typically a `<Sample>`'s children) to a source string. */
|
|
94
|
+
export function jsxToString(node, options = {}) {
|
|
95
|
+
const dialect = options.dialect ?? 'jsx';
|
|
96
|
+
return serializeNode(node, 0, dialect).replace(/\n{2,}/g, '\n');
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=jsx-to-string.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,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E,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC;YAC9F,OAAO,GAAG,GAAG,IAAI,GAAG,GAAG,KAAK,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE,KAAK,GAAG,GAAG,CAAC;QACvE,CAAC;QACD,OAAO,GAAG,GAAG,IAAI,GAAG,GAAG,KAAK,MAAM,KAAK,KAAK,GAAG,KAAK,GAAG,GAAG,CAAC;IAC/D,CAAC;IAED,OAAO,EAAE,CAAC;AACd,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,WAAW,CAAC,IAAqB,EAAE,UAA8B,EAAE;IAC/E,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,KAAK,CAAC;IACzC,OAAO,aAAa,CAAC,IAAI,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;AACpE,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type ShowcaseSampleLayout } from './doc-page.js';
|
|
3
|
+
/**
|
|
4
|
+
* Shared showcase authoring wrappers, reused by BOTH standalone showcase hosts
|
|
5
|
+
* (`eui-showcase-react` and `eui-showcase-webcomponents`). `Section` + `Sample` are thin
|
|
6
|
+
* compat wrappers over the `doc-page` primitives so a samples file authors with familiar
|
|
7
|
+
* section/sample blocks and gets the doc-page frame + per-sample code toggle for free.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* A demo entry: one migrated EDS component rendered through its projection (`Eds*` React
|
|
11
|
+
* component in the React host, `eds-wc-*` Web Component in the WC host). `id` is the hash
|
|
12
|
+
* route segment (e.g. `#/eds-badge`).
|
|
13
|
+
*/
|
|
14
|
+
export interface DemoEntry {
|
|
15
|
+
/** Route segment, matches the Angular `eds-COMPONENT` folder. */
|
|
16
|
+
id: string;
|
|
17
|
+
/** Human-readable name shown in the demo's own header/nav. */
|
|
18
|
+
label: string;
|
|
19
|
+
/** The samples component rendering that component's variants. */
|
|
20
|
+
Samples: React.ComponentType;
|
|
21
|
+
/**
|
|
22
|
+
* When true, the demo renders full-bleed (no `<main>` padding / page header), for
|
|
23
|
+
* full-viewport components like `eds-shell` and the `home` landing page. (React host.)
|
|
24
|
+
*/
|
|
25
|
+
fullBleed?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* When true, the entry is routable but omitted from the sidebar navigation (e.g. the
|
|
28
|
+
* `home` landing page, reached via `/` and the toolbar logo). (React host.)
|
|
29
|
+
*/
|
|
30
|
+
hideFromNav?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Sidebar grouping bucket, mirroring the Angular EDS showcase top-level categories
|
|
33
|
+
* (`eds-links.ts`): `'Shell' | 'EDS validated' | 'Components' | 'Utilities' | 'Patterns'
|
|
34
|
+
* | 'Templates'`. The sidebar renders one expandable group per bucket (in
|
|
35
|
+
* `DEMO_GROUPS` order); entries without a `group` fall into `'Components'`.
|
|
36
|
+
*/
|
|
37
|
+
group?: DemoGroup;
|
|
38
|
+
}
|
|
39
|
+
/** Top-level sidebar categories, in display order (mirrors the Angular EDS showcase). */
|
|
40
|
+
export type DemoGroup = 'Shell' | 'EDS validated' | 'Components' | 'Utilities' | 'Patterns' | 'Templates';
|
|
41
|
+
/** Sidebar group order — the sidebar renders groups in this sequence, skipping empty ones. */
|
|
42
|
+
export declare const DEMO_GROUPS: readonly DemoGroup[];
|
|
43
|
+
/**
|
|
44
|
+
* `Sample` — a titled sample block with a per-sample **Code / Hide code** toggle, delegating
|
|
45
|
+
* to `ShowcaseDocSample`. The code snippet is auto-generated from `children` (or overridden
|
|
46
|
+
* via `code`). Its nav category comes from the enclosing `<Section>`; a sample with no title
|
|
47
|
+
* falls back to the section title as its label so it still appears in the nav.
|
|
48
|
+
*/
|
|
49
|
+
export declare function Sample({ title, code, layout, children }: {
|
|
50
|
+
title?: string;
|
|
51
|
+
code?: string;
|
|
52
|
+
layout?: ShowcaseSampleLayout;
|
|
53
|
+
children: React.ReactNode;
|
|
54
|
+
}): React.JSX.Element;
|
|
55
|
+
/**
|
|
56
|
+
* `Section` — a titled group. Provides its title as the nav category for nested `<Sample>`s
|
|
57
|
+
* (via `SectionContext`), mirroring the Angular doc-page `category` grouping. It renders no
|
|
58
|
+
* visible heading — the sample's own title bar is the heading.
|
|
59
|
+
*/
|
|
60
|
+
export declare function Section({ title, children }: {
|
|
61
|
+
title: string;
|
|
62
|
+
children: React.ReactNode;
|
|
63
|
+
}): React.JSX.Element;
|
|
64
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/showcase/shared.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAqB,KAAK,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAE7E;;;;;GAKG;AAEH;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACtB,iEAAiE;IACjE,EAAE,EAAE,MAAM,CAAC;IACX,8DAA8D;IAC9D,KAAK,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,OAAO,EAAE,KAAK,CAAC,aAAa,CAAC;IAC7B;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;CACrB;AAED,yFAAyF;AACzF,MAAM,MAAM,SAAS,GACf,OAAO,GACP,eAAe,GACf,YAAY,GACZ,WAAW,GACX,UAAU,GACV,WAAW,CAAC;AAElB,8FAA8F;AAC9F,eAAO,MAAM,WAAW,EAAE,SAAS,SAAS,EAO3C,CAAC;AAWF;;;;;GAKG;AACH,wBAAgB,MAAM,CAClB,EAAE,KAAK,EAAE,IAAI,EAAE,MAAc,EAAE,QAAQ,EAAE,EAAE;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC7B,GACF,KAAK,CAAC,GAAG,CAAC,OAAO,CAWnB;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAM5G"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext } from 'react';
|
|
3
|
+
import { ShowcaseDocSample } from './doc-page.js';
|
|
4
|
+
/** Sidebar group order — the sidebar renders groups in this sequence, skipping empty ones. */
|
|
5
|
+
export const DEMO_GROUPS = [
|
|
6
|
+
'Shell',
|
|
7
|
+
'EDS validated',
|
|
8
|
+
'Components',
|
|
9
|
+
'Utilities',
|
|
10
|
+
'Patterns',
|
|
11
|
+
'Templates',
|
|
12
|
+
];
|
|
13
|
+
/**
|
|
14
|
+
* The current `<Section>` title, propagated to nested `<Sample>`s as their nav category —
|
|
15
|
+
* so the `Section` + `Sample` authoring maps onto the doc-page's category-grouped "On this
|
|
16
|
+
* page" nav without editing every samples file. A `<Sample title="…">` inside a
|
|
17
|
+
* `<Section title="Sizes">` registers under the `Sizes` category with label `…` (or the
|
|
18
|
+
* section title when the sample has none).
|
|
19
|
+
*/
|
|
20
|
+
const SectionContext = createContext(undefined);
|
|
21
|
+
/**
|
|
22
|
+
* `Sample` — a titled sample block with a per-sample **Code / Hide code** toggle, delegating
|
|
23
|
+
* to `ShowcaseDocSample`. The code snippet is auto-generated from `children` (or overridden
|
|
24
|
+
* via `code`). Its nav category comes from the enclosing `<Section>`; a sample with no title
|
|
25
|
+
* falls back to the section title as its label so it still appears in the nav.
|
|
26
|
+
*/
|
|
27
|
+
export function Sample({ title, code, layout = 'row', children }) {
|
|
28
|
+
const section = useContext(SectionContext);
|
|
29
|
+
// Category = the section title (so the nav groups by section). Base group when no section.
|
|
30
|
+
const category = section ?? 'Base';
|
|
31
|
+
// Label = the sample's own title, else the section title.
|
|
32
|
+
const label = title ?? section ?? '';
|
|
33
|
+
return (_jsx(ShowcaseDocSample, { label: label, category: category, code: code, layout: layout, children: children }));
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* `Section` — a titled group. Provides its title as the nav category for nested `<Sample>`s
|
|
37
|
+
* (via `SectionContext`), mirroring the Angular doc-page `category` grouping. It renders no
|
|
38
|
+
* visible heading — the sample's own title bar is the heading.
|
|
39
|
+
*/
|
|
40
|
+
export function Section({ title, children }) {
|
|
41
|
+
return (_jsx(SectionContext.Provider, { value: title, children: _jsx("section", { className: "eds-u-mb-xl", children: children }) }));
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/showcase/shared.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAA6B,MAAM,eAAe,CAAC;AAiD7E,8FAA8F;AAC9F,MAAM,CAAC,MAAM,WAAW,GAAyB;IAC7C,OAAO;IACP,eAAe;IACf,YAAY;IACZ,WAAW;IACX,UAAU;IACV,WAAW;CACd,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,cAAc,GAAG,aAAa,CAAqB,SAAS,CAAC,CAAC;AAEpE;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CAClB,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,GAAG,KAAK,EAAE,QAAQ,EAKtC;IAED,MAAM,OAAO,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;IAC3C,2FAA2F;IAC3F,MAAM,QAAQ,GAAG,OAAO,IAAI,MAAM,CAAC;IACnC,0DAA0D;IAC1D,MAAM,KAAK,GAAG,KAAK,IAAI,OAAO,IAAI,EAAE,CAAC;IACrC,OAAO,CACH,KAAC,iBAAiB,IAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,YAC1E,QAAQ,GACO,CACvB,CAAC;AACN,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAgD;IACrF,OAAO,CACH,KAAC,cAAc,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YACjC,kBAAS,SAAS,EAAC,aAAa,YAAE,QAAQ,GAAW,GAC/B,CAC7B,CAAC;AACN,CAAC"}
|