@okshaun/components 3.0.0 → 4.0.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/dist/icon-metadata.json +359 -42
- package/dist/index.js +12890 -5844
- package/dist/index.js.map +1 -1
- package/dist/panda.buildinfo.json +523 -501
- package/dist/{preset-BAn5LBiW.js → preset-BOFHjPdQ.js} +1986 -2045
- package/dist/preset-BOFHjPdQ.js.map +1 -0
- package/dist/preset.js +1 -1
- package/dist/specs/conditions.json +75 -51
- package/dist/specs/keyframes.json +22 -0
- package/dist/specs/recipes.json +222 -106
- package/dist/specs/semantic-tokens.json +152 -44
- package/dist/specs/tokens.json +16 -36
- package/dist/sprite.svg +1 -1
- package/dist/sprite.symbol.html +445 -44
- package/dist/styles.css +11268 -13251
- package/dist/svgs/cheese.svg +1 -0
- package/dist/svgs/collapse-vertical.svg +1 -0
- package/dist/svgs/expand-vertical.svg +1 -0
- package/dist/svgs/magnet.svg +1 -0
- package/dist/svgs/to-date-backward.svg +1 -0
- package/dist/svgs/to-date-forward.svg +1 -0
- package/dist/types/index.d.ts +2815 -288
- package/package.json +4 -2
- package/src/recipes/autocomplete.ts +266 -0
- package/src/recipes/badge.ts +25 -54
- package/src/recipes/button.ts +155 -316
- package/src/recipes/calendar.ts +91 -0
- package/src/recipes/card.ts +4 -70
- package/src/recipes/chip.ts +212 -266
- package/src/recipes/dateMenus.ts +40 -0
- package/src/recipes/dateTimeMenus.ts +43 -0
- package/src/recipes/kbd.ts +42 -39
- package/src/recipes/list.ts +11 -85
- package/src/recipes/listDensity.ts +66 -0
- package/src/recipes/listItem.ts +27 -166
- package/src/recipes/listItemGroup.ts +16 -16
- package/src/recipes/menu.ts +17 -3
- package/src/recipes/modal.ts +65 -65
- package/src/recipes/radio.ts +6 -6
- package/src/recipes/recipes-slot.ts +7 -2
- package/src/recipes/segmentedFields.ts +192 -0
- package/src/recipes/segmentedInputs.ts +109 -0
- package/src/recipes/tag.ts +218 -210
- package/src/recipes/text.ts +37 -19
- package/src/recipes/textInput.ts +103 -155
- package/src/recipes/themeSwitcher.ts +3 -3
- package/src/recipes/timeMenus.ts +110 -0
- package/src/recipes/toggle.ts +3 -1
- package/src/styles/primitives/shadows.ts +26 -60
- package/src/styles/primitives/zIndex.ts +1 -0
- package/src/styles/semantics/colors.ts +43 -0
- package/src/styles/semantics/shadows.ts +4 -30
- package/src/styles/semantics/zIndex.ts +2 -0
- package/src/styles/utilities/conditions.ts +61 -51
- package/src/styles/utilities/dropShadows.ts +51 -0
- package/src/styles/utilities/filters.ts +22 -7
- package/src/styles/utilities/globalStyle.ts +5 -2
- package/src/styles/utilities/index.ts +3 -0
- package/src/styles/utilities/keyframes.ts +27 -4
- package/src/styles/utilities/recipeGlobalStyles.ts +22 -0
- package/src/styles/utilities/shadowDefinitions.ts +112 -0
- package/src/utils/dsChain.ts +113 -0
- package/src/utils/dsComponent.ts +44 -0
- package/src/utils/dsPart.ts +41 -0
- package/dist/preset-BAn5LBiW.js.map +0 -1
- package/src/recipes/datePicker.ts +0 -234
- package/src/recipes/timePicker.ts +0 -216
|
@@ -6,6 +6,7 @@ import { defineSemanticTokens } from '@pandacss/dev';
|
|
|
6
6
|
* elevated → shadows.elevated (menus, dropdowns)
|
|
7
7
|
* overlay → shadows.overlay / surface.overlay (modal backdrop)
|
|
8
8
|
* modal → (modal container, above backdrop)
|
|
9
|
+
* modalFloating → (floating content inside a modal)
|
|
9
10
|
* tooltip → (always on top)
|
|
10
11
|
*/
|
|
11
12
|
export const zIndex = defineSemanticTokens.zIndex({
|
|
@@ -14,5 +15,6 @@ export const zIndex = defineSemanticTokens.zIndex({
|
|
|
14
15
|
elevated: { value: '{zIndex.1000}' },
|
|
15
16
|
overlay: { value: '{zIndex.1100}' },
|
|
16
17
|
modal: { value: '{zIndex.1101}' },
|
|
18
|
+
modalFloating: { value: '{zIndex.1102}' },
|
|
17
19
|
tooltip: { value: '{zIndex.1200}' },
|
|
18
20
|
});
|
|
@@ -1,28 +1,34 @@
|
|
|
1
|
+
// Adopted from the Cetec design system. The important difference is that every
|
|
2
|
+
// data-attribute condition matches `=true` rather than bare presence: React
|
|
3
|
+
// stringifies `false` for data-* props, so `data-disabled="false"` matched the
|
|
4
|
+
// looser selectors and rendered the element as disabled.
|
|
1
5
|
export const conditions = {
|
|
2
6
|
hover: '&:is(:hover, [data-hover=true])',
|
|
3
7
|
focus: '&:is(:focus, [data-focus=true])',
|
|
4
8
|
focusWithin: '&:focus-within',
|
|
5
9
|
focusVisible: '&:is(:focus-visible, [data-focus-visible=true])',
|
|
6
10
|
disabled:
|
|
7
|
-
'&:is(:disabled, [disabled], [data-disabled], [aria-disabled=true])',
|
|
11
|
+
'&:is(:disabled, [disabled], [data-disabled=true], [aria-disabled=true])',
|
|
8
12
|
deleted: '&:is(:deleted, [deleted], [data-deleted=true])',
|
|
9
13
|
active: '&:is(:active, [data-active=true])',
|
|
10
14
|
visited: '&:visited',
|
|
11
15
|
target: '&:target',
|
|
12
|
-
readOnly:
|
|
16
|
+
readOnly:
|
|
17
|
+
'&:is(:read-only, [readonly], [data-read-only=true], [aria-readonly=true])',
|
|
13
18
|
readWrite: '&:read-write',
|
|
14
|
-
empty: '&:is(:empty, [data-empty])',
|
|
19
|
+
empty: '&:is(:empty, [data-empty=true])',
|
|
15
20
|
checked:
|
|
16
|
-
'&:is(:checked, [data-checked], [aria-checked=true], [data-state="checked"])',
|
|
21
|
+
'&:is(:checked, [data-checked=true], [aria-checked=true], [data-state="checked"])',
|
|
17
22
|
enabled: '&:enabled',
|
|
18
23
|
expanded:
|
|
19
|
-
'&:is([aria-expanded=true], [data-expanded], [data-state="expanded"])',
|
|
24
|
+
'&:is([aria-expanded=true], [data-expanded=true], [data-state="expanded"])',
|
|
20
25
|
collapsed:
|
|
21
|
-
'&:is([aria-collapsed=true], [data-collapsed], [data-state="collapsed"])',
|
|
22
|
-
highlighted: '&[data-highlighted]',
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
'&:is([aria-collapsed=true], [data-collapsed=true], [data-state="collapsed"])',
|
|
27
|
+
highlighted: '&[data-highlighted=true]',
|
|
28
|
+
new: '&[data-new=true]',
|
|
29
|
+
complete: '&[data-complete=true]',
|
|
30
|
+
incomplete: '&[data-incomplete=true]',
|
|
31
|
+
dragging: '&[data-dragging=true]',
|
|
26
32
|
utility: '&[data-utility=true]',
|
|
27
33
|
|
|
28
34
|
before: '&::before',
|
|
@@ -44,68 +50,71 @@ export const conditions = {
|
|
|
44
50
|
lastOfType: '&:last-of-type',
|
|
45
51
|
onlyOfType: '&:only-of-type',
|
|
46
52
|
|
|
47
|
-
peerFocus: '.peer:is(:focus, [data-focus]) ~ &',
|
|
48
|
-
peerHover: '.peer:is(:hover, [data-hover]) ~ &',
|
|
49
|
-
peerActive: '.peer:is(:active, [data-active]) ~ &',
|
|
53
|
+
peerFocus: '.peer:is(:focus, [data-focus=true]) ~ &',
|
|
54
|
+
peerHover: '.peer:is(:hover, [data-hover=true]) ~ &',
|
|
55
|
+
peerActive: '.peer:is(:active, [data-active=true]) ~ &',
|
|
50
56
|
peerFocusWithin: '.peer:focus-within ~ &',
|
|
51
57
|
peerFocusVisible: '.peer:is(:focus-visible, [data-focus-visible]) ~ &',
|
|
52
58
|
peerDisabled:
|
|
53
|
-
'.peer:is(:disabled, [disabled], [data-disabled], [aria-disabled=true]) ~ &',
|
|
59
|
+
'.peer:is(:disabled, [disabled], [data-disabled=true], [aria-disabled=true]) ~ &',
|
|
54
60
|
peerChecked:
|
|
55
|
-
'.peer:is(:checked, [data-checked], [aria-checked=true], [data-state="checked"]) ~ &',
|
|
56
|
-
peerInvalid:
|
|
61
|
+
'.peer:is(:checked, [data-checked=true], [aria-checked=true], [data-state="checked"]) ~ &',
|
|
62
|
+
peerInvalid:
|
|
63
|
+
'.peer:is(:invalid, [data-invalid=true], [aria-invalid=true]) ~ &',
|
|
57
64
|
peerExpanded:
|
|
58
|
-
'.peer:is([aria-expanded=true], [data-expanded], [data-state="expanded"]) ~ &',
|
|
65
|
+
'.peer:is([aria-expanded=true], [data-expanded=true], [data-state="expanded"]) ~ &',
|
|
59
66
|
peerPlaceholderShown: '.peer:placeholder-shown ~ &',
|
|
60
67
|
|
|
61
|
-
groupFocus: '.group:is(:focus, [data-focus]) &',
|
|
62
|
-
groupHover: '.group:is(:hover, [data-hover]) &',
|
|
63
|
-
groupActive: '.group:is(:active, [data-active]) &',
|
|
68
|
+
groupFocus: '.group:is(:focus, [data-focus=true]) &',
|
|
69
|
+
groupHover: '.group:is(:hover, [data-hover=true]) &',
|
|
70
|
+
groupActive: '.group:is(:active, [data-active=true]) &',
|
|
64
71
|
groupFocusWithin: '.group:focus-within &',
|
|
65
|
-
groupFocusVisible: '.group:is(:focus-visible, [data-focus-visible]) &',
|
|
72
|
+
groupFocusVisible: '.group:is(:focus-visible, [data-focus-visible=true]) &',
|
|
66
73
|
groupDisabled:
|
|
67
|
-
'.group:is(:disabled, [disabled], [data-disabled], [aria-disabled=true]) &',
|
|
74
|
+
'.group:is(:disabled, [disabled], [data-disabled=true], [aria-disabled=true]) &',
|
|
68
75
|
groupChecked:
|
|
69
|
-
'.group:is(:checked, [data-checked], [aria-checked=true], [data-state="checked"]) &',
|
|
76
|
+
'.group:is(:checked, [data-checked=true], [aria-checked=true], [data-state="checked"]) &',
|
|
70
77
|
groupExpanded:
|
|
71
|
-
'.group:is([aria-expanded=true], [data-expanded], [data-state="expanded"]) &',
|
|
72
|
-
groupInvalid:
|
|
78
|
+
'.group:is([aria-expanded=true], [data-expanded=true], [data-state="expanded"]) &',
|
|
79
|
+
groupInvalid:
|
|
80
|
+
'.group:is(:invalid, [data-invalid=true], [aria-invalid=true]) &',
|
|
73
81
|
|
|
74
82
|
indeterminate:
|
|
75
|
-
'&:is(:indeterminate, [data-indeterminate], [aria-checked=mixed], [data-state="indeterminate"])',
|
|
76
|
-
required: '&:is(:required, [data-required], [aria-required=true])',
|
|
77
|
-
valid: '&:is(:valid, [data-valid])',
|
|
83
|
+
'&:is(:indeterminate, [data-indeterminate=true], [aria-checked=mixed], [data-state="indeterminate"])',
|
|
84
|
+
required: '&:is(:required, [data-required=true], [aria-required=true])',
|
|
85
|
+
valid: '&:is(:valid, [data-valid=true])',
|
|
78
86
|
invalid: '&:is(:invalid, [data-invalid=true], [aria-invalid=true])',
|
|
79
87
|
error: '&:is([data-error=true])',
|
|
88
|
+
success: '&:is([data-success=true])',
|
|
80
89
|
autofill: '&:autofill',
|
|
81
|
-
inRange: '&:is(:in-range, [data-in-range])',
|
|
82
|
-
outOfRange: '&:is(:out-of-range, [data-outside-range])',
|
|
83
|
-
placeholder: '&::placeholder, &[data-placeholder]',
|
|
84
|
-
placeholderShown: '&:is(:placeholder-shown, [data-placeholder-shown])',
|
|
85
|
-
pressed: '&:is([aria-pressed=true], [data-pressed])',
|
|
90
|
+
inRange: '&:is(:in-range, [data-in-range=true])',
|
|
91
|
+
outOfRange: '&:is(:out-of-range, [data-outside-range=true])',
|
|
92
|
+
placeholder: '&::placeholder, &[data-placeholder=true]',
|
|
93
|
+
placeholderShown: '&:is(:placeholder-shown, [data-placeholder-shown=true])',
|
|
94
|
+
pressed: '&:is([aria-pressed=true], [data-pressed=true])',
|
|
86
95
|
selected: '&:is([aria-selected=true], [data-selected=true])',
|
|
87
|
-
grabbed: '&:is([aria-grabbed=true], [data-grabbed])',
|
|
88
|
-
underValue: '&[data-state=under-value]',
|
|
89
|
-
overValue: '&[data-state=over-value]',
|
|
90
|
-
atValue: '&[data-state=at-value]',
|
|
96
|
+
grabbed: '&:is([aria-grabbed=true], [data-grabbed=true])',
|
|
97
|
+
underValue: '&[data-state="under-value"]',
|
|
98
|
+
overValue: '&[data-state="over-value"]',
|
|
99
|
+
atValue: '&[data-state="at-value"]',
|
|
91
100
|
|
|
92
101
|
default: '&:default',
|
|
93
102
|
optional: '&:optional',
|
|
94
|
-
open: '&:is([open], [data-open], [data-state="open"], :popover-open)',
|
|
95
|
-
closed: '&:is([closed], [data-closed], [data-state="closed"])',
|
|
96
|
-
fullscreen: '&:is(:fullscreen, [data-fullscreen])',
|
|
97
|
-
loading: '&:is([data-loading], [aria-busy=true])',
|
|
98
|
-
hidden: '&:is([hidden], [data-hidden])',
|
|
103
|
+
open: '&:is([open], [data-open=true], [data-state="open"], :popover-open)',
|
|
104
|
+
closed: '&:is([closed], [data-closed=true], [data-state="closed"])',
|
|
105
|
+
fullscreen: '&:is(:fullscreen, [data-fullscreen=true])',
|
|
106
|
+
loading: '&:is([data-loading=true], [aria-busy=true])',
|
|
107
|
+
hidden: '&:is([hidden], [data-hidden=true])',
|
|
99
108
|
|
|
100
|
-
current: '&:is([aria-current=true], [data-current])',
|
|
109
|
+
current: '&:is([aria-current=true], [data-current=true])',
|
|
101
110
|
currentPage: '&[aria-current=page]',
|
|
102
111
|
currentStep: '&[aria-current=step]',
|
|
103
|
-
today: '&:is([data-today])',
|
|
104
|
-
unavailable: '&[data-unavailable]',
|
|
105
|
-
rangeStart: '&[data-range-start]',
|
|
106
|
-
rangeEnd: '&[data-range-end]',
|
|
107
|
-
now: '&[data-now]',
|
|
108
|
-
topmost: '&[data-topmost]',
|
|
112
|
+
today: '&:is([data-today=true])',
|
|
113
|
+
unavailable: '&[data-unavailable=true]',
|
|
114
|
+
rangeStart: '&[data-range-start=true]',
|
|
115
|
+
rangeEnd: '&[data-range-end=true]',
|
|
116
|
+
now: '&[data-now=true]',
|
|
117
|
+
topmost: '&[data-topmost=true]',
|
|
109
118
|
|
|
110
119
|
motionReduce: '@media (prefers-reduced-motion: reduce)',
|
|
111
120
|
motionSafe: '@media (prefers-reduced-motion: no-preference)',
|
|
@@ -114,8 +123,9 @@ export const conditions = {
|
|
|
114
123
|
landscape: '@media (orientation: landscape)',
|
|
115
124
|
portrait: '@media (orientation: portrait)',
|
|
116
125
|
|
|
117
|
-
dark: '.dark &, &:is([data-color-mode=dark] *), [data-color-mode=dark] &',
|
|
118
|
-
light:
|
|
126
|
+
dark: '.dark &, &:is([data-color-mode="dark"] *), [data-color-mode="dark"] &',
|
|
127
|
+
light:
|
|
128
|
+
'.light &, &:is([data-color-mode="light"] *), [data-color-mode="light"] &',
|
|
119
129
|
osDark: '@media (prefers-color-scheme: dark)',
|
|
120
130
|
osLight: '@media (prefers-color-scheme: light)',
|
|
121
131
|
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { defineUtility } from '@pandacss/dev';
|
|
2
|
+
|
|
3
|
+
import { filterAutoValue } from './filters';
|
|
4
|
+
import {
|
|
5
|
+
type DropShadowName,
|
|
6
|
+
dropShadowColorToken,
|
|
7
|
+
elevationShadowDefinitions,
|
|
8
|
+
} from './shadowDefinitions';
|
|
9
|
+
|
|
10
|
+
const dropShadowValues = {
|
|
11
|
+
zero: 'zero',
|
|
12
|
+
raised: 'raised',
|
|
13
|
+
elevated: 'elevated',
|
|
14
|
+
overlay: 'overlay',
|
|
15
|
+
} satisfies Record<DropShadowName, DropShadowName>;
|
|
16
|
+
|
|
17
|
+
const resolveDropShadowValue = (
|
|
18
|
+
value: DropShadowName,
|
|
19
|
+
token: (path: string) => string | undefined,
|
|
20
|
+
) =>
|
|
21
|
+
elevationShadowDefinitions[value]
|
|
22
|
+
.map((layer) => {
|
|
23
|
+
const x = token(`sizes.${layer.x}`);
|
|
24
|
+
const y = token(`sizes.${layer.y}`);
|
|
25
|
+
const blur = token(`sizes.${layer.blur}`);
|
|
26
|
+
const color = token(dropShadowColorToken(layer.color));
|
|
27
|
+
|
|
28
|
+
if (!x || !y || !blur || !color) {
|
|
29
|
+
throw new Error(`Unable to resolve dropShadow token for ${value}`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return `drop-shadow(${x} ${y} ${blur} ${color})`;
|
|
33
|
+
})
|
|
34
|
+
.join(' ');
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Replaces Panda's built-in dropShadow utility so drop shadows use the same
|
|
38
|
+
* layer definitions as the boxShadow tokens. Writing through `--drop-shadow`
|
|
39
|
+
* keeps the value composable with the other filter slots.
|
|
40
|
+
*/
|
|
41
|
+
export const dropShadowProperty = defineUtility({
|
|
42
|
+
className: 'drop-shadow',
|
|
43
|
+
group: 'Effect',
|
|
44
|
+
values: dropShadowValues,
|
|
45
|
+
transform(value: DropShadowName, ctx) {
|
|
46
|
+
return {
|
|
47
|
+
filter: filterAutoValue,
|
|
48
|
+
'--drop-shadow': resolveDropShadowValue(value, ctx.token),
|
|
49
|
+
};
|
|
50
|
+
},
|
|
51
|
+
});
|
|
@@ -1,12 +1,27 @@
|
|
|
1
1
|
import { defineUtility } from '@pandacss/dev';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Every filter slot, each empty until a utility fills it. Composing through
|
|
5
|
+
* custom properties lets dropShadow set its own slot without clearing the rest.
|
|
6
|
+
* The string matches Panda's own `filter: auto` value, so the base utility and
|
|
7
|
+
* `dropShadow` stay in agreement.
|
|
8
|
+
*/
|
|
9
|
+
export const filterAutoValue =
|
|
10
|
+
'var(--blur, ) var(--brightness, ) var(--contrast, ) var(--grayscale, ) var(--hue-rotate, ) var(--invert, ) var(--saturate, ) var(--sepia, ) var(--drop-shadow, )';
|
|
11
|
+
|
|
12
|
+
export const filterValues = {
|
|
13
|
+
auto: filterAutoValue,
|
|
14
|
+
invert: 'invert(1)',
|
|
15
|
+
blur: 'blur(8px)',
|
|
16
|
+
none: 'none',
|
|
7
17
|
};
|
|
8
18
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Extends Panda's base `filter` utility, which ships `auto` alone, with the
|
|
21
|
+
* library's named filters.
|
|
22
|
+
*/
|
|
23
|
+
export const filterProperty = defineUtility({
|
|
24
|
+
className: 'filter',
|
|
25
|
+
group: 'Effect',
|
|
26
|
+
values: filterValues,
|
|
12
27
|
});
|
|
@@ -51,12 +51,15 @@ export const globalCss = defineGlobalStyles({
|
|
|
51
51
|
u: {
|
|
52
52
|
textDecoration: 'underline',
|
|
53
53
|
},
|
|
54
|
-
|
|
54
|
+
// `kbd` is deliberately excluded: the Kbd recipe owns its own type scale, and
|
|
55
|
+
// this element-selector rule sits in the `base` layer where it was beating
|
|
56
|
+
// the recipe's font-size. Cetec has no equivalent global rule.
|
|
57
|
+
'code, samp, pre': {
|
|
55
58
|
fontFamily: 'mono',
|
|
56
59
|
fontSize: '1em',
|
|
57
60
|
},
|
|
58
61
|
table: {
|
|
59
|
-
borderColor: 'border.subtle',
|
|
62
|
+
borderColor: 'token(colors.border.subtle)',
|
|
60
63
|
},
|
|
61
64
|
'button, input, optgroup, select, textarea': {
|
|
62
65
|
fontFamily: 'body',
|
|
@@ -4,9 +4,12 @@ export * from './breakpoints';
|
|
|
4
4
|
export * from './conditions';
|
|
5
5
|
export * from './containerSizes';
|
|
6
6
|
// Custom utilities we've added that are not part of Panda's core properties
|
|
7
|
+
export * from './dropShadows';
|
|
7
8
|
export * from './filters';
|
|
8
9
|
export * from './globalStyle';
|
|
9
10
|
export * from './keyframes';
|
|
10
11
|
export * from './layerStyles';
|
|
12
|
+
export * from './recipeGlobalStyles';
|
|
13
|
+
export * from './shadowDefinitions';
|
|
11
14
|
export * from './textStyles';
|
|
12
15
|
export * from './transitions';
|
|
@@ -70,24 +70,47 @@ export const keyframes = defineKeyframes({
|
|
|
70
70
|
'0%': { opacity: '1' },
|
|
71
71
|
'100%': { opacity: '0' },
|
|
72
72
|
},
|
|
73
|
+
// The dialog is centred by `place-content` on the position wrapper, so these
|
|
74
|
+
// carry no translate(-50%, -50%). The old absolutely-positioned modal needed
|
|
75
|
+
// one; keeping it shifted the panel up and left by half its size.
|
|
73
76
|
modalScaleIn: {
|
|
74
77
|
'0%': {
|
|
75
78
|
opacity: '0',
|
|
76
|
-
transform: '
|
|
79
|
+
transform: 'scale(0.95) translateY(20px)',
|
|
77
80
|
},
|
|
78
81
|
'100%': {
|
|
79
82
|
opacity: '1',
|
|
80
|
-
transform: '
|
|
83
|
+
transform: 'scale(1) translateY(0)',
|
|
81
84
|
},
|
|
82
85
|
},
|
|
83
86
|
modalScaleOut: {
|
|
84
87
|
'0%': {
|
|
85
88
|
opacity: '1',
|
|
86
|
-
transform: '
|
|
89
|
+
transform: 'scale(1) translateY(0)',
|
|
87
90
|
},
|
|
88
91
|
'100%': {
|
|
89
92
|
opacity: '0',
|
|
90
|
-
transform: '
|
|
93
|
+
transform: 'scale(0.95) translateY(20px)',
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
modalScaleInTop: {
|
|
97
|
+
'0%': {
|
|
98
|
+
opacity: '0',
|
|
99
|
+
transform: 'scale(0.97) translateY(-40px)',
|
|
100
|
+
},
|
|
101
|
+
'100%': {
|
|
102
|
+
opacity: '1',
|
|
103
|
+
transform: 'scale(1) translateY(0)',
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
modalScaleOutTop: {
|
|
107
|
+
'0%': {
|
|
108
|
+
opacity: '1',
|
|
109
|
+
transform: 'scale(1) translateY(0)',
|
|
110
|
+
},
|
|
111
|
+
'100%': {
|
|
112
|
+
opacity: '0',
|
|
113
|
+
transform: 'scale(0.97) translateY(-40px)',
|
|
91
114
|
},
|
|
92
115
|
},
|
|
93
116
|
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Baseline every recipe applies to its root-ish slots, ported from the Cetec
|
|
3
|
+
* design system so recipe output matches it structurally.
|
|
4
|
+
*
|
|
5
|
+
* Two deliberate differences, both about okshaun's own type identity:
|
|
6
|
+
*
|
|
7
|
+
* - Cetec sets `fontFamily: 'body'` because Recursive is its UI face. okshaun's
|
|
8
|
+
* `body` token is Piazzolla, a serif, and its UI face is `sans`. Copying the
|
|
9
|
+
* token name rather than the meaning would render every component in a serif.
|
|
10
|
+
* - Cetec also sets `fontVariationSettings` from its `fontVariants` map, whose
|
|
11
|
+
* axes (MONO, CRSV, CASL, slnt) belong to Recursive. IBM Plex Sans and
|
|
12
|
+
* Piazzolla do not expose them, so there is nothing to set here.
|
|
13
|
+
*/
|
|
14
|
+
export const globalBaseStyles = {
|
|
15
|
+
boxSizing: 'border-box',
|
|
16
|
+
margin: 0,
|
|
17
|
+
padding: 0,
|
|
18
|
+
fontFamily: 'sans',
|
|
19
|
+
fontWeight: 'normal',
|
|
20
|
+
lineHeight: 'default',
|
|
21
|
+
color: 'text.subtlest',
|
|
22
|
+
};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { ColorToken, NumericSizeToken } from '@styled-system/tokens';
|
|
2
|
+
|
|
3
|
+
type ShadowColorPath =
|
|
4
|
+
| 'shadow.raised.1'
|
|
5
|
+
| 'shadow.raised.2'
|
|
6
|
+
| 'shadow.elevated.1'
|
|
7
|
+
| 'shadow.elevated.2'
|
|
8
|
+
| 'shadow.elevated.3'
|
|
9
|
+
| 'shadow.overlay.1'
|
|
10
|
+
| 'shadow.overlay.2'
|
|
11
|
+
| 'shadow.overlay.3'
|
|
12
|
+
| 'shadow.overflow.1'
|
|
13
|
+
| 'shadow.overflow.2'
|
|
14
|
+
| 'transparent';
|
|
15
|
+
|
|
16
|
+
type ShadowLayer = {
|
|
17
|
+
x: NumericSizeToken;
|
|
18
|
+
y: NumericSizeToken;
|
|
19
|
+
blur: NumericSizeToken;
|
|
20
|
+
color: ShadowColorPath;
|
|
21
|
+
spread?: NumericSizeToken;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type ShadowMode = 'light' | 'dark';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Geometry for each elevation, declared once and consumed by both the boxShadow
|
|
28
|
+
* primitives and the dropShadow utility so the two cannot drift apart. Only the
|
|
29
|
+
* colour differs between modes, except for `overflow`, which also widens.
|
|
30
|
+
*/
|
|
31
|
+
export const elevationShadowDefinitions = {
|
|
32
|
+
zero: [
|
|
33
|
+
{ x: '0', y: '0', blur: '0', color: 'transparent' },
|
|
34
|
+
{ x: '0', y: '0', blur: '0', color: 'transparent' },
|
|
35
|
+
],
|
|
36
|
+
raised: [
|
|
37
|
+
{ x: '0', y: '1', blur: '1', color: 'shadow.raised.1' },
|
|
38
|
+
{ x: '0', y: '0', blur: '1', color: 'shadow.raised.2' },
|
|
39
|
+
],
|
|
40
|
+
elevated: [
|
|
41
|
+
{ x: '0', y: '0', blur: '0', color: 'shadow.elevated.1' },
|
|
42
|
+
{ x: '0', y: '4', blur: '7', color: 'shadow.elevated.2' },
|
|
43
|
+
{ x: '0', y: '0', blur: '1', color: 'shadow.elevated.3' },
|
|
44
|
+
],
|
|
45
|
+
overlay: [
|
|
46
|
+
{ x: '0', y: '0', blur: '0', color: 'shadow.overlay.1' },
|
|
47
|
+
{ x: '0', y: '8', blur: '12', color: 'shadow.overlay.2' },
|
|
48
|
+
{ x: '0', y: '0', blur: '1', color: 'shadow.overlay.3' },
|
|
49
|
+
],
|
|
50
|
+
overflow: [
|
|
51
|
+
{ x: '0', y: '0', blur: '8', color: 'shadow.overflow.1' },
|
|
52
|
+
{ x: '0', y: '0', blur: '1', color: 'shadow.overflow.2' },
|
|
53
|
+
],
|
|
54
|
+
} as const satisfies Record<string, readonly ShadowLayer[]>;
|
|
55
|
+
|
|
56
|
+
/** Dark mode widens the overflow blur. Every other elevation varies by colour. */
|
|
57
|
+
export const darkElevationShadowDefinitions = {
|
|
58
|
+
overflow: [
|
|
59
|
+
{ x: '0', y: '0', blur: '12', color: 'shadow.overflow.1' },
|
|
60
|
+
{ x: '0', y: '0', blur: '1', color: 'shadow.overflow.2' },
|
|
61
|
+
],
|
|
62
|
+
} as const satisfies Record<string, readonly ShadowLayer[]>;
|
|
63
|
+
|
|
64
|
+
export type ElevationShadowName = keyof typeof elevationShadowDefinitions;
|
|
65
|
+
export type DropShadowName = Exclude<ElevationShadowName, 'overflow'>;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* boxShadow primitives are declared on `:root`, and a custom property that
|
|
69
|
+
* references another resolves in the scope where it is DEFINED, not where it is
|
|
70
|
+
* used. A `:root`-level `var(--colors-shadow-raised-1)` would therefore stay on
|
|
71
|
+
* the light value inside a locally dark subtree. So each primitive names a
|
|
72
|
+
* mode-specific colour and the light/dark switch happens on the shadow token.
|
|
73
|
+
*/
|
|
74
|
+
const boxShadowColor = (color: ShadowColorPath, mode: ShadowMode) =>
|
|
75
|
+
color === 'transparent'
|
|
76
|
+
? '{colors.transparent}'
|
|
77
|
+
: `{colors.${color}.${mode}}`;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* dropShadow is emitted on the element that uses it, so its `var()` resolves in
|
|
81
|
+
* the using scope. It can read the mode-aware semantic colour directly.
|
|
82
|
+
*/
|
|
83
|
+
export const dropShadowColorToken = (color: ShadowColorPath) =>
|
|
84
|
+
(color === 'transparent' ? 'colors.transparent' : `colors.${color}`) as
|
|
85
|
+
| 'colors.transparent'
|
|
86
|
+
| `colors.${ColorToken}`;
|
|
87
|
+
|
|
88
|
+
const formatBoxShadowLayer = (layer: ShadowLayer, mode: ShadowMode) =>
|
|
89
|
+
[
|
|
90
|
+
`{sizes.${layer.x}}`,
|
|
91
|
+
`{sizes.${layer.y}}`,
|
|
92
|
+
`{sizes.${layer.blur}}`,
|
|
93
|
+
layer.spread ? `{sizes.${layer.spread}}` : undefined,
|
|
94
|
+
boxShadowColor(layer.color, mode),
|
|
95
|
+
]
|
|
96
|
+
.filter(Boolean)
|
|
97
|
+
.join(' ');
|
|
98
|
+
|
|
99
|
+
export const getBoxShadowPrimitive = (
|
|
100
|
+
name: ElevationShadowName,
|
|
101
|
+
mode: ShadowMode,
|
|
102
|
+
) =>
|
|
103
|
+
elevationShadowDefinitions[name]
|
|
104
|
+
.map((layer) => formatBoxShadowLayer(layer, mode))
|
|
105
|
+
.join(', ');
|
|
106
|
+
|
|
107
|
+
export const getDarkBoxShadowPrimitive = (
|
|
108
|
+
name: keyof typeof darkElevationShadowDefinitions,
|
|
109
|
+
) =>
|
|
110
|
+
darkElevationShadowDefinitions[name]
|
|
111
|
+
.map((layer) => formatBoxShadowLayer(layer, 'dark'))
|
|
112
|
+
.join(', ');
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Attribute name that carries a resolved interaction chain on a portal root.
|
|
5
|
+
* Always lowercase and hyphenated; HTML lowercases attribute names, so a
|
|
6
|
+
* camelCase spelling would silently produce a different attribute.
|
|
7
|
+
*/
|
|
8
|
+
export const DS_CHAIN_ATTRIBUTE = 'data-ds-chain';
|
|
9
|
+
|
|
10
|
+
/** Separator written between chain nodes in the serialized attribute value. */
|
|
11
|
+
export const DS_CHAIN_SEPARATOR = '>';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Attribute marking the wrapper a portal's contents render into. Written
|
|
15
|
+
* unconditionally, including when the resolved chain is empty, so a consumer
|
|
16
|
+
* walking up the DOM can tell a portal boundary from an ordinary element and
|
|
17
|
+
* stop there instead of continuing into `document.body`.
|
|
18
|
+
*/
|
|
19
|
+
export const DS_PORTAL_ROOT_ATTRIBUTE = 'data-ds-portal-root';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Maximum number of chain nodes retained. The nearest nodes are kept because
|
|
23
|
+
* the leaf end of the chain is what identifies an interaction; page-level
|
|
24
|
+
* object identity is carried separately rather than through this chain.
|
|
25
|
+
*/
|
|
26
|
+
export const DS_CHAIN_MAX_DEPTH = 5;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Attribute carrying business-object identity. The application authors it — on
|
|
30
|
+
* a layout wrapper for legacy Perl screens, on individual elements on React
|
|
31
|
+
* screens. The design system never invents a value; it only copies one onto a
|
|
32
|
+
* portal root, which is the single place DOM ancestry cannot supply it.
|
|
33
|
+
*/
|
|
34
|
+
export const DS_OBJECT_ATTRIBUTE = 'data-track-object';
|
|
35
|
+
|
|
36
|
+
// Module-level constant so every reader outside a scope shares one identity.
|
|
37
|
+
// A fresh `[]` default would hand consumers a new value on each render and
|
|
38
|
+
// defeat the memoization in the provider.
|
|
39
|
+
const EMPTY_CHAIN: readonly string[] = Object.freeze([]);
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Carries the `data-testid` values of the enclosing tagged elements, nearest
|
|
43
|
+
* last. React context walks the React tree rather than the DOM, so portaled
|
|
44
|
+
* content still resolves the chain of the subtree that rendered it.
|
|
45
|
+
*/
|
|
46
|
+
export const DsChainContext = createContext<readonly string[]>(EMPTY_CHAIN);
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Returns the interaction chain for the current position in the React tree.
|
|
50
|
+
*
|
|
51
|
+
* Returns a shared empty array outside any scope, so the result is safe to read
|
|
52
|
+
* unconditionally.
|
|
53
|
+
*/
|
|
54
|
+
export const useDsChain = (): readonly string[] => useContext(DsChainContext);
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Appends a `data-testid` value to a chain, keeping the nearest
|
|
58
|
+
* `DS_CHAIN_MAX_DEPTH` nodes.
|
|
59
|
+
*
|
|
60
|
+
* A value equal to the innermost node is dropped rather than repeated. Two
|
|
61
|
+
* supported arrangements produce that case: a component that opens a scope
|
|
62
|
+
* above its root and also writes the same id on an inner element, and a
|
|
63
|
+
* consumer that wraps a design-system component in `DsChainScope` using the
|
|
64
|
+
* `data-testid` that component already emits. Neither is an error, and a
|
|
65
|
+
* repeated node carries no information while it consumes one of five slots.
|
|
66
|
+
*
|
|
67
|
+
* Only the innermost node is compared. A legitimately recurring id further out
|
|
68
|
+
* — a nested grid inside a grid — still contributes, because the repeat there
|
|
69
|
+
* describes real structure.
|
|
70
|
+
*/
|
|
71
|
+
export const extendDsChain = (
|
|
72
|
+
chain: readonly string[],
|
|
73
|
+
testId: string,
|
|
74
|
+
): readonly string[] => {
|
|
75
|
+
if (chain[chain.length - 1] === testId) return chain;
|
|
76
|
+
|
|
77
|
+
const next = [...chain, testId];
|
|
78
|
+
|
|
79
|
+
return next.length > DS_CHAIN_MAX_DEPTH
|
|
80
|
+
? next.slice(-DS_CHAIN_MAX_DEPTH)
|
|
81
|
+
: next;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Serializes a chain for the `data-ds-chain` attribute.
|
|
86
|
+
*
|
|
87
|
+
* Returns `undefined` for an empty chain so React omits the attribute instead
|
|
88
|
+
* of emitting an empty string that consumers would have to special-case.
|
|
89
|
+
*/
|
|
90
|
+
export const dsChainValue = (chain: readonly string[]): string | undefined =>
|
|
91
|
+
chain.length > 0 ? chain.join(DS_CHAIN_SEPARATOR) : undefined;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Resolves the business object governing `element` by walking up the DOM to the
|
|
95
|
+
* nearest ancestor carrying `DS_OBJECT_ATTRIBUTE`, `element` itself included.
|
|
96
|
+
*
|
|
97
|
+
* Nearest wins. A legacy Perl screen tags one layout wrapper, so every element
|
|
98
|
+
* on it resolves to the same object; a React screen tags individual elements,
|
|
99
|
+
* so an interaction resolves to the region it started in rather than to the
|
|
100
|
+
* page. Both fall out of the same walk.
|
|
101
|
+
*
|
|
102
|
+
* Returns `undefined` when no ancestor is tagged — including for an element
|
|
103
|
+
* that is not in the document, and for an empty attribute value — so React
|
|
104
|
+
* omits the attribute instead of emitting an empty string that a consumer would
|
|
105
|
+
* have to special-case. An untagged screen must produce no answer, never a
|
|
106
|
+
* borrowed one.
|
|
107
|
+
*/
|
|
108
|
+
export const dsObjectValue = (
|
|
109
|
+
element: Element | null | undefined,
|
|
110
|
+
): string | undefined =>
|
|
111
|
+
element
|
|
112
|
+
?.closest(`[${DS_OBJECT_ATTRIBUTE}]`)
|
|
113
|
+
?.getAttribute(DS_OBJECT_ATTRIBUTE) || undefined;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Attribute name that identifies which design-system component rendered a DOM
|
|
3
|
+
* element. Always lowercase and hyphenated; HTML lowercases attribute names, so
|
|
4
|
+
* a camelCase spelling would silently produce a different attribute.
|
|
5
|
+
*/
|
|
6
|
+
export const DS_COMPONENT_ATTRIBUTE = 'data-ds-component';
|
|
7
|
+
|
|
8
|
+
/** Attribute record applied to a design-system component's root element. */
|
|
9
|
+
export type DsComponentAttribute = {
|
|
10
|
+
'data-ds-component': string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Returns the `data-ds-component` attribute for a component's root element.
|
|
15
|
+
*
|
|
16
|
+
* Spread the result as the first attribute on the root element so a
|
|
17
|
+
* consumer-supplied `data-ds-component` in the component's rest props still
|
|
18
|
+
* wins. When rest props are forwarded to a nested element instead of the root,
|
|
19
|
+
* pull `data-ds-component` out of the props first and pass it as `override` so
|
|
20
|
+
* the explicit value lands on the root and does not leak onto the inner
|
|
21
|
+
* element.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```tsx
|
|
25
|
+
* // Rest props are spread on the root: ordering handles the override.
|
|
26
|
+
* <Box {...dsComponent('Badge')} className={classes.root} {...otherProps} />
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```tsx
|
|
31
|
+
* // Rest props are forwarded to a nested control: pass the override through.
|
|
32
|
+
* const { 'data-ds-component': dsComponentName, ...rest } = props;
|
|
33
|
+
*
|
|
34
|
+
* <Box {...dsComponent('Checkbox', dsComponentName)}>
|
|
35
|
+
* <Box as="input" {...otherProps} />
|
|
36
|
+
* </Box>;
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export const dsComponent = (
|
|
40
|
+
name: string,
|
|
41
|
+
override?: string,
|
|
42
|
+
): DsComponentAttribute => ({
|
|
43
|
+
[DS_COMPONENT_ATTRIBUTE]: override ?? name,
|
|
44
|
+
});
|