@cognitap/radiant 0.0.1 → 0.0.3
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/CHANGELOG.md +323 -15
- package/LICENSE +1 -1
- package/README.md +963 -220
- package/RELEASE_POLICY.md +23 -95
- package/dist/library/Accordion.d.ts +56 -0
- package/dist/library/Accordion.d.ts.map +1 -0
- package/dist/library/Accordion.js +89 -0
- package/dist/library/Accordion.js.map +1 -0
- package/dist/library/Button.d.ts +25 -3
- package/dist/library/Button.d.ts.map +1 -1
- package/dist/library/Button.js +31 -3
- package/dist/library/Button.js.map +1 -1
- package/dist/library/Card.d.ts +31 -0
- package/dist/library/Card.d.ts.map +1 -0
- package/dist/library/Card.js +69 -0
- package/dist/library/Card.js.map +1 -0
- package/dist/library/Checkbox.d.ts +13 -0
- package/dist/library/Checkbox.d.ts.map +1 -0
- package/dist/library/Checkbox.js +77 -0
- package/dist/library/Checkbox.js.map +1 -0
- package/dist/library/Collapsible.d.ts +32 -0
- package/dist/library/Collapsible.d.ts.map +1 -0
- package/dist/library/Collapsible.js +99 -0
- package/dist/library/Collapsible.js.map +1 -0
- package/dist/library/Dialog.d.ts +50 -0
- package/dist/library/Dialog.d.ts.map +1 -0
- package/dist/library/Dialog.js +215 -0
- package/dist/library/Dialog.js.map +1 -0
- package/dist/library/Field.d.ts +68 -0
- package/dist/library/Field.d.ts.map +1 -0
- package/dist/library/Field.js +114 -0
- package/dist/library/Field.js.map +1 -0
- package/dist/library/Input.d.ts +10 -0
- package/dist/library/Input.d.ts.map +1 -0
- package/dist/library/Input.js +51 -0
- package/dist/library/Input.js.map +1 -0
- package/dist/library/Link.d.ts +27 -0
- package/dist/library/Link.d.ts.map +1 -0
- package/dist/library/Link.js +50 -0
- package/dist/library/Link.js.map +1 -0
- package/dist/library/RadioGroup.d.ts +27 -0
- package/dist/library/RadioGroup.d.ts.map +1 -0
- package/dist/library/RadioGroup.js +103 -0
- package/dist/library/RadioGroup.js.map +1 -0
- package/dist/library/ThemeScope.d.ts +10 -0
- package/dist/library/ThemeScope.d.ts.map +1 -0
- package/dist/library/ThemeScope.js +41 -0
- package/dist/library/ThemeScope.js.map +1 -0
- package/dist/library/actionStyles.d.ts +11 -0
- package/dist/library/actionStyles.d.ts.map +1 -0
- package/dist/library/actionStyles.js +75 -0
- package/dist/library/actionStyles.js.map +1 -0
- package/dist/library/cn.d.ts +1 -2
- package/dist/library/cn.d.ts.map +1 -1
- package/dist/library/cn.js +1 -8
- package/dist/library/cn.js.map +1 -1
- package/dist/library/controlStyles.d.ts +5 -0
- package/dist/library/controlStyles.d.ts.map +1 -0
- package/dist/library/controlStyles.js +15 -0
- package/dist/library/controlStyles.js.map +1 -0
- package/dist/library/index.d.ts +24 -1
- package/dist/library/index.d.ts.map +1 -1
- package/dist/library/index.js +11 -0
- package/dist/library/index.js.map +1 -1
- package/dist/library/internal/events.d.ts +8 -0
- package/dist/library/internal/events.d.ts.map +1 -0
- package/dist/library/internal/events.js +13 -0
- package/dist/library/internal/events.js.map +1 -0
- package/dist/library/internal/ids.d.ts +3 -0
- package/dist/library/internal/ids.d.ts.map +1 -0
- package/dist/library/internal/ids.js +6 -0
- package/dist/library/internal/ids.js.map +1 -0
- package/dist/library/internal/selection.d.ts +5 -0
- package/dist/library/internal/selection.d.ts.map +1 -0
- package/dist/library/internal/selection.js +18 -0
- package/dist/library/internal/selection.js.map +1 -0
- package/dist/library/presentation.d.ts +18 -0
- package/dist/library/presentation.d.ts.map +1 -0
- package/dist/library/presentation.js +2 -0
- package/dist/library/presentation.js.map +1 -0
- package/dist/library/react/useComposedRefs.d.ts +4 -0
- package/dist/library/react/useComposedRefs.d.ts.map +1 -0
- package/dist/library/react/useComposedRefs.js +28 -0
- package/dist/library/react/useComposedRefs.js.map +1 -0
- package/dist/library/react/useControllableState.d.ts +16 -0
- package/dist/library/react/useControllableState.d.ts.map +1 -0
- package/dist/library/react/useControllableState.js +29 -0
- package/dist/library/react/useControllableState.js.map +1 -0
- package/dist/library/react/useNativeOwner.d.ts +17 -0
- package/dist/library/react/useNativeOwner.d.ts.map +1 -0
- package/dist/library/react/useNativeOwner.js +17 -0
- package/dist/library/react/useNativeOwner.js.map +1 -0
- package/dist/library/reset.css +1 -0
- package/dist/library/styles.css +2 -1
- package/dist/library/themes/components.d.ts +217 -0
- package/dist/library/themes/components.d.ts.map +1 -0
- package/dist/library/themes/components.js +229 -0
- package/dist/library/themes/components.js.map +1 -0
- package/dist/library/themes/default.d.ts +2 -0
- package/dist/library/themes/default.d.ts.map +1 -0
- package/dist/library/themes/default.js +4 -0
- package/dist/library/themes/default.js.map +1 -0
- package/dist/library/themes/defineTheme.d.ts +33 -0
- package/dist/library/themes/defineTheme.d.ts.map +1 -0
- package/dist/library/themes/defineTheme.js +98 -0
- package/dist/library/themes/defineTheme.js.map +1 -0
- package/dist/library/themes/expressive.d.ts +2 -0
- package/dist/library/themes/expressive.d.ts.map +1 -0
- package/dist/library/themes/expressive.js +132 -0
- package/dist/library/themes/expressive.js.map +1 -0
- package/dist/library/themes/glass.d.ts +2 -0
- package/dist/library/themes/glass.d.ts.map +1 -0
- package/dist/library/themes/glass.js +132 -0
- package/dist/library/themes/glass.js.map +1 -0
- package/dist/library/themes/index.d.ts +14 -0
- package/dist/library/themes/index.d.ts.map +1 -0
- package/dist/library/themes/index.js +21 -0
- package/dist/library/themes/index.js.map +1 -0
- package/dist/library/themes/jelly.d.ts +2 -0
- package/dist/library/themes/jelly.d.ts.map +1 -0
- package/dist/library/themes/jelly.js +130 -0
- package/dist/library/themes/jelly.js.map +1 -0
- package/dist/library/themes/preset-values.d.ts +4 -0
- package/dist/library/themes/preset-values.d.ts.map +1 -0
- package/dist/library/themes/preset-values.js +5 -0
- package/dist/library/themes/preset-values.js.map +1 -0
- package/dist/library/themes/radiant.d.ts +2 -0
- package/dist/library/themes/radiant.d.ts.map +1 -0
- package/dist/library/themes/radiant.js +129 -0
- package/dist/library/themes/radiant.js.map +1 -0
- package/dist/library/themes/sharp-3d.d.ts +2 -0
- package/dist/library/themes/sharp-3d.d.ts.map +1 -0
- package/dist/library/themes/sharp-3d.js +142 -0
- package/dist/library/themes/sharp-3d.js.map +1 -0
- package/dist/library/themes/soft-squircle.d.ts +2 -0
- package/dist/library/themes/soft-squircle.d.ts.map +1 -0
- package/dist/library/themes/soft-squircle.js +131 -0
- package/dist/library/themes/soft-squircle.js.map +1 -0
- package/dist/library/themes/ticket.d.ts +2 -0
- package/dist/library/themes/ticket.d.ts.map +1 -0
- package/dist/library/themes/ticket.js +141 -0
- package/dist/library/themes/ticket.js.map +1 -0
- package/dist/library/themes/tokens.d.ts +100 -0
- package/dist/library/themes/tokens.d.ts.map +1 -0
- package/dist/library/themes/tokens.js +171 -0
- package/dist/library/themes/tokens.js.map +1 -0
- package/dist/library/themes/types.d.ts +2 -0
- package/dist/library/themes/types.d.ts.map +1 -0
- package/dist/library/themes/types.js +2 -0
- package/dist/library/themes/types.js.map +1 -0
- package/docs/accessibility.md +189 -0
- package/docs/system.md +218 -0
- package/docs/theming.md +392 -0
- package/package.json +28 -11
- package/src/Accordion.tsx +235 -0
- package/src/Button.tsx +95 -15
- package/src/Card.tsx +143 -0
- package/src/Checkbox.tsx +189 -0
- package/src/Collapsible.tsx +193 -0
- package/src/Dialog.tsx +333 -0
- package/src/Field.tsx +293 -0
- package/src/Input.tsx +82 -0
- package/src/Link.tsx +95 -0
- package/src/RadioGroup.tsx +255 -0
- package/src/ThemeScope.tsx +64 -0
- package/src/actionStyles.ts +90 -0
- package/src/cn.ts +1 -10
- package/src/controlStyles.ts +19 -0
- package/src/index.ts +93 -1
- package/src/internal/events.ts +17 -0
- package/src/internal/ids.ts +5 -0
- package/src/internal/selection.ts +20 -0
- package/src/presentation.ts +12 -0
- package/src/react/useComposedRefs.ts +32 -0
- package/src/react/useControllableState.ts +50 -0
- package/src/react/useNativeOwner.ts +33 -0
- package/src/styles.css +2 -14
- package/src/themes/baseline.css +116 -0
- package/src/themes/components.ts +249 -0
- package/src/themes/default.ts +4 -0
- package/src/themes/defineTheme.ts +145 -0
- package/src/themes/expressive.ts +132 -0
- package/src/themes/glass.ts +135 -0
- package/src/themes/index.ts +33 -0
- package/src/themes/jelly.ts +130 -0
- package/src/themes/preset-values.ts +5 -0
- package/src/themes/radiant.ts +129 -0
- package/src/themes/sharp-3d.ts +142 -0
- package/src/themes/soft-squircle.ts +131 -0
- package/src/themes/ticket.ts +141 -0
- package/src/themes/tokens.ts +262 -0
- package/src/themes/types.ts +10 -0
package/RELEASE_POLICY.md
CHANGED
|
@@ -1,113 +1,41 @@
|
|
|
1
1
|
# Radiant release policy
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
deployments; the owner and trusted maintainers control development and merges.
|
|
5
|
-
|
|
6
|
-
## Identity and licensing
|
|
7
|
-
|
|
8
|
-
This repository is the authoritative Radiant source. Its selected GitHub identity
|
|
9
|
-
is `cognitap/radiant`; the npm package is `@cognitap/radiant`.
|
|
10
|
-
|
|
11
|
-
The source is licensed under MIT. [LICENSE](LICENSE) contains the complete text
|
|
12
|
-
and names Zoltán Cserei as the copyright holder. Corporate formation is not a
|
|
13
|
-
prerequisite for source opening or npm publication. This decision supersedes
|
|
14
|
-
DEV-84's initial incorporation gate.
|
|
15
|
-
|
|
16
|
-
Keep `private: true` in the package manifest until npm publication prerequisites
|
|
17
|
-
pass. This prevents package publication while public source development proceeds.
|
|
3
|
+
Radiant releases independently of Cognitap deployments.
|
|
18
4
|
|
|
19
5
|
## Versions
|
|
20
6
|
|
|
21
|
-
|
|
22
|
-
`latest
|
|
23
|
-
|
|
24
|
-
|
|
7
|
+
Releases follow [SemVer](https://semver.org/). `0.x` releases are experimental
|
|
8
|
+
and publish under `latest`; say so in the README and release notes. `1.0.0`
|
|
9
|
+
follows once the full catalog, its documentation, and accessibility
|
|
10
|
+
and compatibility verification are complete.
|
|
25
11
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
| Compatible addition, cosmetic change or deprecation | Minor | Minor |
|
|
30
|
-
| Breaking change | Minor | Major |
|
|
12
|
+
Use the largest applicable bump. A fix that requires consumers to adapt is
|
|
13
|
+
breaking, even for accessibility or security. Published versions are immutable.
|
|
14
|
+
Prereleases use a version suffix and their own npm tag, never `latest`.
|
|
31
15
|
|
|
32
|
-
|
|
33
|
-
is breaking, including accessibility or security corrections. Pure internal
|
|
34
|
-
changes can use a patch when they preserve the public contract. Published
|
|
35
|
-
versions are immutable; follow-up fixes receive a new version.
|
|
16
|
+
## Public contract
|
|
36
17
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
18
|
+
The contract covers documented props and types, package exports, behavior,
|
|
19
|
+
semantic tokens, named parts, state attributes and functional CSS requirements.
|
|
20
|
+
Breaking changes include incompatible changes to any of these, sizing or layout
|
|
21
|
+
changes consumers must adapt to, raised peer dependency ranges and narrowed
|
|
22
|
+
environment support.
|
|
41
23
|
|
|
42
|
-
##
|
|
24
|
+
## Support
|
|
43
25
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
browser or OS support target do not themselves require a breaking release.
|
|
52
|
-
Record tested combinations separately from support targets.
|
|
53
|
-
|
|
54
|
-
Generated utility strings and foundation internals remain private. Package
|
|
55
|
-
exports define the supported import surface; shipping source for editor
|
|
56
|
-
navigation does not make internal imports supported.
|
|
57
|
-
|
|
58
|
-
React remains a peer dependency. Keep the current range initially; changes need
|
|
59
|
-
installed-package verification. The [package manifest](package.json) declares
|
|
60
|
-
current peer ranges and runtime dependencies. Contributor Node, pnpm and
|
|
61
|
-
TypeScript pins belong to development configuration and do not establish
|
|
62
|
-
consumer runtime or declaration requirements.
|
|
63
|
-
|
|
64
|
-
Ordinary consumers use compiled `styles.css` without Tailwind. The optional
|
|
65
|
-
`reset.css` is a separate, global opt-in; importing components loads neither
|
|
66
|
-
stylesheet automatically. Tailwind belongs to the optional `tailwind.css`
|
|
67
|
-
customization route, which registers the library theme and sources for the
|
|
68
|
-
application's own CSS generation. Choose one component stylesheet route.
|
|
69
|
-
|
|
70
|
-
Cognitap pins exact published versions after its migration. Optional local
|
|
71
|
-
development watches this package's public build and selects its exports through
|
|
72
|
-
process-only aliases. The apps use compiled JavaScript/types and the supported
|
|
73
|
-
Tailwind entry. Installed dependencies stay unchanged, so stopping needs no
|
|
74
|
-
restore step. Normal consumption after migration requires
|
|
75
|
-
only the published package. Local updates complement archive and registry
|
|
76
|
-
verification and do not replace publication readiness checks.
|
|
77
|
-
|
|
78
|
-
## Support and upgrades
|
|
79
|
-
|
|
80
|
-
Maintain the current stable major through its latest minor and patch releases.
|
|
81
|
-
Before `1.0.0`, fixes land in the latest experimental release. There is no
|
|
82
|
-
standing commitment to older release branches or response deadlines.
|
|
83
|
-
|
|
84
|
-
Every published version has a changelog entry describing its consumer-facing
|
|
85
|
-
changes and relevant verification limits. Identify breaking changes and include
|
|
86
|
-
actionable migration instructions. After `1.0.0`, normally deprecate in a minor
|
|
87
|
-
before removal in a major, without a fixed waiting period. During `0.x`, direct
|
|
88
|
-
removal is allowed with migration guidance.
|
|
89
|
-
|
|
90
|
-
## Publication readiness
|
|
91
|
-
|
|
92
|
-
Public source opening requires the finalized MIT notice, repository control and
|
|
93
|
-
verified standalone tooling. Initial npm publication additionally
|
|
94
|
-
requires scope permissions, compiled CSS, verified installed archives and an
|
|
95
|
-
independent release workflow.
|
|
96
|
-
|
|
97
|
-
Archives include the public build, stylesheet, editor-navigation sources, README,
|
|
98
|
-
LICENSE, changelog and this policy; exclude tests, stories and Storybook output.
|
|
99
|
-
The manifest's allowlist and exports define what ships and what is public.
|
|
100
|
-
|
|
101
|
-
The selected publishing configuration uses public npm access and `latest`.
|
|
102
|
-
Keep publication disabled until its prerequisites pass. Neither public source
|
|
103
|
-
nor an experimental package establishes stable catalog readiness or conformance
|
|
104
|
-
for an entire consumer application.
|
|
26
|
+
Only the latest release is maintained: the latest `0.x` before `1.0.0`, then the
|
|
27
|
+
current major. There are no backports or response deadlines.
|
|
28
|
+
|
|
29
|
+
Every published version gets a changelog entry covering consumer-facing changes
|
|
30
|
+
and known verification gaps. Mark breaking changes and include migration steps.
|
|
31
|
+
From `1.0.0`, deprecate in a minor before removing in a major; during `0.x`,
|
|
32
|
+
direct removal is allowed.
|
|
105
33
|
|
|
106
34
|
## Release workflow
|
|
107
35
|
|
|
108
36
|
Releases use native pnpm versioning and reviewed changelog notes. In a pull
|
|
109
37
|
request, run `pnpm version patch --no-git-tag-version` (or `minor`, following
|
|
110
|
-
the
|
|
38
|
+
the rules above), move the applicable Unreleased notes under a `## <version>`
|
|
111
39
|
heading in `CHANGELOG.md` and commit both. The first release keeps `0.0.1`.
|
|
112
40
|
|
|
113
41
|
From a clean checkout, `pnpm release:prepare` checks the version and notes,
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { ComponentProps } from 'react';
|
|
2
|
+
import type { ThemeStyle } from './themes/defineTheme.js';
|
|
3
|
+
import { type Selection } from './internal/selection.js';
|
|
4
|
+
import type { CollapsibleContentProps, CollapsibleProps, CollapsibleTriggerProps } from './Collapsible.js';
|
|
5
|
+
declare const headingTag: {
|
|
6
|
+
readonly 1: "h1";
|
|
7
|
+
readonly 2: "h2";
|
|
8
|
+
readonly 3: "h3";
|
|
9
|
+
readonly 4: "h4";
|
|
10
|
+
readonly 5: "h5";
|
|
11
|
+
readonly 6: "h6";
|
|
12
|
+
};
|
|
13
|
+
export type AccordionHeadingLevel = keyof typeof headingTag;
|
|
14
|
+
type ValueOwner<Value> = {
|
|
15
|
+
value: Value;
|
|
16
|
+
defaultValue?: never;
|
|
17
|
+
} | {
|
|
18
|
+
value?: undefined;
|
|
19
|
+
defaultValue?: Value;
|
|
20
|
+
};
|
|
21
|
+
type AccordionBaseProps = Omit<ComponentProps<'div'>, 'defaultValue' | 'onChange' | 'style'> & {
|
|
22
|
+
style?: ThemeStyle;
|
|
23
|
+
'data-slot'?: string;
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
};
|
|
26
|
+
type AccordionSingleProps = AccordionBaseProps & ValueOwner<string | null> & {
|
|
27
|
+
type?: 'single';
|
|
28
|
+
onValueChange?: (value: string | null) => void;
|
|
29
|
+
};
|
|
30
|
+
type AccordionMultipleProps = AccordionBaseProps & ValueOwner<string[]> & {
|
|
31
|
+
type: 'multiple';
|
|
32
|
+
onValueChange?: (value: string[]) => void;
|
|
33
|
+
};
|
|
34
|
+
export type AccordionProps = AccordionSingleProps | AccordionMultipleProps;
|
|
35
|
+
export type AccordionItemProps = Omit<CollapsibleProps, 'open' | 'defaultOpen' | 'onOpenChange' | 'name'> & {
|
|
36
|
+
value: string;
|
|
37
|
+
disabled?: boolean;
|
|
38
|
+
};
|
|
39
|
+
export type AccordionTriggerProps = CollapsibleTriggerProps & {
|
|
40
|
+
level?: AccordionHeadingLevel | null;
|
|
41
|
+
};
|
|
42
|
+
export type AccordionContentProps = CollapsibleContentProps;
|
|
43
|
+
export type AccordionValue = Selection;
|
|
44
|
+
export type AccordionState = {
|
|
45
|
+
type: 'single' | 'multiple';
|
|
46
|
+
value: AccordionValue;
|
|
47
|
+
disabled: boolean;
|
|
48
|
+
setItemOpen: (value: string, open: boolean) => void;
|
|
49
|
+
};
|
|
50
|
+
export declare function useAccordion(): AccordionState | null;
|
|
51
|
+
export declare function Accordion(allProps: AccordionProps): import("react").JSX.Element;
|
|
52
|
+
export declare function AccordionItem({ value, disabled, className, children, ...props }: AccordionItemProps): import("react").JSX.Element;
|
|
53
|
+
export declare function AccordionTrigger({ level, className, children, tabIndex, onClick, onKeyDown, ...props }: AccordionTriggerProps): import("react").JSX.Element;
|
|
54
|
+
export declare function AccordionContent(props: AccordionContentProps): import("react").JSX.Element;
|
|
55
|
+
export {};
|
|
56
|
+
//# sourceMappingURL=Accordion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Accordion.d.ts","sourceRoot":"","sources":["../../src/Accordion.ts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cn } from './cn.js';
|
|
5
|
+
import { joinIds } from './internal/ids.js';
|
|
6
|
+
import { composeAction } from './internal/events.js';
|
|
7
|
+
import { isItemOpen, nextSelection, sameSelection } from './internal/selection.js';
|
|
8
|
+
import { useControllableState } from './react/useControllableState.js';
|
|
9
|
+
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from './Collapsible.js';
|
|
10
|
+
const accordionClass = 'grid w-full gap-[var(--rad-accordion-gap,var(--rad-spacing-group-gap,0.75rem))]';
|
|
11
|
+
const triggerClass = 'in-[[data-slot~=field][data-disabled]]:[--_rad-disabled-opacity:1] data-disabled:cursor-not-allowed data-disabled:opacity-[var(--_rad-disabled-opacity,var(--rad-state-disabled-opacity,0.5))] forced-colors:data-disabled:opacity-100';
|
|
12
|
+
const headingClass = 'm-0 min-w-0 break-words [font:inherit]';
|
|
13
|
+
const headingTag = {
|
|
14
|
+
1: 'h1',
|
|
15
|
+
2: 'h2',
|
|
16
|
+
3: 'h3',
|
|
17
|
+
4: 'h4',
|
|
18
|
+
5: 'h5',
|
|
19
|
+
6: 'h6'
|
|
20
|
+
};
|
|
21
|
+
const AccordionContext = createContext(null);
|
|
22
|
+
const AccordionItemContext = createContext(null);
|
|
23
|
+
export function useAccordion() {
|
|
24
|
+
return useContext(AccordionContext);
|
|
25
|
+
}
|
|
26
|
+
function useAccordionContext() {
|
|
27
|
+
const accordion = useAccordion();
|
|
28
|
+
if (!accordion)
|
|
29
|
+
throw new Error('Accordion parts must render inside Accordion.');
|
|
30
|
+
return accordion;
|
|
31
|
+
}
|
|
32
|
+
function useAccordionItemContext() {
|
|
33
|
+
const item = useContext(AccordionItemContext);
|
|
34
|
+
if (!item)
|
|
35
|
+
throw new Error('Accordion parts must render inside AccordionItem.');
|
|
36
|
+
return item;
|
|
37
|
+
}
|
|
38
|
+
function TriggerHeading({ level, children }) {
|
|
39
|
+
if (level === null)
|
|
40
|
+
return children;
|
|
41
|
+
const Tag = headingTag[level];
|
|
42
|
+
return _jsx(Tag, { className: headingClass, children: children });
|
|
43
|
+
}
|
|
44
|
+
export function Accordion(allProps) {
|
|
45
|
+
const { type = 'single', value, defaultValue, onValueChange: _onValueChange, disabled = false, className, children, ...props } = allProps;
|
|
46
|
+
const [initialType] = useState(type);
|
|
47
|
+
if (type !== initialType)
|
|
48
|
+
throw new TypeError('Accordion cannot change type during a mount. Remount with a new key.');
|
|
49
|
+
const { value: current, request } = useControllableState({
|
|
50
|
+
name: 'Accordion',
|
|
51
|
+
value,
|
|
52
|
+
defaultValue,
|
|
53
|
+
initialValue: type === 'multiple' ? [] : null,
|
|
54
|
+
equal: sameSelection,
|
|
55
|
+
onChange: next => {
|
|
56
|
+
if (allProps.type === 'multiple' && Array.isArray(next))
|
|
57
|
+
allProps.onValueChange?.(next);
|
|
58
|
+
else if (allProps.type !== 'multiple' && !Array.isArray(next))
|
|
59
|
+
allProps.onValueChange?.(next);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
if ((type === 'multiple') !== Array.isArray(current)) {
|
|
63
|
+
throw new TypeError('Accordion selection must match its single or multiple type.');
|
|
64
|
+
}
|
|
65
|
+
const setItemOpen = (itemValue, open) => {
|
|
66
|
+
if (disabled)
|
|
67
|
+
return;
|
|
68
|
+
request(current => nextSelection(current, itemValue, open));
|
|
69
|
+
};
|
|
70
|
+
return (_jsx(AccordionContext.Provider, { value: { type, value: current, disabled, setItemOpen }, children: _jsx("div", { ...props, className: cn(accordionClass, className), "data-disabled": disabled ? '' : undefined, "data-slot": joinIds('accordion', props['data-slot']), "data-type": type, children: children }) }));
|
|
71
|
+
}
|
|
72
|
+
export function AccordionItem({ value, disabled = false, className, children, ...props }) {
|
|
73
|
+
const accordion = useAccordionContext();
|
|
74
|
+
const itemDisabled = accordion.disabled || disabled;
|
|
75
|
+
return (_jsx(AccordionItemContext.Provider, { value: { value, disabled: itemDisabled }, children: _jsx(Collapsible, { ...props, className: className, "data-slot": joinIds('accordion-item', props['data-slot']), name: undefined, "data-disabled": itemDisabled ? '' : undefined, "data-value": value, open: isItemOpen(accordion.value, value), onOpenChange: next => {
|
|
76
|
+
if (itemDisabled)
|
|
77
|
+
return;
|
|
78
|
+
accordion.setItemOpen(value, next);
|
|
79
|
+
}, children: children }) }));
|
|
80
|
+
}
|
|
81
|
+
export function AccordionTrigger({ level = 3, className, children, tabIndex, onClick, onKeyDown, ...props }) {
|
|
82
|
+
const item = useAccordionItemContext();
|
|
83
|
+
return (_jsx(CollapsibleTrigger, { ...props, "aria-disabled": item.disabled || undefined, className: cn(triggerClass, className), "data-slot": joinIds('accordion-trigger', props['data-slot']), "data-disabled": item.disabled ? '' : undefined, tabIndex: item.disabled ? -1 : tabIndex, onClick: composeAction(onClick, undefined, () => item.disabled), onKeyDown: composeAction(onKeyDown, undefined, event => item.disabled && (event.key === 'Enter' || event.key === ' ')), children: _jsx(TriggerHeading, { level: level, children: children }) }));
|
|
84
|
+
}
|
|
85
|
+
export function AccordionContent(props) {
|
|
86
|
+
useAccordionItemContext();
|
|
87
|
+
return (_jsx(CollapsibleContent, { ...props, "data-slot": joinIds('accordion-content', props['data-slot']) }));
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=Accordion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Accordion.js","sourceRoot":"","sources":["../../src/Accordion.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAGZ,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC3D,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAE3C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,aAAa,EAAkB,MAAM,yBAAyB,CAAA;AAClG,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAA;AACtE,OAAO,EAAE,WAA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AK,GAAG,CAAC,EACT,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,SAAS,EACT,GAAG,KAAK,EACc;IACtB,MAAM,IAAI,GAAG,uBAAuB,EAAE,CAAA;IACtC,OAAO,CACL,KAAC,kBAAkB,OACb,KAAK,mBACM,IAAI,CAAC,QAAQ,IAAI,SAAS,EACzC,SAAS,EAAE,EAAE,CAAC,YAAY,EAAE,SAAS,CAAC,eAC3B,OAAO,CAAC,mBAAmB,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC,mBAC5C,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,EAC7C,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EACvC,OAAO,EAAE,aAAa,CAAC,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAC/D,SAAS,EAAE,aAAa,CACtB,SAAS,EACT,SAAS,EACT,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,KAAK,CAAC,GAAG,KAAK,OAAO,IAAI,KAAK,CAAC,GAAG,KAAK,GAAG,CAAC,CACvE,YAED,KAAC,cAAc,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAkB,GACtC,CACtB,CAAA;AACH,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAA4B;IAC3D,uBAAuB,EAAE,CAAA;IACzB,OAAO,CACL,KAAC,kBAAkB,OACb,KAAK,eACE,OAAO,CAAC,mBAAmB,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC,GAC3D,CACH,CAAA;AACH,CAAC","sourcesContent":["'use client'\n\nimport type { ComponentProps, ReactNode } from 'react'\nimport { createContext, useContext, useState } from 'react'\nimport { cn } from './cn.js'\nimport { joinIds } from './internal/ids.js'\nimport type { ThemeStyle } from './themes/defineTheme.js'\nimport { composeAction } from './internal/events.js'\nimport { isItemOpen, nextSelection, sameSelection, type Selection } from './internal/selection.js'\nimport { useControllableState } from './react/useControllableState.js'\nimport { Collapsible, CollapsibleContent, CollapsibleTrigger } from './Collapsible.js'\nimport type {\n CollapsibleContentProps,\n CollapsibleProps,\n CollapsibleTriggerProps\n} from './Collapsible.js'\n\nconst accordionClass =\n 'grid w-full gap-[var(--rad-accordion-gap,var(--rad-spacing-group-gap,0.75rem))]'\nconst triggerClass =\n 'in-[[data-slot~=field][data-disabled]]:[--_rad-disabled-opacity:1] data-disabled:cursor-not-allowed data-disabled:opacity-[var(--_rad-disabled-opacity,var(--rad-state-disabled-opacity,0.5))] forced-colors:data-disabled:opacity-100'\nconst headingClass = 'm-0 min-w-0 break-words [font:inherit]'\n\nconst headingTag = {\n 1: 'h1',\n 2: 'h2',\n 3: 'h3',\n 4: 'h4',\n 5: 'h5',\n 6: 'h6'\n} as const\n\nexport type AccordionHeadingLevel = keyof typeof headingTag\n\ntype ValueOwner<Value> =\n | { value: Value; defaultValue?: never }\n | { value?: undefined; defaultValue?: Value }\n\ntype AccordionBaseProps = Omit<ComponentProps<'div'>, 'defaultValue' | 'onChange' | 'style'> & {\n style?: ThemeStyle\n 'data-slot'?: string\n disabled?: boolean\n}\n\ntype AccordionSingleProps = AccordionBaseProps &\n ValueOwner<string | null> & {\n type?: 'single'\n onValueChange?: (value: string | null) => void\n }\n\ntype AccordionMultipleProps = AccordionBaseProps &\n ValueOwner<string[]> & {\n type: 'multiple'\n onValueChange?: (value: string[]) => void\n }\n\nexport type AccordionProps = AccordionSingleProps | AccordionMultipleProps\n\nexport type AccordionItemProps = Omit<\n CollapsibleProps,\n 'open' | 'defaultOpen' | 'onOpenChange' | 'name'\n> & {\n value: string\n disabled?: boolean\n}\n\nexport type AccordionTriggerProps = CollapsibleTriggerProps & {\n level?: AccordionHeadingLevel | null\n}\n\nexport type AccordionContentProps = CollapsibleContentProps\n\nexport type AccordionValue = Selection\n\nexport type AccordionState = {\n type: 'single' | 'multiple'\n value: AccordionValue\n disabled: boolean\n setItemOpen: (value: string, open: boolean) => void\n}\n\ntype AccordionItemState = {\n value: string\n disabled: boolean\n}\n\nconst AccordionContext = createContext<AccordionState | null>(null)\nconst AccordionItemContext = createContext<AccordionItemState | null>(null)\n\nexport function useAccordion(): AccordionState | null {\n return useContext(AccordionContext)\n}\n\nfunction useAccordionContext() {\n const accordion = useAccordion()\n if (!accordion) throw new Error('Accordion parts must render inside Accordion.')\n return accordion\n}\n\nfunction useAccordionItemContext() {\n const item = useContext(AccordionItemContext)\n if (!item) throw new Error('Accordion parts must render inside AccordionItem.')\n return item\n}\n\nfunction TriggerHeading({\n level,\n children\n}: {\n level: AccordionHeadingLevel | null\n children: ReactNode\n}) {\n if (level === null) return children\n const Tag = headingTag[level]\n return <Tag className={headingClass}>{children}</Tag>\n}\n\nexport function Accordion(allProps: AccordionProps) {\n const {\n type = 'single',\n value,\n defaultValue,\n onValueChange: _onValueChange,\n disabled = false,\n className,\n children,\n ...props\n } = allProps\n const [initialType] = useState(type)\n if (type !== initialType)\n throw new TypeError('Accordion cannot change type during a mount. Remount with a new key.')\n const { value: current, request } = useControllableState<AccordionValue>({\n name: 'Accordion',\n value,\n defaultValue,\n initialValue: type === 'multiple' ? [] : null,\n equal: sameSelection,\n onChange: next => {\n if (allProps.type === 'multiple' && Array.isArray(next)) allProps.onValueChange?.(next)\n else if (allProps.type !== 'multiple' && !Array.isArray(next)) allProps.onValueChange?.(next)\n }\n })\n if ((type === 'multiple') !== Array.isArray(current)) {\n throw new TypeError('Accordion selection must match its single or multiple type.')\n }\n\n const setItemOpen = (itemValue: string, open: boolean) => {\n if (disabled) return\n request(current => nextSelection(current, itemValue, open))\n }\n\n return (\n <AccordionContext.Provider value={{ type, value: current, disabled, setItemOpen }}>\n <div\n {...props}\n className={cn(accordionClass, className)}\n data-disabled={disabled ? '' : undefined}\n data-slot={joinIds('accordion', props['data-slot'])}\n data-type={type}\n >\n {children}\n </div>\n </AccordionContext.Provider>\n )\n}\n\nexport function AccordionItem({\n value,\n disabled = false,\n className,\n children,\n ...props\n}: AccordionItemProps) {\n const accordion = useAccordionContext()\n const itemDisabled = accordion.disabled || disabled\n return (\n <AccordionItemContext.Provider value={{ value, disabled: itemDisabled }}>\n <Collapsible\n {...props}\n className={className}\n data-slot={joinIds('accordion-item', props['data-slot'])}\n name={undefined}\n data-disabled={itemDisabled ? '' : undefined}\n data-value={value}\n open={isItemOpen(accordion.value, value)}\n onOpenChange={next => {\n if (itemDisabled) return\n accordion.setItemOpen(value, next)\n }}\n >\n {children}\n </Collapsible>\n </AccordionItemContext.Provider>\n )\n}\n\nexport function AccordionTrigger({\n level = 3,\n className,\n children,\n tabIndex,\n onClick,\n onKeyDown,\n ...props\n}: AccordionTriggerProps) {\n const item = useAccordionItemContext()\n return (\n <CollapsibleTrigger\n {...props}\n aria-disabled={item.disabled || undefined}\n className={cn(triggerClass, className)}\n data-slot={joinIds('accordion-trigger', props['data-slot'])}\n data-disabled={item.disabled ? '' : undefined}\n tabIndex={item.disabled ? -1 : tabIndex}\n onClick={composeAction(onClick, undefined, () => item.disabled)}\n onKeyDown={composeAction(\n onKeyDown,\n undefined,\n event => item.disabled && (event.key === 'Enter' || event.key === ' ')\n )}\n >\n <TriggerHeading level={level}>{children}</TriggerHeading>\n </CollapsibleTrigger>\n )\n}\n\nexport function AccordionContent(props: AccordionContentProps) {\n useAccordionItemContext()\n return (\n <CollapsibleContent\n {...props}\n data-slot={joinIds('accordion-content', props['data-slot'])}\n />\n )\n}\n"]}
|
package/dist/library/Button.d.ts
CHANGED
|
@@ -1,4 +1,26 @@
|
|
|
1
|
-
import type { ComponentProps } from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type { ComponentProps, ReactElement } from 'react';
|
|
2
|
+
import type { ButtonVariant, ControlSize, Tone } from './presentation.js';
|
|
3
|
+
import type { ThemeStyle } from './themes/defineTheme.js';
|
|
4
|
+
export type { ButtonVariant } from './presentation.js';
|
|
5
|
+
export type ButtonRenderProps = Omit<ComponentProps<'button'>, 'style'> & {
|
|
6
|
+
style?: ThemeStyle;
|
|
7
|
+
'data-slot': string;
|
|
8
|
+
'data-variant': ButtonVariant;
|
|
9
|
+
'data-tone': Tone;
|
|
10
|
+
'data-control-size': ControlSize;
|
|
11
|
+
};
|
|
12
|
+
export type ButtonProps = Omit<ComponentProps<'button'>, 'style'> & {
|
|
13
|
+
style?: ThemeStyle;
|
|
14
|
+
/** Additional composed identities; the button token is always retained. */
|
|
15
|
+
'data-slot'?: string;
|
|
16
|
+
/** Forward resolved presentation, children, native attributes and ref to one button host. */
|
|
17
|
+
render?: (props: ButtonRenderProps) => ReactElement;
|
|
18
|
+
variant?: ButtonVariant;
|
|
19
|
+
tone?: Tone;
|
|
20
|
+
controlSize?: ControlSize;
|
|
21
|
+
iconOnly?: boolean;
|
|
22
|
+
fullWidth?: boolean;
|
|
23
|
+
pending?: boolean;
|
|
24
|
+
};
|
|
25
|
+
export declare function Button({ render, type, variant, tone, controlSize, iconOnly, fullWidth, className, pending, onClick, children, ...props }: ButtonProps): import("react").JSX.Element;
|
|
4
26
|
//# sourceMappingURL=Button.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../src/Button.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../src/Button.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAGzD,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AAIzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAEzD,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEtD,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,GAAG;IACxE,KAAK,CAAC,EAAE,UAAU,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB,cAAc,EAAE,aAAa,CAAA;IAC7B,WAAW,EAAE,IAAI,CAAA;IACjB,mBAAmB,EAAE,WAAW,CAAA;CACjC,CAAA;AAED,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,GAAG;IAClE,KAAK,CAAC,EAAE,UAAU,CAAA;IAClB,2EAA2E;IAC3E,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,6FAA6F;IAC7F,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,YAAY,CAAA;IACnD,OAAO,CAAC,EAAE,aAAa,CAAA;IACvB,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAED,wBAAgB,MAAM,CAAC,EACrB,MAAM,EACN,IAAe,EACf,OAAiB,EACjB,IAAe,EACf,WAAsB,EACtB,QAAQ,EACR,SAAS,EACT,SAAS,EACT,OAAe,EACf,OAAO,EACP,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,WAAW,+BAyCb"}
|
package/dist/library/Button.js
CHANGED
|
@@ -1,6 +1,34 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Fragment, isValidElement } from 'react';
|
|
4
|
+
import { actionVariants } from './actionStyles.js';
|
|
2
5
|
import { cn } from './cn.js';
|
|
3
|
-
|
|
4
|
-
|
|
6
|
+
import { joinIds } from './internal/ids.js';
|
|
7
|
+
import { composeAction } from './internal/events.js';
|
|
8
|
+
export function Button({ render, type = 'button', variant = 'solid', tone = 'accent', controlSize = 'medium', iconOnly, fullWidth, className, pending = false, onClick, children, ...props }) {
|
|
9
|
+
const buttonProps = {
|
|
10
|
+
...props,
|
|
11
|
+
type,
|
|
12
|
+
'aria-busy': pending || props['aria-busy'],
|
|
13
|
+
'data-slot': joinIds('button', props['data-slot']) ?? 'button',
|
|
14
|
+
'data-variant': variant,
|
|
15
|
+
'data-tone': tone,
|
|
16
|
+
'data-control-size': controlSize,
|
|
17
|
+
className: cn(actionVariants({ variant, tone, controlSize, iconOnly, fullWidth }), className),
|
|
18
|
+
onClick: composeAction(onClick, undefined, event => pending || event.currentTarget.matches(':disabled')),
|
|
19
|
+
children: (_jsxs(_Fragment, { children: [_jsx("span", { className: cn('inline-flex items-center gap-[0.5em] [&_svg]:shrink-0', pending && 'opacity-0 motion-reduce:opacity-100'), children: children }), pending ? _jsx(PendingMark, {}) : null] }))
|
|
20
|
+
};
|
|
21
|
+
if (!render)
|
|
22
|
+
return _jsx("button", { ...buttonProps, children: buttonProps.children });
|
|
23
|
+
const element = render(buttonProps);
|
|
24
|
+
if (!isValidElement(element) ||
|
|
25
|
+
element.type === Fragment ||
|
|
26
|
+
(typeof element.type === 'string' && element.type !== 'button')) {
|
|
27
|
+
throw new Error('Button render must return one button or a component that forwards props to a button.');
|
|
28
|
+
}
|
|
29
|
+
return element;
|
|
30
|
+
}
|
|
31
|
+
function PendingMark() {
|
|
32
|
+
return (_jsx("span", { "aria-hidden": "true", className: "pointer-events-none absolute inset-0 flex items-center justify-center motion-reduce:hidden", children: _jsx("span", { className: "size-[1.1em] animate-spin rounded-full border-[1.5px] border-current border-t-transparent" }) }));
|
|
5
33
|
}
|
|
6
34
|
//# sourceMappingURL=Button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../src/Button.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../src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C,CAAC,CAAC,KAAC,WAAW,KAAG,CAAC,CAAC,CAAC,IAAI,IAChC,CACJ;KACF,CAAA;IACD,IAAI,CAAC,MAAM;QAAE,OAAO,oBAAY,WAAW,YAAG,WAAW,CAAC,QAAQ,GAAU,CAAA;IAC5E,MAAM,OAAO,GAAG,MAAM,CAAC,WAAW,CAAC,CAAA;IACnC,IACE,CAAC,cAAc,CAAC,OAAO,CAAC;QACxB,OAAO,CAAC,IAAI,KAAK,QAAQ;QACzB,CAAC,OAAO,OAAO,CAAC,IAAI,KAAK,QAAQ,IAAI,OAAO,CAAC,IAAI,KAAK,QAAQ,CAAC,EAC/D,CAAC;QACD,MAAM,IAAI,KAAK,CACb,sFAAsF,CACvF,CAAA;IACH,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,SAAS,WAAW;IAClB,OAAO,CACL,8BACc,MAAM,EAClB,SAAS,EAAC,4FAA4F,YAEtG,eAAM,SAAS,EAAC,2FAA2F,GAAG,GACzG,CACR,CAAA;AACH,CAAC","sourcesContent":["'use client'\n\nimport type { ComponentProps, ReactElement } from 'react'\nimport { Fragment, isValidElement } from 'react'\nimport { actionVariants } from './actionStyles.js'\nimport type { ButtonVariant, ControlSize, Tone } from './presentation.js'\nimport { cn } from './cn.js'\nimport { joinIds } from './internal/ids.js'\nimport { composeAction } from './internal/events.js'\nimport type { ThemeStyle } from './themes/defineTheme.js'\n\nexport type { ButtonVariant } from './presentation.js'\n\nexport type ButtonRenderProps = Omit<ComponentProps<'button'>, 'style'> & {\n style?: ThemeStyle\n 'data-slot': string\n 'data-variant': ButtonVariant\n 'data-tone': Tone\n 'data-control-size': ControlSize\n}\n\nexport type ButtonProps = Omit<ComponentProps<'button'>, 'style'> & {\n style?: ThemeStyle\n /** Additional composed identities; the button token is always retained. */\n 'data-slot'?: string\n /** Forward resolved presentation, children, native attributes and ref to one button host. */\n render?: (props: ButtonRenderProps) => ReactElement\n variant?: ButtonVariant\n tone?: Tone\n controlSize?: ControlSize\n iconOnly?: boolean\n fullWidth?: boolean\n pending?: boolean\n}\n\nexport function Button({\n render,\n type = 'button',\n variant = 'solid',\n tone = 'accent',\n controlSize = 'medium',\n iconOnly,\n fullWidth,\n className,\n pending = false,\n onClick,\n children,\n ...props\n}: ButtonProps) {\n const buttonProps: ButtonRenderProps = {\n ...props,\n type,\n 'aria-busy': pending || props['aria-busy'],\n 'data-slot': joinIds('button', props['data-slot']) ?? 'button',\n 'data-variant': variant,\n 'data-tone': tone,\n 'data-control-size': controlSize,\n className: cn(actionVariants({ variant, tone, controlSize, iconOnly, fullWidth }), className),\n onClick: composeAction(\n onClick,\n undefined,\n event => pending || event.currentTarget.matches(':disabled')\n ),\n children: (\n <>\n <span\n className={cn(\n 'inline-flex items-center gap-[0.5em] [&_svg]:shrink-0',\n pending && 'opacity-0 motion-reduce:opacity-100'\n )}\n >\n {children}\n </span>\n {pending ? <PendingMark /> : null}\n </>\n )\n }\n if (!render) return <button {...buttonProps}>{buttonProps.children}</button>\n const element = render(buttonProps)\n if (\n !isValidElement(element) ||\n element.type === Fragment ||\n (typeof element.type === 'string' && element.type !== 'button')\n ) {\n throw new Error(\n 'Button render must return one button or a component that forwards props to a button.'\n )\n }\n return element\n}\n\nfunction PendingMark() {\n return (\n <span\n aria-hidden=\"true\"\n className=\"pointer-events-none absolute inset-0 flex items-center justify-center motion-reduce:hidden\"\n >\n <span className=\"size-[1.1em] animate-spin rounded-full border-[1.5px] border-current border-t-transparent\" />\n </span>\n )\n}\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ComponentProps } from 'react';
|
|
2
|
+
import type { ThemeStyle } from './themes/defineTheme.js';
|
|
3
|
+
declare const headingTag: {
|
|
4
|
+
readonly 1: "h1";
|
|
5
|
+
readonly 2: "h2";
|
|
6
|
+
readonly 3: "h3";
|
|
7
|
+
readonly 4: "h4";
|
|
8
|
+
readonly 5: "h5";
|
|
9
|
+
readonly 6: "h6";
|
|
10
|
+
};
|
|
11
|
+
export type CardHeadingLevel = keyof typeof headingTag;
|
|
12
|
+
type CardPartProps<Host extends 'div' | 'h2' | 'p'> = Omit<ComponentProps<Host>, 'style'> & {
|
|
13
|
+
style?: ThemeStyle;
|
|
14
|
+
'data-slot'?: string;
|
|
15
|
+
};
|
|
16
|
+
export type CardProps = CardPartProps<'div'>;
|
|
17
|
+
export type CardHeaderProps = CardPartProps<'div'>;
|
|
18
|
+
export type CardTitleProps = CardPartProps<'h2'> & {
|
|
19
|
+
level?: CardHeadingLevel;
|
|
20
|
+
};
|
|
21
|
+
export type CardDescriptionProps = CardPartProps<'p'>;
|
|
22
|
+
export type CardContentProps = CardPartProps<'div'>;
|
|
23
|
+
export type CardFooterProps = CardPartProps<'div'>;
|
|
24
|
+
export declare function Card({ className, ...props }: CardProps): import("react").JSX.Element;
|
|
25
|
+
export declare function CardHeader({ className, ...props }: CardHeaderProps): import("react").JSX.Element;
|
|
26
|
+
export declare function CardTitle({ level, className, children, ...props }: CardTitleProps): import("react").JSX.Element;
|
|
27
|
+
export declare function CardDescription({ className, ...props }: CardDescriptionProps): import("react").JSX.Element;
|
|
28
|
+
export declare function CardContent({ className, ...props }: CardContentProps): import("react").JSX.Element;
|
|
29
|
+
export declare function CardFooter({ className, ...props }: CardFooterProps): import("react").JSX.Element;
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=Card.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Card.d.ts","sourceRoot":"","sources":["../../src/Card.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAI3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AA+CzD,QAAA,MAAM,UAAU;;;;;;;CAON,CAAA;AAEV,MAAM,MAAM,gBAAgB,GAAG,MAAM,OAAO,UAAU,CAAA;AAEtD,KAAK,aAAa,CAAC,IAAI,SAAS,KAAK,GAAG,IAAI,GAAG,GAA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
+
import { joinIds } from './internal/ids.js';
|
|
5
|
+
const colorMotionClass = 'transition-colors duration-[var(--rad-motion-color-duration,150ms)] motion-reduce:transition-none';
|
|
6
|
+
const cardVariants = cva([
|
|
7
|
+
colorMotionClass,
|
|
8
|
+
'[font-family:var(--rad-typography-family,system-ui,sans-serif)] [letter-spacing:var(--rad-typography-letter-spacing,-0.011em)] [font-size:var(--rad-typography-body-size,0.875rem)] [font-weight:var(--rad-typography-body-weight,400)]',
|
|
9
|
+
'box-border grid w-full gap-[var(--rad-card-gap,var(--rad-surface-gap,1rem))] text-start antialiased',
|
|
10
|
+
'rounded-[var(--rad-card-radius,var(--rad-surface-radius,0.75rem))]',
|
|
11
|
+
'[corner-shape:var(--rad-card-corner-shape,var(--rad-surface-corner-shape,round))]',
|
|
12
|
+
'[border-width:var(--rad-card-border-width,var(--rad-surface-border-width,1px))]',
|
|
13
|
+
'[border-style:var(--rad-card-border-style,var(--rad-surface-border-style,solid))]',
|
|
14
|
+
'[border-color:var(--rad-card-border-color,var(--rad-color-border,oklch(0.885_0.005_286)))]',
|
|
15
|
+
'bg-[var(--rad-card-background,var(--rad-color-surface,oklch(1_0_0)))]',
|
|
16
|
+
'[color:var(--rad-card-color,var(--rad-color-foreground,oklch(0.21_0.006_286)))]',
|
|
17
|
+
'p-[var(--rad-card-padding,var(--rad-surface-padding,1.5rem))]',
|
|
18
|
+
'[box-shadow:var(--rad-card-shadow,var(--rad-surface-shadow,0_1px_2px_0_rgb(0_0_0/0.06)))]',
|
|
19
|
+
'forced-colors:border-[CanvasText] forced-colors:bg-[Canvas] forced-colors:text-[CanvasText] forced-colors:shadow-none'
|
|
20
|
+
]);
|
|
21
|
+
const cardHeaderVariants = cva([
|
|
22
|
+
'grid min-w-0 gap-[var(--rad-card-header-gap,var(--rad-spacing-header-gap,0.375rem))]'
|
|
23
|
+
]);
|
|
24
|
+
const cardTitleVariants = cva([
|
|
25
|
+
colorMotionClass,
|
|
26
|
+
'm-0 min-w-0 break-words leading-snug',
|
|
27
|
+
'[font-size:var(--rad-card-title-size,var(--rad-typography-heading-size,1.125rem))]',
|
|
28
|
+
'[font-weight:var(--rad-card-title-weight,var(--rad-typography-heading-weight,600))]',
|
|
29
|
+
'forced-colors:text-[CanvasText]'
|
|
30
|
+
]);
|
|
31
|
+
const cardDescriptionVariants = cva([
|
|
32
|
+
colorMotionClass,
|
|
33
|
+
'm-0 min-w-0 break-words leading-snug',
|
|
34
|
+
'[color:var(--rad-card-description-color,var(--rad-color-muted-foreground,oklch(0.45_0.01_286)))]',
|
|
35
|
+
'[font-size:var(--rad-card-description-size,var(--rad-typography-small-size,0.8125rem))]',
|
|
36
|
+
'forced-colors:text-[CanvasText]'
|
|
37
|
+
]);
|
|
38
|
+
const cardContentVariants = cva(['min-w-0 break-words']);
|
|
39
|
+
const cardFooterVariants = cva([
|
|
40
|
+
'flex min-w-0 flex-wrap items-center gap-[var(--rad-card-footer-gap,var(--rad-spacing-footer-gap,0.5rem))]'
|
|
41
|
+
]);
|
|
42
|
+
const headingTag = {
|
|
43
|
+
1: 'h1',
|
|
44
|
+
2: 'h2',
|
|
45
|
+
3: 'h3',
|
|
46
|
+
4: 'h4',
|
|
47
|
+
5: 'h5',
|
|
48
|
+
6: 'h6'
|
|
49
|
+
};
|
|
50
|
+
export function Card({ className, ...props }) {
|
|
51
|
+
return (_jsx("div", { ...props, className: cn(cardVariants(), className), "data-slot": joinIds('card', props['data-slot']) }));
|
|
52
|
+
}
|
|
53
|
+
export function CardHeader({ className, ...props }) {
|
|
54
|
+
return (_jsx("div", { ...props, className: cn(cardHeaderVariants(), className), "data-slot": joinIds('card-header', props['data-slot']) }));
|
|
55
|
+
}
|
|
56
|
+
export function CardTitle({ level = 2, className, children, ...props }) {
|
|
57
|
+
const Tag = headingTag[level];
|
|
58
|
+
return (_jsx(Tag, { ...props, className: cn(cardTitleVariants(), className), "data-slot": joinIds('card-title', props['data-slot']), children: children }));
|
|
59
|
+
}
|
|
60
|
+
export function CardDescription({ className, ...props }) {
|
|
61
|
+
return (_jsx("p", { ...props, className: cn(cardDescriptionVariants(), className), "data-slot": joinIds('card-description', props['data-slot']) }));
|
|
62
|
+
}
|
|
63
|
+
export function CardContent({ className, ...props }) {
|
|
64
|
+
return (_jsx("div", { ...props, className: cn(cardContentVariants(), className), "data-slot": joinIds('card-content', props['data-slot']) }));
|
|
65
|
+
}
|
|
66
|
+
export function CardFooter({ className, ...props }) {
|
|
67
|
+
return (_jsx("div", { ...props, className: cn(cardFooterVariants(), className), "data-slot": joinIds('card-footer', props['data-slot']) }));
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=Card.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Card.js","sourceRoot":"","sources":["../../src/Card.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAA;AAC9C,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAG3C,MAAM,gBAAgB,GACpB,mGAAmG,CAAA;AAErG,MAAM,YAAY,GAAG,GAAG,CAAC;IACvB,gBAAgB;IAChB,yOAAyO;IACzO,qGAAqG;IACrG,oEAAoE;IACpE,mFAAmF;IACnF,iFAAiF;IACjF,mFAAmF;IACnF,4FAA4F;IAC5F,uEAAuE;IACvE,iFAAiF;IACjF,+DAA+D;IAC/D,2FAA2F;IAC3F,uHAAuH;CACxH,CAAC,CAAA;AAEF,MAAM,kBAAkB,GAAG,GAAG,CAAC;IAC7B,sFAAsF;CACvF,CAAC,CAAA;AAEF,MAAM,iBAAiB,GAAG,GAAG,CAAC;IAC5B,gBAAgB;IAChB,sCAAsC;IACtC,oFAAoF;IACpF,qFAAqF;IACrF,iCAAiC;CAClC,CAAC,CAAA;AAEF,MAAM,uBAAuB,GAAG,GAAG,CAAC;IAClC,gBAAgB;IAChB,sCAAsC;IACtC,kGAAkG;IAClG,yFAAyF;IAC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,SAAS,EAAE,GAAG,KAAK,EAAwB;IAC3E,OAAO,CACL,eACM,KAAK,EACT,SAAS,EAAE,EAAE,CAAC,uBAAuB,EAAE,EAAE,SAAS,CAAC,eACxC,OAAO,CAAC,kBAAkB,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC,GAC1D,CACH,CAAA;AACH,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAoB;IACnE,OAAO,CACL,iBACM,KAAK,EACT,SAAS,EAAE,EAAE,CAAC,mBAAmB,EAAE,EAAE,SAAS,CAAC,eACpC,OAAO,CAAC,cAAc,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC,GACtD,CACH,CAAA;AACH,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAmB;IACjE,OAAO,CACL,iBACM,KAAK,EACT,SAAS,EAAE,EAAE,CAAC,kBAAkB,EAAE,EAAE,SAAS,CAAC,eACnC,OAAO,CAAC,aAAa,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC,GACrD,CACH,CAAA;AACH,CAAC","sourcesContent":["import type { ComponentProps } from 'react'\nimport { cva } from 'class-variance-authority'\nimport { cn } from './cn.js'\nimport { joinIds } from './internal/ids.js'\nimport type { ThemeStyle } from './themes/defineTheme.js'\n\nconst colorMotionClass =\n 'transition-colors duration-[var(--rad-motion-color-duration,150ms)] motion-reduce:transition-none'\n\nconst cardVariants = cva([\n colorMotionClass,\n '[font-family:var(--rad-typography-family,system-ui,sans-serif)] [letter-spacing:var(--rad-typography-letter-spacing,-0.011em)] [font-size:var(--rad-typography-body-size,0.875rem)] [font-weight:var(--rad-typography-body-weight,400)]',\n 'box-border grid w-full gap-[var(--rad-card-gap,var(--rad-surface-gap,1rem))] text-start antialiased',\n 'rounded-[var(--rad-card-radius,var(--rad-surface-radius,0.75rem))]',\n '[corner-shape:var(--rad-card-corner-shape,var(--rad-surface-corner-shape,round))]',\n '[border-width:var(--rad-card-border-width,var(--rad-surface-border-width,1px))]',\n '[border-style:var(--rad-card-border-style,var(--rad-surface-border-style,solid))]',\n '[border-color:var(--rad-card-border-color,var(--rad-color-border,oklch(0.885_0.005_286)))]',\n 'bg-[var(--rad-card-background,var(--rad-color-surface,oklch(1_0_0)))]',\n '[color:var(--rad-card-color,var(--rad-color-foreground,oklch(0.21_0.006_286)))]',\n 'p-[var(--rad-card-padding,var(--rad-surface-padding,1.5rem))]',\n '[box-shadow:var(--rad-card-shadow,var(--rad-surface-shadow,0_1px_2px_0_rgb(0_0_0/0.06)))]',\n 'forced-colors:border-[CanvasText] forced-colors:bg-[Canvas] forced-colors:text-[CanvasText] forced-colors:shadow-none'\n])\n\nconst cardHeaderVariants = cva([\n 'grid min-w-0 gap-[var(--rad-card-header-gap,var(--rad-spacing-header-gap,0.375rem))]'\n])\n\nconst cardTitleVariants = cva([\n colorMotionClass,\n 'm-0 min-w-0 break-words leading-snug',\n '[font-size:var(--rad-card-title-size,var(--rad-typography-heading-size,1.125rem))]',\n '[font-weight:var(--rad-card-title-weight,var(--rad-typography-heading-weight,600))]',\n 'forced-colors:text-[CanvasText]'\n])\n\nconst cardDescriptionVariants = cva([\n colorMotionClass,\n 'm-0 min-w-0 break-words leading-snug',\n '[color:var(--rad-card-description-color,var(--rad-color-muted-foreground,oklch(0.45_0.01_286)))]',\n '[font-size:var(--rad-card-description-size,var(--rad-typography-small-size,0.8125rem))]',\n 'forced-colors:text-[CanvasText]'\n])\n\nconst cardContentVariants = cva(['min-w-0 break-words'])\n\nconst cardFooterVariants = cva([\n 'flex min-w-0 flex-wrap items-center gap-[var(--rad-card-footer-gap,var(--rad-spacing-footer-gap,0.5rem))]'\n])\n\nconst headingTag = {\n 1: 'h1',\n 2: 'h2',\n 3: 'h3',\n 4: 'h4',\n 5: 'h5',\n 6: 'h6'\n} as const\n\nexport type CardHeadingLevel = keyof typeof headingTag\n\ntype CardPartProps<Host extends 'div' | 'h2' | 'p'> = Omit<ComponentProps<Host>, 'style'> & {\n style?: ThemeStyle\n 'data-slot'?: string\n}\n\nexport type CardProps = CardPartProps<'div'>\n\nexport type CardHeaderProps = CardPartProps<'div'>\n\nexport type CardTitleProps = CardPartProps<'h2'> & {\n level?: CardHeadingLevel\n}\n\nexport type CardDescriptionProps = CardPartProps<'p'>\n\nexport type CardContentProps = CardPartProps<'div'>\n\nexport type CardFooterProps = CardPartProps<'div'>\n\nexport function Card({ className, ...props }: CardProps) {\n return (\n <div\n {...props}\n className={cn(cardVariants(), className)}\n data-slot={joinIds('card', props['data-slot'])}\n />\n )\n}\n\nexport function CardHeader({ className, ...props }: CardHeaderProps) {\n return (\n <div\n {...props}\n className={cn(cardHeaderVariants(), className)}\n data-slot={joinIds('card-header', props['data-slot'])}\n />\n )\n}\n\nexport function CardTitle({ level = 2, className, children, ...props }: CardTitleProps) {\n const Tag = headingTag[level]\n return (\n <Tag\n {...props}\n className={cn(cardTitleVariants(), className)}\n data-slot={joinIds('card-title', props['data-slot'])}\n >\n {children}\n </Tag>\n )\n}\n\nexport function CardDescription({ className, ...props }: CardDescriptionProps) {\n return (\n <p\n {...props}\n className={cn(cardDescriptionVariants(), className)}\n data-slot={joinIds('card-description', props['data-slot'])}\n />\n )\n}\n\nexport function CardContent({ className, ...props }: CardContentProps) {\n return (\n <div\n {...props}\n className={cn(cardContentVariants(), className)}\n data-slot={joinIds('card-content', props['data-slot'])}\n />\n )\n}\n\nexport function CardFooter({ className, ...props }: CardFooterProps) {\n return (\n <div\n {...props}\n className={cn(cardFooterVariants(), className)}\n data-slot={joinIds('card-footer', props['data-slot'])}\n />\n )\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ComponentProps, type ReactNode } from 'react';
|
|
2
|
+
import { type CheckedOwner } from './react/useNativeOwner.js';
|
|
3
|
+
import type { ThemeStyle } from './themes/defineTheme.js';
|
|
4
|
+
import type { ControlSize, ControlParts } from './presentation.js';
|
|
5
|
+
export type CheckboxProps = Omit<ComponentProps<'input'>, 'type' | 'checked' | 'defaultChecked' | 'style'> & CheckedOwner & {
|
|
6
|
+
label?: ReactNode;
|
|
7
|
+
indeterminate?: boolean;
|
|
8
|
+
controlSize?: ControlSize;
|
|
9
|
+
style?: ThemeStyle;
|
|
10
|
+
parts?: ControlParts;
|
|
11
|
+
};
|
|
12
|
+
export declare function Checkbox({ className, controlSize, parts, label, indeterminate, id, disabled, required, checked, defaultChecked, ref, 'aria-describedby': ariaDescribedBy, 'aria-invalid': ariaInvalid, 'aria-required': ariaRequired, ...props }: CheckboxProps): import("react").JSX.Element;
|
|
13
|
+
//# sourceMappingURL=Checkbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Checkbox.d.ts","sourceRoot":"","sources":["../../src/Checkbox.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAwC,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAIjG,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAE7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAyClE,MAAM,MAAM,aAAa,GAAG,IAAI,CAC9B,cAAc,CAAC,OAAO,CAAC,EACvB,MAAM,GAAG,SAAS,GAAG,gBAAgB,GAAG,OAAO,CAChD,GACC,YAAY,GAAG;IACb,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,KAAK,CAAC,EAAE,UAAU,CAAA;IAClB,KAAK,CAAC,EAAE,YAAY,CAAA;CACrB,CAAA;AAMH,wBAAgB,QAAQ,CAAC,EACvB,SAAS,EACT,WAAsB,EACtB,KAAK,EACL,KAAK,EACL,aAAqB,EACrB,EAAE,EACF,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,cAAc,EACd,GAAG,EACH,kBAAkB,EAAE,eAAe,EACnC,cAAc,EAAE,WAAW,EAC3B,eAAe,EAAE,YAAY,EAC7B,GAAG,KAAK,EACT,EAAE,aAAa,+BA0Gf"}
|