@atom-learning/components 2.59.0 → 2.59.2
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/components/checkbox/Checkbox.js +1 -1
- package/dist/components/checkbox/Checkbox.js.map +1 -1
- package/dist/components/navigation/NavigationMenu.d.ts +222 -4
- package/dist/components/navigation/NavigationMenu.js +1 -1
- package/dist/components/navigation/NavigationMenu.js.map +1 -1
- package/dist/components/number-input/NumberInput.d.ts +3 -2
- package/dist/components/number-input/NumberInput.js +1 -1
- package/dist/components/number-input/NumberInput.js.map +1 -1
- package/dist/components/number-input-field/NumberInputField.js +1 -1
- package/dist/components/number-input-field/NumberInputField.js.map +1 -1
- package/dist/docgen.json +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/package.json +1 -1
- package/CHANGELOG.md +0 -217
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Minus as d,Ok as m}from"@atom-learning/icons";import*as t from"@radix-ui/react-checkbox";import*as o from"react";import{styled as a}from"../../stitches.js";import{
|
|
1
|
+
import{Minus as d,Ok as m}from"@atom-learning/icons";import*as t from"@radix-ui/react-checkbox";import*as o from"react";import{styled as a}from"../../stitches.js";import{overrideStitchesVariantValue as c}from"../../utilities/override-stitches-variant-value/overrideStitchesVariantValue.js";import{Icon as p}from"../icon/Icon.js";const u=a(t.Indicator,{position:"absolute",top:"50%",left:"50%",transform:"translateX(-50%) translateY(-50%)"}),f=a(t.Root,{appearance:"none",position:"relative",backgroundColor:"transparent",border:"1px solid $colors$tonal400",borderRadius:"3px",color:"white",cursor:"pointer",size:"$1",p:0,display:"flex",alignItems:"center",justifyContent:"center",transition:"all 50ms ease-out",'&[data-state="checked"]':{backgroundColor:"$primary",borderColor:"$primary"},'&[data-state="indeterminate"]':{backgroundColor:"$primary",borderColor:"$primary"},"&:focus":{outline:"2px solid $primary",outlineOffset:"1px"},"&[disabled]":{backgroundColor:"$tonal100",borderColor:"$tonal400",cursor:"not-allowed",color:"$tonal400"},variants:{state:{error:{borderColor:"$danger"}},size:{md:{size:"$1"},lg:{size:"$2",mt:"-$1"}}}}),$={md:"sm",lg:"md"},i=o.forwardRef(({size:r="md",...e},s)=>{const n=o.useMemo(()=>c(r,l=>$[l]),[r]);return o.createElement(f,{...e,size:r,ref:s},o.createElement(u,{asChild:!0},o.createElement(p,{is:e.checked==="indeterminate"?d:m,css:{strokeWidth:"3"},size:n})))});i.displayName="Checkbox";export{i as Checkbox};
|
|
2
2
|
//# sourceMappingURL=Checkbox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.js","sources":["../../../src/components/checkbox/Checkbox.tsx"],"sourcesContent":["import { Minus, Ok } from '@atom-learning/icons'\nimport * as RadixCheckbox from '@radix-ui/react-checkbox'\nimport * as React from 'react'\n\nimport { styled } from '~/stitches'\
|
|
1
|
+
{"version":3,"file":"Checkbox.js","sources":["../../../src/components/checkbox/Checkbox.tsx"],"sourcesContent":["import { Minus, Ok } from '@atom-learning/icons'\nimport * as RadixCheckbox from '@radix-ui/react-checkbox'\nimport * as React from 'react'\n\nimport { styled } from '~/stitches'\nimport { overrideStitchesVariantValue } from '~/utilities/override-stitches-variant-value/overrideStitchesVariantValue'\n\nimport { Icon } from '../icon'\n\nconst StyledIndicator = styled(RadixCheckbox.Indicator, {\n position: 'absolute',\n top: '50%',\n left: '50%',\n transform: 'translateX(-50%) translateY(-50%)'\n})\n\nconst StyledCheckbox = styled(RadixCheckbox.Root, {\n appearance: 'none',\n position: 'relative',\n backgroundColor: 'transparent',\n border: '1px solid $colors$tonal400',\n borderRadius: '3px',\n color: 'white',\n cursor: 'pointer',\n size: '$1',\n p: 0,\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n transition: 'all 50ms ease-out',\n '&[data-state=\"checked\"]': {\n backgroundColor: '$primary',\n borderColor: '$primary'\n },\n '&[data-state=\"indeterminate\"]': {\n backgroundColor: '$primary',\n borderColor: '$primary'\n },\n '&:focus': {\n outline: '2px solid $primary',\n outlineOffset: '1px'\n },\n '&[disabled]': {\n backgroundColor: '$tonal100',\n borderColor: '$tonal400',\n cursor: 'not-allowed',\n color: '$tonal400'\n },\n variants: {\n state: {\n error: {\n borderColor: '$danger'\n }\n },\n size: {\n md: {\n size: '$1'\n },\n lg: {\n size: '$2',\n mt: '-$1'\n }\n }\n }\n})\n\nconst toIconSize = {\n md: 'sm',\n lg: 'md'\n}\n\ntype CheckboxProps = React.ComponentProps<typeof StyledCheckbox>\n\nexport const Checkbox: React.FC<CheckboxProps> = React.forwardRef(\n ({ size = 'md', ...props }, ref) => {\n const iconSize = React.useMemo(\n () => overrideStitchesVariantValue(size, (s) => toIconSize[s]),\n [size]\n )\n\n return (\n <StyledCheckbox {...props} size={size} ref={ref}>\n <StyledIndicator asChild>\n <Icon\n is={props.checked === 'indeterminate' ? Minus : Ok}\n css={{\n strokeWidth: '3'\n }}\n size={iconSize}\n />\n </StyledIndicator>\n </StyledCheckbox>\n )\n }\n)\n\nCheckbox.displayName = 'Checkbox'\n"],"names":["StyledIndicator","styled","RadixCheckbox","StyledCheckbox","toIconSize","Checkbox","React","size","props","ref","iconSize","overrideStitchesVariantValue","s","Icon","Minus","Ok"],"mappings":"yUASA,MAAMA,EAAkBC,EAAOC,EAAc,UAAW,CACtD,SAAU,WACV,IAAK,MACL,KAAM,MACN,UAAW,mCACb,CAAC,EAEKC,EAAiBF,EAAOC,EAAc,KAAM,CAChD,WAAY,OACZ,SAAU,WACV,gBAAiB,cACjB,OAAQ,6BACR,aAAc,MACd,MAAO,QACP,OAAQ,UACR,KAAM,KACN,EAAG,EACH,QAAS,OACT,WAAY,SACZ,eAAgB,SAChB,WAAY,oBACZ,0BAA2B,CACzB,gBAAiB,WACjB,YAAa,UACf,EACA,gCAAiC,CAC/B,gBAAiB,WACjB,YAAa,UACf,EACA,UAAW,CACT,QAAS,qBACT,cAAe,KACjB,EACA,cAAe,CACb,gBAAiB,YACjB,YAAa,YACb,OAAQ,cACR,MAAO,WACT,EACA,SAAU,CACR,MAAO,CACL,MAAO,CACL,YAAa,SACf,CACF,EACA,KAAM,CACJ,GAAI,CACF,KAAM,IACR,EACA,GAAI,CACF,KAAM,KACN,GAAI,KACN,CACF,CACF,CACF,CAAC,EAEKE,EAAa,CACjB,GAAI,KACJ,GAAI,IACN,EAIaC,EAAoCC,EAAM,WACrD,CAAC,CAAE,KAAAC,EAAO,QAASC,CAAM,EAAGC,IAAQ,CAClC,MAAMC,EAAWJ,EAAM,QACrB,IAAMK,EAA6BJ,EAAOK,GAAMR,EAAWQ,EAAE,EAC7D,CAACL,CAAI,CACP,EAEA,OACED,EAAA,cAACH,EAAA,CAAgB,GAAGK,EAAO,KAAMD,EAAM,IAAKE,CAAAA,EAC1CH,EAAA,cAACN,EAAA,CAAgB,QAAO,EACtBM,EAAAA,EAAA,cAACO,EAAA,CACC,GAAIL,EAAM,UAAY,gBAAkBM,EAAQC,EAChD,IAAK,CACH,YAAa,GACf,EACA,KAAML,CACR,CAAA,CACF,CACF,CAEJ,CACF,EAEAL,EAAS,YAAc"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import * as NavigationMenuPrimitive from '@radix-ui/react-navigation-menu';
|
|
1
2
|
import React from 'react';
|
|
2
|
-
import { CSS } from '../../stitches';
|
|
3
3
|
import { NavigationMenuDropdown } from './NavigationMenuDropdown';
|
|
4
4
|
import { NavigationMenuDropdownContent } from './NavigationMenuDropdownContent';
|
|
5
5
|
import { NavigationMenuDropdownItem, NavigationMenuDropdownItemTitle } from './NavigationMenuDropdownItem';
|
|
@@ -13,8 +13,226 @@ declare type NavigationMenuSubComponents = {
|
|
|
13
13
|
DropdownItemTitle: typeof NavigationMenuDropdownItemTitle;
|
|
14
14
|
DropdownTrigger: typeof NavigationMenuDropdownTrigger;
|
|
15
15
|
};
|
|
16
|
-
declare
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
declare const StyledMenu: import("@stitches/react/types/styled-component").StyledComponent<React.ForwardRefExoticComponent<NavigationMenuPrimitive.NavigationMenuProps & React.RefAttributes<HTMLElement>>, {}, {
|
|
17
|
+
sm: string;
|
|
18
|
+
md: string;
|
|
19
|
+
lg: string;
|
|
20
|
+
xl: string;
|
|
21
|
+
reducedMotion: string;
|
|
22
|
+
allowMotion: string;
|
|
23
|
+
hover: string;
|
|
24
|
+
}, import("@stitches/react/types/css-util").CSS<{
|
|
25
|
+
sm: string;
|
|
26
|
+
md: string;
|
|
27
|
+
lg: string;
|
|
28
|
+
xl: string;
|
|
29
|
+
reducedMotion: string;
|
|
30
|
+
allowMotion: string;
|
|
31
|
+
hover: string;
|
|
32
|
+
}, {
|
|
33
|
+
colors: {
|
|
34
|
+
textForeground: any;
|
|
35
|
+
textSubtle: any;
|
|
36
|
+
textPlaceholder: any;
|
|
37
|
+
background: any;
|
|
38
|
+
backgroundAccent: any;
|
|
39
|
+
grey100: any;
|
|
40
|
+
grey200: any;
|
|
41
|
+
grey300: any;
|
|
42
|
+
grey400: any;
|
|
43
|
+
grey500: any;
|
|
44
|
+
grey600: any;
|
|
45
|
+
grey700: any;
|
|
46
|
+
grey800: any;
|
|
47
|
+
grey900: any;
|
|
48
|
+
grey1000: any;
|
|
49
|
+
grey1100: any;
|
|
50
|
+
grey1200: any;
|
|
51
|
+
blue100: any;
|
|
52
|
+
blue200: any;
|
|
53
|
+
blue300: any;
|
|
54
|
+
blue400: any;
|
|
55
|
+
blue500: any;
|
|
56
|
+
blue600: any;
|
|
57
|
+
blue700: any;
|
|
58
|
+
blue800: any;
|
|
59
|
+
blue900: any;
|
|
60
|
+
blue1000: any;
|
|
61
|
+
blue1100: any;
|
|
62
|
+
blue1200: any;
|
|
63
|
+
purple100: any;
|
|
64
|
+
purple200: any;
|
|
65
|
+
purple300: any;
|
|
66
|
+
purple400: any;
|
|
67
|
+
purple500: any;
|
|
68
|
+
purple600: any;
|
|
69
|
+
purple700: any;
|
|
70
|
+
purple800: any;
|
|
71
|
+
purple900: any;
|
|
72
|
+
purple1000: any;
|
|
73
|
+
purple1100: any;
|
|
74
|
+
purple1200: any;
|
|
75
|
+
tonal50: any;
|
|
76
|
+
tonal100: any;
|
|
77
|
+
tonal200: any;
|
|
78
|
+
tonal300: any;
|
|
79
|
+
tonal400: any;
|
|
80
|
+
tonal500: any;
|
|
81
|
+
tonal600: any;
|
|
82
|
+
alpha100: any;
|
|
83
|
+
alpha150: any;
|
|
84
|
+
alpha200: any;
|
|
85
|
+
alpha250: any;
|
|
86
|
+
alpha600: any;
|
|
87
|
+
primaryLight: any;
|
|
88
|
+
primary: any;
|
|
89
|
+
primaryMid: any;
|
|
90
|
+
primaryDark: any;
|
|
91
|
+
secondary: any;
|
|
92
|
+
brandRed: any;
|
|
93
|
+
brandRedAccent: any;
|
|
94
|
+
brandGreen: any;
|
|
95
|
+
brandGreenAccent: any;
|
|
96
|
+
brandPurple: any;
|
|
97
|
+
brandPurpleAccent: any;
|
|
98
|
+
brandYellow: any;
|
|
99
|
+
brandYellowAccent: any;
|
|
100
|
+
successLight: any;
|
|
101
|
+
success: any;
|
|
102
|
+
successMid: any;
|
|
103
|
+
successDark: any;
|
|
104
|
+
dangerLight: any;
|
|
105
|
+
danger: any;
|
|
106
|
+
dangerMid: any;
|
|
107
|
+
dangerDark: any;
|
|
108
|
+
warningLight: any;
|
|
109
|
+
warning: any;
|
|
110
|
+
warningMid: any;
|
|
111
|
+
warningDark: any;
|
|
112
|
+
warningText: any;
|
|
113
|
+
subjectEnglish: any;
|
|
114
|
+
subjectMaths: any;
|
|
115
|
+
subjectScience: any;
|
|
116
|
+
subjectVerbalReasoning: any;
|
|
117
|
+
subjectNonVerbalReasoning: any;
|
|
118
|
+
subjectCreativeWriting: any;
|
|
119
|
+
subjectExamSkills: any;
|
|
120
|
+
};
|
|
121
|
+
space: {
|
|
122
|
+
"0": any;
|
|
123
|
+
"1": any;
|
|
124
|
+
"2": any;
|
|
125
|
+
"3": any;
|
|
126
|
+
"4": any;
|
|
127
|
+
"5": any;
|
|
128
|
+
"6": any;
|
|
129
|
+
"7": any;
|
|
130
|
+
"8": any;
|
|
131
|
+
"9": any;
|
|
132
|
+
"24": any;
|
|
133
|
+
};
|
|
134
|
+
fontSizes: {
|
|
135
|
+
xs: any;
|
|
136
|
+
sm: any;
|
|
137
|
+
md: any;
|
|
138
|
+
lg: any;
|
|
139
|
+
xl: any;
|
|
140
|
+
"2xl": any;
|
|
141
|
+
"3xl": any;
|
|
142
|
+
"4xl": any;
|
|
143
|
+
};
|
|
144
|
+
fonts: {
|
|
145
|
+
sans: any;
|
|
146
|
+
mono: any;
|
|
147
|
+
display: any;
|
|
148
|
+
body: any;
|
|
149
|
+
};
|
|
150
|
+
sizes: {
|
|
151
|
+
"0": any;
|
|
152
|
+
"1": any;
|
|
153
|
+
"2": any;
|
|
154
|
+
"3": any;
|
|
155
|
+
"4": any;
|
|
156
|
+
"5": any;
|
|
157
|
+
"6": any;
|
|
158
|
+
"7": any;
|
|
159
|
+
"8": any;
|
|
160
|
+
};
|
|
161
|
+
radii: {
|
|
162
|
+
"0": any;
|
|
163
|
+
"1": any;
|
|
164
|
+
"2": any;
|
|
165
|
+
"3": any;
|
|
166
|
+
round: any;
|
|
167
|
+
};
|
|
168
|
+
shadows: {
|
|
169
|
+
"0": any;
|
|
170
|
+
"1": any;
|
|
171
|
+
"2": any;
|
|
172
|
+
"3": any;
|
|
173
|
+
};
|
|
174
|
+
ratios: {
|
|
175
|
+
"16-9": any;
|
|
176
|
+
"3-2": any;
|
|
177
|
+
"4-3": any;
|
|
178
|
+
"1-1": any;
|
|
179
|
+
"3-4": any;
|
|
180
|
+
};
|
|
181
|
+
}, import("@stitches/react/types/config").DefaultThemeMap, {
|
|
182
|
+
bg: (value: import("@stitches/react/types/css-util").WithPropertyValue<"background">) => {
|
|
183
|
+
background: import("@stitches/react/types/css-util").WithPropertyValue<"background">;
|
|
184
|
+
};
|
|
185
|
+
size: (value: string | number | import("@stitches/react/types/css-util").WithScaleValue<"size">) => {
|
|
186
|
+
height: string | number | import("@stitches/react/types/css-util").WithScaleValue<"size">;
|
|
187
|
+
width: string | number | import("@stitches/react/types/css-util").WithScaleValue<"size">;
|
|
188
|
+
};
|
|
189
|
+
p: (value: string | number | import("@stitches/react/types/css-util").WithScaleValue<"space">) => {
|
|
190
|
+
padding: string | number | import("@stitches/react/types/css-util").WithScaleValue<"space">;
|
|
191
|
+
};
|
|
192
|
+
pt: (value: string | number | import("@stitches/react/types/css-util").WithScaleValue<"space">) => {
|
|
193
|
+
paddingTop: string | number | import("@stitches/react/types/css-util").WithScaleValue<"space">;
|
|
194
|
+
};
|
|
195
|
+
pr: (value: string | number | import("@stitches/react/types/css-util").WithScaleValue<"space">) => {
|
|
196
|
+
paddingRight: string | number | import("@stitches/react/types/css-util").WithScaleValue<"space">;
|
|
197
|
+
};
|
|
198
|
+
pb: (value: string | number | import("@stitches/react/types/css-util").WithScaleValue<"space">) => {
|
|
199
|
+
paddingBottom: string | number | import("@stitches/react/types/css-util").WithScaleValue<"space">;
|
|
200
|
+
};
|
|
201
|
+
pl: (value: string | number | import("@stitches/react/types/css-util").WithScaleValue<"space">) => {
|
|
202
|
+
paddingLeft: string | number | import("@stitches/react/types/css-util").WithScaleValue<"space">;
|
|
203
|
+
};
|
|
204
|
+
px: (value: string | number | import("@stitches/react/types/css-util").WithScaleValue<"space">) => {
|
|
205
|
+
paddingLeft: string | number | import("@stitches/react/types/css-util").WithScaleValue<"space">;
|
|
206
|
+
paddingRight: string | number | import("@stitches/react/types/css-util").WithScaleValue<"space">;
|
|
207
|
+
};
|
|
208
|
+
py: (value: string | number | import("@stitches/react/types/css-util").WithScaleValue<"space">) => {
|
|
209
|
+
paddingTop: string | number | import("@stitches/react/types/css-util").WithScaleValue<"space">;
|
|
210
|
+
paddingBottom: string | number | import("@stitches/react/types/css-util").WithScaleValue<"space">;
|
|
211
|
+
};
|
|
212
|
+
m: (value: string | number | import("@stitches/react/types/css-util").WithScaleValue<"space">) => {
|
|
213
|
+
margin: string | number | import("@stitches/react/types/css-util").WithScaleValue<"space">;
|
|
214
|
+
};
|
|
215
|
+
mt: (value: string | number | import("@stitches/react/types/css-util").WithScaleValue<"space">) => {
|
|
216
|
+
marginTop: string | number | import("@stitches/react/types/css-util").WithScaleValue<"space">;
|
|
217
|
+
};
|
|
218
|
+
mr: (value: string | number | import("@stitches/react/types/css-util").WithScaleValue<"space">) => {
|
|
219
|
+
marginRight: string | number | import("@stitches/react/types/css-util").WithScaleValue<"space">;
|
|
220
|
+
};
|
|
221
|
+
mb: (value: string | number | import("@stitches/react/types/css-util").WithScaleValue<"space">) => {
|
|
222
|
+
marginBottom: string | number | import("@stitches/react/types/css-util").WithScaleValue<"space">;
|
|
223
|
+
};
|
|
224
|
+
ml: (value: string | number | import("@stitches/react/types/css-util").WithScaleValue<"space">) => {
|
|
225
|
+
marginLeft: string | number | import("@stitches/react/types/css-util").WithScaleValue<"space">;
|
|
226
|
+
};
|
|
227
|
+
mx: (value: string | number | import("@stitches/react/types/css-util").WithScaleValue<"space">) => {
|
|
228
|
+
marginLeft: string | number | import("@stitches/react/types/css-util").WithScaleValue<"space">;
|
|
229
|
+
marginRight: string | number | import("@stitches/react/types/css-util").WithScaleValue<"space">;
|
|
230
|
+
};
|
|
231
|
+
my: (value: string | number | import("@stitches/react/types/css-util").WithScaleValue<"space">) => {
|
|
232
|
+
marginTop: string | number | import("@stitches/react/types/css-util").WithScaleValue<"space">;
|
|
233
|
+
marginBottom: string | number | import("@stitches/react/types/css-util").WithScaleValue<"space">;
|
|
234
|
+
};
|
|
235
|
+
}>>;
|
|
236
|
+
declare type NavigationMenuProps = React.ComponentProps<typeof StyledMenu>;
|
|
19
237
|
export declare const NavigationMenu: React.FC<NavigationMenuProps> & NavigationMenuSubComponents;
|
|
20
238
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import*as m from"@radix-ui/react-navigation-menu";import t from"react";import{MAX_Z_INDEX as N}from"../../constants/zIndices.js";import{keyframes as D,styled as n}from"../../stitches.js";import{fadeOut as
|
|
1
|
+
import*as m from"@radix-ui/react-navigation-menu";import t from"react";import{MAX_Z_INDEX as N}from"../../constants/zIndices.js";import{keyframes as D,styled as n}from"../../stitches.js";import{fadeOut as E}from"../../utilities/style/keyframe-animations.js";import{NavigationMenuContext as h}from"./NavigationMenuContext.js";import{NavigationMenuDropdown as x}from"./NavigationMenuDropdown.js";import{NavigationMenuDropdownContent as C}from"./NavigationMenuDropdownContent.js";import{NavigationMenuDropdownItem as I,NavigationMenuDropdownItemTitle as $}from"./NavigationMenuDropdownItem.js";import{NavigationMenuDropdownTrigger as T}from"./NavigationMenuDropdownTrigger.js";import{NavigationMenuLink as L}from"./NavigationMenuLink.js";const _=D({"0%, 50%":{opacity:0},"100%":{opacity:1}}),k=n(m.Root,{display:"flex",justifyContent:"center",position:"relative"}),S=n(m.List,{all:"unset",display:"flex",justifyContent:"center",alignItems:"center",gap:"$1",listStyle:"none"}),j=n(m.Viewport,{zIndex:N}),V=n("div",{position:"absolute",left:0,top:"100%",width:"100%",display:"flex",justifyContent:"center"}),o=({children:f,css:u,...p})=>{const[d,l]=t.useState(),[r,c]=t.useState(),[i,g]=t.useState(0),a=t.useRef(null),s=200;t.useLayoutEffect(()=>{a.current&&g(a.current.offsetWidth)},[]),t.useEffect(()=>{let e;return r===""&&(e=setTimeout(()=>l(null),s)),()=>{e!==null&&clearTimeout(e)}},[r]);const v=(e,y)=>{if(e&&i&&r===y){const w=i/2,M=i-e.offsetLeft-e.offsetWidth+e.offsetWidth/2;l(Math.round(w-M))}return e};return t.createElement(h.Provider,{value:{onNodeUpdate:v}},t.createElement(k,{onValueChange:c,css:u,...p},t.createElement(S,{ref:a},f),t.createElement(V,null,t.createElement(j,{css:{transform:`translateX(${d||0}px)`,'&[data-state="open"]':{animation:`${_} ${s}ms ease`},'&[data-state="closed"]':{animation:`${E} ${s}ms ease-out`}}}))))};o.Link=L,o.Dropdown=x,o.DropdownContent=C,o.DropdownItem=I,o.DropdownItemTitle=$,o.DropdownTrigger=T,o.displayName="NavigationMenu";export{o as NavigationMenu};
|
|
2
2
|
//# sourceMappingURL=NavigationMenu.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationMenu.js","sources":["../../../src/components/navigation/NavigationMenu.tsx"],"sourcesContent":["import * as NavigationMenuPrimitive from '@radix-ui/react-navigation-menu'\nimport React from 'react'\n\nimport { MAX_Z_INDEX } from '~/constants/zIndices'\nimport { CSS, keyframes, styled } from '~/stitches'\nimport { fadeOut } from '~/utilities/style/keyframe-animations'\n\nimport { NavigationMenuContext } from './NavigationMenuContext'\nimport { NavigationMenuDropdown } from './NavigationMenuDropdown'\nimport { NavigationMenuDropdownContent } from './NavigationMenuDropdownContent'\nimport {\n NavigationMenuDropdownItem,\n NavigationMenuDropdownItemTitle\n} from './NavigationMenuDropdownItem'\nimport { NavigationMenuDropdownTrigger } from './NavigationMenuDropdownTrigger'\nimport { NavigationMenuLink } from './NavigationMenuLink'\n\ntype NavigationMenuSubComponents = {\n Link: typeof NavigationMenuLink\n Dropdown: typeof NavigationMenuDropdown\n DropdownContent: typeof NavigationMenuDropdownContent\n DropdownItem: typeof NavigationMenuDropdownItem\n DropdownItemTitle: typeof NavigationMenuDropdownItemTitle\n DropdownTrigger: typeof NavigationMenuDropdownTrigger\n}\n\nconst delayedFadeIn = keyframes({\n '0%, 50%': { opacity: 0 },\n '100%': { opacity: 1 }\n})\n\nconst StyledMenu = styled(NavigationMenuPrimitive.Root, {\n display: 'flex',\n justifyContent: 'center',\n position: 'relative'\n})\n\nconst StyledList = styled(NavigationMenuPrimitive.List, {\n all: 'unset',\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\n gap: '$1',\n listStyle: 'none'\n})\n\nconst StyledViewport = styled(NavigationMenuPrimitive.Viewport, {\n zIndex: MAX_Z_INDEX\n})\n\nconst ViewportPosition = styled('div', {\n position: 'absolute',\n left: 0,\n top: '100%',\n width: '100%',\n display: 'flex',\n justifyContent: 'center'\n})\n\ntype NavigationMenuProps =
|
|
1
|
+
{"version":3,"file":"NavigationMenu.js","sources":["../../../src/components/navigation/NavigationMenu.tsx"],"sourcesContent":["import * as NavigationMenuPrimitive from '@radix-ui/react-navigation-menu'\nimport React from 'react'\n\nimport { MAX_Z_INDEX } from '~/constants/zIndices'\nimport { CSS, keyframes, styled } from '~/stitches'\nimport { fadeOut } from '~/utilities/style/keyframe-animations'\n\nimport { NavigationMenuContext } from './NavigationMenuContext'\nimport { NavigationMenuDropdown } from './NavigationMenuDropdown'\nimport { NavigationMenuDropdownContent } from './NavigationMenuDropdownContent'\nimport {\n NavigationMenuDropdownItem,\n NavigationMenuDropdownItemTitle\n} from './NavigationMenuDropdownItem'\nimport { NavigationMenuDropdownTrigger } from './NavigationMenuDropdownTrigger'\nimport { NavigationMenuLink } from './NavigationMenuLink'\n\ntype NavigationMenuSubComponents = {\n Link: typeof NavigationMenuLink\n Dropdown: typeof NavigationMenuDropdown\n DropdownContent: typeof NavigationMenuDropdownContent\n DropdownItem: typeof NavigationMenuDropdownItem\n DropdownItemTitle: typeof NavigationMenuDropdownItemTitle\n DropdownTrigger: typeof NavigationMenuDropdownTrigger\n}\n\nconst delayedFadeIn = keyframes({\n '0%, 50%': { opacity: 0 },\n '100%': { opacity: 1 }\n})\n\nconst StyledMenu = styled(NavigationMenuPrimitive.Root, {\n display: 'flex',\n justifyContent: 'center',\n position: 'relative'\n})\n\nconst StyledList = styled(NavigationMenuPrimitive.List, {\n all: 'unset',\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\n gap: '$1',\n listStyle: 'none'\n})\n\nconst StyledViewport = styled(NavigationMenuPrimitive.Viewport, {\n zIndex: MAX_Z_INDEX\n})\n\nconst ViewportPosition = styled('div', {\n position: 'absolute',\n left: 0,\n top: '100%',\n width: '100%',\n display: 'flex',\n justifyContent: 'center'\n})\n\ntype NavigationMenuProps = React.ComponentProps<typeof StyledMenu>\n\nexport const NavigationMenu: React.FC<NavigationMenuProps> &\n NavigationMenuSubComponents = ({ children, css, ...props }) => {\n const [offset, setOffset] = React.useState<number | null | undefined>()\n const [activeItem, setActiveItem] = React.useState<string | undefined>()\n const [listWidth, setListWidth] = React.useState(0)\n const listRef = React.useRef<HTMLUListElement>(null)\n const fadeDuration = 200\n\n React.useLayoutEffect(() => {\n if (listRef.current) {\n setListWidth(listRef.current.offsetWidth)\n }\n }, [])\n\n React.useEffect(() => {\n let timer: NodeJS.Timer\n\n // Delay transitioning back to initial position\n // to allow enough time for fadeOut animation to complete\n if (activeItem === '') {\n timer = setTimeout(() => setOffset(null), fadeDuration)\n }\n\n return () => {\n if (timer !== null) {\n clearTimeout(timer)\n }\n }\n }, [activeItem])\n\n // https://github.com/radix-ui/primitives/issues/1462\n const onNodeUpdate = (trigger: HTMLButtonElement, itemValue: string) => {\n if (trigger && listWidth && activeItem === itemValue) {\n const listCenter = listWidth / 2\n\n const triggerOffsetRight =\n listWidth -\n trigger.offsetLeft -\n trigger.offsetWidth +\n trigger.offsetWidth / 2\n\n setOffset(Math.round(listCenter - triggerOffsetRight))\n }\n\n return trigger\n }\n\n return (\n <NavigationMenuContext.Provider value={{ onNodeUpdate }}>\n <StyledMenu onValueChange={setActiveItem} css={css} {...props}>\n <StyledList ref={listRef}>{children}</StyledList>\n <ViewportPosition>\n <StyledViewport\n css={{\n transform: `translateX(${offset || 0}px)`,\n '&[data-state=\"open\"]': {\n animation: `${delayedFadeIn} ${fadeDuration}ms ease`\n },\n '&[data-state=\"closed\"]': {\n animation: `${fadeOut} ${fadeDuration}ms ease-out`\n }\n }}\n />\n </ViewportPosition>\n </StyledMenu>\n </NavigationMenuContext.Provider>\n )\n}\n\nNavigationMenu.Link = NavigationMenuLink\nNavigationMenu.Dropdown = NavigationMenuDropdown\nNavigationMenu.DropdownContent = NavigationMenuDropdownContent\nNavigationMenu.DropdownItem = NavigationMenuDropdownItem\nNavigationMenu.DropdownItemTitle = NavigationMenuDropdownItemTitle\nNavigationMenu.DropdownTrigger = NavigationMenuDropdownTrigger\n\nNavigationMenu.displayName = 'NavigationMenu'\n"],"names":["delayedFadeIn","keyframes","StyledMenu","styled","NavigationMenuPrimitive","StyledList","StyledViewport","MAX_Z_INDEX","ViewportPosition","NavigationMenu","children","css","props","offset","setOffset","React","activeItem","setActiveItem","listWidth","setListWidth","listRef","fadeDuration","timer","onNodeUpdate","trigger","itemValue","listCenter","triggerOffsetRight","NavigationMenuContext","fadeOut","NavigationMenuLink","NavigationMenuDropdown","NavigationMenuDropdownContent","NavigationMenuDropdownItem","NavigationMenuDropdownItemTitle","NavigationMenuDropdownTrigger"],"mappings":"+tBA0BA,MAAMA,EAAgBC,EAAU,CAC9B,UAAW,CAAE,QAAS,CAAE,EACxB,OAAQ,CAAE,QAAS,CAAE,CACvB,CAAC,EAEKC,EAAaC,EAAOC,EAAwB,KAAM,CACtD,QAAS,OACT,eAAgB,SAChB,SAAU,UACZ,CAAC,EAEKC,EAAaF,EAAOC,EAAwB,KAAM,CACtD,IAAK,QACL,QAAS,OACT,eAAgB,SAChB,WAAY,SACZ,IAAK,KACL,UAAW,MACb,CAAC,EAEKE,EAAiBH,EAAOC,EAAwB,SAAU,CAC9D,OAAQG,CACV,CAAC,EAEKC,EAAmBL,EAAO,MAAO,CACrC,SAAU,WACV,KAAM,EACN,IAAK,OACL,MAAO,OACP,QAAS,OACT,eAAgB,QAClB,CAAC,EAIYM,EACmB,CAAC,CAAE,SAAAC,EAAU,IAAAC,KAAQC,CAAM,IAAM,CAC/D,KAAM,CAACC,EAAQC,CAAS,EAAIC,EAAM,SAAA,EAC5B,CAACC,EAAYC,CAAa,EAAIF,EAAM,SAA6B,EACjE,CAACG,EAAWC,CAAY,EAAIJ,EAAM,SAAS,CAAC,EAC5CK,EAAUL,EAAM,OAAyB,IAAI,EAC7CM,EAAe,IAErBN,EAAM,gBAAgB,IAAM,CACtBK,EAAQ,SACVD,EAAaC,EAAQ,QAAQ,WAAW,CAE5C,EAAG,CAAE,CAAA,EAELL,EAAM,UAAU,IAAM,CACpB,IAAIO,EAIJ,OAAIN,IAAe,KACjBM,EAAQ,WAAW,IAAMR,EAAU,IAAI,EAAGO,CAAY,GAGjD,IAAM,CACPC,IAAU,MACZ,aAAaA,CAAK,CAEtB,CACF,EAAG,CAACN,CAAU,CAAC,EAGf,MAAMO,EAAe,CAACC,EAA4BC,IAAsB,CACtE,GAAID,GAAWN,GAAaF,IAAeS,EAAW,CACpD,MAAMC,EAAaR,EAAY,EAEzBS,EACJT,EACAM,EAAQ,WACRA,EAAQ,YACRA,EAAQ,YAAc,EAExBV,EAAU,KAAK,MAAMY,EAAaC,CAAkB,CAAC,CACvD,CAEA,OAAOH,CACT,EAEA,OACET,EAAA,cAACa,EAAsB,SAAtB,CAA+B,MAAO,CAAE,aAAAL,CAAa,CACpDR,EAAAA,EAAA,cAACb,EAAA,CAAW,cAAee,EAAe,IAAKN,EAAM,GAAGC,CACtDG,EAAAA,EAAA,cAACV,EAAA,CAAW,IAAKe,CAAAA,EAAUV,CAAS,EACpCK,EAAA,cAACP,EAAA,KACCO,EAAA,cAACT,EAAA,CACC,IAAK,CACH,UAAW,cAAcO,GAAU,OACnC,uBAAwB,CACtB,UAAW,GAAGb,KAAiBqB,UACjC,EACA,yBAA0B,CACxB,UAAW,GAAGQ,KAAWR,cAC3B,CACF,CAAA,CACF,CACF,CACF,CACF,CAEJ,EAEAZ,EAAe,KAAOqB,EACtBrB,EAAe,SAAWsB,EAC1BtB,EAAe,gBAAkBuB,EACjCvB,EAAe,aAAewB,EAC9BxB,EAAe,kBAAoByB,EACnCzB,EAAe,gBAAkB0B,EAEjC1B,EAAe,YAAc"}
|
|
@@ -5,11 +5,12 @@ export interface NumberInputProps {
|
|
|
5
5
|
min?: number;
|
|
6
6
|
max?: number;
|
|
7
7
|
step?: number;
|
|
8
|
-
|
|
8
|
+
value?: number;
|
|
9
|
+
defaultValue?: number;
|
|
9
10
|
disabled?: boolean;
|
|
10
11
|
readonly?: boolean;
|
|
11
12
|
size?: 'sm' | 'md';
|
|
12
|
-
|
|
13
|
+
onValueChange?: (value: number) => void;
|
|
13
14
|
stepperButtonLabels?: {
|
|
14
15
|
increment?: string;
|
|
15
16
|
decrement?: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Minus as
|
|
1
|
+
import{Minus as S,Plus as B}from"@atom-learning/icons";import*as t from"react";import{Flex as H}from"../flex/Flex.js";import{Input as $}from"../input/Input.js";import{NumberInputStepper as g}from"./NumberInputStepper.js";const k=t.forwardRef(({value:d,defaultValue:N=0,onValueChange:C,min:r=0,max:o=Number.MAX_SAFE_INTEGER,step:m=1,disabled:i=!1,readonly:u=!1,size:w="md",stepperButtonLabels:T,disabledTooltipContent:y,css:A,...L},z)=>{const[a,E]=t.useState(d||N);t.useEffect(()=>{typeof d<"u"&&E(d)},[d]);const s=t.useRef(null);t.useImperativeHandle(z,()=>s.current);const R={increment:"increment",decrement:"decrement",...T},h={decrement:`Cannot enter values below ${r}`,increment:`Cannot enter values above ${o}`,...y},c=a>=o,b=a<=r,p=t.useCallback(e=>Math.min(Math.max(e,r),o),[o,r]),n=t.useCallback(e=>{C==null||C(e),E(e)},[C]),D=t.useCallback(e=>{const l=Number(e.target.value.replace(/\D/g,""));n(l)},[n]),f=t.useCallback(()=>{var e;if(c||u)return;(e=s==null?void 0:s.current)==null||e.focus();const l=Number(a)+m;n(p(l))},[p,c,u,m,n,a]),v=t.useCallback(()=>{var e;if(b||u)return;(e=s==null?void 0:s.current)==null||e.focus();const l=Number(a)-m;n(p(l))},[p,b,u,r,m,n,a]),I=t.useCallback(e=>{if(e.nativeEvent.isComposing)return;const l=e.key,x={ArrowUp:f,ArrowRight:f,ArrowDown:v,ArrowLeft:v,Home:()=>n(r),End:()=>n(o)}[l];x&&(e.preventDefault(),x(e))},[f,v,n,r,o]),M={type:"number",value:a,...L,onChange:D,onKeyDown:I,size:w,css:{borderRadius:"0px",width:"$6","&:disabled":{opacity:.3,pointerEvents:"none"}},ref:s,readOnly:u,disabled:i,"aria-valuemin":r,"aria-valuemax":o,"aria-valuenow":a,role:"spinbutton"};return t.createElement(H,{css:A},t.createElement(g,{onClick:v,icon:S,css:{borderRight:"none",borderTopRightRadius:"0px",borderBottomRightRadius:"0px"},size:w,disabled:b||i,showTooltip:b&&!i,disabledTooltipContent:h.decrement,label:R.decrement}),t.createElement($,{...M}),t.createElement(g,{onClick:f,icon:B,css:{borderLeft:"none",borderTopLeftRadius:"0px",borderBottomLeftRadius:"0px"},size:w,disabled:c||i,showTooltip:c&&!i,disabledTooltipContent:h.increment,label:R.increment}))});k.displayName="NumberInput";export{k as NumberInput};
|
|
2
2
|
//# sourceMappingURL=NumberInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumberInput.js","sources":["../../../src/components/number-input/NumberInput.tsx"],"sourcesContent":["import { Minus, Plus } from '@atom-learning/icons'\nimport * as React from 'react'\n\nimport type { CSS } from '~/stitches'\n\nimport { Flex } from '../flex'\nimport { Input } from '../input'\nimport { NumberInputStepper } from './NumberInputStepper'\n\nexport interface NumberInputProps {\n name: string\n min?: number\n max?: number\n step?: number\n
|
|
1
|
+
{"version":3,"file":"NumberInput.js","sources":["../../../src/components/number-input/NumberInput.tsx"],"sourcesContent":["import { Minus, Plus } from '@atom-learning/icons'\nimport * as React from 'react'\n\nimport type { CSS } from '~/stitches'\n\nimport { Flex } from '../flex'\nimport { Input } from '../input'\nimport { NumberInputStepper } from './NumberInputStepper'\n\nexport interface NumberInputProps {\n name: string\n min?: number\n max?: number\n step?: number\n value?: number\n defaultValue?: number\n disabled?: boolean\n readonly?: boolean\n size?: 'sm' | 'md'\n onValueChange?: (value: number) => void\n stepperButtonLabels?: { increment?: string; decrement?: string }\n disabledTooltipContent?: { increment?: string; decrement?: string }\n css?: CSS\n}\n\nexport const NumberInput = React.forwardRef<HTMLInputElement, NumberInputProps>(\n (\n {\n value,\n defaultValue = 0,\n onValueChange,\n min = 0,\n max = Number.MAX_SAFE_INTEGER,\n step = 1,\n disabled: isDisabled = false,\n readonly: isReadOnly = false,\n size = 'md',\n stepperButtonLabels: stepperButtonLabelsProp,\n disabledTooltipContent: disabledTooltipContentProp,\n css,\n ...rest\n },\n ref\n ): JSX.Element => {\n const [internalValue, setInternalValue] = React.useState<number>(\n value || defaultValue\n )\n React.useEffect(() => {\n // Update the internal value to match what is passed in.\n if (typeof value !== 'undefined') setInternalValue(value)\n }, [value])\n\n const inputRef = React.useRef<HTMLInputElement | null>(null)\n\n React.useImperativeHandle(ref, () => inputRef.current as HTMLInputElement)\n\n const stepperButtonLabels = {\n increment: 'increment',\n decrement: 'decrement',\n ...stepperButtonLabelsProp\n }\n\n const disabledTooltipContent = {\n decrement: `Cannot enter values below ${min}`,\n increment: `Cannot enter values above ${max}`,\n ...disabledTooltipContentProp\n }\n\n const isAtMax = internalValue >= max\n const isAtMin = internalValue <= min\n\n const clamp = React.useCallback(\n (internalValue: number) => Math.min(Math.max(internalValue, min), max),\n [max, min]\n )\n\n const updateValue = React.useCallback(\n (newValue: number) => {\n onValueChange?.(newValue)\n setInternalValue(newValue)\n },\n [onValueChange]\n )\n\n const onInputChange = React.useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) => {\n const parsedValue = Number(event.target.value.replace(/\\D/g, ''))\n updateValue(parsedValue)\n },\n [updateValue]\n )\n\n const increment = React.useCallback(() => {\n if (isAtMax || isReadOnly) return\n inputRef?.current?.focus()\n const newValue = Number(internalValue) + step\n updateValue(clamp(newValue))\n }, [clamp, isAtMax, isReadOnly, step, updateValue, internalValue])\n\n const decrement = React.useCallback(() => {\n if (isAtMin || isReadOnly) return\n inputRef?.current?.focus()\n const newValue = Number(internalValue) - step\n updateValue(clamp(newValue))\n }, [clamp, isAtMin, isReadOnly, min, step, updateValue, internalValue])\n\n const onKeyDown = React.useCallback(\n (event: React.KeyboardEvent) => {\n if (event.nativeEvent.isComposing) return\n\n /**\n * Keyboard Accessibility\n *\n * We want to increase or decrease the input's value\n * based on if the user the arrow keys.\n *\n * @see https://www.w3.org/TR/wai-aria-practices-1.1/#keyboard-interaction-17\n */\n const eventKey = event.key\n\n const keyMap: Record<string, React.KeyboardEventHandler> = {\n ArrowUp: increment,\n ArrowRight: increment,\n ArrowDown: decrement,\n ArrowLeft: decrement,\n Home: () => updateValue(min),\n End: () => updateValue(max)\n }\n\n const action = keyMap[eventKey]\n\n if (action) {\n event.preventDefault()\n action(event)\n }\n },\n [increment, decrement, updateValue, min, max]\n )\n\n const inputProps: React.ComponentProps<typeof Input> = {\n type: 'number',\n value: internalValue,\n ...rest,\n onChange: onInputChange,\n onKeyDown,\n size,\n css: {\n borderRadius: '0px',\n width: '$6',\n '&:disabled': { opacity: 0.3, pointerEvents: 'none' }\n },\n ref: inputRef,\n readOnly: isReadOnly,\n disabled: isDisabled,\n 'aria-valuemin': min,\n 'aria-valuemax': max,\n 'aria-valuenow': internalValue,\n role: 'spinbutton'\n }\n\n return (\n <Flex css={css}>\n <NumberInputStepper\n onClick={decrement}\n icon={Minus}\n css={{\n borderRight: 'none',\n borderTopRightRadius: '0px',\n borderBottomRightRadius: '0px'\n }}\n size={size}\n disabled={isAtMin || isDisabled}\n showTooltip={isAtMin && !isDisabled}\n disabledTooltipContent={disabledTooltipContent.decrement}\n label={stepperButtonLabels.decrement}\n />\n <Input {...inputProps} />\n <NumberInputStepper\n onClick={increment}\n icon={Plus}\n css={{\n borderLeft: 'none',\n borderTopLeftRadius: '0px',\n borderBottomLeftRadius: '0px'\n }}\n size={size}\n disabled={isAtMax || isDisabled}\n showTooltip={isAtMax && !isDisabled}\n disabledTooltipContent={disabledTooltipContent.increment}\n label={stepperButtonLabels.increment}\n />\n </Flex>\n )\n }\n)\n\nNumberInput.displayName = 'NumberInput'\n"],"names":["NumberInput","React","value","defaultValue","onValueChange","min","max","step","isDisabled","isReadOnly","size","stepperButtonLabelsProp","disabledTooltipContentProp","css","rest","ref","internalValue","setInternalValue","inputRef","stepperButtonLabels","disabledTooltipContent","isAtMax","isAtMin","clamp","updateValue","newValue","onInputChange","event","parsedValue","increment","_a","decrement","onKeyDown","eventKey","action","inputProps","Flex","NumberInputStepper","Minus","Input","Plus"],"mappings":"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"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import*as
|
|
1
|
+
import*as l from"react";import{useFormContext as I,useController as N}from"react-hook-form";import{FieldWrapper as V}from"../field-wrapper/FieldWrapper.js";import"../field-wrapper/InlineFieldWrapper.js";import"../form/Form.js";import{useFieldError as E}from"../form/useFieldError.js";import{NumberInput as g}from"../number-input/NumberInput.js";const m=({css:p,defaultValue:t=0,value:r,prompt:d,description:s,label:f,name:e,validation:o,onValueChange:a,...c})=>{const{control:v}=I(),{field:{ref:F,onChange:n,value:b,name:C}}=N({name:e,control:v,rules:o,defaultValue:t}),{error:u}=E(e);return l.useEffect(()=>{typeof r<"u"&&n(r)},[r]),l.createElement(V,{css:p,description:s,error:u,fieldId:e,label:f,prompt:d,required:Boolean(o==null?void 0:o.required)},l.createElement(g,{id:e,name:C,ref:F,...u&&{state:"error","aria-invalid":!0},defaultValue:t,onValueChange:i=>{n(i),a==null||a(i)},value:b,...c}))};m.displayName="NumberInputField";export{m as NumberInputField};
|
|
2
2
|
//# sourceMappingURL=NumberInputField.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumberInputField.js","sources":["../../../src/components/number-input-field/NumberInputField.tsx"],"sourcesContent":["import * as React from 'react'\nimport { useFormContext } from 'react-hook-form'\n\nimport { FieldWrapper } from '~/components/field-wrapper'\nimport { useFieldError, ValidationOptions } from '~/components/form'\nimport type { CSS } from '~/stitches'\n\nimport type { NumberInputProps } from '../number-input/NumberInput'\nimport { NumberInput } from '../number-input/NumberInput'\n\nexport interface NumberInputFieldProps extends NumberInputProps {\n css?: CSS\n description?: string\n label: string\n name: string\n prompt?: { link: string; label: string }\n validation?: ValidationOptions\n}\n\nexport const NumberInputField: React.FC<NumberInputFieldProps> = ({\n css,\n label,\n name,\n validation,\n
|
|
1
|
+
{"version":3,"file":"NumberInputField.js","sources":["../../../src/components/number-input-field/NumberInputField.tsx"],"sourcesContent":["import * as React from 'react'\nimport { useController, useFormContext } from 'react-hook-form'\n\nimport { FieldWrapper } from '~/components/field-wrapper'\nimport { useFieldError, ValidationOptions } from '~/components/form'\nimport type { CSS } from '~/stitches'\n\nimport type { NumberInputProps } from '../number-input/NumberInput'\nimport { NumberInput } from '../number-input/NumberInput'\n\nexport interface NumberInputFieldProps extends NumberInputProps {\n css?: CSS\n description?: string\n label: string\n name: string\n prompt?: { link: string; label: string }\n validation?: ValidationOptions\n}\n\nexport const NumberInputField: React.FC<NumberInputFieldProps> = ({\n css,\n defaultValue = 0,\n value,\n prompt,\n description,\n label,\n name,\n validation,\n onValueChange,\n ...remainingProps\n}) => {\n const { control } = useFormContext()\n const {\n field: { ref, onChange, value: innerValue, name: innerName }\n } = useController({\n name,\n control,\n rules: validation,\n defaultValue\n })\n const { error } = useFieldError(name)\n\n React.useEffect(() => {\n // Update the react-hook-form inner value to match what is passed in.\n if (typeof value !== 'undefined') onChange(value)\n }, [value])\n\n return (\n <FieldWrapper\n css={css}\n description={description}\n error={error}\n fieldId={name}\n label={label}\n prompt={prompt}\n required={Boolean(validation?.required)}\n >\n <NumberInput\n id={name}\n name={innerName}\n ref={ref}\n {...(error && { state: 'error', 'aria-invalid': true })}\n defaultValue={defaultValue}\n onValueChange={(newValue) => {\n onChange(newValue)\n onValueChange?.(newValue)\n }}\n value={innerValue}\n {...remainingProps}\n />\n </FieldWrapper>\n )\n}\n\nNumberInputField.displayName = 'NumberInputField'\n"],"names":["NumberInputField","css","defaultValue","value","prompt","description","label","name","validation","onValueChange","remainingProps","control","useFormContext","ref","onChange","innerValue","innerName","useController","error","useFieldError","React","FieldWrapper","NumberInput","newValue"],"mappings":"+VAmBaA,EAAoD,CAAC,CAChE,IAAAC,EACA,aAAAC,EAAe,EACf,MAAAC,EACA,OAAAC,EACA,YAAAC,EACA,MAAAC,EACA,KAAAC,EACA,WAAAC,EACA,cAAAC,KACGC,CACL,IAAM,CACJ,KAAM,CAAE,QAAAC,CAAQ,EAAIC,IACd,CACJ,MAAO,CAAE,IAAAC,EAAK,SAAAC,EAAU,MAAOC,EAAY,KAAMC,CAAU,CAC7D,EAAIC,EAAc,CAChB,KAAAV,EACA,QAAAI,EACA,MAAOH,EACP,aAAAN,CACF,CAAC,EACK,CAAE,MAAAgB,CAAM,EAAIC,EAAcZ,CAAI,EAEpC,OAAAa,EAAM,UAAU,IAAM,CAEhB,OAAOjB,EAAU,KAAaW,EAASX,CAAK,CAClD,EAAG,CAACA,CAAK,CAAC,EAGRiB,EAAA,cAACC,EAAA,CACC,IAAKpB,EACL,YAAaI,EACb,MAAOa,EACP,QAASX,EACT,MAAOD,EACP,OAAQF,EACR,SAAU,QAAQI,GAAA,YAAAA,EAAY,QAAQ,CAEtCY,EAAAA,EAAA,cAACE,EAAA,CACC,GAAIf,EACJ,KAAMS,EACN,IAAKH,EACJ,GAAIK,GAAS,CAAE,MAAO,QAAS,eAAgB,EAAK,EACrD,aAAchB,EACd,cAAgBqB,GAAa,CAC3BT,EAASS,CAAQ,EACjBd,GAAA,MAAAA,EAAgBc,CAAAA,CAClB,EACA,MAAOR,EACN,GAAGL,CAAAA,CACN,CACF,CAEJ,EAEAV,EAAiB,YAAc"}
|