@vygruppen/spor-react 11.3.10 → 12.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.
Files changed (322) hide show
  1. package/.turbo/turbo-build.log +32 -11
  2. package/.turbo/turbo-typegen.log +23 -0
  3. package/CHANGELOG.md +239 -0
  4. package/dist/index.d.mts +2552 -8319
  5. package/dist/index.d.ts +2552 -8319
  6. package/dist/index.js +9609 -8608
  7. package/dist/index.js.map +1 -1
  8. package/dist/index.mjs +9487 -8455
  9. package/dist/index.mjs.map +1 -1
  10. package/package.json +21 -13
  11. package/src/accordion/Accordion.tsx +96 -45
  12. package/src/accordion/Expandable.tsx +54 -127
  13. package/src/accordion/helpers.ts +31 -0
  14. package/src/accordion/types.ts +60 -0
  15. package/src/alert/Alert.tsx +101 -0
  16. package/src/alert/AlertIcon.tsx +63 -45
  17. package/src/alert/ExpandableAlert.tsx +96 -64
  18. package/src/alert/ServiceAlert.tsx +127 -125
  19. package/src/alert/{index.tsx → index.ts} +1 -2
  20. package/src/breadcrumb/Breadcrumb.tsx +39 -24
  21. package/src/button/Button.tsx +86 -105
  22. package/src/button/ButtonGroup.tsx +45 -20
  23. package/src/button/Clipboard.tsx +82 -0
  24. package/src/button/CloseButton.tsx +4 -3
  25. package/src/button/FloatingActionButton.tsx +35 -41
  26. package/src/button/IconButton.tsx +34 -30
  27. package/src/button/index.tsx +1 -0
  28. package/src/color-mode/color-mode.tsx +75 -0
  29. package/src/color-mode/index.ts +1 -0
  30. package/src/datepicker/Calendar.tsx +17 -8
  31. package/src/datepicker/CalendarCell.tsx +20 -13
  32. package/src/datepicker/CalendarGrid.tsx +18 -10
  33. package/src/datepicker/CalendarHeader.tsx +2 -0
  34. package/src/datepicker/CalendarNavigationButton.tsx +1 -0
  35. package/src/datepicker/CalendarTriggerButton.tsx +43 -45
  36. package/src/datepicker/DateField.tsx +21 -12
  37. package/src/datepicker/DatePicker.tsx +61 -58
  38. package/src/datepicker/DateRangePicker.tsx +52 -58
  39. package/src/datepicker/DateTimeSegment.tsx +13 -5
  40. package/src/datepicker/RangeCalendar.tsx +13 -7
  41. package/src/datepicker/StyledField.tsx +25 -17
  42. package/src/datepicker/TimeField.tsx +10 -8
  43. package/src/datepicker/TimePicker.tsx +48 -45
  44. package/src/datepicker/types.ts +5 -0
  45. package/src/dialog/Dialog.tsx +56 -0
  46. package/src/dialog/Drawer.tsx +187 -0
  47. package/src/dialog/index.ts +2 -0
  48. package/src/dialog/types.ts +26 -0
  49. package/src/image/index.tsx +2 -2
  50. package/src/index.tsx +5 -3
  51. package/src/input/AttachedInputs.tsx +17 -42
  52. package/src/input/CardSelect.tsx +75 -162
  53. package/src/input/Checkbox.tsx +30 -6
  54. package/src/input/CheckboxGroup.tsx +25 -16
  55. package/src/input/ChoiceChip.tsx +58 -77
  56. package/src/input/Combobox.tsx +172 -172
  57. package/src/input/CountryCodeSelect.tsx +42 -28
  58. package/src/input/Dialog.tsx +1 -0
  59. package/src/input/Field.tsx +71 -0
  60. package/src/input/Fieldset.tsx +7 -0
  61. package/src/input/Input.tsx +68 -73
  62. package/src/input/InputGroup.tsx +66 -0
  63. package/src/input/ListBox.tsx +83 -70
  64. package/src/input/NativeSelect.tsx +68 -33
  65. package/src/input/NumericStepper.tsx +173 -171
  66. package/src/input/PasswordInput.tsx +99 -52
  67. package/src/input/PhoneNumberInput.tsx +69 -72
  68. package/src/input/Popover.tsx +1 -0
  69. package/src/input/Radio.tsx +37 -17
  70. package/src/input/SearchInput.tsx +24 -86
  71. package/src/input/Select.tsx +237 -0
  72. package/src/input/Switch.tsx +60 -18
  73. package/src/input/Textarea.tsx +53 -101
  74. package/src/input/{index.tsx → index.ts} +2 -8
  75. package/src/layout/PressableCard.tsx +12 -21
  76. package/src/layout/RadioCard.tsx +68 -101
  77. package/src/layout/Separator.tsx +32 -0
  78. package/src/layout/StaticCard.tsx +13 -33
  79. package/src/layout/index.tsx +3 -7
  80. package/src/linjetag/InfoTag.tsx +16 -9
  81. package/src/linjetag/LineIcon.tsx +74 -28
  82. package/src/linjetag/TravelTag.tsx +38 -27
  83. package/src/link/TextLink.tsx +25 -16
  84. package/src/list/index.tsx +24 -2
  85. package/src/loader/ClientOnly.tsx +8 -7
  86. package/src/loader/ColorInlineLoader.tsx +4 -3
  87. package/src/loader/ColorSpinner.tsx +5 -4
  88. package/src/loader/ContentLoader.tsx +6 -4
  89. package/src/loader/DarkFullScreenLoader.tsx +11 -3
  90. package/src/loader/DarkInlineLoader.tsx +5 -3
  91. package/src/loader/DarkSpinner.tsx +7 -3
  92. package/src/loader/LightFullScreenLoader.tsx +11 -3
  93. package/src/loader/LightInlineLoader.tsx +11 -3
  94. package/src/loader/LightSpinner.tsx +5 -3
  95. package/src/loader/Lottie.tsx +3 -3
  96. package/src/loader/ProgressBar.tsx +83 -84
  97. package/src/loader/ProgressLoader.tsx +120 -75
  98. package/src/loader/Skeleton.tsx +94 -19
  99. package/src/loader/index.tsx +0 -2
  100. package/src/loader/useHydrated.tsx +1 -0
  101. package/src/loader/useRotatingLabel.tsx +2 -1
  102. package/src/logo/CargonetLogo.tsx +89 -89
  103. package/src/logo/VyLogo.tsx +61 -42
  104. package/src/logo/VyLogoPride.tsx +137 -139
  105. package/src/media-controller/JumpButton.tsx +48 -38
  106. package/src/media-controller/PlayPauseButton.tsx +31 -29
  107. package/src/media-controller/SkipButton.tsx +38 -37
  108. package/src/nudge/Nudge.tsx +195 -123
  109. package/src/nudge/index.tsx +0 -1
  110. package/src/pagination/Pagination.tsx +221 -118
  111. package/src/pagination/types.ts +23 -0
  112. package/src/popover/index.tsx +67 -0
  113. package/src/progress-indicator/ProgressDot.tsx +11 -10
  114. package/src/progress-indicator/ProgressIndicator.tsx +28 -15
  115. package/src/provider/SporProvider.tsx +17 -14
  116. package/src/stepper/Stepper.tsx +88 -85
  117. package/src/stepper/StepperContext.tsx +2 -1
  118. package/src/stepper/StepperStep.tsx +28 -21
  119. package/src/tab/Tabs.tsx +62 -12
  120. package/src/tab/index.tsx +1 -9
  121. package/src/table/Table.tsx +35 -30
  122. package/src/table/index.tsx +11 -7
  123. package/src/theme/brand.ts +7 -0
  124. package/src/theme/index.ts +45 -37
  125. package/src/theme/recipes/attached-inputs.ts +43 -0
  126. package/src/theme/recipes/badge.ts +104 -0
  127. package/src/theme/recipes/button.ts +124 -0
  128. package/src/theme/recipes/choice-chip.ts +144 -0
  129. package/src/theme/recipes/close-button.ts +41 -0
  130. package/src/theme/recipes/code.ts +14 -0
  131. package/src/theme/recipes/group.ts +19 -0
  132. package/src/theme/recipes/index.ts +29 -0
  133. package/src/theme/recipes/input.ts +89 -0
  134. package/src/theme/recipes/link.ts +64 -0
  135. package/src/theme/recipes/nudge.ts +12 -0
  136. package/src/theme/recipes/pressable-card.ts +83 -0
  137. package/src/theme/recipes/progress-loader.ts +14 -0
  138. package/src/theme/recipes/separator.ts +85 -0
  139. package/src/theme/recipes/skeleton.ts +57 -0
  140. package/src/theme/recipes/static-card.ts +39 -0
  141. package/src/theme/recipes/textarea.ts +27 -0
  142. package/src/theme/semantic-tokens/colors.ts +22 -0
  143. package/src/theme/semantic-tokens/index.ts +24 -0
  144. package/src/theme/semantic-tokens/radii.ts +14 -0
  145. package/src/theme/semantic-tokens/shadows.ts +17 -0
  146. package/src/theme/slot-recipes/accordion.ts +131 -0
  147. package/src/theme/slot-recipes/alert-expandable.ts +133 -0
  148. package/src/theme/slot-recipes/alert-service.ts +66 -0
  149. package/src/theme/slot-recipes/alert.ts +72 -0
  150. package/src/theme/slot-recipes/anatomy.ts +269 -0
  151. package/src/theme/slot-recipes/breadcrumb.ts +61 -0
  152. package/src/theme/slot-recipes/checkbox.ts +89 -0
  153. package/src/theme/slot-recipes/datepicker.ts +214 -0
  154. package/src/theme/slot-recipes/dialog.ts +221 -0
  155. package/src/theme/slot-recipes/drawer.ts +205 -0
  156. package/src/theme/slot-recipes/field.ts +79 -0
  157. package/src/theme/slot-recipes/floating-action-button.ts +131 -0
  158. package/src/theme/slot-recipes/index.ts +65 -0
  159. package/src/theme/slot-recipes/info-tag.ts +62 -0
  160. package/src/theme/slot-recipes/line-icon.ts +140 -0
  161. package/src/theme/slot-recipes/list.ts +45 -0
  162. package/src/theme/slot-recipes/listbox.ts +72 -0
  163. package/src/theme/slot-recipes/media-controller-button.ts +131 -0
  164. package/src/theme/slot-recipes/native-select.ts +54 -0
  165. package/src/theme/slot-recipes/numeric-stepper.ts +65 -0
  166. package/src/theme/slot-recipes/pagination.ts +41 -0
  167. package/src/theme/slot-recipes/popover.ts +78 -0
  168. package/src/theme/slot-recipes/progress-bar.ts +39 -0
  169. package/src/theme/slot-recipes/progress-indicator.ts +22 -0
  170. package/src/theme/slot-recipes/radio-card.ts +112 -0
  171. package/src/theme/slot-recipes/radio.ts +80 -0
  172. package/src/theme/slot-recipes/select.ts +243 -0
  173. package/src/theme/slot-recipes/stepper.ts +92 -0
  174. package/src/theme/slot-recipes/switch.ts +147 -0
  175. package/src/theme/slot-recipes/table.ts +200 -0
  176. package/src/theme/slot-recipes/tabs.ts +169 -0
  177. package/src/theme/slot-recipes/toast.ts +56 -0
  178. package/src/theme/slot-recipes/travel-tag.ts +192 -0
  179. package/src/theme/tokens/animation-styles.ts +50 -0
  180. package/src/theme/tokens/animations.ts +22 -0
  181. package/src/theme/tokens/aspect-ratios.ts +22 -0
  182. package/src/theme/tokens/blurs.ts +28 -0
  183. package/src/theme/tokens/borders.ts +26 -0
  184. package/src/theme/{foundations → tokens}/breakpoints.ts +0 -1
  185. package/src/theme/tokens/colors.ts +10 -0
  186. package/src/theme/tokens/config.ts +10 -0
  187. package/src/theme/tokens/cursor.ts +28 -0
  188. package/src/theme/tokens/durations.ts +25 -0
  189. package/src/theme/tokens/easings.ts +16 -0
  190. package/src/theme/tokens/font-sizes.ts +30 -0
  191. package/src/theme/tokens/font-weights.ts +31 -0
  192. package/src/theme/tokens/fonts.ts +8 -0
  193. package/src/theme/tokens/global-css.ts +18 -0
  194. package/src/theme/tokens/index.ts +37 -0
  195. package/src/theme/tokens/keyframes.ts +255 -0
  196. package/src/theme/tokens/letter-spacings.ts +19 -0
  197. package/src/theme/tokens/line-heights.ts +19 -0
  198. package/src/theme/tokens/radii.ts +13 -0
  199. package/src/theme/tokens/sizes.ts +51 -0
  200. package/src/theme/tokens/spacing.ts +20 -0
  201. package/src/theme/tokens/text-styles.ts +89 -0
  202. package/src/theme/tokens/z-index.ts +17 -0
  203. package/src/theme/utils/accent-utils.ts +8 -21
  204. package/src/theme/utils/bg-utils.ts +4 -6
  205. package/src/theme/utils/brand-utils.ts +6 -19
  206. package/src/theme/utils/core-utils.ts +91 -0
  207. package/src/theme/utils/floating-utils.ts +20 -39
  208. package/src/theme/utils/ghost-utils.ts +7 -21
  209. package/src/theme/utils/input-utils.ts +32 -37
  210. package/src/theme/utils/outline-utils.ts +4 -11
  211. package/src/theme/utils/surface-utils.ts +5 -19
  212. package/src/theme/utils/types.ts +1 -0
  213. package/src/toast/index.tsx +1 -1
  214. package/src/toast/toast.tsx +105 -0
  215. package/src/transition/index.ts +2 -8
  216. package/src/typography/Badge.tsx +15 -61
  217. package/src/typography/Code.tsx +16 -28
  218. package/src/typography/Heading.tsx +34 -19
  219. package/src/typography/Text.tsx +9 -6
  220. package/src/typography/{index.tsx → index.ts} +1 -0
  221. package/src/util/externals.tsx +13 -27
  222. package/tsconfig.json +5 -1
  223. package/src/accordion/Accordion.test.tsx +0 -20
  224. package/src/alert/BaseAlert.test.tsx +0 -37
  225. package/src/alert/BaseAlert.tsx +0 -34
  226. package/src/alert/ClosableAlert.test.tsx +0 -37
  227. package/src/alert/ClosableAlert.tsx +0 -85
  228. package/src/alert/ExpandableAlert.test.tsx +0 -84
  229. package/src/alert/StaticAlert.tsx +0 -33
  230. package/src/button/Button.test.tsx +0 -23
  231. package/src/datepicker/TimePicker.test.tsx +0 -74
  232. package/src/input/FormControl.tsx +0 -2
  233. package/src/input/FormErrorMessage.tsx +0 -95
  234. package/src/input/FormLabel.tsx +0 -11
  235. package/src/input/InfoSelect.tsx +0 -274
  236. package/src/input/InputElement.tsx +0 -44
  237. package/src/input/RadioGroup.tsx +0 -47
  238. package/src/layout/Divider.tsx +0 -27
  239. package/src/layout/RadioCardGroup.tsx +0 -79
  240. package/src/layout/Stack.tsx +0 -42
  241. package/src/loader/SkeletonCircle.tsx +0 -13
  242. package/src/loader/SkeletonText.tsx +0 -14
  243. package/src/media-controller/index.test.tsx +0 -59
  244. package/src/modal/Drawer.tsx +0 -120
  245. package/src/modal/FullScreenDrawer.tsx +0 -239
  246. package/src/modal/Modal.tsx +0 -15
  247. package/src/modal/ModalHeader.tsx +0 -31
  248. package/src/modal/SimpleDrawer.tsx +0 -51
  249. package/src/modal/index.tsx +0 -5
  250. package/src/nudge/WizardNudge.tsx +0 -107
  251. package/src/theme/components/accordion.ts +0 -102
  252. package/src/theme/components/alert-expandable.ts +0 -125
  253. package/src/theme/components/alert-service.ts +0 -98
  254. package/src/theme/components/alert.ts +0 -71
  255. package/src/theme/components/badge.ts +0 -109
  256. package/src/theme/components/breadcrumb.ts +0 -60
  257. package/src/theme/components/button.ts +0 -125
  258. package/src/theme/components/card-select.ts +0 -117
  259. package/src/theme/components/checkbox.ts +0 -88
  260. package/src/theme/components/choice-chip.ts +0 -161
  261. package/src/theme/components/close-button.ts +0 -48
  262. package/src/theme/components/code.ts +0 -17
  263. package/src/theme/components/datepicker.ts +0 -198
  264. package/src/theme/components/divider.ts +0 -50
  265. package/src/theme/components/drawer.ts +0 -95
  266. package/src/theme/components/fab.ts +0 -109
  267. package/src/theme/components/form-label.ts +0 -17
  268. package/src/theme/components/form.ts +0 -27
  269. package/src/theme/components/index.ts +0 -45
  270. package/src/theme/components/info-select.ts +0 -85
  271. package/src/theme/components/info-tag.ts +0 -63
  272. package/src/theme/components/input.ts +0 -28
  273. package/src/theme/components/line-icon.ts +0 -129
  274. package/src/theme/components/link.ts +0 -78
  275. package/src/theme/components/list.ts +0 -23
  276. package/src/theme/components/listbox.ts +0 -77
  277. package/src/theme/components/media-controller-button.ts +0 -97
  278. package/src/theme/components/modal.ts +0 -96
  279. package/src/theme/components/numeric-stepper.ts +0 -65
  280. package/src/theme/components/pagination.ts +0 -74
  281. package/src/theme/components/popover.ts +0 -68
  282. package/src/theme/components/pressable-card.ts +0 -72
  283. package/src/theme/components/progress-bar.ts +0 -47
  284. package/src/theme/components/progress-indicator.ts +0 -44
  285. package/src/theme/components/radio-card.ts +0 -134
  286. package/src/theme/components/radio.ts +0 -68
  287. package/src/theme/components/select.ts +0 -74
  288. package/src/theme/components/skeleton.ts +0 -40
  289. package/src/theme/components/static-card.ts +0 -82
  290. package/src/theme/components/stepper.ts +0 -100
  291. package/src/theme/components/switch.ts +0 -112
  292. package/src/theme/components/table.ts +0 -161
  293. package/src/theme/components/tabs.ts +0 -135
  294. package/src/theme/components/textarea.ts +0 -33
  295. package/src/theme/components/toast.ts +0 -28
  296. package/src/theme/components/travel-tag.ts +0 -256
  297. package/src/theme/foundations/borders.ts +0 -11
  298. package/src/theme/foundations/colors.ts +0 -12
  299. package/src/theme/foundations/config.ts +0 -5
  300. package/src/theme/foundations/fontSizes.ts +0 -29
  301. package/src/theme/foundations/fontWeights.ts +0 -5
  302. package/src/theme/foundations/fonts.ts +0 -7
  303. package/src/theme/foundations/index.ts +0 -15
  304. package/src/theme/foundations/lineHeights.ts +0 -6
  305. package/src/theme/foundations/radii.ts +0 -12
  306. package/src/theme/foundations/shadows.ts +0 -8
  307. package/src/theme/foundations/sizes.ts +0 -36
  308. package/src/theme/foundations/spacing.ts +0 -31
  309. package/src/theme/foundations/styles.ts +0 -12
  310. package/src/theme/foundations/textStyles.ts +0 -74
  311. package/src/theme/foundations/zIndices.ts +0 -17
  312. package/src/theme/utils/base-utils.ts +0 -104
  313. package/src/theme/utils/focus-utils.ts +0 -10
  314. package/src/toast/ActionToast.test.tsx +0 -22
  315. package/src/toast/ActionToast.tsx +0 -28
  316. package/src/toast/BaseToast.test.tsx +0 -27
  317. package/src/toast/BaseToast.tsx +0 -75
  318. package/src/toast/ClosableToast.test.tsx +0 -17
  319. package/src/toast/ClosableToast.tsx +0 -40
  320. package/src/toast/useToast.tsx +0 -121
  321. package/src/tooltip/Tooltip.tsx +0 -70
  322. package/src/tooltip/index.tsx +0 -1
@@ -0,0 +1,91 @@
1
+ import { brandBackground } from "./brand-utils";
2
+ import { surface } from "./surface-utils";
3
+ import { State, Subset } from "./types";
4
+
5
+ type coreBackgroundState = Subset<
6
+ State,
7
+ "default" | "active" | "selected" | "hover" | "disabled"
8
+ >;
9
+ export function coreBackground(state: coreBackgroundState) {
10
+ switch (state) {
11
+ case "active":
12
+ return brandBackground("active");
13
+ case "selected":
14
+ return brandBackground("default");
15
+
16
+ case "disabled":
17
+ return surface("disabled");
18
+ case "hover":
19
+ default:
20
+ return { backgroundColor: "transparent" };
21
+ }
22
+ }
23
+
24
+ type BorderState = Subset<
25
+ State,
26
+ "hover" | "focus" | "active" | "disabled" | "selected" | "invalid" | "default"
27
+ >;
28
+
29
+ export function coreBorder(state: BorderState) {
30
+ switch (state) {
31
+ case "hover":
32
+ return {
33
+ outline: "2px solid",
34
+ outlineColor: "core.outline",
35
+ };
36
+
37
+ case "disabled": {
38
+ return {
39
+ outline: "1px solid",
40
+ outlineColor: "outline.disabled",
41
+ };
42
+ }
43
+ case "active": {
44
+ return {
45
+ outline: "1px solid",
46
+ outlineColor: "core.outline",
47
+ };
48
+ }
49
+ case "invalid": {
50
+ return {
51
+ outline: "2px solid",
52
+ outlineColor: "outline.error",
53
+ };
54
+ }
55
+ case "default":
56
+ default:
57
+ return {
58
+ outline: "1px solid",
59
+ outlineColor: "core.outline",
60
+ };
61
+ }
62
+ }
63
+
64
+ type coreTextState = Subset<
65
+ State,
66
+ "default" | "selected" | "disabled" | "highlight" | "active"
67
+ >;
68
+ export function coreText(state: coreTextState) {
69
+ switch (state) {
70
+ case "selected":
71
+ return {
72
+ color: "brand.text",
73
+ };
74
+ case "active":
75
+ return {
76
+ color: "brand.text",
77
+ };
78
+ case "highlight":
79
+ return {
80
+ color: "text.highlight",
81
+ };
82
+ case "disabled":
83
+ return {
84
+ color: "text.disabled",
85
+ };
86
+ default:
87
+ return {
88
+ color: "core.text",
89
+ };
90
+ }
91
+ }
@@ -1,80 +1,61 @@
1
- import { mode, StyleFunctionProps } from "@chakra-ui/theme-tools";
2
1
  import { brandBackground } from "./brand-utils";
3
2
  import { State, Subset } from "./types";
4
3
 
5
4
  type FloatingBackgroundState = Subset<
6
5
  State,
7
- "default" | "hover" | "active" | "selected"
6
+ "default" | "hover" | "active" | "focus"
8
7
  >;
9
8
 
10
- export function floatingBackground(
11
- state: FloatingBackgroundState,
12
- props: StyleFunctionProps,
13
- ) {
9
+ export function floatingBackground(state: FloatingBackgroundState) {
14
10
  switch (state) {
15
- case "selected":
16
- return brandBackground("default", props);
11
+ case "focus":
12
+ return brandBackground("default");
17
13
  case "active":
18
14
  return {
19
- backgroundColor: mode(
20
- "floating.surface.active.light",
21
- "floating.surface.active.dark",
22
- )(props),
15
+ backgroundColor: "floating.surface.active",
23
16
  };
24
17
  case "hover":
25
18
  return {
26
- backgroundColor: mode(
27
- "floating.surface.hover.light",
28
- `color-mix(in srgb, white 10%, var(--spor-colors-bg-default-dark))`,
29
- )(props),
19
+ backgroundColor: {
20
+ _light: "floating.surface.hover",
21
+ _dark: `color-mix(in srgb, white 10%, var(--spor-colors-bg))`,
22
+ },
30
23
  };
31
24
  case "default":
32
25
  return {
33
- backgroundColor: mode(
34
- "white",
35
- `color-mix(in srgb, white 10%, var(--spor-colors-bg-default-dark))`,
36
- )(props),
26
+ backgroundColor: {
27
+ _light: "bg",
28
+ _dark: `color-mix(in srgb, white 10%, var(--spor-colors-bg))`,
29
+ },
37
30
  };
38
31
  }
39
32
  }
40
33
 
41
34
  type FloatingBorderState = Subset<
42
35
  State,
43
- "default" | "hover" | "active" | "selected"
36
+ "default" | "hover" | "active" | "focus"
44
37
  >;
45
- export function floatingBorder(
46
- state: FloatingBorderState,
47
- props: StyleFunctionProps,
48
- ) {
38
+ export function floatingBorder(state: FloatingBorderState) {
49
39
  switch (state) {
50
40
  case "hover":
51
41
  return {
52
42
  outline: "1px solid",
53
- outlineColor: mode(
54
- "floating.outline.hover.light",
55
- "floating.outline.hover.dark",
56
- )(props),
43
+ outlineColor: "floating.outline.hover",
57
44
  };
58
- case "selected":
45
+ case "focus":
59
46
  return {
60
47
  outline: "1px solid",
61
- outlineColor: mode("outline.focus.light", "outline.focus.dark")(props),
48
+ outlineColor: "outline.focus",
62
49
  };
63
50
  case "active":
64
51
  return {
65
52
  outline: "1px solid",
66
- outlineColor: mode(
67
- "floating.outline.active.light",
68
- "floating.outline.active.dark",
69
- )(props),
53
+ outlineColor: "floating.outline.active",
70
54
  };
71
55
  default:
72
56
  return {
73
57
  outline: "1px solid",
74
- outlineColor: mode(
75
- "floating.outline.default.light",
76
- "floating.outline.default.dark",
77
- )(props),
58
+ outlineColor: "floating.outline",
78
59
  };
79
60
  }
80
61
  }
@@ -1,6 +1,4 @@
1
- import { mode, StyleFunctionProps } from "@chakra-ui/theme-tools";
2
1
  import { State, Subset } from "./types";
3
- import { fontWeights } from "../foundations";
4
2
 
5
3
  type GhostBackgroundState = Subset<
6
4
  State,
@@ -8,32 +6,20 @@ type GhostBackgroundState = Subset<
8
6
  >;
9
7
 
10
8
  /** 👻👻👻👻👻👻👻👻👻👻👻👻👻👻 */
11
- export function ghostBackground(
12
- state: GhostBackgroundState,
13
- props: StyleFunctionProps,
14
- ) {
9
+ export function ghostBackground(state: GhostBackgroundState) {
15
10
  switch (state) {
16
11
  case "hover": {
17
12
  return {
18
- backgroundColor: mode(
19
- "ghost.surface.hover.light",
20
- "ghost.surface.hover.dark",
21
- )(props),
13
+ backgroundColor: "ghost.surface.hover",
22
14
  };
23
15
  }
24
16
  case "active":
25
17
  return {
26
- backgroundColor: mode(
27
- "ghost.surface.active.light",
28
- "ghost.surface.active.dark",
29
- )(props),
18
+ backgroundColor: "ghost.surface.active",
30
19
  };
31
20
  case "selected": {
32
21
  return {
33
- backgroundColor: mode(
34
- "ghost.surface.hover.light",
35
- "ghost.surface.hover.dark",
36
- )(props),
22
+ backgroundColor: "ghost.surface.selected",
37
23
  };
38
24
  }
39
25
  case "default":
@@ -45,15 +31,15 @@ export function ghostBackground(
45
31
 
46
32
  type GhostTextState = Subset<State, "default" | "selected">;
47
33
 
48
- export function ghostText(state: GhostTextState, props: StyleFunctionProps) {
34
+ export function ghostText(state: GhostTextState) {
49
35
  switch (state) {
50
36
  case "selected":
51
37
  return {
52
- color: mode("ghost.text.light", "ghost.text.dark")(props),
38
+ color: "ghost.text",
53
39
  };
54
40
  default:
55
41
  return {
56
- color: mode("ghost.text.light", "ghost.text.dark")(props),
42
+ color: "ghost.text",
57
43
  };
58
44
  }
59
45
  }
@@ -1,68 +1,66 @@
1
- import { StyleFunctionProps } from "@chakra-ui/theme-tools";
2
- import { baseBackground, baseBorder, baseText } from "./base-utils";
1
+ import { coreBackground, coreBorder, coreText } from "./core-utils";
3
2
  import { floatingBackground, floatingBorder } from "./floating-utils";
4
3
  import { InputState } from "./types";
5
- import { focusVisibleStyles } from "./focus-utils";
6
4
  import { surface } from "./surface-utils";
7
5
 
8
- export function inputVariant(state: InputState, props: StyleFunctionProps) {
6
+ export function inputVariant(state: InputState) {
9
7
  switch (state) {
10
8
  case "base":
11
9
  return {
12
- ...baseBackground("default", props),
13
- ...baseBorder("default", props),
10
+ ...coreBackground("default"),
11
+ ...coreBorder("default"),
14
12
  _hover: {
15
- ...baseBorder("hover", props),
13
+ ...coreBorder("hover"),
16
14
  },
17
15
  _active: {
18
- ...baseBackground("active", props),
19
- ...baseBorder("default", props),
16
+ backgroundColor: "core.surface.active",
17
+ ...coreBorder("default"),
20
18
  },
21
19
  _selected: {
22
- ...baseBackground("selected", props),
23
- ...baseBorder("selected", props),
20
+ ...coreBackground("selected"),
21
+ ...coreBorder("selected"),
24
22
  },
25
23
  };
26
24
  case "floating":
27
25
  return {
28
26
  boxShadow: "sm",
29
- ...floatingBackground("default", props),
30
- ...floatingBorder("default", props),
27
+ ...floatingBackground("default"),
28
+ ...floatingBorder("default"),
31
29
 
32
30
  _hover: {
33
- ...floatingBorder("hover", props),
34
- ...floatingBackground("hover", props),
31
+ ...floatingBorder("hover"),
32
+ ...floatingBackground("hover"),
35
33
  },
36
34
  _active: {
37
- ...floatingBorder("active", props),
38
- ...floatingBackground("active", props),
35
+ ...floatingBorder("active"),
36
+ backgroundColor: "core.surface.active",
39
37
  },
40
38
  _selected: {
41
- ...floatingBorder("selected", props),
42
- ...floatingBackground("selected", props),
39
+ backgroundColor: "floating.surface.selected",
40
+ borderColor: "floating.border.selected",
43
41
  },
44
42
  };
45
43
  case "default":
46
44
  default:
47
45
  return {
48
- ...baseBackground("default", props),
49
- ...baseBorder("default", props),
46
+ ...coreBackground("default"),
47
+ ...coreBorder("default"),
50
48
  _hover: {
51
- ...baseBorder("hover", props),
49
+ ...coreBorder("hover"),
52
50
  },
53
51
  _active: {
54
- ...baseBackground("active", props),
55
- ...baseBorder("default", props),
52
+ backgroundColor: "core.surface.active",
53
+ ...coreBorder("default"),
56
54
  },
57
55
  _selected: {
58
- ...baseBackground("selected", props),
59
- ...baseBorder("selected", props),
56
+ ...coreBackground("selected"),
57
+ ...coreBorder("selected"),
60
58
  },
61
59
  };
62
60
  }
63
61
  }
64
62
 
65
- export const inputBaseStyle = (props: StyleFunctionProps) => ({
63
+ export const inputBaseStyle = () => ({
66
64
  field: {
67
65
  appearance: "none",
68
66
  width: "100%",
@@ -75,25 +73,22 @@ export const inputBaseStyle = (props: StyleFunctionProps) => ({
75
73
  paddingX: 3,
76
74
  height: 8,
77
75
  fontSize: "mobile.md",
78
- _focusVisible: {
79
- ...focusVisibleStyles(props)._focusVisible,
80
- outlineOffset: 0,
81
- },
76
+
82
77
  _disabled: {
83
- ...surface("disabled", props),
84
- ...baseBorder("disabled", props),
78
+ ...surface("disabled"),
79
+ ...coreBorder("disabled"),
85
80
  pointerEvents: "none",
86
81
  },
87
82
  _invalid: {
88
- ...baseBorder("invalid", props),
83
+ ...coreBorder("invalid"),
89
84
  _hover: {
90
- ...baseBorder("hover", props),
85
+ ...coreBorder("hover"),
91
86
  },
92
87
  },
93
88
  " + label, + div[data-lastpass-icon-root] + label": {
94
89
  fontSize: ["mobile.sm", "desktop.sm"],
95
90
  top: "2px",
96
- left: props.paddingLeft || props.pl || 3,
91
+ left: 3,
97
92
  zIndex: 2,
98
93
  position: "absolute",
99
94
  marginY: 2,
@@ -113,7 +108,7 @@ export const inputBaseStyle = (props: StyleFunctionProps) => ({
113
108
  },
114
109
  group: {
115
110
  ":has(:disabled)": {
116
- ...baseText("disabled", props),
111
+ ...coreText("disabled"),
117
112
  },
118
113
  },
119
114
  });
@@ -1,26 +1,19 @@
1
- import { mode, StyleFunctionProps } from "@chakra-ui/theme-tools";
2
1
  import { State, Subset } from "./types";
3
2
 
4
3
  type OutlineBorderState = Subset<State, "default" | "error" | "focus">;
5
- export function outlineBorder(
6
- state: OutlineBorderState,
7
- props: StyleFunctionProps,
8
- ) {
4
+ export function outlineBorder(state: OutlineBorderState) {
9
5
  switch (state) {
10
6
  case "error":
11
7
  return {
12
- outlineColor: mode("outline.error.light", "outline.error.dark")(props),
8
+ outlineColor: "outline.error",
13
9
  };
14
10
  case "focus":
15
11
  return {
16
- outlineColor: mode("outline.focus.light", "outline.focus.dark")(props),
12
+ outlineColor: "outline.focus",
17
13
  };
18
14
  default:
19
15
  return {
20
- outlineColor: mode(
21
- "outline.default.light",
22
- "outline.default.dark",
23
- )(props),
16
+ outlineColor: "outline",
24
17
  };
25
18
  }
26
19
  }
@@ -1,35 +1,21 @@
1
- import { mode } from "@chakra-ui/theme-tools";
2
-
3
1
  type Surface = "default" | "secondary" | "tertiary" | "disabled";
4
- export const surface = (surface: Surface, props: any) => {
2
+ export const surface = (surface: Surface) => {
5
3
  switch (surface) {
6
4
  case "default":
7
5
  return {
8
- backgroundColor: mode(
9
- "surface.default.light",
10
- "surface.default.dark",
11
- )(props),
6
+ backgroundColor: "surface",
12
7
  };
13
8
  case "secondary":
14
9
  return {
15
- backgroundColor: mode(
16
- "surface.secondary.light",
17
- "surface.secondary.dark",
18
- )(props),
10
+ backgroundColor: "surface.secondary",
19
11
  };
20
12
  case "tertiary":
21
13
  return {
22
- backgroundColor: mode(
23
- "surface.tertiary.light",
24
- "surface.tertiary.dark",
25
- )(props),
14
+ backgroundColor: "surface.tertiary",
26
15
  };
27
16
  case "disabled":
28
17
  return {
29
- backgroundColor: mode(
30
- "surface.disabled.light",
31
- "surface.disabled.dark",
32
- )(props),
18
+ backgroundColor: "surface.disabled",
33
19
  };
34
20
  }
35
21
  };
@@ -6,6 +6,7 @@ export type State =
6
6
  | "selected"
7
7
  | "invalid"
8
8
  | "disabled"
9
+ | "highlight"
9
10
  | "error"
10
11
  | "focus";
11
12
 
@@ -1 +1 @@
1
- export * from "./useToast";
1
+ export { createToast } from "./toast";
@@ -0,0 +1,105 @@
1
+ "use client";
2
+
3
+ import React from "react";
4
+
5
+ import {
6
+ Toaster as ChakraToaster,
7
+ Icon,
8
+ Portal,
9
+ Stack,
10
+ Toast,
11
+ createToaster,
12
+ } from "@chakra-ui/react";
13
+ import { createTexts, useTranslation } from "@/i18n";
14
+ import {
15
+ InformationFill18Icon,
16
+ SuccessFill18Icon,
17
+ ErrorFill18Icon,
18
+ } from "@vygruppen/spor-icon-react";
19
+
20
+ const toaster = createToaster({
21
+ placement: "bottom",
22
+ pauseOnPageIdle: true,
23
+ });
24
+
25
+ type Variant = "info" | "success" | "error";
26
+
27
+ type ToastProps = {
28
+ duration?: number;
29
+ text: string;
30
+ variant: Variant;
31
+ id?: string;
32
+ };
33
+
34
+ export const createToast = ({
35
+ text,
36
+ variant,
37
+ id,
38
+ duration = 6000,
39
+ }: ToastProps) =>
40
+ toaster.create({
41
+ description: text,
42
+ type: variant,
43
+ id,
44
+ duration,
45
+ });
46
+
47
+ export const Toaster = () => {
48
+ return (
49
+ <Portal>
50
+ <ChakraToaster toaster={toaster} insetInline={{ mdDown: "4" }}>
51
+ {(toast) => (
52
+ <Toast.Root width={{ md: "sm" }} role="alert">
53
+ <ToastIcon variant={toast.type as Variant} />
54
+ <Stack gap="1" flex="1" maxWidth="100%">
55
+ <Toast.Description>{toast.description}</Toast.Description>
56
+ </Stack>
57
+ </Toast.Root>
58
+ )}
59
+ </ChakraToaster>
60
+ </Portal>
61
+ );
62
+ };
63
+
64
+ const iconComponents = {
65
+ info: InformationFill18Icon,
66
+ success: SuccessFill18Icon,
67
+ error: ErrorFill18Icon,
68
+ } as const;
69
+
70
+ const ToastIcon = ({ variant }: { variant: Variant }) => {
71
+ const { t } = useTranslation();
72
+
73
+ const ariaLabel = t(texts[variant as keyof typeof texts]);
74
+
75
+ const IconComponent = iconComponents[variant];
76
+
77
+ if (!IconComponent) return null;
78
+
79
+ return (
80
+ <Icon aria-label={ariaLabel}>
81
+ <IconComponent />
82
+ </Icon>
83
+ );
84
+ };
85
+
86
+ const texts = createTexts({
87
+ info: {
88
+ nb: "Informasjon",
89
+ nn: "Informasjon",
90
+ sv: "Information",
91
+ en: "Information",
92
+ },
93
+ success: {
94
+ nb: "Suksess",
95
+ nn: "Suksess",
96
+ sv: "Succé",
97
+ en: "Success",
98
+ },
99
+ error: {
100
+ nb: "Feil",
101
+ nn: "Feil",
102
+ sv: "Error",
103
+ en: "Error",
104
+ },
105
+ });
@@ -1,8 +1,2 @@
1
- export { Collapse, Fade, ScaleFade, Slide, SlideFade } from "@chakra-ui/react";
2
- export type {
3
- CollapseProps,
4
- FadeProps,
5
- ScaleFadeProps,
6
- SlideFadeProps,
7
- SlideProps,
8
- } from "@chakra-ui/react";
1
+ export { Collapsible } from "@chakra-ui/react";
2
+ export type { CollapsibleRootProps } from "@chakra-ui/react";
@@ -1,68 +1,22 @@
1
+ "use client";
2
+
1
3
  import {
4
+ Box,
2
5
  Badge as ChakraBadge,
3
6
  BadgeProps as ChakraBadgeProps,
4
- forwardRef,
5
7
  } from "@chakra-ui/react";
6
- import { As } from "@chakra-ui/system";
7
- import React from "react";
8
+ import { IconComponent } from "@vygruppen/spor-icon-react";
9
+ import React, { forwardRef } from "react";
8
10
 
9
- export type BadgeProps = Omit<
10
- ChakraBadgeProps,
11
- "variant" | "colorScheme" | "size"
12
- > & {
13
- /**
14
- * The color scheme of the badge.
15
- */
16
- colorScheme?:
17
- | "yellow"
18
- | "light-yellow"
19
- | "red"
20
- | "light-green"
21
- | "dark-green"
22
- | "orange"
23
- | "light-blue"
24
- | "dark-blue"
25
- | "grey"
26
- | "white";
27
- /** The design variant – "solid" by default.
28
- *
29
- * Can be specified as `outline` to render a border around the badge. */
30
- variant?: "solid" | "outline";
31
- /** Optional badge icon. Will be rendered to the left of the text.
32
- *
33
- * Make sure you pass in the 18px version of the icon.
34
- */
35
- icon?: React.ReactElement;
11
+ export type BadgeProps = ChakraBadgeProps & {
12
+ icon?: IconComponent;
36
13
  };
37
- /**
38
- * Shows some additional information about the component it's used within.
39
- *
40
- * You have to specify some content (icons should be placed to the left, if present), and a colorScheme.
41
- *
42
- * ```tsx
43
- * <Badge colorScheme="light-green">Hello</Badge>
44
- * ```
45
- *
46
- * If you want an icon, pass it in through the `icon` prop:
47
- *
48
- * ```tsx
49
- * <Badge colorScheme="light-blue" icon={<InformationOutline18Icon />}>
50
- * Information
51
- * </Badge>
52
- * ```
53
- */
54
- export const Badge = forwardRef<BadgeProps, As>(
55
- ({ icon, colorScheme = "grey", children, ...props }, ref) => {
56
- return (
57
- <ChakraBadge
58
- colorScheme={colorScheme}
59
- {...props}
60
- paddingLeft={icon ? 1 : undefined}
61
- ref={ref}
62
- >
63
- {icon && React.cloneElement(icon, { marginRight: 1 })}
64
- {children}
65
- </ChakraBadge>
66
- );
67
- },
14
+
15
+ export const Badge = forwardRef<HTMLSpanElement, BadgeProps>(
16
+ ({ icon, children, ...props }, ref) => (
17
+ <ChakraBadge ref={ref} {...props}>
18
+ {children}
19
+ {icon && <Box as={icon} />}
20
+ </ChakraBadge>
21
+ ),
68
22
  );