@godxjp/ui 18.9.0 → 18.10.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/LICENSE +202 -0
- package/dist/components/data-display/badge.d.ts +7 -0
- package/dist/components/data-display/badge.js +1 -1
- package/dist/components/data-display/card.d.ts +3 -27
- package/dist/components/data-display/card.js +1 -4
- package/dist/components/data-display/data-table.js +5 -4
- package/dist/components/data-display/index.d.ts +2 -0
- package/dist/components/data-display/index.js +2 -0
- package/dist/components/data-display/permission-matrix.d.ts +26 -0
- package/dist/components/data-display/permission-matrix.js +219 -0
- package/dist/components/data-display/table.d.ts +12 -0
- package/dist/components/data-entry/branch-scope-picker.d.ts +43 -0
- package/dist/components/data-entry/branch-scope-picker.js +200 -0
- package/dist/components/data-entry/command-palette.d.ts +1 -42
- package/dist/components/data-entry/command-palette.js +2 -31
- package/dist/components/data-entry/index.d.ts +2 -0
- package/dist/components/data-entry/index.js +2 -0
- package/dist/components/data-entry/input-otp.d.ts +1 -1
- package/dist/components/feedback/alert.d.ts +2 -20
- package/dist/components/feedback/alert.js +1 -11
- package/dist/components/feedback/banner.d.ts +21 -0
- package/dist/components/feedback/banner.js +15 -0
- package/dist/components/feedback/index.d.ts +4 -2
- package/dist/components/feedback/index.js +2 -2
- package/dist/components/general/typography.d.ts +1 -0
- package/dist/components/general/typography.js +32 -13
- package/dist/components/layout/auth-shell.d.ts +2 -2
- package/dist/components/layout/index.d.ts +2 -2
- package/dist/components/layout/index.js +2 -2
- package/dist/components/layout/page-container.d.ts +1 -1
- package/dist/components/layout/page-container.js +45 -19
- package/dist/components/layout/service-role-panel.d.ts +25 -0
- package/dist/components/layout/service-role-panel.js +206 -0
- package/dist/components/navigation/filter-bar.d.ts +2 -2
- package/dist/components/navigation/filter-bar.js +113 -34
- package/dist/components/navigation/index.d.ts +1 -1
- package/dist/components/navigation/steps.d.ts +2 -2
- package/dist/components/navigation/steps.js +2 -4
- package/dist/components/ui/avatar.d.ts +1 -1
- package/dist/components/ui/avatar.js +1 -2
- package/dist/components/ui/input-otp.d.ts +3 -15
- package/dist/components/ui/input-otp.js +1 -2
- package/dist/email/tokens.generated.d.ts +2 -2
- package/dist/email/tokens.generated.js +2 -2
- package/dist/i18n/messages/en.json +56 -4
- package/dist/i18n/messages/ja.json +51 -5
- package/dist/i18n/messages/vi.json +50 -4
- package/dist/props/components/data-display.prop.d.ts +66 -16
- package/dist/props/components/data-entry.prop.d.ts +54 -7
- package/dist/props/components/feedback.prop.d.ts +3 -3
- package/dist/props/components/general.prop.d.ts +8 -1
- package/dist/props/components/layout.prop.d.ts +75 -54
- package/dist/props/components/navigation.prop.d.ts +77 -59
- package/dist/props/registry.d.ts +274 -73
- package/dist/props/registry.js +362 -93
- package/dist/props/vocabulary/content.prop.d.ts +5 -0
- package/dist/props/vocabulary/index.d.ts +1 -1
- package/dist/props/vocabulary/interaction.prop.d.ts +4 -7
- package/dist/props/vocabulary/layout.prop.d.ts +2 -2
- package/dist/styles/alert-layout.css +15 -32
- package/dist/styles/badge-layout.css +5 -0
- package/dist/styles/base.css +0 -28
- package/dist/styles/card-layout.css +13 -49
- package/dist/styles/control.css +2 -12
- package/dist/styles/data-display-layout.css +0 -16
- package/dist/styles/layout.css +102 -108
- package/dist/styles/navigation-layout.css +3 -8
- package/dist/styles/shell-layout.css +17 -17
- package/dist/styles/table-layout.css +77 -29
- package/dist/styles/text-layout.css +13 -0
- package/dist/tokens/base.css +1 -0
- package/dist/tokens/components/badge.css +5 -0
- package/dist/tokens/components/banner.css +16 -0
- package/dist/tokens/components/card.css +0 -12
- package/dist/tokens/components/control.css +0 -16
- package/dist/tokens/components/data-display.css +0 -12
- package/dist/tokens/components/email.css +2 -8
- package/dist/tokens/components/feedback.css +0 -20
- package/dist/tokens/components/navigation.css +10 -34
- package/dist/tokens/components/shell.css +24 -36
- package/dist/tokens/components/table.css +41 -22
- package/dist/tokens/semantic/layout.css +5 -12
- package/package.json +15 -2
- package/dist/components/layout/page-header.d.ts +0 -22
- package/dist/components/layout/page-header.js +0 -89
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -8,6 +8,13 @@ export type BadgeVariant = "default" | "secondary" | "outline" | "dashed";
|
|
|
8
8
|
* for a SOLID brand fill use `variant="default"`.
|
|
9
9
|
*/
|
|
10
10
|
export type BadgeTone = ToneProp | "primary";
|
|
11
|
+
/**
|
|
12
|
+
* NO `text-xs` here (gh#260): a font-size utility lands in `@layer utilities`, which always beats
|
|
13
|
+
* the `@layer components` rule in badge-layout.css — making the documented `--badge-font-size`
|
|
14
|
+
* knob structurally inert. Font-size (and the line-height `text-xs` used to carry) are owned by
|
|
15
|
+
* badge-layout.css via `--badge-font-size` / `--badge-line-height`, whose defaults reproduce the
|
|
16
|
+
* old `text-xs` rendering exactly.
|
|
17
|
+
*/
|
|
11
18
|
declare const badgeVariants: (props?: ({
|
|
12
19
|
variant?: "default" | "outline" | "dashed" | "secondary" | null | undefined;
|
|
13
20
|
shape?: "default" | "pill" | "sharp" | null | undefined;
|
|
@@ -50,7 +50,7 @@ const STATUS_MAP = {
|
|
|
50
50
|
ASSIGNMENT_STATUS_TERMINATED: { tone: "destructive", icon: XCircle }
|
|
51
51
|
};
|
|
52
52
|
const badgeVariants = cva(
|
|
53
|
-
"inline-flex items-center border
|
|
53
|
+
"inline-flex items-center border font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-ring",
|
|
54
54
|
{
|
|
55
55
|
variants: {
|
|
56
56
|
variant: {
|
|
@@ -3,21 +3,9 @@ import { type VariantProps } from "class-variance-authority";
|
|
|
3
3
|
import type { LucideIcon } from "lucide-react";
|
|
4
4
|
import type { HeadingLevelProp } from "../../props/vocabulary/index.js";
|
|
5
5
|
type CardSize = "md" | "compact";
|
|
6
|
-
/** Semantic accent
|
|
7
|
-
*
|
|
6
|
+
/** Semantic leading-edge accent stripe (border-inline-start; width via the
|
|
7
|
+
* --card-accent-rail-width token, default 6px). */
|
|
8
8
|
type CardAccent = "primary" | "success" | "warning" | "info" | "attention" | "destructive";
|
|
9
|
-
/**
|
|
10
|
-
* Where the semantic `accent` tone is drawn.
|
|
11
|
-
*
|
|
12
|
-
* - `"edge"` (default) — the leading-edge stripe on `border-inline-start` only, at the
|
|
13
|
-
* `--card-accent-rail-width` measure (6px). The classic "this row needs a look" rail.
|
|
14
|
-
* - `"perimeter"` — a full attention border around the WHOLE card in the same semantic
|
|
15
|
-
* tone, measured by `--card-accent-perimeter-width` + `--card-accent-perimeter-ring-width`.
|
|
16
|
-
* This is what `variant="featured"` does, except the tone is yours instead of `--primary`,
|
|
17
|
-
* so a card can shout "action required" (`accent="attention"`) or "this failed"
|
|
18
|
-
* (`accent="destructive"`) without borrowing the brand colour.
|
|
19
|
-
*/
|
|
20
|
-
type CardAccentPlacement = "edge" | "perimeter";
|
|
21
9
|
/** Surface fill — plain card, muted band, borderless outline, or emphasized featured ring. */
|
|
22
10
|
type CardVariant = "default" | "muted" | "outline" | "featured";
|
|
23
11
|
/** Padding density — base 16px · tight 12px · cozy 20px. */
|
|
@@ -28,11 +16,6 @@ declare const cardVariants: (props?: ({
|
|
|
28
16
|
export type CardProps = React.HTMLAttributes<HTMLDivElement> & VariantProps<typeof cardVariants> & {
|
|
29
17
|
size?: CardSize;
|
|
30
18
|
accent?: CardAccent;
|
|
31
|
-
/**
|
|
32
|
-
* Where `accent` is drawn — `"edge"` (default, the leading-edge stripe) or `"perimeter"`
|
|
33
|
-
* (a full attention border in the accent tone). Inert without `accent`.
|
|
34
|
-
*/
|
|
35
|
-
accentPlacement?: CardAccentPlacement;
|
|
36
19
|
variant?: CardVariant;
|
|
37
20
|
density?: CardDensity;
|
|
38
21
|
};
|
|
@@ -41,11 +24,6 @@ export declare const Card: React.ForwardRefExoticComponent<React.HTMLAttributes<
|
|
|
41
24
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string> & {
|
|
42
25
|
size?: CardSize;
|
|
43
26
|
accent?: CardAccent;
|
|
44
|
-
/**
|
|
45
|
-
* Where `accent` is drawn — `"edge"` (default, the leading-edge stripe) or `"perimeter"`
|
|
46
|
-
* (a full attention border in the accent tone). Inert without `accent`.
|
|
47
|
-
*/
|
|
48
|
-
accentPlacement?: CardAccentPlacement;
|
|
49
27
|
variant?: CardVariant;
|
|
50
28
|
density?: CardDensity;
|
|
51
29
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -158,11 +136,9 @@ export type StatCardProps = React.HTMLAttributes<HTMLDivElement> & VariantProps<
|
|
|
158
136
|
inverse?: boolean;
|
|
159
137
|
/** Semantic leading-edge rail (Card accent) — flags a KPI needing attention. */
|
|
160
138
|
accent?: CardAccent;
|
|
161
|
-
/** Where `accent` is drawn — `"edge"` (default rail) or `"perimeter"` (full attention border). */
|
|
162
|
-
accentPlacement?: CardAccentPlacement;
|
|
163
139
|
};
|
|
164
140
|
/** KPI / stat tile — token-driven layout aligned to dashboard KPI cards. */
|
|
165
|
-
export declare function StatCard({ label, value, hint, icon: Icon, delta, layout, align, inverse, accent,
|
|
141
|
+
export declare function StatCard({ label, value, hint, icon: Icon, delta, layout, align, inverse, accent, className, size, ...props }: StatCardProps): React.JSX.Element;
|
|
166
142
|
/** Header actions slot — pair with `CardHeader className="flex flex-row …"`. */
|
|
167
143
|
export declare const CardAction: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
168
144
|
export {};
|
|
@@ -12,7 +12,7 @@ const cardVariants = cva("group/card", {
|
|
|
12
12
|
defaultVariants: { size: "md" }
|
|
13
13
|
});
|
|
14
14
|
const Card = React.forwardRef(
|
|
15
|
-
({ className, size = "md", accent,
|
|
15
|
+
({ className, size = "md", accent, variant, density, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
16
16
|
"div",
|
|
17
17
|
{
|
|
18
18
|
ref,
|
|
@@ -20,7 +20,6 @@ const Card = React.forwardRef(
|
|
|
20
20
|
"data-slot": "card",
|
|
21
21
|
"data-size": size === "compact" ? "compact" : void 0,
|
|
22
22
|
"data-accent": accent,
|
|
23
|
-
"data-accent-placement": accentPlacement === "perimeter" ? "perimeter" : void 0,
|
|
24
23
|
"data-variant": variant && variant !== "default" ? variant : void 0,
|
|
25
24
|
"data-density": density,
|
|
26
25
|
...props
|
|
@@ -109,7 +108,6 @@ function StatCard({
|
|
|
109
108
|
align = "start",
|
|
110
109
|
inverse = false,
|
|
111
110
|
accent,
|
|
112
|
-
accentPlacement,
|
|
113
111
|
className,
|
|
114
112
|
size = "compact",
|
|
115
113
|
...props
|
|
@@ -120,7 +118,6 @@ function StatCard({
|
|
|
120
118
|
{
|
|
121
119
|
size: size ?? "compact",
|
|
122
120
|
accent,
|
|
123
|
-
accentPlacement,
|
|
124
121
|
className: cn("ui-stat-card", className),
|
|
125
122
|
"data-stat-card": "",
|
|
126
123
|
"data-stat-layout": layout,
|
|
@@ -442,7 +442,7 @@ DataTable.Content = function DataTableContent() {
|
|
|
442
442
|
{
|
|
443
443
|
className: cn("ui-data-table-scroll", hasPinEnd && "ui-data-table-has-pin-end"),
|
|
444
444
|
"aria-busy": loading,
|
|
445
|
-
tabIndex: 0,
|
|
445
|
+
tabIndex: presetAttr ? void 0 : 0,
|
|
446
446
|
children: /* @__PURE__ */ jsx(
|
|
447
447
|
"div",
|
|
448
448
|
{
|
|
@@ -450,7 +450,7 @@ DataTable.Content = function DataTableContent() {
|
|
|
450
450
|
"data-preset": presetAttr,
|
|
451
451
|
"data-striped": striped ? "" : void 0,
|
|
452
452
|
"data-hoverable": hoverable ? "" : void 0,
|
|
453
|
-
children: /* @__PURE__ */ jsxs(Table, { scrollable:
|
|
453
|
+
children: /* @__PURE__ */ jsxs(Table, { scrollable: preset !== "default", preset, collapseBelow, children: [
|
|
454
454
|
/* @__PURE__ */ jsx(TableHeader, { className: cn("bg-secondary", stickyHeader && "sticky top-0 z-10"), children: /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
455
455
|
selectable && /* @__PURE__ */ jsx(TableHead, { className: "w-10", children: /* @__PURE__ */ jsx(DataTable.SelectAll, {}) }),
|
|
456
456
|
visibleColumns.map((col) => {
|
|
@@ -636,8 +636,9 @@ DataTable.Content = function DataTableContent() {
|
|
|
636
636
|
),
|
|
637
637
|
children: col.render ? col.render(original) : (() => {
|
|
638
638
|
const v = original[col.key];
|
|
639
|
-
|
|
640
|
-
|
|
639
|
+
if (v == null) return "\u2014";
|
|
640
|
+
if (typeof v === "string" || typeof v === "number") return String(v);
|
|
641
|
+
return "\u2014";
|
|
641
642
|
})()
|
|
642
643
|
},
|
|
643
644
|
col.key
|
|
@@ -31,3 +31,5 @@ export { Accordion, AccordionItem, AccordionTrigger, AccordionContent } from "./
|
|
|
31
31
|
export { HoverCard, HoverCardTrigger, HoverCardContent } from "./hover-card.js";
|
|
32
32
|
export { Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, CarouselDots, useCarousel, } from "./carousel.js";
|
|
33
33
|
export type { CarouselApi } from "./carousel.js";
|
|
34
|
+
export { PermissionMatrix } from "./permission-matrix.js";
|
|
35
|
+
export type { PermissionMatrixGrantsProp, PermissionMatrixPermissionProp, PermissionMatrixProp, PermissionMatrixProps, PermissionMatrixRoleProp, } from "./permission-matrix.js";
|
|
@@ -49,6 +49,7 @@ import {
|
|
|
49
49
|
CarouselDots,
|
|
50
50
|
useCarousel
|
|
51
51
|
} from "./carousel.js";
|
|
52
|
+
import { PermissionMatrix } from "./permission-matrix.js";
|
|
52
53
|
export {
|
|
53
54
|
Accordion,
|
|
54
55
|
AccordionContent,
|
|
@@ -84,6 +85,7 @@ export {
|
|
|
84
85
|
HoverCardContent,
|
|
85
86
|
HoverCardTrigger,
|
|
86
87
|
ListRow,
|
|
88
|
+
PermissionMatrix,
|
|
87
89
|
Popover,
|
|
88
90
|
PopoverAnchor,
|
|
89
91
|
PopoverContent,
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { PermissionMatrixProp } from "../../props/components/data-display.prop.js";
|
|
3
|
+
export type { PermissionMatrixGrantsProp, PermissionMatrixPermissionProp, PermissionMatrixProp, PermissionMatrixProp as PermissionMatrixProps, PermissionMatrixRoleProp, } from "../../props/components/data-display.prop.js";
|
|
4
|
+
/**
|
|
5
|
+
* PermissionMatrix — the canonical role × permission grid (gh#257 / DXS platform#311).
|
|
6
|
+
*
|
|
7
|
+
* Formalizes the `docs/showcase/permission-matrix` composition as a PACKAGE-OWNED export, for the
|
|
8
|
+
* same reason `ErrorSurface` became one (gh#251): a consumer cannot import a docs page, and every
|
|
9
|
+
* RBAC admin was about to re-derive the same sticky-column grid, ✓/— cell semantics and lifecycle
|
|
10
|
+
* states. The matrix stays THIN: all data logic lives in the already-tested
|
|
11
|
+
* `@godxjp/ui/lib/permission-grid` helpers, the table is the real Table family, and the states are
|
|
12
|
+
* the DataTable #216 vocabulary (`loading` → `denied` → `error` → `empty`, same precedence).
|
|
13
|
+
*
|
|
14
|
+
* - **Read-only by default.** Without `onGrantChange` (or with `readOnly`) cells are shape-encoded
|
|
15
|
+
* ✓/— (icon + `sr-only` text, never colour alone). With `onGrantChange` the cells become real
|
|
16
|
+
* `Checkbox` controls — except for roles marked `locked`, which keep the read-only cell and a
|
|
17
|
+
* lock badge.
|
|
18
|
+
* - **Compare mode** (`compare` + `diffOnly`) reuses `lib/permission-grid` verbatim: compared
|
|
19
|
+
* columns are tinted, differing rows carry a localized 差分 badge.
|
|
20
|
+
* - **Domain-neutral**: roles, permissions and grants all arrive via props; nothing about the
|
|
21
|
+
* consuming platform is encoded.
|
|
22
|
+
* - **Responsive**: the grid scrolls horizontally inside its own container below its natural
|
|
23
|
+
* measure (390px shows the sticky permission column + scrollable role columns); 1024/1440 render
|
|
24
|
+
* the full grid.
|
|
25
|
+
*/
|
|
26
|
+
export declare const PermissionMatrix: React.ForwardRefExoticComponent<PermissionMatrixProp & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { AlertCircle, Check, Lock, Minus, RefreshCw, ShieldAlert } from "lucide-react";
|
|
5
|
+
import { useTranslation } from "../../i18n/use-translation.js";
|
|
6
|
+
import {
|
|
7
|
+
grantKey,
|
|
8
|
+
hasGrant,
|
|
9
|
+
rolesDifferOnPermission,
|
|
10
|
+
visibleRows
|
|
11
|
+
} from "../../lib/permission-grid.js";
|
|
12
|
+
import { cn } from "../../lib/utils.js";
|
|
13
|
+
import { Checkbox } from "../data-entry/checkbox.js";
|
|
14
|
+
import { SkeletonTable } from "../feedback/skeleton.js";
|
|
15
|
+
import { Button } from "../general/button.js";
|
|
16
|
+
import { Text } from "../general/typography.js";
|
|
17
|
+
import { Badge } from "./badge.js";
|
|
18
|
+
import { EmptyState } from "./empty-state.js";
|
|
19
|
+
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "./table.js";
|
|
20
|
+
function toGrantSet(grants) {
|
|
21
|
+
if (grants instanceof Set) return grants;
|
|
22
|
+
return new Set(
|
|
23
|
+
grants.map(
|
|
24
|
+
(pair) => grantKey(pair.roleId, pair.permissionId)
|
|
25
|
+
)
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
const PIN_START = "sticky start-0 z-20 bg-inherit border-e border-border";
|
|
29
|
+
const PermissionMatrix = React.forwardRef(
|
|
30
|
+
function PermissionMatrix2({
|
|
31
|
+
roles,
|
|
32
|
+
permissions,
|
|
33
|
+
grants,
|
|
34
|
+
onGrantChange,
|
|
35
|
+
readOnly = false,
|
|
36
|
+
compare = null,
|
|
37
|
+
diffOnly = false,
|
|
38
|
+
label,
|
|
39
|
+
loading = false,
|
|
40
|
+
empty,
|
|
41
|
+
error,
|
|
42
|
+
denied,
|
|
43
|
+
onRetry,
|
|
44
|
+
className,
|
|
45
|
+
id
|
|
46
|
+
}, ref) {
|
|
47
|
+
const { t } = useTranslation();
|
|
48
|
+
const grantSet = React.useMemo(() => toGrantSet(grants), [grants]);
|
|
49
|
+
const compareA = compare?.[0];
|
|
50
|
+
const compareB = compare?.[1];
|
|
51
|
+
const comparePair = React.useMemo(
|
|
52
|
+
() => compareA === void 0 || compareB === void 0 || compareA === compareB ? null : [compareA, compareB],
|
|
53
|
+
[compareA, compareB]
|
|
54
|
+
);
|
|
55
|
+
const compared = React.useMemo(() => new Set(comparePair ?? []), [comparePair]);
|
|
56
|
+
const rows = React.useMemo(
|
|
57
|
+
() => visibleRows(permissions, grantSet, {
|
|
58
|
+
compare: comparePair,
|
|
59
|
+
diffOnly: diffOnly && comparePair !== null
|
|
60
|
+
}),
|
|
61
|
+
[permissions, grantSet, comparePair, diffOnly]
|
|
62
|
+
);
|
|
63
|
+
const editable = typeof onGrantChange === "function" && !readOnly;
|
|
64
|
+
const isDenied = denied !== void 0 && denied !== null && denied !== false;
|
|
65
|
+
const isError = error !== void 0 && error !== null && error !== false;
|
|
66
|
+
const stateSurface = (state) => /* @__PURE__ */ jsx(
|
|
67
|
+
"div",
|
|
68
|
+
{
|
|
69
|
+
ref,
|
|
70
|
+
id,
|
|
71
|
+
"data-slot": "permission-matrix",
|
|
72
|
+
className: cn("ui-permission-matrix", className),
|
|
73
|
+
children: state
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
if (loading) {
|
|
77
|
+
return stateSurface(
|
|
78
|
+
/* @__PURE__ */ jsx("div", { "aria-busy": "true", "aria-label": t("dataDisplay.permissionMatrix.loading"), role: "status", children: /* @__PURE__ */ jsx(SkeletonTable, { rows: 6, columns: Math.max(2, roles.length + 1) }) })
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
if (isDenied) {
|
|
82
|
+
return stateSurface(
|
|
83
|
+
/* @__PURE__ */ jsx("div", { "aria-live": "polite", children: denied === true ? /* @__PURE__ */ jsx(
|
|
84
|
+
EmptyState,
|
|
85
|
+
{
|
|
86
|
+
icon: ShieldAlert,
|
|
87
|
+
tone: "warning",
|
|
88
|
+
variant: "section",
|
|
89
|
+
title: t("dataDisplay.permissionMatrix.denied"),
|
|
90
|
+
description: t("dataDisplay.permissionMatrix.deniedDescription"),
|
|
91
|
+
titleAs: "p"
|
|
92
|
+
}
|
|
93
|
+
) : denied })
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
if (isError) {
|
|
97
|
+
return stateSurface(
|
|
98
|
+
/* @__PURE__ */ jsx("div", { role: "alert", children: error === true ? /* @__PURE__ */ jsx(
|
|
99
|
+
EmptyState,
|
|
100
|
+
{
|
|
101
|
+
icon: AlertCircle,
|
|
102
|
+
tone: "destructive",
|
|
103
|
+
variant: "section",
|
|
104
|
+
title: t("dataDisplay.permissionMatrix.error"),
|
|
105
|
+
description: t("dataDisplay.permissionMatrix.errorDescription"),
|
|
106
|
+
titleAs: "p",
|
|
107
|
+
action: onRetry ? /* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", onClick: onRetry, children: [
|
|
108
|
+
/* @__PURE__ */ jsx(RefreshCw, { "aria-hidden": "true" }),
|
|
109
|
+
t("common.retry")
|
|
110
|
+
] }) : void 0
|
|
111
|
+
}
|
|
112
|
+
) : error })
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
if (permissions.length === 0) {
|
|
116
|
+
return stateSurface(
|
|
117
|
+
/* @__PURE__ */ jsx("div", { "aria-live": "polite", children: empty ?? /* @__PURE__ */ jsx(
|
|
118
|
+
EmptyState,
|
|
119
|
+
{
|
|
120
|
+
variant: "section",
|
|
121
|
+
title: t("dataDisplay.permissionMatrix.empty"),
|
|
122
|
+
titleAs: "p"
|
|
123
|
+
}
|
|
124
|
+
) })
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
const accessibleName = typeof label === "string" ? label : t("dataDisplay.permissionMatrix.caption");
|
|
128
|
+
return /* @__PURE__ */ jsx(
|
|
129
|
+
"div",
|
|
130
|
+
{
|
|
131
|
+
ref,
|
|
132
|
+
id,
|
|
133
|
+
"data-slot": "permission-matrix",
|
|
134
|
+
"data-editable": editable || void 0,
|
|
135
|
+
className: cn("ui-permission-matrix overflow-x-auto", className),
|
|
136
|
+
children: /* @__PURE__ */ jsxs(Table, { className: "min-w-[48rem]", "aria-label": accessibleName, children: [
|
|
137
|
+
/* @__PURE__ */ jsx(TableHeader, { className: "bg-secondary [&_tr]:bg-secondary", children: /* @__PURE__ */ jsxs(TableRow, { className: "bg-secondary hover:bg-secondary", children: [
|
|
138
|
+
/* @__PURE__ */ jsx(TableHead, { className: cn(PIN_START, "w-64 min-w-64"), children: t("dataDisplay.permissionMatrix.permissionColumn") }),
|
|
139
|
+
roles.map((role) => {
|
|
140
|
+
const isCompared = compared.has(role.id);
|
|
141
|
+
return /* @__PURE__ */ jsx(
|
|
142
|
+
TableHead,
|
|
143
|
+
{
|
|
144
|
+
className: cn("text-center", isCompared && "bg-primary/[0.06]"),
|
|
145
|
+
children: /* @__PURE__ */ jsxs("span", { className: "inline-flex flex-col items-center leading-tight", children: [
|
|
146
|
+
/* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1", children: [
|
|
147
|
+
/* @__PURE__ */ jsx(Text, { weight: "medium", children: role.name }),
|
|
148
|
+
role.locked && /* @__PURE__ */ jsxs(Badge, { tone: "default", variant: "outline", children: [
|
|
149
|
+
/* @__PURE__ */ jsx(Lock, { "aria-hidden": "true" }),
|
|
150
|
+
t("dataDisplay.permissionMatrix.locked")
|
|
151
|
+
] })
|
|
152
|
+
] }),
|
|
153
|
+
role.description !== void 0 && /* @__PURE__ */ jsx(Text, { size: "2xs", tone: "muted", children: role.description })
|
|
154
|
+
] })
|
|
155
|
+
},
|
|
156
|
+
role.id
|
|
157
|
+
);
|
|
158
|
+
})
|
|
159
|
+
] }) }),
|
|
160
|
+
/* @__PURE__ */ jsx(TableBody, { children: rows.map((permission) => {
|
|
161
|
+
const isDiffRow = comparePair !== null && rolesDifferOnPermission(grantSet, comparePair, permission.id);
|
|
162
|
+
return /* @__PURE__ */ jsxs(
|
|
163
|
+
TableRow,
|
|
164
|
+
{
|
|
165
|
+
className: cn(isDiffRow && "bg-warning/[0.07] hover:bg-warning/10"),
|
|
166
|
+
children: [
|
|
167
|
+
/* @__PURE__ */ jsx(TableCell, { className: cn(PIN_START, "w-64 min-w-64 align-middle"), children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col leading-tight", children: [
|
|
168
|
+
/* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1.5", children: [
|
|
169
|
+
/* @__PURE__ */ jsx(Text, { weight: "medium", children: permission.name }),
|
|
170
|
+
isDiffRow && /* @__PURE__ */ jsx(Badge, { tone: "warning", variant: "outline", children: t("dataDisplay.permissionMatrix.difference") })
|
|
171
|
+
] }),
|
|
172
|
+
(permission.group !== void 0 || permission.description !== void 0) && /* @__PURE__ */ jsx(Text, { size: "2xs", tone: "muted", children: [permission.group, permission.description].filter((part) => part !== void 0).join(" \xB7 ") })
|
|
173
|
+
] }) }),
|
|
174
|
+
roles.map((role) => {
|
|
175
|
+
const granted = hasGrant(grantSet, role.id, permission.id);
|
|
176
|
+
const isCompared = compared.has(role.id);
|
|
177
|
+
const cellEditable = editable && !role.locked;
|
|
178
|
+
return /* @__PURE__ */ jsx(
|
|
179
|
+
TableCell,
|
|
180
|
+
{
|
|
181
|
+
className: cn(
|
|
182
|
+
"text-center align-middle",
|
|
183
|
+
isCompared && "bg-primary/[0.04]"
|
|
184
|
+
),
|
|
185
|
+
children: cellEditable ? /* @__PURE__ */ jsx(
|
|
186
|
+
Checkbox,
|
|
187
|
+
{
|
|
188
|
+
checked: granted,
|
|
189
|
+
onCheckedChange: (next) => onGrantChange?.(role.id, permission.id, next === true),
|
|
190
|
+
"aria-label": t("dataDisplay.permissionMatrix.toggle", {
|
|
191
|
+
role: role.name,
|
|
192
|
+
permission: permission.name
|
|
193
|
+
})
|
|
194
|
+
}
|
|
195
|
+
) : granted ? /* @__PURE__ */ jsxs(Badge, { tone: "success", variant: "outline", className: "justify-center", children: [
|
|
196
|
+
/* @__PURE__ */ jsx(Check, { "aria-hidden": "true" }),
|
|
197
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: t("dataDisplay.permissionMatrix.granted") })
|
|
198
|
+
] }) : /* @__PURE__ */ jsxs("span", { className: "text-muted-foreground inline-flex items-center justify-center", children: [
|
|
199
|
+
/* @__PURE__ */ jsx(Minus, { "aria-hidden": "true", className: "size-4" }),
|
|
200
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: t("dataDisplay.permissionMatrix.notGranted") })
|
|
201
|
+
] })
|
|
202
|
+
},
|
|
203
|
+
role.id
|
|
204
|
+
);
|
|
205
|
+
})
|
|
206
|
+
]
|
|
207
|
+
},
|
|
208
|
+
permission.id
|
|
209
|
+
);
|
|
210
|
+
}) })
|
|
211
|
+
] })
|
|
212
|
+
}
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
);
|
|
216
|
+
PermissionMatrix.displayName = "PermissionMatrix";
|
|
217
|
+
export {
|
|
218
|
+
PermissionMatrix
|
|
219
|
+
};
|
|
@@ -18,6 +18,12 @@ export type TableProps = React.HTMLAttributes<HTMLTableElement> & {
|
|
|
18
18
|
* of forcing a horizontal scroll. Mark each column with `priority` on its `TableHead`/`TableCell`.
|
|
19
19
|
* The table keeps its real semantics: no `display` change, no role rewriting, no card swap, so
|
|
20
20
|
* header association, `aria-sort` and screen-reader table navigation are identical at every width.
|
|
21
|
+
*
|
|
22
|
+
* Column-count ceiling (gh#262): the wrap-instead-of-scroll contract holds up to SIX columns.
|
|
23
|
+
* From seven, the priority shares cannot fit a phone frame, so below the step each column takes
|
|
24
|
+
* its rem floor (`--table-action-collection-*-width-floor`, ~5 CJK glyphs per line) and the
|
|
25
|
+
* table intentionally scrolls inside this wrapper — SC 1.4.10 permits one-dimensional scrolling
|
|
26
|
+
* of a data table; compressing further would shred CJK headers one character per line.
|
|
21
27
|
*/
|
|
22
28
|
preset?: TablePresetProp;
|
|
23
29
|
/**
|
|
@@ -45,6 +51,12 @@ export declare const Table: React.ForwardRefExoticComponent<React.HTMLAttributes
|
|
|
45
51
|
* of forcing a horizontal scroll. Mark each column with `priority` on its `TableHead`/`TableCell`.
|
|
46
52
|
* The table keeps its real semantics: no `display` change, no role rewriting, no card swap, so
|
|
47
53
|
* header association, `aria-sort` and screen-reader table navigation are identical at every width.
|
|
54
|
+
*
|
|
55
|
+
* Column-count ceiling (gh#262): the wrap-instead-of-scroll contract holds up to SIX columns.
|
|
56
|
+
* From seven, the priority shares cannot fit a phone frame, so below the step each column takes
|
|
57
|
+
* its rem floor (`--table-action-collection-*-width-floor`, ~5 CJK glyphs per line) and the
|
|
58
|
+
* table intentionally scrolls inside this wrapper — SC 1.4.10 permits one-dimensional scrolling
|
|
59
|
+
* of a data table; compressing further would shred CJK headers one character per line.
|
|
48
60
|
*/
|
|
49
61
|
preset?: TablePresetProp;
|
|
50
62
|
/**
|