@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.
- package/.cspell/custom-words.txt +4 -0
- package/.storybook/main.js +30 -0
- package/.storybook/manager-head.html +4 -0
- package/.storybook/preview-head.html +17 -0
- package/CHANGELOG.md +28 -0
- package/lib/components/Badge/Badge.js +3 -1
- package/lib/components/Badge/Badge.js.flow +2 -2
- package/lib/components/Checkbox/Checkbox.js +3 -7
- package/lib/components/Checkbox/Checkbox.js.flow +3 -8
- package/lib/components/Pagination/Pagination.js +2 -2
- package/lib/components/Pagination/Pagination.js.flow +1 -1
- package/lib/hooks/useCopyToClipboard/index.js +16 -0
- package/lib/hooks/useCopyToClipboard/index.js.flow +3 -0
- package/lib/hooks/useInputState/index.js +16 -0
- package/lib/hooks/useInputState/index.js.flow +3 -0
- package/lib/hooks/useLockedBody/index.js +16 -0
- package/lib/hooks/useLockedBody/index.js.flow +3 -0
- package/lib/hooks/usePagination/index.js +16 -0
- package/lib/hooks/usePagination/index.js.flow +3 -0
- package/lib/hooks/{usePagination.js → usePagination/usePagination.js} +5 -4
- package/lib/hooks/{usePagination.js.flow → usePagination/usePagination.js.flow} +7 -5
- package/lib/hooks/useToastPortal/index.js +16 -0
- package/lib/hooks/useToastPortal/index.js.flow +3 -0
- package/lib/hooks/{useToastPortal.js → useToastPortal/useToastPortal.js} +2 -2
- package/lib/hooks/{useToastPortal.js.flow → useToastPortal/useToastPortal.js.flow} +2 -2
- package/lib/hooks/useToggle/index.js +16 -0
- package/lib/hooks/useToggle/index.js.flow +3 -0
- package/lib/hooks/useWindowSize/index.js +16 -0
- package/lib/hooks/useWindowSize/index.js.flow +3 -0
- package/lib/utils/{click-away.js → click-away/click-away.js} +1 -1
- package/lib/utils/{click-away.js.flow → click-away/click-away.js.flow} +1 -1
- package/lib/utils/click-away/index.js +16 -0
- package/lib/utils/click-away/index.js.flow +3 -0
- package/lib/utils/dom/index.js +16 -0
- package/lib/utils/dom/index.js.flow +3 -0
- package/lib/utils/helpers/index.js +16 -0
- package/lib/utils/helpers/index.js.flow +3 -0
- package/lib/utils/makeClassNameComponent/index.js +16 -0
- package/lib/utils/makeClassNameComponent/index.js.flow +3 -0
- package/lib/utils/{makeClassNameComponent.js → makeClassNameComponent/makeClassNameComponent.js} +1 -1
- package/lib/utils/{makeClassNameComponent.js.flow → makeClassNameComponent/makeClassNameComponent.js.flow} +1 -1
- package/lib/utils/menu/index.js +16 -0
- package/lib/utils/menu/index.js.flow +3 -0
- package/lib/utils/{menu.js → menu/menu.js} +1 -1
- package/lib/utils/{menu.js.flow → menu/menu.js.flow} +2 -3
- package/lib/utils/merge-refs/index.js +16 -0
- package/lib/utils/merge-refs/index.js.flow +3 -0
- package/lib/utils/string/index.js +16 -0
- package/lib/utils/string/index.js.flow +3 -0
- package/lib/utils/tokens/index.js +16 -0
- package/lib/utils/tokens/index.js.flow +3 -0
- package/lib/utils/tokens/tokens.js +154 -0
- package/lib/utils/tokens/tokens.js.flow +228 -0
- package/package.json +2 -1
- package/lib/utils/tokens.js +0 -74
- package/lib/utils/tokens.js.flow +0 -82
- /package/lib/hooks/{useCopyToClipboard.js → useCopyToClipboard/useCopyToClipboard.js} +0 -0
- /package/lib/hooks/{useCopyToClipboard.js.flow → useCopyToClipboard/useCopyToClipboard.js.flow} +0 -0
- /package/lib/hooks/{useInputState.js → useInputState/useInputState.js} +0 -0
- /package/lib/hooks/{useInputState.js.flow → useInputState/useInputState.js.flow} +0 -0
- /package/lib/hooks/{useLockedBody.js → useLockedBody/useLockedBody.js} +0 -0
- /package/lib/hooks/{useLockedBody.js.flow → useLockedBody/useLockedBody.js.flow} +0 -0
- /package/lib/hooks/{useMountTransition.js → useMountTransition/index.js} +0 -0
- /package/lib/hooks/{useMountTransition.js.flow → useMountTransition/index.js.flow} +0 -0
- /package/lib/hooks/{useToggle.js → useToggle/useToggle.js} +0 -0
- /package/lib/hooks/{useToggle.js.flow → useToggle/useToggle.js.flow} +0 -0
- /package/lib/hooks/{useWindowSize.js → useWindowSize/useWindowSize.js} +0 -0
- /package/lib/hooks/{useWindowSize.js.flow → useWindowSize/useWindowSize.js.flow} +0 -0
- /package/lib/utils/{classify.js → classify/index.js} +0 -0
- /package/lib/utils/{classify.js.flow → classify/index.js.flow} +0 -0
- /package/lib/utils/{dom.js → dom/dom.js} +0 -0
- /package/lib/utils/{dom.js.flow → dom/dom.js.flow} +0 -0
- /package/lib/utils/{helpers.js → helpers/helpers.js} +0 -0
- /package/lib/utils/{helpers.js.flow → helpers/helpers.js.flow} +0 -0
- /package/lib/utils/{merge-refs.js → merge-refs/merge-refs.js} +0 -0
- /package/lib/utils/{merge-refs.js.flow → merge-refs/merge-refs.js.flow} +0 -0
- /package/lib/utils/{string.js → string/string.js} +0 -0
- /package/lib/utils/{string.js.flow → string/string.js.flow} +0 -0
package/lib/utils/tokens.js.flow
DELETED
|
@@ -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
|
/package/lib/hooks/{useCopyToClipboard.js.flow → useCopyToClipboard/useCopyToClipboard.js.flow}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|