@spaced-out/ui-design-system 0.1.27 → 0.1.29

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 (78) hide show
  1. package/.cspell/custom-words.txt +4 -0
  2. package/.storybook/main.js +30 -0
  3. package/.storybook/manager-head.html +4 -0
  4. package/.storybook/preview-head.html +17 -0
  5. package/CHANGELOG.md +28 -0
  6. package/lib/components/Badge/Badge.js +3 -1
  7. package/lib/components/Badge/Badge.js.flow +2 -2
  8. package/lib/components/Checkbox/Checkbox.js +3 -7
  9. package/lib/components/Checkbox/Checkbox.js.flow +3 -8
  10. package/lib/components/Pagination/Pagination.js +2 -2
  11. package/lib/components/Pagination/Pagination.js.flow +1 -1
  12. package/lib/hooks/useCopyToClipboard/index.js +16 -0
  13. package/lib/hooks/useCopyToClipboard/index.js.flow +3 -0
  14. package/lib/hooks/useInputState/index.js +16 -0
  15. package/lib/hooks/useInputState/index.js.flow +3 -0
  16. package/lib/hooks/useLockedBody/index.js +16 -0
  17. package/lib/hooks/useLockedBody/index.js.flow +3 -0
  18. package/lib/hooks/usePagination/index.js +16 -0
  19. package/lib/hooks/usePagination/index.js.flow +3 -0
  20. package/lib/hooks/{usePagination.js → usePagination/usePagination.js} +5 -4
  21. package/lib/hooks/{usePagination.js.flow → usePagination/usePagination.js.flow} +7 -5
  22. package/lib/hooks/useToastPortal/index.js +16 -0
  23. package/lib/hooks/useToastPortal/index.js.flow +3 -0
  24. package/lib/hooks/{useToastPortal.js → useToastPortal/useToastPortal.js} +2 -2
  25. package/lib/hooks/{useToastPortal.js.flow → useToastPortal/useToastPortal.js.flow} +2 -2
  26. package/lib/hooks/useToggle/index.js +16 -0
  27. package/lib/hooks/useToggle/index.js.flow +3 -0
  28. package/lib/hooks/useWindowSize/index.js +16 -0
  29. package/lib/hooks/useWindowSize/index.js.flow +3 -0
  30. package/lib/utils/{click-away.js → click-away/click-away.js} +1 -1
  31. package/lib/utils/{click-away.js.flow → click-away/click-away.js.flow} +1 -1
  32. package/lib/utils/click-away/index.js +16 -0
  33. package/lib/utils/click-away/index.js.flow +3 -0
  34. package/lib/utils/dom/index.js +16 -0
  35. package/lib/utils/dom/index.js.flow +3 -0
  36. package/lib/utils/helpers/index.js +16 -0
  37. package/lib/utils/helpers/index.js.flow +3 -0
  38. package/lib/utils/makeClassNameComponent/index.js +16 -0
  39. package/lib/utils/makeClassNameComponent/index.js.flow +3 -0
  40. package/lib/utils/{makeClassNameComponent.js → makeClassNameComponent/makeClassNameComponent.js} +1 -1
  41. package/lib/utils/{makeClassNameComponent.js.flow → makeClassNameComponent/makeClassNameComponent.js.flow} +1 -1
  42. package/lib/utils/menu/index.js +16 -0
  43. package/lib/utils/menu/index.js.flow +3 -0
  44. package/lib/utils/{menu.js → menu/menu.js} +1 -1
  45. package/lib/utils/{menu.js.flow → menu/menu.js.flow} +2 -3
  46. package/lib/utils/merge-refs/index.js +16 -0
  47. package/lib/utils/merge-refs/index.js.flow +3 -0
  48. package/lib/utils/string/index.js +16 -0
  49. package/lib/utils/string/index.js.flow +3 -0
  50. package/lib/utils/tokens/index.js +16 -0
  51. package/lib/utils/tokens/index.js.flow +3 -0
  52. package/lib/utils/tokens/tokens.js +154 -0
  53. package/lib/utils/tokens/tokens.js.flow +228 -0
  54. package/package.json +2 -1
  55. package/lib/utils/tokens.js +0 -74
  56. package/lib/utils/tokens.js.flow +0 -82
  57. /package/lib/hooks/{useCopyToClipboard.js → useCopyToClipboard/useCopyToClipboard.js} +0 -0
  58. /package/lib/hooks/{useCopyToClipboard.js.flow → useCopyToClipboard/useCopyToClipboard.js.flow} +0 -0
  59. /package/lib/hooks/{useInputState.js → useInputState/useInputState.js} +0 -0
  60. /package/lib/hooks/{useInputState.js.flow → useInputState/useInputState.js.flow} +0 -0
  61. /package/lib/hooks/{useLockedBody.js → useLockedBody/useLockedBody.js} +0 -0
  62. /package/lib/hooks/{useLockedBody.js.flow → useLockedBody/useLockedBody.js.flow} +0 -0
  63. /package/lib/hooks/{useMountTransition.js → useMountTransition/index.js} +0 -0
  64. /package/lib/hooks/{useMountTransition.js.flow → useMountTransition/index.js.flow} +0 -0
  65. /package/lib/hooks/{useToggle.js → useToggle/useToggle.js} +0 -0
  66. /package/lib/hooks/{useToggle.js.flow → useToggle/useToggle.js.flow} +0 -0
  67. /package/lib/hooks/{useWindowSize.js → useWindowSize/useWindowSize.js} +0 -0
  68. /package/lib/hooks/{useWindowSize.js.flow → useWindowSize/useWindowSize.js.flow} +0 -0
  69. /package/lib/utils/{classify.js → classify/index.js} +0 -0
  70. /package/lib/utils/{classify.js.flow → classify/index.js.flow} +0 -0
  71. /package/lib/utils/{dom.js → dom/dom.js} +0 -0
  72. /package/lib/utils/{dom.js.flow → dom/dom.js.flow} +0 -0
  73. /package/lib/utils/{helpers.js → helpers/helpers.js} +0 -0
  74. /package/lib/utils/{helpers.js.flow → helpers/helpers.js.flow} +0 -0
  75. /package/lib/utils/{merge-refs.js → merge-refs/merge-refs.js} +0 -0
  76. /package/lib/utils/{merge-refs.js.flow → merge-refs/merge-refs.js.flow} +0 -0
  77. /package/lib/utils/{string.js → string/string.js} +0 -0
  78. /package/lib/utils/{string.js.flow → string/string.js.flow} +0 -0
@@ -1,82 +0,0 @@
1
- // @flow strict
2
-
3
- type TokenObject = {[key: string]: string};
4
- export type SortOrder = 'asc' | 'desc';
5
- export type SortBy = 'name' | 'value';
6
-
7
- /**
8
- *
9
- * This function takes in an object containing key-value pairs of tokens,
10
- * where values are strings representing numerical
11
- * values with optional percentage or viewport units. It also takes in an optional
12
- * sort order ('asc' or 'desc') and an optional sort by parameter ('name' or 'value').
13
- *
14
- * The function sorts the tokens by either their key names (if sortBy='name') or their
15
- * numerical values (if sortBy='value'). The sort order can be specified as
16
- * ascending (order='asc') or descending (order='desc').
17
- *
18
- * The function handles values with different units by comparing their numerical values.
19
- * If both values have the same unit, their numerical values are compared directly.
20
- * If their units are different, tokens with percentage values are considered greater than
21
- * those with viewport units, and tokens without a percentage or viewport unit are compared
22
- * based on their numerical values.
23
- *
24
- */
25
- export const getSortedTokenNames = (
26
- obj: TokenObject,
27
- order?: SortOrder = 'asc',
28
- sortBy?: SortBy = 'value',
29
- ): Array<string> => {
30
- // Create an array from the object keys and sort the array
31
- const sortedTokens = Object.keys(obj).sort((token1, token2) => {
32
- const value1 = obj[token1];
33
- const value2 = obj[token2];
34
-
35
- // Convert value1 to a number
36
- const numValue1 = parseFloat(value1);
37
- // Convert value2 to a number
38
- const numValue2 = parseFloat(value2);
39
-
40
- if (sortBy === 'name') {
41
- // Sorting by name
42
- return order === 'asc'
43
- ? token1.localeCompare(token2) // Compare key names directly
44
- : token2.localeCompare(token1);
45
- } else {
46
- const isPercentage1 = value1.endsWith('%');
47
- const isPercentage2 = value2.endsWith('%');
48
- const isViewport1 = value1.endsWith('vw') || value1.endsWith('vh');
49
- const isViewport2 = value2.endsWith('vw') || value2.endsWith('vh');
50
-
51
- if ((isPercentage1 && isPercentage2) || (isViewport1 && isViewport2)) {
52
- // If both tokens have the same unit (percentage or viewport), compare their numerical values
53
- return order === 'asc' ? numValue1 - numValue2 : numValue2 - numValue1;
54
- }
55
-
56
- if (isPercentage1 && !isPercentage2) {
57
- // Only token1 has a percentage value, consider it greater than token2
58
- return order === 'asc' ? 1 : -1;
59
- }
60
-
61
- if (!isPercentage1 && isPercentage2) {
62
- // Only token2 has a percentage value, consider it greater than token1
63
- return order === 'asc' ? -1 : 1;
64
- }
65
-
66
- if (isViewport1 && !isViewport2) {
67
- // Only token1 has a viewport unit value, consider it greater than token2
68
- return order === 'asc' ? 1 : -1;
69
- }
70
-
71
- if (!isViewport1 && isViewport2) {
72
- // Only token2 has a viewport unit value, consider it greater than token1
73
- return order === 'asc' ? -1 : 1;
74
- }
75
-
76
- // Neither token has a percentage or viewport unit value, compare their numerical values
77
- return order === 'asc' ? numValue1 - numValue2 : numValue2 - numValue1;
78
- }
79
- });
80
-
81
- return sortedTokens;
82
- };
File without changes
File without changes
File without changes
File without changes
File without changes