@yahoo/uds 3.59.0-beta.1 → 3.59.0-beta.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.
Files changed (304) hide show
  1. package/cli/bin/uds-darwin-arm64-baseline +0 -0
  2. package/cli/bin/uds-darwin-x64 +0 -0
  3. package/cli/bin/uds-linux-arm64 +0 -0
  4. package/cli/bin/uds-linux-x64-baseline +0 -0
  5. package/dist/components/Box.d.ts +2 -2
  6. package/dist/components/Box.d.ts.map +1 -1
  7. package/dist/components/Divider/Divider.d.cts +2 -2
  8. package/dist/components/Divider/Divider.d.ts +2 -2
  9. package/dist/components/Divider/DividerCore.d.cts +2 -2
  10. package/dist/components/Divider/DividerCore.d.ts +2 -2
  11. package/dist/components/Divider/DividerInternal.d.cts +2 -2
  12. package/dist/components/Divider/DividerInternal.d.ts +2 -2
  13. package/dist/components/FormLabel.d.ts +2 -2
  14. package/dist/components/HStack.d.ts +2 -2
  15. package/dist/components/Icon.d.ts +2 -2
  16. package/dist/components/Link.d.ts +2 -2
  17. package/dist/components/Text.d.cts +5 -5
  18. package/dist/components/Text.d.cts.map +1 -1
  19. package/dist/components/Text.d.ts +8 -8
  20. package/dist/components/Text.d.ts.map +1 -1
  21. package/dist/components/VStack.d.ts +2 -2
  22. package/dist/components/VStack.d.ts.map +1 -1
  23. package/dist/components/client/AnimateHeightChange.d.cts +2 -2
  24. package/dist/components/client/AnimateHeightChange.d.ts +2 -2
  25. package/dist/components/client/Avatar/Avatar.d.cts +2 -2
  26. package/dist/components/client/Avatar/Avatar.d.cts.map +1 -1
  27. package/dist/components/client/Avatar/Avatar.d.ts +2 -2
  28. package/dist/components/client/Avatar/AvatarIcon.d.cts +2 -2
  29. package/dist/components/client/Avatar/AvatarIcon.d.cts.map +1 -1
  30. package/dist/components/client/Avatar/AvatarIcon.d.ts +2 -2
  31. package/dist/components/client/Avatar/AvatarImage.d.cts +2 -2
  32. package/dist/components/client/Avatar/AvatarImage.d.ts +2 -2
  33. package/dist/components/client/Avatar/AvatarText.d.cts +2 -2
  34. package/dist/components/client/Avatar/AvatarText.d.ts +2 -2
  35. package/dist/components/client/IconButton.d.cts +2 -2
  36. package/dist/components/client/IconButton.d.ts +2 -2
  37. package/dist/components/client/IconButton.d.ts.map +1 -1
  38. package/dist/components/client/Input/Input.d.cts +2 -2
  39. package/dist/components/client/Input/Input.d.ts +2 -2
  40. package/dist/components/client/Input/InputHelpText.d.cts +2 -2
  41. package/dist/components/client/Input/InputHelpText.d.cts.map +1 -1
  42. package/dist/components/client/Input/InputHelpText.d.ts +2 -2
  43. package/dist/components/client/Input/InputHelpTextInternal.d.cts +4 -4
  44. package/dist/components/client/Input/InputHelpTextInternal.d.cts.map +1 -1
  45. package/dist/components/client/Input/InputHelpTextInternal.d.ts +4 -4
  46. package/dist/components/client/Menu/Menu.Content.d.cts +2 -2
  47. package/dist/components/client/Menu/Menu.Content.d.ts +2 -2
  48. package/dist/components/client/Menu/Menu.Divider.d.cts +2 -2
  49. package/dist/components/client/Menu/Menu.Divider.d.ts +2 -2
  50. package/dist/components/client/Menu/Menu.Item.d.cts +2 -2
  51. package/dist/components/client/Menu/Menu.ItemBase.d.cts +2 -2
  52. package/dist/components/client/Menu/Menu.ItemBase.d.ts +2 -2
  53. package/dist/components/client/Menu/Menu.ItemCheckbox.d.cts +2 -2
  54. package/dist/components/client/Menu/Menu.ItemCheckbox.d.ts +2 -2
  55. package/dist/components/client/Menu/Menu.Provider.d.cts +2 -2
  56. package/dist/components/client/Menu/Menu.Provider.d.ts +2 -2
  57. package/dist/components/client/Menu/Menu.Trigger.d.cts +2 -2
  58. package/dist/components/client/Menu/Menu.Trigger.d.ts +2 -2
  59. package/dist/components/client/Pressable.d.cts +2 -2
  60. package/dist/components/client/Pressable.d.ts +2 -2
  61. package/dist/components/client/Pressable.d.ts.map +1 -1
  62. package/dist/components/client/Radio/RadioGroupStore.d.ts +2 -2
  63. package/dist/components/client/SpringMotionConfig.d.cts +3 -3
  64. package/dist/components/client/SpringMotionConfig.d.ts +3 -3
  65. package/dist/components/client/SpringMotionConfig.d.ts.map +1 -1
  66. package/dist/components/experimental/Spinner.d.cts +2 -2
  67. package/dist/components/experimental/Spinner.d.cts.map +1 -1
  68. package/dist/components/experimental/Spinner.d.ts +2 -2
  69. package/dist/components/experimental/Table.d.cts +2 -2
  70. package/dist/components/experimental/Table.d.ts +2 -2
  71. package/dist/components/experimental/client/Accordion.d.cts +2 -2
  72. package/dist/components/experimental/client/Accordion.d.cts.map +1 -1
  73. package/dist/components/experimental/client/Accordion.d.ts +2 -2
  74. package/dist/components/experimental/client/AvoidMotionLibraryProvider.d.cts +2 -2
  75. package/dist/components/experimental/client/AvoidMotionLibraryProvider.d.ts +2 -2
  76. package/dist/components/experimental/client/Modal.d.cts +3 -3
  77. package/dist/components/experimental/client/Modal.d.cts.map +1 -1
  78. package/dist/components/experimental/client/Modal.d.ts +3 -3
  79. package/dist/components/experimental/client/Popover.d.cts +3 -3
  80. package/dist/components/experimental/client/Popover.d.cts.map +1 -1
  81. package/dist/components/experimental/client/Popover.d.ts +3 -3
  82. package/dist/components/experimental/client/Tabs.d.cts +3 -3
  83. package/dist/components/experimental/client/Tabs.d.ts +6 -6
  84. package/dist/components/experimental/client/Toast.d.cts +2 -2
  85. package/dist/components/experimental/client/Toast.d.ts +2 -2
  86. package/dist/providers/ColorModeProvider.d.cts +4 -4
  87. package/dist/providers/ColorModeProvider.d.cts.map +1 -1
  88. package/dist/providers/ColorModeProvider.d.ts +4 -4
  89. package/dist/providers/ColorModeProvider.d.ts.map +1 -1
  90. package/dist/providers/ScaleModeProvider.d.cts +4 -4
  91. package/dist/providers/ScaleModeProvider.d.cts.map +1 -1
  92. package/dist/providers/ScaleModeProvider.d.ts +4 -4
  93. package/dist/providers/ScaleModeProvider.d.ts.map +1 -1
  94. package/dist/providers/ThemeProvider.d.cts +2 -2
  95. package/dist/providers/ThemeProvider.d.cts.map +1 -1
  96. package/dist/providers/ThemeProvider.d.ts +2 -2
  97. package/dist/styles/styler.d.cts +33 -33
  98. package/dist/styles/styler.d.ts +33 -33
  99. package/dist/styles/stylerTypes.d.ts.map +1 -1
  100. package/dist/tailwind/tailwind.config.d.ts +3 -3
  101. package/dist/tailwind/tailwindPlugin.d.ts +3 -3
  102. package/dist/tailwind/utils/getMotionStyles.d.cts +1 -1
  103. package/dist/tailwind/utils/getMotionStyles.d.ts +1 -1
  104. package/dist/tokens/automation/utils/getConfigVariantProperties.d.cts +2 -2
  105. package/dist/tokens/automation/utils/getConfigVariantProperties.d.cts.map +1 -1
  106. package/dist/tokens/automation/utils/getConfigVariantProperties.d.ts +2 -2
  107. package/dist/tokens/automation/utils/getConfigVariantProperties.d.ts.map +1 -1
  108. package/dist/tokens/types.d.cts.map +1 -1
  109. package/dist/tokens/types.d.ts.map +1 -1
  110. package/dist/utils/intersperse.d.cts +2 -2
  111. package/dist/utils/intersperse.d.ts +2 -2
  112. package/package.json +1 -3
  113. package/cli/FlattenButtonVariant.mock.tsx +0 -17
  114. package/src/components/Box.tsx +0 -181
  115. package/src/components/Divider/Divider.tsx +0 -44
  116. package/src/components/Divider/DividerCore.tsx +0 -101
  117. package/src/components/Divider/DividerInternal.tsx +0 -56
  118. package/src/components/Divider/index.ts +0 -1
  119. package/src/components/FormLabel.tsx +0 -66
  120. package/src/components/HStack.tsx +0 -53
  121. package/src/components/Icon.tsx +0 -82
  122. package/src/components/IconSlot.tsx +0 -82
  123. package/src/components/Image.tsx +0 -162
  124. package/src/components/Link.tsx +0 -134
  125. package/src/components/Text.tsx +0 -272
  126. package/src/components/VStack.tsx +0 -53
  127. package/src/components/client/AnimateHeightChange.tsx +0 -50
  128. package/src/components/client/Avatar/Avatar.tsx +0 -31
  129. package/src/components/client/Avatar/AvatarIcon.tsx +0 -103
  130. package/src/components/client/Avatar/AvatarImage.tsx +0 -147
  131. package/src/components/client/Avatar/AvatarText.tsx +0 -88
  132. package/src/components/client/Avatar/index.ts +0 -4
  133. package/src/components/client/Avatar/utils.ts +0 -105
  134. package/src/components/client/Badge.tsx +0 -133
  135. package/src/components/client/Button.tsx +0 -312
  136. package/src/components/client/Checkbox.tsx +0 -377
  137. package/src/components/client/Chip/Chip.tsx +0 -81
  138. package/src/components/client/Chip/ChipBase.tsx +0 -151
  139. package/src/components/client/Chip/ChipButton.tsx +0 -54
  140. package/src/components/client/Chip/ChipDismissible.tsx +0 -90
  141. package/src/components/client/Chip/ChipLink.tsx +0 -60
  142. package/src/components/client/Chip/ChipToggle.tsx +0 -79
  143. package/src/components/client/Chip/index.ts +0 -5
  144. package/src/components/client/IconButton.tsx +0 -198
  145. package/src/components/client/Input/Input.tsx +0 -323
  146. package/src/components/client/Input/InputHelpText.tsx +0 -52
  147. package/src/components/client/Input/InputHelpTextInternal.tsx +0 -81
  148. package/src/components/client/Input/index.ts +0 -2
  149. package/src/components/client/Menu/Menu.Content.tsx +0 -391
  150. package/src/components/client/Menu/Menu.Divider.tsx +0 -102
  151. package/src/components/client/Menu/Menu.Item.tsx +0 -114
  152. package/src/components/client/Menu/Menu.ItemBase.tsx +0 -265
  153. package/src/components/client/Menu/Menu.ItemCheckbox.tsx +0 -197
  154. package/src/components/client/Menu/Menu.Provider.tsx +0 -154
  155. package/src/components/client/Menu/Menu.Trigger.tsx +0 -119
  156. package/src/components/client/Menu/Menu.index.tsx +0 -9
  157. package/src/components/client/Menu/Menu.tsx +0 -2
  158. package/src/components/client/Menu/index.ts +0 -7
  159. package/src/components/client/Menu/utils/transformAriakitPlacement.ts +0 -66
  160. package/src/components/client/Pressable.tsx +0 -194
  161. package/src/components/client/Radio/Radio.tsx +0 -351
  162. package/src/components/client/Radio/RadioGroupProvider.tsx +0 -122
  163. package/src/components/client/Radio/RadioGroupStore.tsx +0 -56
  164. package/src/components/client/Radio/index.ts +0 -2
  165. package/src/components/client/Radio/useRadioGroup.ts +0 -149
  166. package/src/components/client/SpringMotionConfig.tsx +0 -151
  167. package/src/components/client/Switch.tsx +0 -377
  168. package/src/components/client/index.ts +0 -30
  169. package/src/components/client/motionFeatures/domAnimation.ts +0 -2
  170. package/src/components/client/motionFeatures/domMax.ts +0 -2
  171. package/src/components/experimental/Spinner.tsx +0 -30
  172. package/src/components/experimental/Table.mocks.tsx +0 -38
  173. package/src/components/experimental/Table.tsx +0 -239
  174. package/src/components/experimental/client/Accordion.tsx +0 -77
  175. package/src/components/experimental/client/AvoidMotionLibraryProvider.tsx +0 -10
  176. package/src/components/experimental/client/Modal.tsx +0 -68
  177. package/src/components/experimental/client/Popover.tsx +0 -63
  178. package/src/components/experimental/client/SwitchV2.tsx +0 -343
  179. package/src/components/experimental/client/Tabs.tsx +0 -106
  180. package/src/components/experimental/client/Toast.tsx +0 -186
  181. package/src/components/experimental/client/index.ts +0 -15
  182. package/src/components/experimental/index.ts +0 -48
  183. package/src/components/index.ts +0 -41
  184. package/src/defaultTokensConfig.ts +0 -31
  185. package/src/fixtures/index.ts +0 -638
  186. package/src/fixtures/macros/typesToConstants.ts +0 -42
  187. package/src/fixtures/utils/getScaleModeRamp.ts +0 -48
  188. package/src/fixtures/utils/getTailwindAsUdsColors.ts +0 -115
  189. package/src/flags.ts +0 -45
  190. package/src/hooks/useForkRef.ts +0 -34
  191. package/src/hooks/useNestedBorderRadius.ts +0 -138
  192. package/src/hooks/useRtl.ts +0 -64
  193. package/src/index.ts +0 -4
  194. package/src/providers/ColorModeProvider.tsx +0 -21
  195. package/src/providers/ScaleModeProvider.tsx +0 -29
  196. package/src/providers/ThemeProvider.tsx +0 -26
  197. package/src/styles/styler.ts +0 -194
  198. package/src/styles/stylerTypes.ts +0 -81
  199. package/src/styles/toast.css +0 -0
  200. package/src/styles/variants.ts +0 -1351
  201. package/src/tailwind/base/addColorModeVars.ts +0 -23
  202. package/src/tailwind/base/addColorModeVarsV2.ts +0 -57
  203. package/src/tailwind/base/addFontFaceDeclarations.ts +0 -13
  204. package/src/tailwind/base/addFontVars.ts +0 -9
  205. package/src/tailwind/base/addMotionVars.ts +0 -9
  206. package/src/tailwind/base/addScaleModeVars.ts +0 -33
  207. package/src/tailwind/base/types.ts +0 -8
  208. package/src/tailwind/components/getButtonStyles.ts +0 -240
  209. package/src/tailwind/components/getFocusRingStyles.ts +0 -32
  210. package/src/tailwind/components/getGroupedTextStyles.ts +0 -29
  211. package/src/tailwind/components/getHitTargetStyles.ts +0 -23
  212. package/src/tailwind/components/getIconButtonStyles.ts +0 -49
  213. package/src/tailwind/components/getIconStyles.ts +0 -13
  214. package/src/tailwind/components/getInputStyles.ts +0 -20
  215. package/src/tailwind/components/getResponsiveTextStyles.ts +0 -161
  216. package/src/tailwind/components/types.ts +0 -14
  217. package/src/tailwind/components/utils.ts +0 -73
  218. package/src/tailwind/defaultTailwindThemeAsUdsConfig.ts +0 -78
  219. package/src/tailwind/postcss.config.ts +0 -6
  220. package/src/tailwind/purger/index.ts +0 -1
  221. package/src/tailwind/tailwind.config.ts +0 -50
  222. package/src/tailwind/tailwind.d.ts +0 -5
  223. package/src/tailwind/tailwindPlugin.ts +0 -724
  224. package/src/tailwind/theme/getFontFamilyTheme.ts +0 -28
  225. package/src/tailwind/tsMorph.ts +0 -1
  226. package/src/tailwind/uds.css +0 -3
  227. package/src/tailwind/utils/addFontsPlugin.ts +0 -17
  228. package/src/tailwind/utils/getColorModeStyles.ts +0 -21
  229. package/src/tailwind/utils/getFontFaceDeclarations.ts +0 -12
  230. package/src/tailwind/utils/getFontStyles.ts +0 -38
  231. package/src/tailwind/utils/getMotionStyles.ts +0 -35
  232. package/src/tailwind/utils/getScaleModeStyles.ts +0 -23
  233. package/src/tailwind/utils/getShadowPresetValues.ts +0 -133
  234. package/src/tailwind/utils/getShadowStyles.ts +0 -26
  235. package/src/tailwind/utils/getShadowVars.ts +0 -40
  236. package/src/tailwind/utils/index.ts +0 -9
  237. package/src/tokens/automation/configs/avatar.ts +0 -297
  238. package/src/tokens/automation/configs/badge.ts +0 -306
  239. package/src/tokens/automation/configs/checkbox.ts +0 -226
  240. package/src/tokens/automation/configs/chip.ts +0 -521
  241. package/src/tokens/automation/configs/divider.ts +0 -112
  242. package/src/tokens/automation/configs/index.ts +0 -10
  243. package/src/tokens/automation/configs/input.ts +0 -496
  244. package/src/tokens/automation/configs/link.ts +0 -183
  245. package/src/tokens/automation/configs/menu.ts +0 -344
  246. package/src/tokens/automation/configs/radio.ts +0 -225
  247. package/src/tokens/automation/configs/switch.ts +0 -323
  248. package/src/tokens/automation/index.ts +0 -5
  249. package/src/tokens/automation/mapTextVariantFixtureToValue.ts +0 -8
  250. package/src/tokens/automation/properties.ts +0 -433
  251. package/src/tokens/automation/types/ComponentConfig.ts +0 -116
  252. package/src/tokens/automation/types/ComponentDB.ts +0 -1
  253. package/src/tokens/automation/types/ComponentStyles.ts +0 -47
  254. package/src/tokens/automation/types/index.ts +0 -2
  255. package/src/tokens/automation/utils/cartesianProduct.ts +0 -13
  256. package/src/tokens/automation/utils/coalesceConfigVariant.ts +0 -49
  257. package/src/tokens/automation/utils/defaults.ts +0 -29
  258. package/src/tokens/automation/utils/generateKeyFromFlatConfigPath.ts +0 -15
  259. package/src/tokens/automation/utils/generateSchemaKey.ts +0 -29
  260. package/src/tokens/automation/utils/getConfigComponentVariant.ts +0 -28
  261. package/src/tokens/automation/utils/getConfigVariantComponentStatesMatrix.ts +0 -40
  262. package/src/tokens/automation/utils/getConfigVariantProperties.ts +0 -32
  263. package/src/tokens/automation/utils/getConfigVariantPseudoStates.ts +0 -70
  264. package/src/tokens/automation/utils/getConfigVariants.ts +0 -73
  265. package/src/tokens/automation/utils/index.ts +0 -939
  266. package/src/tokens/automation/utils/mapColorFixtureToValue.ts +0 -34
  267. package/src/tokens/automation/utils/subcomponents.ts +0 -13
  268. package/src/tokens/automation/utils/variableData.ts +0 -79
  269. package/src/tokens/automation/utils/variantConfigGuards.ts +0 -17
  270. package/src/tokens/configs/borderRadius.ts +0 -23
  271. package/src/tokens/configs/borderWidth.ts +0 -17
  272. package/src/tokens/configs/button.ts +0 -888
  273. package/src/tokens/configs/colorMode.ts +0 -14
  274. package/src/tokens/configs/font.ts +0 -9
  275. package/src/tokens/configs/iconButton.ts +0 -28
  276. package/src/tokens/configs/motion.ts +0 -135
  277. package/src/tokens/configs/palette.ts +0 -124
  278. package/src/tokens/configs/scaleMode.ts +0 -28
  279. package/src/tokens/configs/shadow.ts +0 -286
  280. package/src/tokens/configs/sizes.ts +0 -23
  281. package/src/tokens/configs/spectrum.ts +0 -729
  282. package/src/tokens/configs/typography.ts +0 -417
  283. package/src/tokens/configs/yosConfig.ts +0 -7651
  284. package/src/tokens/consts/buttonMotionTokens.ts +0 -99
  285. package/src/tokens/consts/cssTokens.ts +0 -110
  286. package/src/tokens/consts/defaultModes.ts +0 -15
  287. package/src/tokens/consts/fontDeclarationsMap.ts +0 -509
  288. package/src/tokens/index.ts +0 -15
  289. package/src/tokens/parseButtonVariants.ts +0 -59
  290. package/src/tokens/parseTokens.ts +0 -122
  291. package/src/tokens/types.ts +0 -1882
  292. package/src/tokens/utils/entries.ts +0 -14
  293. package/src/tokens/utils/fromEntries.ts +0 -11
  294. package/src/tokens/utils/mapValues.ts +0 -15
  295. package/src/types.ts +0 -2
  296. package/src/utils/assertUnreachable.ts +0 -6
  297. package/src/utils/composeRefs.ts +0 -23
  298. package/src/utils/createSlot.tsx +0 -131
  299. package/src/utils/entries.ts +0 -6
  300. package/src/utils/falsyToString.ts +0 -3
  301. package/src/utils/getMotionVar.ts +0 -18
  302. package/src/utils/intersperse.ts +0 -45
  303. package/src/utils/mapValues.ts +0 -15
  304. package/src/utils/mergeSlotProps.ts +0 -70
@@ -1,939 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
-
3
- import type {
4
- ComponentConfig,
5
- ComponentStateConfig,
6
- LayerConfig,
7
- PossibleStates,
8
- SubComponentConfig,
9
- VariantConfig,
10
- VariantConfigWithComponentStates,
11
- VariantConfigWithProperties,
12
- } from '@yahoo/uds/tokens';
13
- import type {
14
- ConfigurablePropertiesName,
15
- SelectedConfigurableProperty,
16
- } from '@yahoo/uds/tokens/automation/properties';
17
- import { configurableProperties } from '@yahoo/uds/tokens/automation/properties';
18
- import { isFunction, lowerCase, mergeWith } from 'lodash';
19
-
20
- import { generateSchemaKey } from './generateSchemaKey';
21
-
22
- type ThemeFn = (path: string) => string;
23
-
24
- type SchemaStateValue<T = any> = {
25
- type: string;
26
- valueType: 'alias' | 'custom';
27
- value: T; // You might want to define a more specific type here
28
- };
29
-
30
- type VariableState = {
31
- rest: SchemaStateValue;
32
- } & {
33
- [K in PossibleStates]?: SchemaStateValue;
34
- };
35
-
36
- /**
37
- * Map our "states" to pseudo-classes (hover => :hover, pressed => :active, etc.).
38
- * Adjust or extend as needed.
39
- */
40
- const statePseudoMap: Record<PossibleStates | 'rest', string> = {
41
- rest: '',
42
- hover: ':hover:not(:has(:disabled))',
43
- pressed: ':active:not(:has(:disabled))',
44
- focused: ':focus',
45
- 'focus-within': ':focus-within',
46
- // TODO: some of these are very specific to input we need to find a way to make them generic
47
- invalid: ':has(input[aria-invalid="true"])',
48
- 'focused-keyboard': ':focus-visible',
49
- visited: ':visited',
50
- readonly: ':has(input:read-only)',
51
- disabled: ':has(:disabled)',
52
-
53
- // Compound selectors
54
- 'invalid&hover': ':has(input[aria-invalid="true"]):hover:not(:has(:disabled))',
55
- 'invalid&pressed': ':has(input[aria-invalid="true"]):active:not(:has(:disabled))',
56
- };
57
-
58
- export const statePseudoMapDocsMode: Record<PossibleStates | 'rest', string> = {
59
- rest: '',
60
- hover: 'hover',
61
- pressed: 'active',
62
- focused: 'focus',
63
- 'focus-within': 'focus-within',
64
- invalid: 'has-input-invalid',
65
- 'focused-keyboard': 'focus-visible',
66
- visited: 'visited',
67
- readonly: 'input-readonly',
68
- disabled: 'has-disabled',
69
-
70
- // Compound selectors
71
- 'invalid&hover': 'has-input-invalid-and-hover',
72
- 'invalid&pressed': 'has-input-invalid-and-active',
73
- };
74
-
75
- export function findFixtureType(
76
- property: SelectedConfigurableProperty<ConfigurablePropertiesName, string>,
77
- variantKey: string,
78
- ): string {
79
- const defaultValue = property.defaults[variantKey];
80
- const typeOfFixture = property.typeOfFixture;
81
- // find the corresponding fixture type
82
- let index = 0;
83
- property.values.forEach((arrayOfValues, i) => {
84
- if (arrayOfValues.includes(defaultValue)) {
85
- index = i;
86
- }
87
- });
88
- return typeOfFixture[index];
89
- }
90
-
91
- // We define a helper to produce the minimal shape at runtime
92
- // TODO: the return type shouldn't be `any` we need to have some sort of type safety for this, at least, just the shape
93
- export function toMinimalDbConfigObject<C extends ComponentConfig>(config: C): any {
94
- const result: any = {};
95
- // 1) "defaults"
96
- // For each variant -> use the "default" if it is in `options`
97
- const defaultsObj: any = {};
98
- for (const variantKey in config.variants) {
99
- const v = config.variants[variantKey];
100
- // For runtime, we trust the user that "v.default" is in "v.options"
101
- defaultsObj[variantKey] = v.default;
102
- }
103
- result.defaults = defaultsObj;
104
-
105
- result.variables = {};
106
- // for each variant key
107
- for (const variantKey in config.variants) {
108
- const variantConfig = config.variants[variantKey];
109
- // for each variant option
110
- for (const variantOption of variantConfig.options) {
111
- // if we have componentStates
112
- if ((variantConfig as VariantConfigWithComponentStates<string>).componentStates) {
113
- const componentStates = (variantConfig as VariantConfigWithComponentStates<string>)
114
- .componentStates;
115
- // for each component state key
116
- for (const componentStateKey in componentStates) {
117
- const componentState = componentStates[componentStateKey];
118
- // for each component state option
119
- for (const componentStateOption of componentState.options) {
120
- // for each layer key
121
- for (const layerKey in componentState.layers) {
122
- const layer = componentState.layers[layerKey];
123
- // for each prop
124
- const schemaKey = generateSchemaKey({
125
- variantKey,
126
- variantValue: variantOption,
127
- stateKey: componentStateKey,
128
- stateValue: componentStateOption,
129
- layer: layerKey,
130
- });
131
-
132
- result.variables[schemaKey] = {};
133
- for (const propKey in layer.properties) {
134
- const prop = layer.properties[propKey];
135
- // if the property has component states
136
- // TODO: create a concrete type instead of using `any`
137
- const variableObject: any = {
138
- [propKey]: {
139
- // for each pseudo state
140
- rest: {
141
- type: findFixtureType(prop, variantOption),
142
- valueType: 'alias',
143
- value: prop.defaults[variantOption],
144
- },
145
- },
146
- };
147
- if (prop.pseudoStates) {
148
- for (const pseudoState of prop.pseudoStates) {
149
- variableObject[propKey][pseudoState] = {
150
- type: findFixtureType(prop, variantOption),
151
- valueType: 'alias',
152
- value: prop.defaults[variantOption],
153
- };
154
- }
155
- }
156
- // add it to the result
157
- result.variables[schemaKey] = {
158
- ...result.variables[schemaKey],
159
- ...variableObject,
160
- };
161
- }
162
- }
163
- }
164
- }
165
- }
166
- // we don't have component states
167
- else {
168
- // for each layer key
169
- for (const layerKey in (variantConfig as VariantConfigWithProperties).layers) {
170
- const layer = (variantConfig as VariantConfigWithProperties).layers[layerKey];
171
- // for each prop
172
- const schemaKey = generateSchemaKey({
173
- variantKey,
174
- variantValue: variantOption,
175
- layer: layerKey,
176
- });
177
-
178
- result.variables[schemaKey] = {};
179
- for (const propKey in layer.properties) {
180
- const prop = layer.properties[propKey];
181
- // if the property has component states
182
- // TODO: create a concrete type instead of using `any`
183
- const variableObject: any = {
184
- [propKey]: {
185
- rest: {
186
- type: findFixtureType(prop, variantOption),
187
- valueType: 'alias',
188
- value: prop.defaults[variantOption],
189
- },
190
- },
191
- };
192
- if (prop.pseudoStates) {
193
- for (const pseudoState of prop.pseudoStates) {
194
- variableObject[propKey][pseudoState] = {
195
- type: findFixtureType(prop, variantOption),
196
- valueType: 'alias',
197
- value: prop.defaults[variantOption],
198
- };
199
- }
200
- }
201
- // add it to the result
202
- result.variables[schemaKey] = {
203
- ...result.variables[schemaKey],
204
- ...variableObject,
205
- };
206
- }
207
- }
208
- }
209
- }
210
- }
211
-
212
- // if we have sub components
213
- if (config.subComponents) {
214
- const { subComponents } = config;
215
- for (const subComponentKey in subComponents) {
216
- // for each variant key
217
- for (const variantKey in subComponents[subComponentKey].variants) {
218
- const variantConfig = subComponents[subComponentKey].variants[variantKey];
219
- // add to the defaults
220
- result.defaults[variantKey] = variantConfig.default;
221
- // for each variant option
222
- for (const variantOption of variantConfig.options) {
223
- // if we have componentStates
224
- if ((variantConfig as VariantConfigWithComponentStates<string>).componentStates) {
225
- const componentStates = (variantConfig as VariantConfigWithComponentStates<string>)
226
- .componentStates;
227
- // for each component state key
228
- for (const componentStateKey in componentStates) {
229
- const componentState = componentStates[componentStateKey];
230
- // for each component state option
231
- for (const componentStateOption of componentState.options) {
232
- // for each layer key
233
- for (const layerKey in componentState.layers) {
234
- const layer = componentState.layers[layerKey];
235
- // for each prop
236
- const schemaKey = generateSchemaKey({
237
- variantKey,
238
- variantValue: variantOption,
239
- stateKey: componentStateKey,
240
- stateValue: componentStateOption,
241
- layer: layerKey,
242
- subComponentName: subComponentKey,
243
- });
244
- result.variables[schemaKey] = {};
245
- for (const propKey in layer.properties) {
246
- const prop = layer.properties[propKey];
247
- // if the property has component states
248
- // TODO: create a concrete type instead of using `any`
249
- const variableObject: any = {
250
- [propKey]: {
251
- rest: {
252
- type: findFixtureType(prop, variantOption),
253
- valueType: 'alias',
254
- value: prop.defaults[variantOption],
255
- },
256
- },
257
- };
258
- if (prop.pseudoStates) {
259
- for (const pseudoState of prop.pseudoStates) {
260
- variableObject[propKey][pseudoState] = {
261
- type: findFixtureType(prop, variantOption),
262
- valueType: 'alias',
263
- value: prop.defaults[variantOption],
264
- };
265
- }
266
- }
267
- // add it to the result
268
- result.variables[schemaKey] = {
269
- ...result.variables[schemaKey],
270
- ...variableObject,
271
- };
272
- }
273
- }
274
- }
275
- }
276
- }
277
- // we don't have component states
278
- else {
279
- // for each layer key
280
- for (const layerKey in (variantConfig as VariantConfigWithProperties).layers) {
281
- const layer = (variantConfig as VariantConfigWithProperties).layers[layerKey];
282
- // for each prop
283
- const schemaKey = generateSchemaKey({
284
- variantKey,
285
- variantValue: variantOption,
286
- layer: layerKey,
287
- subComponentName: subComponentKey,
288
- });
289
-
290
- result.variables[schemaKey] = {};
291
- for (const propKey in layer.properties) {
292
- const prop = layer.properties[propKey];
293
- // if the property has component states
294
- // TODO: create a concrete type instead of using `any`
295
- const variableObject: any = {
296
- [propKey]: {
297
- rest: {
298
- type: findFixtureType(prop, variantOption),
299
- valueType: 'alias',
300
- value: prop.defaults[variantOption],
301
- },
302
- },
303
- };
304
- if (prop.pseudoStates) {
305
- for (const pseudoState of prop.pseudoStates) {
306
- variableObject[propKey][pseudoState] = {
307
- type: findFixtureType(prop, variantOption),
308
- valueType: 'alias',
309
- value: prop.defaults[variantOption],
310
- };
311
- }
312
- }
313
- // add it to the result
314
- result.variables[schemaKey] = {
315
- ...result.variables[schemaKey],
316
- ...variableObject,
317
- };
318
- }
319
- }
320
- }
321
- }
322
- }
323
- }
324
- }
325
-
326
- return result;
327
- }
328
-
329
- export function generateClassName({
330
- componentName,
331
- variantKey,
332
- variantValue,
333
- layer,
334
- layerOptionalPseudoSelector,
335
- subComponentName,
336
- stateKey,
337
- stateValue,
338
- }: {
339
- componentName: string;
340
- variantKey: string;
341
- variantValue?: string;
342
- layer: string;
343
- layerOptionalPseudoSelector?: string;
344
- subComponentName?: string;
345
- stateKey?: string;
346
- stateValue?: string;
347
- }): string {
348
- let className = '';
349
- if (subComponentName) {
350
- className = `uds-${lowerCase(componentName)}-${lowerCase(subComponentName)}-${lowerCase(variantKey)}`;
351
- } else {
352
- className = `uds-${lowerCase(componentName)}-${lowerCase(variantKey)}`;
353
- }
354
-
355
- if (variantValue) {
356
- className = `${className}-${lowerCase(variantValue)}`;
357
- }
358
-
359
- if (stateKey && stateValue) {
360
- className = `${className}-${lowerCase(stateKey)}-${lowerCase(stateValue)}`;
361
- }
362
-
363
- className = `${className}-${lowerCase(layer)}`;
364
-
365
- if (layerOptionalPseudoSelector) {
366
- className = `${className}${layerOptionalPseudoSelector}`;
367
- }
368
-
369
- return className.replaceAll(/\s+/g, '-');
370
- }
371
-
372
- export function generateDeclaration({
373
- componentName,
374
- variantKey,
375
- variantValue,
376
- layer,
377
- layerOptionalPseudoSelector,
378
- subComponentName,
379
- stateKey,
380
- stateValue,
381
- schema,
382
- propertyKey,
383
- originalPropertyDefinition,
384
- theme,
385
- currentStyles,
386
- previewOptions,
387
- }: {
388
- componentName: string;
389
- variantKey: string;
390
- variantValue: string;
391
- layer: string;
392
- layerOptionalPseudoSelector?: string; // only gets applied to non root layers
393
- subComponentName?: string;
394
- stateKey?: string;
395
- stateValue?: string;
396
- // TODO: define and use a type for the Schema
397
- schema: unknown;
398
- propertyKey: string;
399
- originalPropertyDefinition: SelectedConfigurableProperty<ConfigurablePropertiesName, any>;
400
- theme: ThemeFn;
401
- currentStyles: Readonly<Record<string, Record<string, string>>>;
402
- previewOptions?: {
403
- generatePseudoStateClassModifier?: boolean;
404
- };
405
- }) {
406
- /// Logic for generating the class names:
407
- /// If its the root layer
408
- /// - if we have component states
409
- /// - We need to combine the class that has the variant and the class that has the component state
410
- /// => example: '.uds-chip-toggle-variant-primary-root.uds-chip-toggle-variant-active-off-root'
411
- /// - else
412
- /// - We only need one class for the root layer
413
- /// => example: '.uds-chip-link-variant-primary-root'
414
- /// If its not the root layer
415
- /// - We need to nest the child layer under the root layer
416
- /// - if we have component states
417
- /// - The child layer should only have the variant and its value present since the root layer already has the component state present
418
- /// => example: '.uds-chip-toggle-variant-primary-root.uds-chip-toggle-variant-active-off-root .uds-chip-toggle-variant-primary-icon'
419
- /// - If we dont have component state
420
- /// => example: '.uds-chip-dismissible-variant-primary-root .uds-chip-dismissible-variant-primary-icon'
421
- /// Note: The classes should match what's on `autoVariants.ts`
422
- const schemaKey = generateSchemaKey({
423
- variantKey,
424
- variantValue,
425
- layer,
426
- subComponentName,
427
- stateKey,
428
- stateValue,
429
- });
430
-
431
- let className = generateClassName({
432
- componentName,
433
- variantKey,
434
- variantValue,
435
- layer,
436
- subComponentName,
437
- stateKey,
438
- stateValue,
439
- });
440
-
441
- // @ts-expect-error - fix the types later
442
- const propertySelectedValueInSchema = schema.variables[schemaKey][propertyKey] as VariableState;
443
-
444
- if (!propertySelectedValueInSchema) {
445
- if (schemaKey === 'size/md/root' && propertyKey === 'spacingHorizontal') {
446
- // @ts-expect-error - log
447
- console.log({ componentName, schemaKey, propertyKey }, schema.variables);
448
- }
449
-
450
- throw new Error(
451
- `Prop definition (${componentName} - ${schemaKey} - ${propertyKey}) not found, this is not expected, please report the bug to the UDS team`,
452
- );
453
- }
454
-
455
- const styles: Record<string, Record<string, string>> = {};
456
- // loop through the property states
457
- for (const stateStr in propertySelectedValueInSchema) {
458
- const state = stateStr as keyof VariableState;
459
- const pseudo = statePseudoMap[state] ?? '';
460
- const schemaValueForState = propertySelectedValueInSchema[state] as SchemaStateValue;
461
-
462
- let fullClassName = ``;
463
- if (layer === 'root') {
464
- // We need to nest the component state classes under the variant classes
465
- if (stateKey && stateValue) {
466
- // We need to nest the component state classes under the variant class
467
- const rootVariantClass = generateClassName({
468
- componentName,
469
- variantKey,
470
- variantValue,
471
- layer,
472
- subComponentName,
473
- });
474
-
475
- className = generateClassName({
476
- componentName,
477
- variantKey,
478
- layer,
479
- subComponentName,
480
- stateKey,
481
- stateValue,
482
- });
483
-
484
- fullClassName = `.${rootVariantClass}${pseudo}.${className}`;
485
- } else {
486
- fullClassName = `.${className}${pseudo}`;
487
- }
488
- } else {
489
- const rootVariantClassName = generateClassName({
490
- componentName,
491
- variantKey,
492
- variantValue,
493
- layer: 'root',
494
- subComponentName,
495
- });
496
-
497
- if (stateKey && stateValue) {
498
- const rootVariantClassNameWithComponentState = generateClassName({
499
- componentName,
500
- variantKey,
501
- layer: 'root',
502
- subComponentName,
503
- stateKey,
504
- stateValue,
505
- });
506
- // the layer class name should not have component states, but we need the variant key and value
507
- className = generateClassName({
508
- componentName,
509
- variantKey,
510
- variantValue,
511
- layer,
512
- layerOptionalPseudoSelector,
513
- subComponentName,
514
- });
515
- fullClassName = `.${rootVariantClassName}${pseudo}.${rootVariantClassNameWithComponentState} .${className}`;
516
- } else {
517
- fullClassName = `.${rootVariantClassName}${pseudo} .${className}`;
518
- }
519
- }
520
-
521
- const getTheCssPropertyValue = (
522
- schemaStateValue: SchemaStateValue,
523
- propertyName: keyof typeof configurableProperties,
524
- theme: ThemeFn,
525
- existingValue?: string,
526
- ): string => {
527
- const { value, type } = schemaStateValue;
528
- const propertyConfig = configurableProperties[propertyName];
529
-
530
- let newValue: string;
531
- if (configurableProperties[propertyName].customValueRenderer) {
532
- newValue = configurableProperties[propertyName].customValueRenderer(
533
- schemaStateValue,
534
- schema,
535
- theme,
536
- );
537
- } else {
538
- const twThemePath = configurableProperties[propertyName].twThemePath(
539
- // @ts-expect-error - fix the types later
540
- type,
541
- String(value),
542
- );
543
- newValue = theme(twThemePath);
544
- }
545
-
546
- // If this property should be concatenated with existing values and we have an existing value
547
- if (propertyConfig.concatenate && existingValue) {
548
- const delimiter = propertyConfig.concatenationDelimiter || ', ';
549
- return `${existingValue}${delimiter}${newValue}`;
550
- }
551
-
552
- return newValue;
553
- };
554
-
555
- // we need to get the property definition from the typescript object
556
- // because we need to know the property name (not just the fixture type)
557
- const { cssProperties, extendedProperties: extendedPropertiesGetter } =
558
- configurableProperties[originalPropertyDefinition.name];
559
- const cssDeclarations: Record<string, string> = {};
560
-
561
- // Extended properties can either be a hardcoded array of strings or a function that returns an array of strings.
562
- const isExtendedPropertiesFunction = isFunction(extendedPropertiesGetter);
563
- const extendedProperties = isExtendedPropertiesFunction
564
- ? extendedPropertiesGetter({ componentName, subComponentName, layer, propertyKey })
565
- : extendedPropertiesGetter;
566
-
567
- if (extendedProperties && extendedProperties.length) {
568
- if (
569
- !isExtendedPropertiesFunction &&
570
- (typeof cssProperties === 'string' ||
571
- (Array.isArray(cssProperties) && cssProperties.length > 0))
572
- ) {
573
- throw new Error(
574
- 'Invalid configuration: cssProperties should not be configured when extendedProperties are defined. Please update your property configuration accordingly.',
575
- );
576
- }
577
-
578
- for (const extendedProp of extendedProperties) {
579
- const originalPropertyDefinition = configurableProperties[extendedProp];
580
- const cssPropertiesRef = originalPropertyDefinition.cssProperties;
581
-
582
- if (typeof cssPropertiesRef === 'string') {
583
- const existingValue = currentStyles?.[fullClassName]?.[cssPropertiesRef];
584
-
585
- cssDeclarations[cssPropertiesRef] = getTheCssPropertyValue(
586
- schemaValueForState,
587
- extendedProp,
588
- theme,
589
- existingValue,
590
- );
591
- } else if (Array.isArray(cssPropertiesRef)) {
592
- for (const cssProp of cssPropertiesRef) {
593
- const existingValue = currentStyles?.[fullClassName]?.[cssProp];
594
-
595
- cssDeclarations[cssProp] = getTheCssPropertyValue(
596
- schemaValueForState,
597
- extendedProp,
598
- theme,
599
- existingValue,
600
- );
601
- }
602
- }
603
- }
604
- } else {
605
- if (typeof cssProperties === 'string') {
606
- // Check if we already have a value for this CSS property
607
- const existingValue = currentStyles?.[fullClassName]?.[cssProperties];
608
-
609
- cssDeclarations[cssProperties] = getTheCssPropertyValue(
610
- schemaValueForState,
611
- originalPropertyDefinition.name,
612
- theme,
613
- existingValue,
614
- );
615
- } else if (Array.isArray(cssProperties)) {
616
- for (const cssProp of cssProperties) {
617
- const existingValue = currentStyles?.[fullClassName]?.[cssProp];
618
-
619
- cssDeclarations[cssProp] = getTheCssPropertyValue(
620
- schemaValueForState,
621
- originalPropertyDefinition.name,
622
- theme,
623
- existingValue,
624
- );
625
- }
626
- }
627
- }
628
-
629
- if (!styles[fullClassName]) {
630
- styles[fullClassName] = {
631
- ...cssDeclarations,
632
- ...styles[fullClassName],
633
- };
634
- }
635
-
636
- // todo rename to prefix
637
- if (previewOptions?.generatePseudoStateClassModifier) {
638
- const pseudoPrefixClass = statePseudoMapDocsMode[state] ?? '';
639
-
640
- if (pseudoPrefixClass.length > 0 && stateStr !== 'root') {
641
- // Add !important to all CSS declarations for docs mode to ensure they override pseudo-class styles
642
- const importantCssDeclarations = Object.fromEntries(
643
- Object.entries(cssDeclarations).map(([prop, value]) => [prop, `${value} !important`]),
644
- );
645
-
646
- styles[`.${pseudoPrefixClass}${fullClassName}`.replace(pseudo, '')] = {
647
- ...importantCssDeclarations,
648
- ...styles[`.${pseudoPrefixClass}${fullClassName}`.replace(pseudo, '')],
649
- };
650
- }
651
- }
652
- }
653
-
654
- return styles;
655
- }
656
-
657
- export function generateStyles<C extends ComponentConfig>(
658
- config: C,
659
- schema: any,
660
- theme: ThemeFn,
661
- previewOptions?: {
662
- generatePseudoStateClassModifier: boolean;
663
- },
664
- ): Record<string, Record<string, string>> {
665
- function deepMerge<T extends object, U extends object>(target: T, source: U): T & U {
666
- return mergeWith({}, target, source);
667
- }
668
-
669
- let componentName = config.label.toLowerCase();
670
- if (config.overrideComponentName) {
671
- componentName = config.overrideComponentName.toLowerCase();
672
- }
673
-
674
- let styles: Record<string, Record<string, string>> = {};
675
- for (const variantKey in config.variants) {
676
- const variantConfig = config.variants[variantKey];
677
- // for each variant option
678
- for (const variantOption of variantConfig.options) {
679
- // if we have componentStates
680
- if ((variantConfig as VariantConfigWithComponentStates<string>).componentStates) {
681
- const componentStates = (variantConfig as VariantConfigWithComponentStates<string>)
682
- .componentStates;
683
- // for each component state key
684
- for (const componentStateKey in componentStates) {
685
- const componentState = componentStates[componentStateKey];
686
- // for each component state option
687
- for (const componentStateOption of componentState.options) {
688
- // for each layer key
689
- for (const layerKey in componentState.layers) {
690
- const layer = componentState.layers[layerKey];
691
- // for each prop
692
- for (const propertyKey in layer.properties) {
693
- const originalPropertyDefinition = layer.properties[propertyKey];
694
- const declarations = generateDeclaration({
695
- componentName,
696
- variantKey,
697
- variantValue: variantOption,
698
- stateKey: componentStateKey,
699
- stateValue: componentStateOption,
700
- layer: layerKey,
701
- layerOptionalPseudoSelector: layer.pseudoSelector,
702
- propertyKey,
703
- originalPropertyDefinition,
704
- theme,
705
- schema,
706
- currentStyles: styles,
707
- previewOptions,
708
- });
709
- styles = deepMerge(styles, declarations);
710
- }
711
- }
712
- }
713
- }
714
- }
715
- // we don't have component states
716
- else {
717
- // for each layer key
718
- for (const layerKey in (variantConfig as VariantConfigWithProperties).layers) {
719
- const layer = (variantConfig as VariantConfigWithProperties).layers[layerKey];
720
-
721
- for (const propertyKey in layer.properties) {
722
- const originalPropertyDefinition = layer.properties[propertyKey];
723
- const declarations = generateDeclaration({
724
- componentName,
725
- variantKey,
726
- variantValue: variantOption,
727
- layer: layerKey,
728
- layerOptionalPseudoSelector: layer.pseudoSelector,
729
- propertyKey,
730
- originalPropertyDefinition,
731
- theme,
732
- schema,
733
- currentStyles: styles,
734
- previewOptions,
735
- });
736
- styles = deepMerge(styles, declarations);
737
- }
738
- }
739
- }
740
- }
741
- }
742
-
743
- // if we have sub components
744
- if (config.subComponents) {
745
- const { subComponents } = config;
746
- for (const subComponentKey in subComponents) {
747
- // for each variant key
748
- for (const variantKey in subComponents[subComponentKey].variants) {
749
- const variantConfig = subComponents[subComponentKey].variants[variantKey];
750
- // for each variant option
751
- for (const variantOption of variantConfig.options) {
752
- // if we have componentStates
753
- if ((variantConfig as VariantConfigWithComponentStates<string>).componentStates) {
754
- const componentStates = (variantConfig as VariantConfigWithComponentStates<string>)
755
- .componentStates;
756
- // for each component state key
757
- for (const componentStateKey in componentStates) {
758
- const componentState = componentStates[componentStateKey];
759
- // for each component state option
760
- for (const componentStateOption of componentState.options) {
761
- // for each layer key
762
- for (const layerKey in componentState.layers) {
763
- const layer = componentState.layers[layerKey];
764
- for (const propertyKey in layer.properties) {
765
- const originalPropertyDefinition = layer.properties[propertyKey];
766
- const declarations = generateDeclaration({
767
- componentName,
768
- variantKey,
769
- variantValue: variantOption,
770
- stateKey: componentStateKey,
771
- stateValue: componentStateOption,
772
- subComponentName: subComponentKey,
773
- layer: layerKey,
774
- layerOptionalPseudoSelector: layer.pseudoSelector,
775
- propertyKey,
776
- originalPropertyDefinition,
777
- theme,
778
- schema,
779
- currentStyles: styles,
780
- previewOptions,
781
- });
782
- styles = deepMerge(styles, declarations);
783
- }
784
- }
785
- }
786
- }
787
- }
788
- // we don't have component states
789
- else {
790
- // for each layer key
791
- for (const layerKey in (variantConfig as VariantConfigWithProperties).layers) {
792
- const layer = (variantConfig as VariantConfigWithProperties).layers[layerKey];
793
- // for each prop
794
- for (const propertyKey in layer.properties) {
795
- // if the property has component states
796
- const originalPropertyDefinition = layer.properties[propertyKey];
797
- const declarations = generateDeclaration({
798
- componentName,
799
- subComponentName: subComponentKey,
800
- variantKey,
801
- variantValue: variantOption,
802
- layer: layerKey,
803
- layerOptionalPseudoSelector: layer.pseudoSelector,
804
- propertyKey,
805
- originalPropertyDefinition,
806
- theme,
807
- schema,
808
- currentStyles: styles,
809
- previewOptions,
810
- });
811
- styles = deepMerge(styles, declarations);
812
- }
813
- }
814
- }
815
- }
816
- }
817
- }
818
- }
819
-
820
- return styles;
821
- }
822
-
823
- export function createConfigurableProperty<
824
- C extends ConfigurablePropertiesName,
825
- O extends string,
826
- T extends (typeof configurableProperties)[C]['possibleFixtures'],
827
- V extends readonly (readonly string[])[] = readonly (readonly string[])[],
828
- >(prop: {
829
- name: C;
830
- typeOfFixture: T;
831
- values: V;
832
- defaults: { [K in O]: V[number][number] };
833
- label: string;
834
- pseudoStates?: PossibleStates[];
835
- supportsCustom?: boolean;
836
- }): SelectedConfigurableProperty<C, O, T, V> {
837
- return prop;
838
- }
839
-
840
- /**
841
- * @deprecated use the new functions instead
842
- */
843
- export function createVariantConfig<
844
- O extends string,
845
- T extends Record<string, SelectedConfigurableProperty<ConfigurablePropertiesName, O>>,
846
- >(config: {
847
- label: string;
848
- description: string;
849
- isConfigurable: boolean;
850
- default: O;
851
- options: readonly O[];
852
- properties: T;
853
- }): VariantConfig<O> {
854
- return config;
855
- }
856
-
857
- export function createComponentStateConfig(config: {
858
- label: string;
859
- options: string[];
860
- layers: {
861
- root: LayerConfig;
862
- } & Record<string, LayerConfig>;
863
- }): ComponentStateConfig {
864
- return config;
865
- }
866
-
867
- export function createVariantConfigWithProperties(config: {
868
- label: string;
869
- description: string;
870
- isConfigurable: boolean;
871
- default: string;
872
- options: readonly string[];
873
- layers: {
874
- root: LayerConfig;
875
- } & Record<string, LayerConfig>;
876
- }): VariantConfigWithProperties {
877
- return config;
878
- }
879
-
880
- export function createVariantConfigWithComponentStates(config: {
881
- label: string;
882
- description: string;
883
- isConfigurable: boolean;
884
- default: string;
885
- options: readonly string[];
886
- componentStates: Record<string, ComponentStateConfig>;
887
- }): VariantConfigWithComponentStates {
888
- return config;
889
- }
890
-
891
- export function createComponentStates(config: {
892
- label: string;
893
- options: string[];
894
- layers: {
895
- root: LayerConfig;
896
- } & Record<string, LayerConfig>;
897
- }): ComponentStateConfig {
898
- return config;
899
- }
900
-
901
- export function createLayerConfig(config: {
902
- label: string;
903
- // a pseudo selector to apply to the layer (example placeholder on input)
904
- pseudoSelector?: string;
905
- properties: Readonly<
906
- Record<string, SelectedConfigurableProperty<ConfigurablePropertiesName, string>>
907
- >;
908
- }): LayerConfig {
909
- return config;
910
- }
911
-
912
- export function createSubComponentConfig(config: {
913
- label: string;
914
- description: string;
915
- overrideComponentName?: string;
916
- variants: Record<string, VariantConfigWithProperties | VariantConfigWithComponentStates>;
917
- }): SubComponentConfig {
918
- return config;
919
- }
920
-
921
- export type { SchemaStateValue };
922
- export { cartesianProduct } from './cartesianProduct';
923
- export { coalesceConfigVariant } from './coalesceConfigVariant';
924
- export { getConfigDefaultValue, isConfigDefaultValue } from './defaults';
925
- export { generateKeyFromFlatConfigPath } from './generateKeyFromFlatConfigPath';
926
- export { generateSchemaKey } from './generateSchemaKey';
927
- export {
928
- getConfigVariantComponentStates,
929
- getConfigVariantComponentStatesMatrix,
930
- } from './getConfigVariantComponentStatesMatrix';
931
- export { getConfigVariantProperties } from './getConfigVariantProperties';
932
- export { getConfigVariantPseudoStates } from './getConfigVariantPseudoStates';
933
- export { getConfigVariants } from './getConfigVariants';
934
- export { getConfigSubcomponents } from './subcomponents';
935
- export {
936
- getConfigPseudoStateVariables,
937
- getConfigPseudoStateVariablesWithSetter,
938
- setConfigPseudoStateVariable,
939
- } from './variableData';