@godxjp/ui 31.4.0 → 31.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agent/START-HERE.md +6 -6
- package/agent/components/BranchScopePicker.json +5 -0
- package/agent/components/Cascader.json +1 -1
- package/agent/components/CodeBlock.json +7 -1
- package/agent/components/DataTable.json +2 -2
- package/agent/components/InfiniteQueryState.json +6 -1
- package/agent/components/OrgChart.json +59 -0
- package/agent/components/RangeTimeline.json +6 -0
- package/agent/components/RecordPicker.json +10 -0
- package/agent/components/Transfer.json +5 -0
- package/agent/components/Tree.json +21 -4
- package/agent/components/TreeSelect.json +1 -1
- package/agent/components-index.json +5 -0
- package/agent/components.json +123 -10
- package/agent/index.json +7 -7
- package/agent/llms.txt +7 -7
- package/agent/tokens.json +114 -0
- package/dist/components/data-display/code-block.js +90 -4
- package/dist/components/data-display/data-table.d.ts +3 -0
- package/dist/components/data-display/data-table.js +415 -370
- package/dist/components/data-display/index.d.ts +2 -0
- package/dist/components/data-display/index.js +2 -0
- package/dist/components/data-display/org-chart.d.ts +5 -0
- package/dist/components/data-display/org-chart.js +169 -0
- package/dist/components/data-display/range-timeline.d.ts +20 -0
- package/dist/components/data-display/range-timeline.js +217 -197
- package/dist/components/data-display/tree.js +179 -23
- package/dist/components/data-entry/branch-scope-picker.d.ts +1 -0
- package/dist/components/data-entry/branch-scope-picker.js +2 -1
- package/dist/components/data-entry/cascader.js +4 -5
- package/dist/components/data-entry/record-picker.d.ts +2 -0
- package/dist/components/data-entry/record-picker.js +22 -3
- package/dist/components/data-entry/transfer.d.ts +1 -1
- package/dist/components/data-entry/transfer.js +5 -2
- package/dist/components/data-entry/tree-select.js +14 -5
- package/dist/components/general/typography.d.ts +32 -0
- package/dist/components/general/typography.js +11 -2
- package/dist/components/query/infinite-query-state.d.ts +1 -1
- package/dist/components/query/infinite-query-state.js +2 -1
- package/dist/contracts/measurement.json +1 -1
- package/dist/i18n/messages/en.json +26 -2
- package/dist/i18n/messages/ja.json +17 -2
- package/dist/i18n/messages/vi.json +17 -2
- package/dist/lib/hooks.d.ts +8 -4
- package/dist/lib/hooks.js +5 -2
- package/dist/lib/tree.d.ts +23 -0
- package/dist/lib/tree.js +29 -0
- package/dist/props/components/data-display.prop.d.ts +72 -3
- package/dist/props/components/data-entry.prop.d.ts +31 -4
- package/dist/props/components/query.prop.d.ts +8 -1
- package/dist/props/registry.d.ts +63 -6
- package/dist/props/registry.js +90 -4
- package/dist/props/vocabulary/data.prop.d.ts +32 -2
- package/dist/props/vocabulary/index.d.ts +1 -1
- package/dist/styles/data-display-layout.css +225 -0
- package/dist/styles/layers.json +14 -1
- package/dist/styles/table-layout.css +16 -1
- package/dist/tokens/base.css +1 -0
- package/dist/tokens/components/org-chart.css +27 -0
- package/dist/tokens/components/tree.css +2 -0
- package/docs/FRAME-COVERAGE-REPORT.md +3 -2
- package/docs/data-display/code-block.tsx +27 -0
- package/docs/data-display/data-table/examples/server-paged.tsx +23 -0
- package/docs/data-display/data-table/index.md +2 -0
- package/docs/data-display/org-chart.tsx +165 -0
- package/docs/data-display/timeline.tsx +33 -0
- package/docs/data-display/tree.tsx +154 -0
- package/docs/data-entry/branch-scope-picker.tsx +6 -1
- package/docs/data-entry/record-picker.tsx +1 -0
- package/docs/data-entry/transfer.tsx +1 -0
- package/docs/i18n/messages/en.json +19 -0
- package/docs/i18n/messages/ja.json +18 -0
- package/docs/i18n/messages/vi.json +18 -0
- package/docs/navigation/tabs.tsx +17 -15
- package/docs/query/data-state.tsx +2 -4
- package/docs/query/infinite-query-state.tsx +5 -1
- package/docs/roadmap/tree-components.md +2 -1
- package/docs/showcase/table-view-tabs.tsx +1 -1
- package/package.json +2 -2
- package/scripts/ui-audit.mjs +15 -5
package/agent/index.json
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"counts": {
|
|
3
3
|
"anti-ai-tells": 26,
|
|
4
|
-
"components":
|
|
4
|
+
"components": 177,
|
|
5
5
|
"patterns": 21,
|
|
6
6
|
"rules": 50,
|
|
7
|
-
"tokens":
|
|
7
|
+
"tokens": 2099,
|
|
8
8
|
"vocabulary": 14
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
{
|
|
12
12
|
"file": "components-index.json",
|
|
13
|
-
"note": "47 KB — name + group + tagline for all
|
|
13
|
+
"note": "47 KB — name + group + tagline for all 177. FETCH THIS FIRST, then fetch only the components you chose.",
|
|
14
14
|
"url": "https://raw.githubusercontent.com/godx-jp/godxjp-ui/main/agent/components-index.json"
|
|
15
15
|
},
|
|
16
16
|
{
|
|
17
17
|
"file": "components/<Name>.json",
|
|
18
|
-
"note": "One file per component (1 KB–
|
|
18
|
+
"note": "One file per component (1 KB–36 KB, median 6 KB), each carrying its importPath. This is the selective route: read the index, then fetch only what you need instead of the 1.2 MB blob.",
|
|
19
19
|
"url": "https://raw.githubusercontent.com/godx-jp/godxjp-ui/main/agent/components/<Name>.json"
|
|
20
20
|
},
|
|
21
21
|
{
|
|
@@ -48,19 +48,19 @@
|
|
|
48
48
|
"note": "Pin to the tag that matches the @godxjp/ui version you installed. A catalog newer than your package describes props you do not have; older, and it hides props you do.",
|
|
49
49
|
"read": {
|
|
50
50
|
"live": "https://raw.githubusercontent.com/godx-jp/godxjp-ui/main/agent/index.json",
|
|
51
|
-
"pinned": "https://raw.githubusercontent.com/godx-jp/godxjp-ui/v31.
|
|
51
|
+
"pinned": "https://raw.githubusercontent.com/godx-jp/godxjp-ui/v31.6.0/agent/index.json"
|
|
52
52
|
},
|
|
53
53
|
"source": "mcp/src/data — the same data @godxjp/ui-mcp serves — plus the foundation and semantic token tiers, read from src/tokens/*.css",
|
|
54
54
|
"start": "https://raw.githubusercontent.com/godx-jp/godxjp-ui/main/agent/START-HERE.md",
|
|
55
55
|
"tokenTiers": {
|
|
56
56
|
"component": "per-part knobs, --{component}-{part}-{property}; usually leave these alone",
|
|
57
57
|
"counts": {
|
|
58
|
-
"component":
|
|
58
|
+
"component": 1784,
|
|
59
59
|
"foundation": 211,
|
|
60
60
|
"semantic": 104
|
|
61
61
|
},
|
|
62
62
|
"foundation": "the seeds a consumer is invited to set — --primary, --background, --radius",
|
|
63
63
|
"semantic": "named roles that follow the seeds — --ring, --text-link, --overlay-background"
|
|
64
64
|
},
|
|
65
|
-
"version": "31.
|
|
65
|
+
"version": "31.6.0"
|
|
66
66
|
}
|
package/agent/llms.txt
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# @godxjp/ui
|
|
2
2
|
|
|
3
|
-
> A Japanese-enterprise React design system:
|
|
4
|
-
> 50 cardinal rules. This file is the entry point for AI agents. Catalog version 31.
|
|
3
|
+
> A Japanese-enterprise React design system: 177 components, 2099 design tokens,
|
|
4
|
+
> 50 cardinal rules. This file is the entry point for AI agents. Catalog version 31.6.0.
|
|
5
5
|
|
|
6
6
|
If your client can run a process, do not read these files — run the MCP server instead
|
|
7
|
-
(`npx @godxjp/ui-mcp@31.
|
|
7
|
+
(`npx @godxjp/ui-mcp@31.6.0`). It is searchable and version-locked. These files exist for agents
|
|
8
8
|
that can only fetch URLs.
|
|
9
9
|
|
|
10
10
|
## Start
|
|
@@ -15,10 +15,10 @@ that can only fetch URLs.
|
|
|
15
15
|
## Catalog
|
|
16
16
|
|
|
17
17
|
- [patterns-index.json](https://raw.githubusercontent.com/godx-jp/godxjp-ui/main/agent/patterns-index.json): 21 whole-task patterns (name, tagline, tags). Start here when the task is a TASK — "build a settings page" — then fetch `patterns/<name>.json` for complete code.
|
|
18
|
-
- [components-index.json](https://raw.githubusercontent.com/godx-jp/godxjp-ui/main/agent/components-index.json): 47 KB — all
|
|
19
|
-
- [components/<Name>.json](https://raw.githubusercontent.com/godx-jp/godxjp-ui/main/agent/components/Select.json): one file per component (1 KB–
|
|
18
|
+
- [components-index.json](https://raw.githubusercontent.com/godx-jp/godxjp-ui/main/agent/components-index.json): 47 KB — all 177 components as name, group, tagline, plus `absorbed`: the names that do NOT exist and map to it (`Combobox` → `Select`).
|
|
19
|
+
- [components/<Name>.json](https://raw.githubusercontent.com/godx-jp/godxjp-ui/main/agent/components/Select.json): one file per component (1 KB–36 KB, median 6 KB). Read the index, then fetch only the ones you chose — this is the selective route, and the reason you do not need the blob.
|
|
20
20
|
- [components.json](https://raw.githubusercontent.com/godx-jp/godxjp-ui/main/agent/components.json): 1.2 MB — every entry in one file. Most URL fetchers truncate a response this size without saying so; prefer the per-component files.
|
|
21
|
-
- [tokens.json](https://raw.githubusercontent.com/godx-jp/godxjp-ui/main/agent/tokens.json): every design token with its value, the reason it exists, and its `tier` — 211 `foundation` seeds (`--primary`, `--background`, `--radius`: set these when you are handed a brand), 104 `semantic` roles,
|
|
21
|
+
- [tokens.json](https://raw.githubusercontent.com/godx-jp/godxjp-ui/main/agent/tokens.json): every design token with its value, the reason it exists, and its `tier` — 211 `foundation` seeds (`--primary`, `--background`, `--radius`: set these when you are handed a brand), 104 `semantic` roles, 1784 `component` knobs.
|
|
22
22
|
- [vocabulary.json](https://raw.githubusercontent.com/godx-jp/godxjp-ui/main/agent/vocabulary.json): the controlled prop vocabulary — which prop name means what, across every component.
|
|
23
23
|
- [rules.json](https://raw.githubusercontent.com/godx-jp/godxjp-ui/main/agent/rules.json): 50 cardinal rules.
|
|
24
24
|
- [anti-ai-tells.json](https://raw.githubusercontent.com/godx-jp/godxjp-ui/main/agent/anti-ai-tells.json): 26 shapes that make generated UI look generated, each with its fix.
|
|
@@ -26,7 +26,7 @@ that can only fetch URLs.
|
|
|
26
26
|
## Pinning
|
|
27
27
|
|
|
28
28
|
Every URL above tracks `main`. To pin to the release a project actually installed, swap `main` for
|
|
29
|
-
the tag: `.../godx-jp/godxjp-ui/v31.
|
|
29
|
+
the tag: `.../godx-jp/godxjp-ui/v31.6.0/agent/...`. A catalog that does not match the installed
|
|
30
30
|
package describes props that are absent, or hides props that are present, and says nothing either way.
|
|
31
31
|
|
|
32
32
|
Pinned catalogs only exist for releases whose tag actually contains `agent/`. If `…/v<version>/agent/index.json` returns 404, that release predates this catalog: read `…/main/…` instead and compare `index.json` → `version` against the package you have, so you at least know which way it drifted.
|
package/agent/tokens.json
CHANGED
|
@@ -9221,6 +9221,114 @@
|
|
|
9221
9221
|
"tier": "component",
|
|
9222
9222
|
"value": "0.7"
|
|
9223
9223
|
},
|
|
9224
|
+
{
|
|
9225
|
+
"description": "The box. A fixed inline size, so siblings line up in even columns and the connector bus has a predictable pitch; long names wrap inside it instead of widening one box.",
|
|
9226
|
+
"name": "--org-chart-node-inline-size",
|
|
9227
|
+
"tier": "component",
|
|
9228
|
+
"value": "13rem"
|
|
9229
|
+
},
|
|
9230
|
+
{
|
|
9231
|
+
"description": "ORG CHART — boxes joined by lines, top-down (`src/components/data-display/org-chart.tsx`). Every length the chart paints is a knob (cardinal rule #45) and the defaults are the quiet reading (#44): a hairline connector in the border hue, a card-coloured box with the hairline edge every other surface here has. An `agent` box differs by its STROKE STYLE only (dashed), so a theme that retunes the edge colour retunes both kinds at once. ROLE-MIRROR KNOBS ARE `initial`, WITH THE DEFAULT AT THE CALL SITE (docs/TOKENS.md · \"Role-mirror knobs MUST be `initial`\"), so a scoped `[data-tenant]` / `.dark` override reaches them instead of freezing at `:root`.",
|
|
9232
|
+
"name": "--org-chart-node-padding-block",
|
|
9233
|
+
"tier": "component",
|
|
9234
|
+
"value": "var(--space-3)"
|
|
9235
|
+
},
|
|
9236
|
+
{
|
|
9237
|
+
"description": "ORG CHART — boxes joined by lines, top-down (`src/components/data-display/org-chart.tsx`). Every length the chart paints is a knob (cardinal rule #45) and the defaults are the quiet reading (#44): a hairline connector in the border hue, a card-coloured box with the hairline edge every other surface here has. An `agent` box differs by its STROKE STYLE only (dashed), so a theme that retunes the edge colour retunes both kinds at once. ROLE-MIRROR KNOBS ARE `initial`, WITH THE DEFAULT AT THE CALL SITE (docs/TOKENS.md · \"Role-mirror knobs MUST be `initial`\"), so a scoped `[data-tenant]` / `.dark` override reaches them instead of freezing at `:root`.",
|
|
9238
|
+
"name": "--org-chart-node-padding-inline",
|
|
9239
|
+
"tier": "component",
|
|
9240
|
+
"value": "var(--space-3)"
|
|
9241
|
+
},
|
|
9242
|
+
{
|
|
9243
|
+
"description": "ORG CHART — boxes joined by lines, top-down (`src/components/data-display/org-chart.tsx`). Every length the chart paints is a knob (cardinal rule #45) and the defaults are the quiet reading (#44): a hairline connector in the border hue, a card-coloured box with the hairline edge every other surface here has. An `agent` box differs by its STROKE STYLE only (dashed), so a theme that retunes the edge colour retunes both kinds at once. ROLE-MIRROR KNOBS ARE `initial`, WITH THE DEFAULT AT THE CALL SITE (docs/TOKENS.md · \"Role-mirror knobs MUST be `initial`\"), so a scoped `[data-tenant]` / `.dark` override reaches them instead of freezing at `:root`.",
|
|
9244
|
+
"name": "--org-chart-node-gap",
|
|
9245
|
+
"tier": "component",
|
|
9246
|
+
"value": "var(--space-3)"
|
|
9247
|
+
},
|
|
9248
|
+
{
|
|
9249
|
+
"description": "ORG CHART — boxes joined by lines, top-down (`src/components/data-display/org-chart.tsx`). Every length the chart paints is a knob (cardinal rule #45) and the defaults are the quiet reading (#44): a hairline connector in the border hue, a card-coloured box with the hairline edge every other surface here has. An `agent` box differs by its STROKE STYLE only (dashed), so a theme that retunes the edge colour retunes both kinds at once. ROLE-MIRROR KNOBS ARE `initial`, WITH THE DEFAULT AT THE CALL SITE (docs/TOKENS.md · \"Role-mirror knobs MUST be `initial`\"), so a scoped `[data-tenant]` / `.dark` override reaches them instead of freezing at `:root`.",
|
|
9250
|
+
"name": "--org-chart-node-text-gap",
|
|
9251
|
+
"tier": "component",
|
|
9252
|
+
"value": "var(--space-1)"
|
|
9253
|
+
},
|
|
9254
|
+
{
|
|
9255
|
+
"description": "gh#888 — φ tier freezes at :root; default = var(--radius)",
|
|
9256
|
+
"name": "--org-chart-node-radius",
|
|
9257
|
+
"tier": "component",
|
|
9258
|
+
"value": "initial"
|
|
9259
|
+
},
|
|
9260
|
+
{
|
|
9261
|
+
"description": "default = var(--stroke-hairline)",
|
|
9262
|
+
"name": "--org-chart-node-border-width",
|
|
9263
|
+
"tier": "component",
|
|
9264
|
+
"value": "initial"
|
|
9265
|
+
},
|
|
9266
|
+
{
|
|
9267
|
+
"description": "default = hsl(var(--border))",
|
|
9268
|
+
"name": "--org-chart-node-border-color",
|
|
9269
|
+
"tier": "component",
|
|
9270
|
+
"value": "initial"
|
|
9271
|
+
},
|
|
9272
|
+
{
|
|
9273
|
+
"description": "default = hsl(var(--card))",
|
|
9274
|
+
"name": "--org-chart-node-background",
|
|
9275
|
+
"tier": "component",
|
|
9276
|
+
"value": "initial"
|
|
9277
|
+
},
|
|
9278
|
+
{
|
|
9279
|
+
"description": "default = hsl(var(--card-foreground))",
|
|
9280
|
+
"name": "--org-chart-node-foreground",
|
|
9281
|
+
"tier": "component",
|
|
9282
|
+
"value": "initial"
|
|
9283
|
+
},
|
|
9284
|
+
{
|
|
9285
|
+
"description": "default = hsl(var(--muted-foreground))",
|
|
9286
|
+
"name": "--org-chart-node-title-color",
|
|
9287
|
+
"tier": "component",
|
|
9288
|
+
"value": "initial"
|
|
9289
|
+
},
|
|
9290
|
+
{
|
|
9291
|
+
"description": "ORG CHART — boxes joined by lines, top-down (`src/components/data-display/org-chart.tsx`). Every length the chart paints is a knob (cardinal rule #45) and the defaults are the quiet reading (#44): a hairline connector in the border hue, a card-coloured box with the hairline edge every other surface here has. An `agent` box differs by its STROKE STYLE only (dashed), so a theme that retunes the edge colour retunes both kinds at once. ROLE-MIRROR KNOBS ARE `initial`, WITH THE DEFAULT AT THE CALL SITE (docs/TOKENS.md · \"Role-mirror knobs MUST be `initial`\"), so a scoped `[data-tenant]` / `.dark` override reaches them instead of freezing at `:root`.",
|
|
9292
|
+
"name": "--org-chart-node-font-size",
|
|
9293
|
+
"tier": "component",
|
|
9294
|
+
"value": "var(--font-size-sm, var(--font-size-base))"
|
|
9295
|
+
},
|
|
9296
|
+
{
|
|
9297
|
+
"description": "The `agent` variant's stroke style. A dashed edge, not a second colour — the difference must survive greyscale, and the sr-only \"AI agent\" carries it for a screen reader.",
|
|
9298
|
+
"name": "--org-chart-agent-border-style",
|
|
9299
|
+
"tier": "component",
|
|
9300
|
+
"value": "dashed"
|
|
9301
|
+
},
|
|
9302
|
+
{
|
|
9303
|
+
"description": "Spacing of the tree itself: the vertical run between a parent and its children's row, and the gutter between two siblings. The connector is drawn inside these gaps, half above the bus and half below it.",
|
|
9304
|
+
"name": "--org-chart-level-gap",
|
|
9305
|
+
"tier": "component",
|
|
9306
|
+
"value": "var(--space-8)"
|
|
9307
|
+
},
|
|
9308
|
+
{
|
|
9309
|
+
"description": "ORG CHART — boxes joined by lines, top-down (`src/components/data-display/org-chart.tsx`). Every length the chart paints is a knob (cardinal rule #45) and the defaults are the quiet reading (#44): a hairline connector in the border hue, a card-coloured box with the hairline edge every other surface here has. An `agent` box differs by its STROKE STYLE only (dashed), so a theme that retunes the edge colour retunes both kinds at once. ROLE-MIRROR KNOBS ARE `initial`, WITH THE DEFAULT AT THE CALL SITE (docs/TOKENS.md · \"Role-mirror knobs MUST be `initial`\"), so a scoped `[data-tenant]` / `.dark` override reaches them instead of freezing at `:root`.",
|
|
9310
|
+
"name": "--org-chart-sibling-gap",
|
|
9311
|
+
"tier": "component",
|
|
9312
|
+
"value": "var(--space-4)"
|
|
9313
|
+
},
|
|
9314
|
+
{
|
|
9315
|
+
"description": "The connector. default = var(--stroke-hairline)",
|
|
9316
|
+
"name": "--org-chart-line-width",
|
|
9317
|
+
"tier": "component",
|
|
9318
|
+
"value": "initial"
|
|
9319
|
+
},
|
|
9320
|
+
{
|
|
9321
|
+
"description": "default = hsl(var(--border))",
|
|
9322
|
+
"name": "--org-chart-line-color",
|
|
9323
|
+
"tier": "component",
|
|
9324
|
+
"value": "initial"
|
|
9325
|
+
},
|
|
9326
|
+
{
|
|
9327
|
+
"description": "Room around the chart inside its scroll region, so an edge box's focus ring is not clipped.",
|
|
9328
|
+
"name": "--org-chart-padding",
|
|
9329
|
+
"tier": "component",
|
|
9330
|
+
"value": "var(--space-2)"
|
|
9331
|
+
},
|
|
9224
9332
|
{
|
|
9225
9333
|
"description": "`thin` reproduces the old 10px rail closely on the platforms that draw a classic scrollbar; `auto` gives the full-width platform bar, which is what a touch/coarse-pointer console wants. Only `auto | thin | none` are valid — a length is not (that is the standard property's whole bargain, and the reason `--scroll-area-bar-size` could not survive as a rem).",
|
|
9226
9334
|
"name": "--scroll-area-scrollbar-width",
|
|
@@ -12083,6 +12191,12 @@
|
|
|
12083
12191
|
"tier": "component",
|
|
12084
12192
|
"value": "initial"
|
|
12085
12193
|
},
|
|
12194
|
+
{
|
|
12195
|
+
"description": "Label of a node `filterTreeNode` matched (antd `.filter-node` title: primary colour, strong weight). A role mirror, so `initial` with the role at the call site. Documented default: --tree-node-filter-foreground = hsl(var(--text-brand, var(--primary))).",
|
|
12196
|
+
"name": "--tree-node-filter-foreground",
|
|
12197
|
+
"tier": "component",
|
|
12198
|
+
"value": "initial"
|
|
12199
|
+
},
|
|
12086
12200
|
{
|
|
12087
12201
|
"description": "Width of the indeterminate bar shown while `loadData` resolves a branch. A fraction, not a length: it has to read as \"part of a row\" at every row width and every density.",
|
|
12088
12202
|
"name": "--tree-loading-bar-inline-size",
|
|
@@ -1,15 +1,96 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
3
|
import * as React from "react";
|
|
4
|
+
import { Check, Copy, LoaderCircle } from "lucide-react";
|
|
5
|
+
import { useTranslation } from "../../i18n/use-translation.js";
|
|
3
6
|
import { cn } from "../../lib/utils.js";
|
|
4
|
-
|
|
7
|
+
import { Button } from "../general/button.js";
|
|
8
|
+
import {
|
|
9
|
+
ActionTooltip,
|
|
10
|
+
COPIED_RESET_MS,
|
|
11
|
+
getNode,
|
|
12
|
+
toCopyConfigList,
|
|
13
|
+
useMergedConfig,
|
|
14
|
+
writeClipboard
|
|
15
|
+
} from "../general/typography.js";
|
|
16
|
+
function CodeBlockCopy({
|
|
17
|
+
config,
|
|
18
|
+
codeRef
|
|
19
|
+
}) {
|
|
20
|
+
const { t } = useTranslation();
|
|
21
|
+
const [copied, setCopied] = React.useState(false);
|
|
22
|
+
const [copyLoading, setCopyLoading] = React.useState(false);
|
|
23
|
+
const copyTimer = React.useRef(null);
|
|
24
|
+
React.useEffect(
|
|
25
|
+
() => () => {
|
|
26
|
+
if (copyTimer.current) clearTimeout(copyTimer.current);
|
|
27
|
+
},
|
|
28
|
+
[]
|
|
29
|
+
);
|
|
30
|
+
const onCopyClick = async (event) => {
|
|
31
|
+
setCopyLoading(true);
|
|
32
|
+
try {
|
|
33
|
+
const configured = typeof config.text === "function" ? await config.text() : config.text;
|
|
34
|
+
await writeClipboard(configured || codeRef.current?.textContent || "", config.format);
|
|
35
|
+
setCopyLoading(false);
|
|
36
|
+
setCopied(true);
|
|
37
|
+
if (copyTimer.current) clearTimeout(copyTimer.current);
|
|
38
|
+
copyTimer.current = setTimeout(() => setCopied(false), COPIED_RESET_MS);
|
|
39
|
+
config.onCopy?.(event);
|
|
40
|
+
} catch {
|
|
41
|
+
setCopyLoading(false);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const copyLabels = toCopyConfigList(config.tooltips);
|
|
45
|
+
const copyIcons = toCopyConfigList(config.icon);
|
|
46
|
+
const systemCopyLabel = copied ? t("ui.codeBlock.copied") : t("ui.codeBlock.copy");
|
|
47
|
+
const copyTitle = getNode(copyLabels[copied ? 1 : 0], systemCopyLabel);
|
|
48
|
+
const copyAriaLabel = typeof copyTitle === "string" ? copyTitle : systemCopyLabel;
|
|
49
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
50
|
+
/* @__PURE__ */ jsx(ActionTooltip, { title: copyTitle, children: /* @__PURE__ */ jsx(
|
|
51
|
+
Button,
|
|
52
|
+
{
|
|
53
|
+
type: "button",
|
|
54
|
+
variant: "ghost",
|
|
55
|
+
size: "icon-xs",
|
|
56
|
+
"data-slot": "code-block-copy",
|
|
57
|
+
"data-state": copied ? "copied" : "idle",
|
|
58
|
+
"aria-label": copyAriaLabel,
|
|
59
|
+
tabIndex: config.tabIndex,
|
|
60
|
+
onClick: onCopyClick,
|
|
61
|
+
className: "ui-code-block-copy",
|
|
62
|
+
children: copied ? getNode(copyIcons[1], /* @__PURE__ */ jsx(Check, { "aria-hidden": "true" }), true) : getNode(
|
|
63
|
+
copyIcons[0],
|
|
64
|
+
copyLoading ? /* @__PURE__ */ jsx(LoaderCircle, { "aria-hidden": "true" }) : /* @__PURE__ */ jsx(Copy, { "aria-hidden": "true" }),
|
|
65
|
+
true
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
) }),
|
|
69
|
+
/* @__PURE__ */ jsx("span", { "aria-live": "polite", className: "sr-only", "data-slot": "code-block-status", children: copied ? t("ui.codeBlock.copiedAnnounce") : "" })
|
|
70
|
+
] });
|
|
71
|
+
}
|
|
72
|
+
const CodeBlock = React.forwardRef(function CodeBlock2({
|
|
73
|
+
children,
|
|
74
|
+
wrap = true,
|
|
75
|
+
maxHeight = "none",
|
|
76
|
+
size = "sm",
|
|
77
|
+
language,
|
|
78
|
+
copyable,
|
|
79
|
+
className,
|
|
80
|
+
style,
|
|
81
|
+
...rest
|
|
82
|
+
}, ref) {
|
|
83
|
+
const [enableCopy, copyConfig] = useMergedConfig(copyable);
|
|
84
|
+
const codeRef = React.useRef(null);
|
|
5
85
|
const scrolls = maxHeight !== "none" || !wrap;
|
|
6
|
-
|
|
86
|
+
const pre = /* @__PURE__ */ jsx(
|
|
7
87
|
"pre",
|
|
8
88
|
{
|
|
9
89
|
ref,
|
|
10
90
|
"data-slot": "code-block",
|
|
11
91
|
"data-wrap": wrap ? void 0 : "false",
|
|
12
92
|
"data-max-height": typeof maxHeight === "string" && maxHeight !== "none" ? maxHeight : void 0,
|
|
93
|
+
"data-copyable": enableCopy ? "" : void 0,
|
|
13
94
|
style: {
|
|
14
95
|
...style,
|
|
15
96
|
...typeof maxHeight === "object" ? { maxBlockSize: maxHeight.value, overflow: "auto" } : void 0
|
|
@@ -19,9 +100,14 @@ const CodeBlock = React.forwardRef(function CodeBlock2({ children, wrap = true,
|
|
|
19
100
|
tabIndex: scrolls ? 0 : void 0,
|
|
20
101
|
className: cn("ui-code-block", className),
|
|
21
102
|
...rest,
|
|
22
|
-
children: /* @__PURE__ */ jsx("code", { children })
|
|
103
|
+
children: /* @__PURE__ */ jsx("code", { ref: codeRef, children })
|
|
23
104
|
}
|
|
24
105
|
);
|
|
106
|
+
if (!enableCopy) return pre;
|
|
107
|
+
return /* @__PURE__ */ jsxs("div", { "data-slot": "code-block-frame", className: "ui-code-block-frame", children: [
|
|
108
|
+
pre,
|
|
109
|
+
/* @__PURE__ */ jsx(CodeBlockCopy, { config: copyConfig, codeRef })
|
|
110
|
+
] });
|
|
25
111
|
});
|
|
26
112
|
export {
|
|
27
113
|
CodeBlock
|
|
@@ -175,6 +175,9 @@ export declare namespace DataTable {
|
|
|
175
175
|
label?: React.ReactNode;
|
|
176
176
|
}) => React.JSX.Element | null;
|
|
177
177
|
export var SelectAll: () => React.JSX.Element | null;
|
|
178
|
+
export var SELECTION_ALL: "SELECT_ALL";
|
|
179
|
+
export var SELECTION_INVERT: "SELECT_INVERT";
|
|
180
|
+
export var SELECTION_NONE: "SELECT_NONE";
|
|
178
181
|
export var BulkActions: ({ count, children, className, }: BulkActionsProps) => React.JSX.Element | null;
|
|
179
182
|
export var DensityToggle: () => React.JSX.Element;
|
|
180
183
|
export var Content: () => React.JSX.Element;
|