@spaced-out/ui-design-system 0.1.26 → 0.1.28

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 (73) hide show
  1. package/.cspell/custom-words.txt +7 -0
  2. package/.storybook/main.js +70 -28
  3. package/.storybook/manager-head.html +4 -0
  4. package/.storybook/manager.js +0 -4
  5. package/.storybook/preview-head.html +32 -6
  6. package/.storybook/preview.js +0 -5
  7. package/CHANGELOG.md +41 -0
  8. package/babel.config.js +1 -0
  9. package/lib/components/Badge/Badge.module.css +1 -0
  10. package/lib/components/ButtonDropdown/ButtonDropdown.js +10 -9
  11. package/lib/components/ButtonDropdown/ButtonDropdown.js.flow +6 -4
  12. package/lib/components/Checkbox/Checkbox.js +3 -7
  13. package/lib/components/Checkbox/Checkbox.js.flow +3 -8
  14. package/lib/components/Chip/Chip.js +1 -1
  15. package/lib/components/Chip/Chip.js.flow +2 -2
  16. package/lib/components/CollapsibleCard/CollapsibleCard.js +3 -0
  17. package/lib/components/CollapsibleCard/CollapsibleCard.js.flow +4 -0
  18. package/lib/components/Dialog/Dialog.js +23 -2
  19. package/lib/components/Dialog/Dialog.js.flow +38 -0
  20. package/lib/components/Dropdown/Dropdown.js +10 -9
  21. package/lib/components/Dropdown/Dropdown.js.flow +6 -4
  22. package/lib/components/FocusManager/FocusManager.js +7 -5
  23. package/lib/components/FocusManager/FocusManager.js.flow +3 -3
  24. package/lib/components/InlineDropdown/InlineDropdown.js +10 -9
  25. package/lib/components/InlineDropdown/InlineDropdown.js.flow +6 -4
  26. package/lib/components/Menu/Menu.js +48 -12
  27. package/lib/components/Menu/Menu.js.flow +102 -9
  28. package/lib/components/Menu/Menu.module.css +10 -0
  29. package/lib/components/Menu/MenuOptionButton.js +21 -4
  30. package/lib/components/Menu/MenuOptionButton.js.flow +21 -0
  31. package/lib/components/Modal/Modal.js +35 -8
  32. package/lib/components/Modal/Modal.js.flow +52 -7
  33. package/lib/components/Modal/Modal.module.css +1 -3
  34. package/lib/components/Panel/Panel.js +21 -1
  35. package/lib/components/Panel/Panel.js.flow +30 -1
  36. package/lib/components/Panel/Panel.module.css +0 -1
  37. package/lib/components/Table/DefaultRow.js +5 -5
  38. package/lib/components/Table/DefaultRow.js.flow +14 -11
  39. package/lib/components/Table/StaticTable.js +5 -1
  40. package/lib/components/Table/StaticTable.js.flow +4 -0
  41. package/lib/components/Table/Table.js.flow +2 -0
  42. package/lib/components/Tabs/TabList/TabDropdown.js +10 -9
  43. package/lib/components/Tabs/TabList/TabDropdown.js.flow +6 -4
  44. package/lib/components/Toast/Toast.js +7 -5
  45. package/lib/components/Toast/Toast.js.flow +5 -3
  46. package/lib/components/Tooltip/Tooltip.js +22 -25
  47. package/lib/components/Tooltip/Tooltip.js.flow +25 -22
  48. package/lib/components/Typeahead/Typeahead.js +10 -9
  49. package/lib/components/Typeahead/Typeahead.js.flow +6 -4
  50. package/lib/hooks/index.js +55 -0
  51. package/lib/hooks/index.js.flow +5 -0
  52. package/lib/hooks/useCopyToClipboard.js +31 -0
  53. package/lib/hooks/useCopyToClipboard.js.flow +31 -0
  54. package/lib/hooks/useInputState.js +23 -0
  55. package/lib/hooks/useInputState.js.flow +28 -0
  56. package/lib/hooks/useLockedBody.js +54 -0
  57. package/lib/hooks/useLockedBody.js.flow +55 -0
  58. package/lib/hooks/useToggle.js +18 -0
  59. package/lib/hooks/useToggle.js.flow +17 -0
  60. package/lib/hooks/useWindowSize.js +32 -0
  61. package/lib/hooks/useWindowSize.js.flow +37 -0
  62. package/lib/styles/typography.module.css +1 -0
  63. package/lib/types/common.js +0 -1
  64. package/lib/utils/index.js +11 -0
  65. package/lib/utils/index.js.flow +1 -0
  66. package/lib/utils/menu.js +57 -2
  67. package/lib/utils/menu.js.flow +109 -1
  68. package/lib/utils/string.js +4 -2
  69. package/lib/utils/string.js.flow +3 -0
  70. package/lib/utils/tokens.js +154 -0
  71. package/lib/utils/tokens.js.flow +228 -0
  72. package/package.json +19 -16
  73. package/.storybook/public/favicon.svg +0 -6
@@ -0,0 +1,228 @@
1
+ // @flow strict
2
+
3
+ type TokenObject = {[key: string]: string};
4
+
5
+ export type SortOrder = 'asc' | 'desc';
6
+
7
+ export type SortBy = 'name' | 'value';
8
+
9
+ export type TableDataItem = {
10
+ id: string | number,
11
+ name: string,
12
+ value: string,
13
+ demo: string,
14
+ };
15
+
16
+ export type TableData = Array<TableDataItem>;
17
+
18
+ export type DataVariation = {
19
+ title: string,
20
+ description: string,
21
+ };
22
+
23
+ export const dataVariations: Array<DataVariation> = [
24
+ {
25
+ title: 'The Great HTML Escape 🎩🌐',
26
+ description:
27
+ 'Watch out! Our HTML has escaped and is running wild on the web. It\'s causing mischief, adding tags and styles wherever it pleases! <div>🙈</div>',
28
+ },
29
+ {
30
+ title: 'The CSS Enigma 🔍💡',
31
+ description:
32
+ 'Behold the CSS enigma! Our styles have tangled themselves into a web of complexity. Can you decipher the mystery and bring order to the chaos? 💻🎨',
33
+ },
34
+ {
35
+ title: 'The Missing Dependency 😱📦',
36
+ description:
37
+ 'Uh-oh! It seems like a crucial frontend dependency went on a vacation and forgot to come back. Without it, our application feels a bit incomplete. We\'re on the lookout for its grand return! 🏖️🌴',
38
+ },
39
+ {
40
+ title: 'The Vanishing CSS Rule 🙀🎩',
41
+ description:
42
+ 'Hocus pocus! A CSS rule vanished into thin air, leaving our styles in a state of bewilderment. We\'re summoning all our magical powers to bring it back. Abracadabra, where did it go? 🧙‍♂️✨',
43
+ },
44
+ {
45
+ title: 'The Mysterious JavaScript Bug 🐞❓',
46
+ description:
47
+ 'We\'ve encountered a puzzling JavaScript bug that seems to have hidden itself in the shadows of our codebase. It\'s playing hide-and-seek, but fear not! We\'ll track it down and restore order to our application. 🔍🔦',
48
+ },
49
+ {
50
+ title: 'The Lost Code Snippet 🧐🔍',
51
+ description:
52
+ 'Oh no! It appears that a valuable code snippet has gone missing, leaving us scratching our heads. We\'re combing through the archives and retracing our steps to recover it. We won\'t stop until it\'s back where it belongs! 🕵️‍♂️🔎',
53
+ },
54
+ {
55
+ title: 'The Hidden API Endpoint 🕵️‍♀️🔐',
56
+ description:
57
+ 'We\'re on a mission to find an elusive API endpoint that seems to have vanished into the depths of the backend. We\'re following the clues, decoding cryptic messages, and hacking our way through the digital maze. Stay tuned for its triumphant rediscovery! 🚀🌐',
58
+ },
59
+ {
60
+ title: 'The Ghostly UI Element 👻👁️',
61
+ description:
62
+ 'Beware of the ghostly UI element! It has mysteriously disappeared from our interface, leaving behind an empty void. We\'ve dispatched our best designers to investigate and resurrect it. Soon, it\'ll return to haunt the pixels once again! 🎃💻',
63
+ },
64
+ {
65
+ title: 'The Evaporating Stylesheet 💦🎨',
66
+ description:
67
+ 'Uh-oh! It seems like our stylesheet got caught in a cosmic evaporation event, and now our carefully crafted styles are floating in the digital ether. We\'re working on a rescue mission to bring them back to the realm of the browser. ✨🚀',
68
+ },
69
+ {
70
+ title: 'The Missing Feature Fairy 🧚✨',
71
+ description:
72
+ 'We\'ve sent out an APB (All Points Bulletin) for the missing feature fairy. She\'s known for sprinkling delightful functionalities into our applications, but it seems she took a detour. We\'re patiently waiting for her magical return! 🌟🧚‍♀️',
73
+ },
74
+ {
75
+ title: 'The Invisible DOM Element 🙈🌐',
76
+ description:
77
+ 'Something peculiar has happened! A DOM element has turned invisible, playing tricks on our frontend. We\'ve called in our best detectives to investigate this optical illusion and restore its rightful visibility. Stay tuned for the grand unveiling! 👀✨',
78
+ },
79
+ {
80
+ title: 'The Elusive Frontend Bug 🐛❓',
81
+ description:
82
+ 'Our frontend bug seems to have gained a PhD in camouflage and disappeared into the code jungle. We\'re conducting bug-hunting expeditions, armed with magnifying glasses and a good sense of humor. It won\'t escape our watchful eyes for long! 🕵️‍♀️🔍',
83
+ },
84
+ {
85
+ title: 'The Abducted Animation 🌪️🎥',
86
+ description:
87
+ 'Alert! An animation has been abducted from our frontend, leaving us with static screens. We suspect interdimensional interference. We\'re assembling a rescue team armed with keyframes and transition effects. Together, we\'ll bring motion back to our digital world! ⚡️🎬',
88
+ },
89
+ {
90
+ title: 'The Disappearing Click Event 🙀🖱️',
91
+ description:
92
+ 'In a twist of events, a click event has mysteriously vanished, eluding our attempts to capture it. We\'ve set up mouse traps and deployed debugging tools to solve this enigma. Don\'t worry, we\'ll catch that sneaky click and restore its functionality! 🔍🔧',
93
+ },
94
+ {
95
+ title: 'The Phantom Mobile Responsiveness 👻📱',
96
+ description:
97
+ 'Beware of the phantom mobile responsiveness! It likes to hide in the shadows, making our web pages look like a ghost town on small screens. We\'re summoning our media queries and responsive design tactics to banish this spectral issue. Soon, our pages will be mobile-friendly once more! 📲💪',
98
+ },
99
+ {
100
+ title: 'The Misplaced UI Element 🧭🔄',
101
+ description:
102
+ 'Oops! It seems like a UI element lost its way and ended up in the wrong place. We\'re guiding it back to its rightful position with pixel-perfect precision. Soon, order will be restored, and our interface will be back in balance! 🗺️🔀',
103
+ },
104
+ {
105
+ title: 'The Cryptic JavaScript Error 🔐❓',
106
+ description:
107
+ 'We\'ve stumbled upon a cryptic JavaScript error that speaks in riddles, leaving us scratching our heads. Fear not, our code sorcerers are deciphering the error message, searching for the hidden clues to resolve this enigmatic mystery. ✨🔍',
108
+ },
109
+ {
110
+ title: 'The Broken CSS Grid 📏🔩',
111
+ description:
112
+ 'Oh no! Our CSS grid has sprung a leak and lost its structure. We\'re patching it up with grid areas and grid-template-areas to bring order back to the layout. Soon, the grid will stand strong and proud! 🧰🔧',
113
+ },
114
+ {
115
+ title: 'The Disappearing Web Fonts 🙈🖊️',
116
+ description:
117
+ 'Web fonts have vanished without a trace, leaving our text looking plain and dull. We\'re calling in the font detectives to investigate this typographic disappearance. We won\'t rest until our words are dressed in style once again! 👓🔎',
118
+ },
119
+ {
120
+ title: 'The Forgotten Vendor Prefixes 🤔🔍',
121
+ description:
122
+ 'Oops! It seems that some vendor prefixes got lost in the shuffle, leaving our CSS properties puzzled. We\'re on a mission to rediscover these elusive prefixes and ensure our styles are cross-browser compatible. Together, we\'ll navigate the prefix labyrinth and emerge victorious! 💪🚀',
123
+ },
124
+ {
125
+ title: 'The Invisible API Response 🙈📡',
126
+ description:
127
+ 'We\'re experiencing an API response that\'s mastered the art of invisibility. It\'s hiding behind layers of middleware and network protocols. We\'ve enlisted our finest backend wizards to conjure it back into visibility. Be patient, and soon the data will reappear like magic! 🧙‍♂️✨',
128
+ },
129
+ ];
130
+
131
+ /**
132
+ *
133
+ * This function takes in an object containing key-value pairs of tokens,
134
+ * where values are strings representing numerical
135
+ * values with optional percentage or viewport units. It also takes in an optional
136
+ * sort order ('asc' or 'desc') and an optional sort by parameter ('name' or 'value').
137
+ *
138
+ * The function sorts the tokens by either their key names (if sortBy='name') or their
139
+ * numerical values (if sortBy='value'). The sort order can be specified as
140
+ * ascending (order='asc') or descending (order='desc').
141
+ *
142
+ * The function handles values with different units by comparing their numerical values.
143
+ * If both values have the same unit, their numerical values are compared directly.
144
+ * If their units are different, tokens with percentage values are considered greater than
145
+ * those with viewport units, and tokens without a percentage or viewport unit are compared
146
+ * based on their numerical values.
147
+ *
148
+ */
149
+ export const getSortedTokenNames = (
150
+ obj: TokenObject,
151
+ order?: SortOrder = 'asc',
152
+ sortBy?: SortBy = 'value',
153
+ ): Array<string> => {
154
+ // Create an array from the object keys and sort the array
155
+ const sortedTokens = Object.keys(obj).sort((token1, token2) => {
156
+ const value1 = obj[token1];
157
+ const value2 = obj[token2];
158
+
159
+ // Convert value1 to a number
160
+ const numValue1 = parseFloat(value1);
161
+ // Convert value2 to a number
162
+ const numValue2 = parseFloat(value2);
163
+
164
+ if (sortBy === 'name') {
165
+ // Sorting by name
166
+ return order === 'asc'
167
+ ? token1.localeCompare(token2) // Compare key names directly
168
+ : token2.localeCompare(token1);
169
+ } else {
170
+ const isPercentage1 = value1.endsWith('%');
171
+ const isPercentage2 = value2.endsWith('%');
172
+ const isViewport1 = value1.endsWith('vw') || value1.endsWith('vh');
173
+ const isViewport2 = value2.endsWith('vw') || value2.endsWith('vh');
174
+
175
+ if ((isPercentage1 && isPercentage2) || (isViewport1 && isViewport2)) {
176
+ // If both tokens have the same unit (percentage or viewport), compare their numerical values
177
+ return order === 'asc' ? numValue1 - numValue2 : numValue2 - numValue1;
178
+ }
179
+
180
+ if (isPercentage1 && !isPercentage2) {
181
+ // Only token1 has a percentage value, consider it greater than token2
182
+ return order === 'asc' ? 1 : -1;
183
+ }
184
+
185
+ if (!isPercentage1 && isPercentage2) {
186
+ // Only token2 has a percentage value, consider it greater than token1
187
+ return order === 'asc' ? -1 : 1;
188
+ }
189
+
190
+ if (isViewport1 && !isViewport2) {
191
+ // Only token1 has a viewport unit value, consider it greater than token2
192
+ return order === 'asc' ? 1 : -1;
193
+ }
194
+
195
+ if (!isViewport1 && isViewport2) {
196
+ // Only token2 has a viewport unit value, consider it greater than token1
197
+ return order === 'asc' ? -1 : 1;
198
+ }
199
+
200
+ // Neither token has a percentage or viewport unit value, compare their numerical values
201
+ return order === 'asc' ? numValue1 - numValue2 : numValue2 - numValue1;
202
+ }
203
+ });
204
+
205
+ return sortedTokens;
206
+ };
207
+
208
+ export const filterTableDataBySearchText = (
209
+ TABLE_DATA: TableData,
210
+ searchText: string,
211
+ ): TableData => {
212
+ const filteredData: TableData = TABLE_DATA.filter((item) => {
213
+ const nameMatch: boolean = item.name
214
+ .toLowerCase()
215
+ .includes(searchText.toLowerCase());
216
+ const valueMatch: boolean = item.value
217
+ .toLowerCase()
218
+ .includes(searchText.toLowerCase());
219
+ return nameMatch || valueMatch;
220
+ });
221
+
222
+ return filteredData;
223
+ };
224
+
225
+ export const getRandomDataVariation = (): DataVariation => {
226
+ const randomIndex: number = Math.floor(Math.random() * dataVariations.length);
227
+ return dataVariations[randomIndex];
228
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spaced-out/ui-design-system",
3
- "version": "0.1.26",
3
+ "version": "0.1.28",
4
4
  "main": "index.js",
5
5
  "description": "Sense UI components library",
6
6
  "author": {
@@ -10,9 +10,9 @@
10
10
  "scripts": {
11
11
  "build": "rimraf lib && yarn build:style-variables && gulp build",
12
12
  "build:style-variables": "rimraf src/styles/variables && style-dictionary build --config ./config.js",
13
- "storybook": "yarn build:style-variables && start-storybook -p 6006",
14
- "storybook:export": "yarn build:style-variables && rimraf storybook-static && build-storybook",
15
- "build-storybook": "yarn build:style-variables && rimraf storybook-static && build-storybook",
13
+ "storybook": "yarn build:style-variables && storybook dev -p 6006",
14
+ "storybook:export": "yarn build:style-variables && rimraf storybook-static && storybook build",
15
+ "build-storybook": "yarn build:style-variables && rimraf storybook-static && storybook build",
16
16
  "generate": "node ./scripts/create-component",
17
17
  "generateHook": "node ./scripts/create-hook",
18
18
  "prepublishOnly": "yarn build",
@@ -44,8 +44,7 @@
44
44
  "react-dom": ">=16.8.0"
45
45
  },
46
46
  "dependencies": {
47
- "@floating-ui/react-dom": "^1.0.0",
48
- "@floating-ui/react-dom-interactions": "^0.10.1",
47
+ "@floating-ui/react": "^0.24.0",
49
48
  "date-fns": "^2.29.3",
50
49
  "lodash": "^4.17.21"
51
50
  },
@@ -59,14 +58,16 @@
59
58
  "@babel/preset-react": "^7.18.6",
60
59
  "@commitlint/cli": "^17.1.2",
61
60
  "@commitlint/config-conventional": "^17.1.0",
62
- "@storybook/addon-a11y": "^6.5.13",
63
- "@storybook/addon-essentials": "^6.5.13",
64
- "@storybook/addon-postcss": "^2.0.0",
65
- "@storybook/addons": "^6.5.13",
66
- "@storybook/react": "^6.5.13",
67
- "@storybook/test-runner": "^0.9.0",
68
- "@storybook/testing-react": "^1.3.0",
69
- "@storybook/theming": "^6.5.13",
61
+ "@storybook/addon-a11y": "^7.0.8",
62
+ "@storybook/addon-essentials": "^7.0.8",
63
+ "@storybook/addon-mdx-gfm": "^7.0.8",
64
+ "@storybook/addon-storysource": "^7.0.12",
65
+ "@storybook/addons": "^7.0.8",
66
+ "@storybook/react": "^7.0.8",
67
+ "@storybook/react-webpack5": "^7.0.8",
68
+ "@storybook/test-runner": "^0.10.0",
69
+ "@storybook/testing-react": "^2.0.0",
70
+ "@storybook/theming": "^7.0.8",
70
71
  "@testing-library/react": "^11.2.7",
71
72
  "all-contributors-cli": "^6.20.0",
72
73
  "babel-eslint": "^10.1.0",
@@ -84,7 +85,7 @@
84
85
  "eslint-plugin-react": "^7.30.1",
85
86
  "eslint-plugin-react-hooks": "^4.6.0",
86
87
  "eslint-plugin-simple-import-sort": "^8.0.0",
87
- "eslint-plugin-storybook": "^0.6.7",
88
+ "eslint-plugin-storybook": "^0.6.12",
88
89
  "eslint-plugin-unused-imports": "^2.0.0",
89
90
  "flow-bin": "^0.184.0",
90
91
  "gulp": "^4.0.2",
@@ -92,6 +93,7 @@
92
93
  "gulp-rename": "^2.0.0",
93
94
  "gulp-replace": "^1.1.3",
94
95
  "husky": "2.1.0",
96
+ "invariant": "^2.2.4",
95
97
  "jest": "^29.3.1",
96
98
  "lint-staged": "^10.5.1",
97
99
  "node-sass": "^7.0.0",
@@ -103,8 +105,9 @@
103
105
  "rimraf": "^3.0.2",
104
106
  "simple-git": "^3.12.0",
105
107
  "standard-version": "^9.5.0",
108
+ "storybook": "^7.0.8",
106
109
  "storybook-css-modules": "^1.0.8",
107
- "storybook-vscode-component": "^1.0.8",
110
+ "storybook-vscode-component": "^1.0.9",
108
111
  "style-dictionary": "^3.7.1"
109
112
  },
110
113
  "homepage": "https://spaced-out.github.io/ui-design-system",
@@ -1,6 +0,0 @@
1
- <svg width="137" height="137" viewBox="0 0 137 137" fill="none" xmlns="http://www.w3.org/2000/svg">
2
- <path d="M46.5 76C56.7173 76 65 67.7173 65 57.5C65 47.2827 56.7173 39 46.5 39C36.2827 39 28 47.2827 28 57.5C28 67.7173 36.2827 76 46.5 76Z" fill="#FFD252"/>
3
- <path d="M90.5 47C100.717 47 109 38.4934 109 28C109 17.5066 100.717 9 90.5 9C80.2827 9 72 17.5066 72 28C72 38.4934 80.2827 47 90.5 47Z" fill="#F05A28"/>
4
- <path d="M46.5 128C56.7173 128 65 119.717 65 109.5C65 99.2827 56.7173 91 46.5 91C36.2827 91 28 99.2827 28 109.5C28 119.717 36.2827 128 46.5 128Z" fill="#7461E5"/>
5
- <path d="M90.5 98C100.717 98 109 89.9411 109 80C109 70.0589 100.717 62 90.5 62C80.2827 62 72 70.0589 72 80C72 89.9411 80.2827 98 90.5 98Z" fill="#33A30F"/>
6
- </svg>