@spaced-out/ui-design-system 0.1.30 → 0.1.31

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 (51) hide show
  1. package/.cspell/custom-words.txt +5 -0
  2. package/.github/workflows/pages.yml +3 -0
  3. package/.github/workflows/publish_to_npm.yml +1 -1
  4. package/.github/workflows/pull_request_checks.yml +44 -0
  5. package/.github/workflows/pull_request_semantics_checker.yml +1 -0
  6. package/.storybook/preview-head.html +2 -2
  7. package/CHANGELOG.md +18 -0
  8. package/design-tokens/color/app-color.json +3 -0
  9. package/design-tokens/color/base-color.json +3 -0
  10. package/design-tokens/size/base-size.json +15 -0
  11. package/lib/components/Dialog/Dialog.module.css +1 -1
  12. package/lib/components/FileUpload/FileUpload.js +195 -0
  13. package/lib/components/FileUpload/FileUpload.js.flow +301 -0
  14. package/lib/components/FileUpload/FileUpload.module.css +185 -0
  15. package/lib/components/FileUpload/index.js +16 -0
  16. package/lib/components/FileUpload/index.js.flow +3 -0
  17. package/lib/components/Input/Input.js +2 -2
  18. package/lib/components/Input/Input.js.flow +11 -7
  19. package/lib/components/Input/Input.module.css +16 -5
  20. package/lib/components/LinearLoader/LinearLoader.js +10 -3
  21. package/lib/components/LinearLoader/LinearLoader.js.flow +15 -2
  22. package/lib/components/LinearLoader/LinearLoader.module.css +34 -1
  23. package/lib/components/Modal/Modal.js +3 -2
  24. package/lib/components/Modal/Modal.js.flow +10 -4
  25. package/lib/components/Modal/Modal.module.css +13 -1
  26. package/lib/components/Modal/index.js.flow +1 -0
  27. package/lib/components/Textarea/Textarea.js +2 -2
  28. package/lib/components/Textarea/Textarea.js.flow +10 -6
  29. package/lib/components/Textarea/Textarea.module.css +16 -6
  30. package/lib/components/index.js +11 -0
  31. package/lib/components/index.js.flow +1 -0
  32. package/lib/hooks/index.js +11 -0
  33. package/lib/hooks/index.js.flow +1 -0
  34. package/lib/hooks/useFileUpload/index.js +16 -0
  35. package/lib/hooks/useFileUpload/index.js.flow +3 -0
  36. package/lib/hooks/useFileUpload/useFileUpload.js +279 -0
  37. package/lib/hooks/useFileUpload/useFileUpload.js.flow +304 -0
  38. package/lib/styles/index.css +12 -0
  39. package/lib/styles/index.js +15 -3
  40. package/lib/styles/index.js.flow +12 -0
  41. package/lib/styles/variables/_color.css +2 -0
  42. package/lib/styles/variables/_color.js +3 -1
  43. package/lib/styles/variables/_color.js.flow +2 -0
  44. package/lib/styles/variables/_size.css +10 -0
  45. package/lib/styles/variables/_size.js +11 -1
  46. package/lib/styles/variables/_size.js.flow +10 -0
  47. package/lib/utils/helpers/helpers.js +39 -2
  48. package/lib/utils/helpers/helpers.js.flow +37 -0
  49. package/lib/utils/tokens/tokens.js +1 -2
  50. package/lib/utils/tokens/tokens.js.flow +1 -3
  51. package/package.json +3 -2
@@ -1,3 +1,4 @@
1
+ amet
1
2
  Anant
2
3
  argstable
3
4
  atleast
@@ -10,6 +11,7 @@ Crespo
10
11
  datetime
11
12
  DEFAULTTEXT
12
13
  dismissable
14
+ dropzone
13
15
  eqeqeq
14
16
  fbjs
15
17
  Fennimore
@@ -20,6 +22,7 @@ Gaurav
20
22
  innerref
21
23
  interdimensional
22
24
  Lipsey
25
+ msword
23
26
  Neue
24
27
  Nishant
25
28
  nofollow
@@ -33,6 +36,7 @@ pocus
33
36
  premajor
34
37
  preminor
35
38
  prepatch
39
+ progressbar
36
40
  rgba
37
41
  sbdocs
38
42
  Stapleton
@@ -46,6 +50,7 @@ tnum
46
50
  transclude
47
51
  Typeahead
48
52
  typeof
53
+ valuenow
49
54
  Verda
50
55
  xmark
51
56
  yourcomponentname
@@ -1,3 +1,6 @@
1
+ # Author: Anant Raj
2
+ # Note: Do not change
3
+
1
4
  # Simple workflow for deploying static content to GitHub Pages
2
5
  name: Publish Genesis Design System Storybook to Github Pages
3
6
 
@@ -42,7 +42,7 @@ jobs:
42
42
  uses: actions/setup-node@v2
43
43
  with:
44
44
  registry-url: https://registry.npmjs.org/
45
- node-version: '16'
45
+ node-version: '18'
46
46
 
47
47
  # Install dependencies (required by Run tests step)
48
48
  - name: Install dependencies
@@ -0,0 +1,44 @@
1
+ # Author: Nishant Gaurav
2
+ # Note: Do not change
3
+
4
+ name: Run Yarn Flow, Lint, and Spell Check
5
+
6
+ on:
7
+ pull_request:
8
+ branches:
9
+ - master
10
+ types:
11
+ - opened
12
+ - edited
13
+ - synchronize
14
+
15
+ jobs:
16
+ run_yarn_checks:
17
+ runs-on: ubuntu-latest
18
+
19
+ steps:
20
+ - name: Checkout code
21
+ uses: actions/checkout@v3
22
+
23
+ # Set up Node.js environment
24
+ - name: Setup Node.js
25
+ uses: actions/setup-node@v2
26
+ with:
27
+ registry-url: https://registry.npmjs.org/
28
+ node-version: '18'
29
+
30
+ # Install project dependencies
31
+ - name: Install dependencies
32
+ run: yarn install
33
+
34
+ # Run Yarn Flow static type checking
35
+ - name: Run Yarn Flow
36
+ run: yarn flow
37
+
38
+ # Run spell-checking for documentation or comments
39
+ - name: Run Yarn Spell Check
40
+ run: yarn spell-check
41
+
42
+ # Run ESLint code linting
43
+ - name: Run Yarn Lint
44
+ run: yarn lint:strict
@@ -1,5 +1,6 @@
1
1
  # Author: Nishant Gaurav
2
2
  # workflow to check for PR names wrt conventional commits, uses a third party action
3
+
3
4
  name: 'Lint PR'
4
5
 
5
6
  on:
@@ -38,7 +38,7 @@
38
38
  height: auto;
39
39
  margin: 0px;
40
40
  padding: 0px;
41
- background: white;
41
+ background: #fafafa;
42
42
  color: #606060;
43
43
  font-size: 16px;
44
44
  text-size-adjust: none;
@@ -117,7 +117,7 @@
117
117
  font-family: 'Centra No 2' !important;
118
118
  }
119
119
 
120
- #docs-root .sbdocs {
120
+ .sbdocs {
121
121
  background: #fafafa !important;
122
122
  }
123
123
 
package/CHANGELOG.md CHANGED
@@ -2,6 +2,24 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.1.31](https://github.com/spaced-out/ui-design-system/compare/v0.1.30...v0.1.31) (2023-06-16)
6
+
7
+
8
+ ### Features
9
+
10
+ * added colorBorderTertiary ([731c25d](https://github.com/spaced-out/ui-design-system/commit/731c25d8996fd94e6c7e52c86fcb16e169b0e187))
11
+ * file upload component useFileUpload hook and lint workflow ([#120](https://github.com/spaced-out/ui-design-system/issues/120)) ([79351a4](https://github.com/spaced-out/ui-design-system/commit/79351a40e6b18c9aa035baccb5cb029de0027514)), closes [#1](https://github.com/spaced-out/ui-design-system/issues/1)
12
+ * hover state for input and its derivatives and textarea ([01db867](https://github.com/spaced-out/ui-design-system/commit/01db8676f9245fda4540abf6e00d671732342f3b))
13
+ * sizing support in modals ([478f4eb](https://github.com/spaced-out/ui-design-system/commit/478f4eba8a07f76c706231f64a35a922fac6558d))
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+ * changed borders of input textarea and avatar border to use borderWidthPrimary ([337fad0](https://github.com/spaced-out/ui-design-system/commit/337fad0db3443428da769af17ef461c290417b29))
19
+ * file path fixes ([5563ffc](https://github.com/spaced-out/ui-design-system/commit/5563ffc1b51802a570f423f677ae601c9854dd77))
20
+ * modal documentation fixes ([572b4a6](https://github.com/spaced-out/ui-design-system/commit/572b4a6732eb6d3b73c24c259b8f7b794353452b))
21
+ * placeholder for input, textarea and its derivatives change to colorTextTertiary ([beb6252](https://github.com/spaced-out/ui-design-system/commit/beb62520a19c3f2192875181dd3821d424f67304))
22
+
5
23
  ### [0.1.30](https://github.com/spaced-out/ui-design-system/compare/v0.1.29...v0.1.30) (2023-06-06)
6
24
 
7
25
 
@@ -47,6 +47,9 @@
47
47
  "secondary": {
48
48
  "value": "{baseColor.gray.200.value}"
49
49
  },
50
+ "tertiary": {
51
+ "value": "{baseColor.gray.250.value}"
52
+ },
50
53
  "danger": {
51
54
  "value": "{baseColor.red.500.value}"
52
55
  }
@@ -48,6 +48,9 @@
48
48
  "200": {
49
49
  "value": "#d1d1d1"
50
50
  },
51
+ "250": {
52
+ "value": "#AEAEAE"
53
+ },
51
54
  "300": {
52
55
  "value": "#939393"
53
56
  },
@@ -54,12 +54,18 @@
54
54
  "48": {
55
55
  "value": "48px"
56
56
  },
57
+ "50": {
58
+ "value": "50px"
59
+ },
57
60
  "58": {
58
61
  "value": "58px"
59
62
  },
60
63
  "60": {
61
64
  "value": "60px"
62
65
  },
66
+ "70": {
67
+ "value": "70px"
68
+ },
63
69
  "90": {
64
70
  "value": "90px"
65
71
  },
@@ -69,6 +75,9 @@
69
75
  "110": {
70
76
  "value": "110px"
71
77
  },
78
+ "125": {
79
+ "value": "125px"
80
+ },
72
81
  "140": {
73
82
  "value": "140px"
74
83
  },
@@ -90,6 +99,9 @@
90
99
  "300": {
91
100
  "value": "300px"
92
101
  },
102
+ "320": {
103
+ "value": "320px"
104
+ },
93
105
  "380": {
94
106
  "value": "380px"
95
107
  },
@@ -105,6 +117,9 @@
105
117
  "580": {
106
118
  "value": "580px"
107
119
  },
120
+ "640": {
121
+ "value": "640px"
122
+ },
108
123
  "720": {
109
124
  "value": "720px"
110
125
  },
@@ -83,5 +83,5 @@
83
83
  .dialogFooterActions {
84
84
  display: flex;
85
85
  gap: spaceSmall;
86
- width: 100%;
86
+ width: sizeFluid;
87
87
  }
@@ -0,0 +1,195 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.FileUpload = void 0;
7
+ var React = _interopRequireWildcard(require("react"));
8
+ var _useFileUpload = require("../../hooks/useFileUpload");
9
+ var _classify = _interopRequireDefault(require("../../utils/classify"));
10
+ var _Button = require("../Button");
11
+ var _Icon = require("../Icon");
12
+ var _LinearLoader = require("../LinearLoader");
13
+ var _Truncate = require("../Truncate");
14
+ var _FileUploadModule = _interopRequireDefault(require("./FileUpload.module.css"));
15
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
18
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
19
+ const FileUploadBase = (props, ref) => {
20
+ const {
21
+ classNames,
22
+ label = 'Upload File',
23
+ disabled = false,
24
+ instruction = 'Drag and drop or click to upload',
25
+ draggingInstruction = 'Drop here to start uploading..',
26
+ error = false,
27
+ required = false,
28
+ secondaryInstruction = '',
29
+ maxSize,
30
+ accept,
31
+ onValidFilesDrop,
32
+ onRejectedFilesDrop,
33
+ onFileClear,
34
+ onFileRefreshClick,
35
+ maxFiles = 1
36
+ } = props;
37
+
38
+ // Get file upload state from useFileUpload hook
39
+ const {
40
+ validFiles,
41
+ rejectedFiles,
42
+ isDragActive,
43
+ getRootProps,
44
+ shouldAcceptFiles,
45
+ getInputProps,
46
+ handleFileClear,
47
+ moveFileToProgress,
48
+ moveFileToSuccess,
49
+ moveFileToReject,
50
+ setShowReUpload
51
+ } = (0, _useFileUpload.useFileUpload)({
52
+ maxFiles,
53
+ maxSize,
54
+ accept,
55
+ disabled,
56
+ onValidFilesDrop,
57
+ onRejectedFilesDrop,
58
+ onFileClear
59
+ });
60
+
61
+ // Expose file upload actions to parent component
62
+ React.useImperativeHandle(ref, () => ({
63
+ moveFileToProgress,
64
+ moveFileToSuccess,
65
+ moveFileToReject,
66
+ setShowReUpload,
67
+ validFiles,
68
+ rejectedFiles,
69
+ files: [...validFiles, ...rejectedFiles]
70
+ }));
71
+
72
+ // Merge valid and rejected files
73
+ const files = [...validFiles, ...rejectedFiles];
74
+ return /*#__PURE__*/React.createElement("div", {
75
+ className: (0, _classify.default)(_FileUploadModule.default.wrapper, classNames?.wrapper)
76
+ }, Boolean(label) && /*#__PURE__*/React.createElement("div", {
77
+ className: _FileUploadModule.default.label
78
+ }, /*#__PURE__*/React.createElement(_Truncate.Truncate, null, label), required && /*#__PURE__*/React.createElement("span", {
79
+ className: _FileUploadModule.default.required
80
+ }, '*')), /*#__PURE__*/React.createElement(_Button.UnstyledButton, _extends({
81
+ disabled: disabled || !shouldAcceptFiles
82
+ }, getRootProps(), {
83
+ className: (0, _classify.default)(_FileUploadModule.default.dropzone, {
84
+ [_FileUploadModule.default.disabled]: disabled || !shouldAcceptFiles,
85
+ [_FileUploadModule.default.dragActive]: isDragActive,
86
+ [_FileUploadModule.default.error]: error
87
+ })
88
+ }), /*#__PURE__*/React.createElement("input", getInputProps()), /*#__PURE__*/React.createElement("div", {
89
+ className: (0, _classify.default)(_FileUploadModule.default.instruction, classNames?.instruction)
90
+ }, isDragActive ? draggingInstruction : instruction), /*#__PURE__*/React.createElement("div", {
91
+ className: (0, _classify.default)(_FileUploadModule.default.secondaryInstruction, classNames?.secondaryInstruction)
92
+ }, secondaryInstruction)), files.length > 0 && /*#__PURE__*/React.createElement("div", {
93
+ className: _FileUploadModule.default.files
94
+ }, files.map(file => /*#__PURE__*/React.createElement(React.Fragment, {
95
+ key: file.id
96
+ }, /*#__PURE__*/React.createElement(FileBlock, {
97
+ file: file,
98
+ onFileRefreshClick: onFileRefreshClick,
99
+ handleFileClear: handleFileClear
100
+ })))));
101
+ };
102
+ const FileBlock = _ref => {
103
+ let {
104
+ file,
105
+ onFileRefreshClick,
106
+ handleFileClear
107
+ } = _ref;
108
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
109
+ className: _FileUploadModule.default.file
110
+ }, /*#__PURE__*/React.createElement("div", {
111
+ className: _FileUploadModule.default.fileInfo
112
+ }, /*#__PURE__*/React.createElement("div", {
113
+ className: _FileUploadModule.default.fileNameBlock
114
+ }, /*#__PURE__*/React.createElement("div", {
115
+ className: _FileUploadModule.default.icon
116
+ }, /*#__PURE__*/React.createElement(FileStatusIcon, {
117
+ file: file
118
+ })), /*#__PURE__*/React.createElement("div", {
119
+ className: _FileUploadModule.default.fileName
120
+ }, /*#__PURE__*/React.createElement(_Truncate.Truncate, null, file.file.name))), file.success && !!file.successMessage && /*#__PURE__*/React.createElement("div", {
121
+ className: _FileUploadModule.default.fileSuccess
122
+ }, /*#__PURE__*/React.createElement(_Truncate.Truncate, null, file.successMessage)), file.reject && !!file.rejectReason && /*#__PURE__*/React.createElement("div", {
123
+ className: _FileUploadModule.default.fileError
124
+ }, /*#__PURE__*/React.createElement(_Truncate.Truncate, null, file.rejectReason)), !!file.progress && /*#__PURE__*/React.createElement("div", {
125
+ className: _FileUploadModule.default.progress
126
+ }, /*#__PURE__*/React.createElement(_LinearLoader.LinearLoader, {
127
+ size: "small",
128
+ value: file.progress === 'indeterminate' ? 0 : file.progress,
129
+ indeterminate: file.progress === 'indeterminate'
130
+ }))), /*#__PURE__*/React.createElement("div", {
131
+ className: _FileUploadModule.default.rightSection
132
+ }, file.showReUpload && /*#__PURE__*/React.createElement("div", {
133
+ className: _FileUploadModule.default.rightBlock
134
+ }, /*#__PURE__*/React.createElement(_Icon.ClickableIcon, {
135
+ name: "refresh",
136
+ size: "small",
137
+ onClick: () => onFileRefreshClick?.(file)
138
+ })), /*#__PURE__*/React.createElement("div", {
139
+ className: _FileUploadModule.default.rightBlock
140
+ }, /*#__PURE__*/React.createElement(_Icon.CloseIcon, {
141
+ size: "small",
142
+ onClick: () => handleFileClear?.(file.id)
143
+ })))));
144
+ };
145
+
146
+ // This function returns the status of a file
147
+ const getFileStatus = file => {
148
+ if (file.progress) {
149
+ return 'progress';
150
+ }
151
+ if (file.success) {
152
+ return 'success';
153
+ }
154
+ if (file.reject) {
155
+ return 'error';
156
+ }
157
+ return 'default';
158
+ };
159
+
160
+ // This component renders the status icon for a file
161
+ const FileStatusIcon = _ref2 => {
162
+ let {
163
+ file
164
+ } = _ref2;
165
+ const status = getFileStatus(file);
166
+ switch (status) {
167
+ case 'progress':
168
+ return /*#__PURE__*/React.createElement(_Icon.Icon, {
169
+ size: "small",
170
+ name: "loader",
171
+ color: "tertiary"
172
+ });
173
+ case 'success':
174
+ return /*#__PURE__*/React.createElement(_Icon.Icon, {
175
+ size: "small",
176
+ name: "check",
177
+ color: "success"
178
+ });
179
+ case 'error':
180
+ return /*#__PURE__*/React.createElement(_Icon.Icon, {
181
+ size: "small",
182
+ name: "circle-exclamation",
183
+ color: "danger",
184
+ type: "solid"
185
+ });
186
+ default:
187
+ return /*#__PURE__*/React.createElement(_Icon.Icon, {
188
+ size: "small",
189
+ name: "check",
190
+ color: "success"
191
+ });
192
+ }
193
+ };
194
+ const FileUpload = /*#__PURE__*/React.forwardRef(FileUploadBase);
195
+ exports.FileUpload = FileUpload;