@bspk/ui 1.1.16 → 1.1.18
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/dist/Avatar.d.ts +44 -10
- package/dist/Avatar.js +32 -13
- package/dist/Avatar.js.map +1 -1
- package/dist/AvatarGroup.d.ts +49 -0
- package/dist/AvatarGroup.js +18 -0
- package/dist/AvatarGroup.js.map +1 -0
- package/dist/Badge.js +1 -1
- package/dist/Button.d.ts +14 -4
- package/dist/Button.js +1 -1
- package/dist/Button.js.map +1 -1
- package/dist/Checkbox.d.ts +15 -2
- package/dist/Checkbox.js.map +1 -1
- package/dist/CheckboxGroup.d.ts +6 -3
- package/dist/CheckboxGroup.js.map +1 -1
- package/dist/CheckboxOption.d.ts +8 -1
- package/dist/CheckboxOption.js.map +1 -1
- package/dist/Chip.d.ts +3 -1
- package/dist/Chip.js.map +1 -1
- package/dist/Dialog.d.ts +3 -3
- package/dist/Dialog.js.map +1 -1
- package/dist/Divider.js +1 -1
- package/dist/Dropdown.d.ts +26 -6
- package/dist/Dropdown.js +2 -2
- package/dist/Dropdown.js.map +1 -1
- package/dist/ListItem.js +1 -1
- package/dist/Menu.d.ts +27 -15
- package/dist/Menu.js +1 -1
- package/dist/Menu.js.map +1 -1
- package/dist/NumberInput.d.ts +5 -1
- package/dist/NumberInput.js +7 -5
- package/dist/NumberInput.js.map +1 -1
- package/dist/Portal.d.ts +5 -1
- package/dist/Portal.js.map +1 -1
- package/dist/ProgressBar.d.ts +4 -0
- package/dist/ProgressBar.js.map +1 -1
- package/dist/ProgressionStepper.d.ts +9 -2
- package/dist/ProgressionStepper.js +1 -1
- package/dist/ProgressionStepper.js.map +1 -1
- package/dist/ProgressionStepperBar.d.ts +6 -0
- package/dist/ProgressionStepperBar.js.map +1 -1
- package/dist/Radio.d.ts +16 -2
- package/dist/Radio.js +2 -2
- package/dist/Radio.js.map +1 -1
- package/dist/RadioGroup.d.ts +26 -3
- package/dist/RadioGroup.js +3 -3
- package/dist/RadioGroup.js.map +1 -1
- package/dist/RadioOption.d.ts +9 -1
- package/dist/RadioOption.js.map +1 -1
- package/dist/SegmentedControl.d.ts +21 -2
- package/dist/SegmentedControl.js +1 -1
- package/dist/SegmentedControl.js.map +1 -1
- package/dist/Switch.d.ts +1 -1
- package/dist/SwitchGroup.d.ts +13 -6
- package/dist/SwitchGroup.js +1 -1
- package/dist/SwitchGroup.js.map +1 -1
- package/dist/TabGroup.d.ts +23 -5
- package/dist/TabGroup.js +1 -1
- package/dist/TabGroup.js.map +1 -1
- package/dist/Tag.d.ts +5 -2
- package/dist/Tag.js +1 -1
- package/dist/Tag.js.map +1 -1
- package/dist/TextInput.d.ts +15 -6
- package/dist/TextInput.js +11 -5
- package/dist/TextInput.js.map +1 -1
- package/dist/Textarea.d.ts +3 -3
- package/dist/avatar-group.css +1 -0
- package/dist/avatar.css +1 -1
- package/dist/badge.css +1 -1
- package/dist/button.css +1 -1
- package/dist/demo/ExampleModalRender.d.ts +7 -0
- package/dist/demo/ExampleModalRender.js +16 -0
- package/dist/demo/ExampleModalRender.js.map +1 -0
- package/dist/demo/ExamplePlaceholder.d.ts +7 -0
- package/dist/demo/ExamplePlaceholder.js +13 -0
- package/dist/demo/ExamplePlaceholder.js.map +1 -0
- package/dist/demo/examples.d.ts +101 -0
- package/dist/demo/examples.js +472 -0
- package/dist/demo/examples.js.map +1 -0
- package/dist/divider.css +1 -1
- package/dist/hooks/useOptionIconsInvalid.d.ts +10 -1
- package/dist/hooks/useOptionIconsInvalid.js.map +1 -1
- package/dist/index.d.ts +4 -26
- package/dist/index.js.map +1 -1
- package/dist/list-item.css +1 -1
- package/dist/menu.css +1 -1
- package/dist/segmented-control.css +1 -1
- package/dist/tab-group.css +1 -1
- package/dist/tag.css +1 -1
- package/dist/text-input.css +1 -1
- package/dist/utils/children.js.map +1 -1
- package/meta-types.ts +2 -0
- package/meta.ts +76 -42
- package/package.json +1 -1
- package/src/Avatar.tsx +80 -27
- package/src/AvatarGroup.tsx +71 -0
- package/src/Button.tsx +14 -4
- package/src/Checkbox.tsx +25 -11
- package/src/CheckboxGroup.tsx +6 -3
- package/src/CheckboxOption.tsx +9 -2
- package/src/Chip.tsx +3 -1
- package/src/Dialog.tsx +3 -3
- package/src/Dropdown.tsx +30 -10
- package/src/Menu.tsx +30 -18
- package/src/NumberInput.tsx +15 -6
- package/src/Portal.tsx +5 -1
- package/src/ProgressBar.tsx +4 -0
- package/src/ProgressionStepper.tsx +9 -2
- package/src/ProgressionStepperBar.tsx +6 -0
- package/src/Radio.tsx +21 -4
- package/src/RadioGroup.tsx +34 -6
- package/src/RadioOption.tsx +11 -2
- package/src/SegmentedControl.tsx +21 -2
- package/src/Switch.tsx +1 -1
- package/src/SwitchGroup.tsx +19 -7
- package/src/TabGroup.tsx +23 -5
- package/src/Tag.tsx +5 -2
- package/src/TextInput.tsx +25 -15
- package/src/Textarea.tsx +3 -3
- package/src/avatar-group.scss +17 -0
- package/src/avatar.scss +5 -2
- package/src/badge.scss +1 -0
- package/src/button.scss +1 -0
- package/src/demo/ExampleModalRender.tsx +37 -0
- package/src/demo/ExamplePlaceholder.tsx +40 -0
- package/src/demo/examples.tsx +683 -0
- package/src/divider.scss +2 -0
- package/src/dropdown.scss +1 -0
- package/src/hooks/useOptionIconsInvalid.ts +10 -1
- package/src/index.ts +5 -32
- package/src/list-item.scss +5 -1
- package/src/menu.scss +1 -1
- package/src/segmented-control.scss +1 -0
- package/src/tab-group.scss +1 -0
- package/src/tag.scss +1 -0
- package/src/text-input.scss +13 -18
- package/src/utils/children.ts +1 -1
package/dist/text-input.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
[data-bspk=text-input]{--border-color: var(--stroke-neutral-base);display:flex;flex-flow:row nowrap;background-color:var(--surface-neutral-t1-base);border:solid 1px var(--border-color);height:var(--field-height);border-radius:var(--radius-small);padding:0 var(--field-padding);gap:var(--spacing-sizing-01);width:100%}[data-bspk=text-input]>*{display:flex;justify-content:center;align-items:center;height:var(--field-height);font:var(--field-font);color:var(--foreground-neutral-on-surface);min-width:0}[data-bspk=text-input]:hover:not(:focus-within){background:linear-gradient(var(--interactions-hover-opacity), var(--interactions-hover-opacity)),linear-gradient(var(--surface-neutral-t1-base), var(--surface-neutral-t1-base))}[data-bspk=text-input]:active:not(:focus-within){background:linear-gradient(var(--interactions-press-opacity), var(--interactions-press-opacity)),linear-gradient(var(--surface-neutral-t1-base), var(--surface-neutral-t1-base))}[data-bspk=text-input][data-readonly]{--border-color: var(--stroke-neutral-disabled-light);background:linear-gradient(var(--interactions-disabled-opacity), var(--interactions-disabled-opacity)),linear-gradient(var(--surface-neutral-t1-base), var(--surface-neutral-t1-base))}[data-bspk=text-input][data-disabled]{--border-color: var(--stroke-neutral-disabled-light);background:linear-gradient(var(--interactions-disabled-opacity), var(--interactions-disabled-opacity)),linear-gradient(var(--surface-neutral-t1-base), var(--surface-neutral-t1-base))}[data-bspk=text-input][data-disabled]>*{color:var(--foreground-neutral-disabled-on-surface)}[data-bspk=text-input][data-invalid]{--border-color: var(--status-error)}[data-bspk=text-input][data-size=small]{--field-padding: var(--spacing-sizing-02);--field-height: var(--spacing-sizing-08);--field-font: var(--body-small);--field-icon-width: var(--spacing-sizing-04);--field-clear-width: var(--spacing-sizing-05)}[data-bspk=text-input][data-size=medium]{--field-padding: var(--spacing-sizing-03);--field-height: var(--spacing-sizing-10);--field-font: var(--body-base);--field-icon-width: var(--spacing-sizing-05);--field-clear-width: var(--spacing-sizing-05)}[data-bspk=text-input][data-size=large]{--field-padding: var(--spacing-sizing-03);--field-height: var(--spacing-sizing-12);--field-font: var(--body-large);--field-icon-width: var(--spacing-sizing-06);--field-clear-width: var(--spacing-sizing-06)}[data-bspk=text-input] [data-leading] svg,[data-bspk=text-input] [data-trailing] svg{width:var(--field-icon-width)}[data-bspk=text-input] label{font:var(--labels-small);color:var(--foreground-neutral-on-surface-variant-01)}[data-bspk=text-input] input{flex:1;background-color:rgba(0,0,0,0) !important;border:none;outline:none;padding:0;pointer-events:all;text-overflow:ellipsis}[data-bspk=text-input] input[type=number]::-webkit-inner-spin-button,[data-bspk=text-input] input[type=number]::-webkit-outer-spin-button{display:none}[data-bspk=text-input] button[data-clear]{display:
|
|
1
|
+
[data-bspk=text-input]{--border-color: var(--stroke-neutral-base);display:flex;flex-flow:row nowrap;background-color:var(--surface-neutral-t1-base);border:solid 1px var(--border-color);height:var(--field-height);border-radius:var(--radius-small);padding:0 0 0 var(--field-padding);gap:var(--spacing-sizing-01);width:100%}[data-bspk=text-input]>*{display:flex;justify-content:center;align-items:center;height:var(--field-height);font:var(--field-font);color:var(--foreground-neutral-on-surface);min-width:0}[data-bspk=text-input]:hover:not(:focus-within){background:linear-gradient(var(--interactions-hover-opacity), var(--interactions-hover-opacity)),linear-gradient(var(--surface-neutral-t1-base), var(--surface-neutral-t1-base))}[data-bspk=text-input]:active:not(:focus-within){background:linear-gradient(var(--interactions-press-opacity), var(--interactions-press-opacity)),linear-gradient(var(--surface-neutral-t1-base), var(--surface-neutral-t1-base))}[data-bspk=text-input][data-readonly]{--border-color: var(--stroke-neutral-disabled-light);background:linear-gradient(var(--interactions-disabled-opacity), var(--interactions-disabled-opacity)),linear-gradient(var(--surface-neutral-t1-base), var(--surface-neutral-t1-base))}[data-bspk=text-input][data-disabled]{--border-color: var(--stroke-neutral-disabled-light);background:linear-gradient(var(--interactions-disabled-opacity), var(--interactions-disabled-opacity)),linear-gradient(var(--surface-neutral-t1-base), var(--surface-neutral-t1-base))}[data-bspk=text-input][data-disabled]>*{color:var(--foreground-neutral-disabled-on-surface)}[data-bspk=text-input][data-invalid]{--border-color: var(--status-error)}[data-bspk=text-input][data-size=small]{--field-padding: var(--spacing-sizing-02);--field-height: var(--spacing-sizing-08);--field-font: var(--body-small);--field-icon-width: var(--spacing-sizing-04);--field-clear-width: var(--spacing-sizing-05)}[data-bspk=text-input][data-size=medium]{--field-padding: var(--spacing-sizing-03);--field-height: var(--spacing-sizing-10);--field-font: var(--body-base);--field-icon-width: var(--spacing-sizing-05);--field-clear-width: var(--spacing-sizing-05)}[data-bspk=text-input][data-size=large]{--field-padding: var(--spacing-sizing-03);--field-height: var(--spacing-sizing-12);--field-font: var(--body-large);--field-icon-width: var(--spacing-sizing-06);--field-clear-width: var(--spacing-sizing-06)}[data-bspk=text-input] [data-leading] svg,[data-bspk=text-input] [data-trailing] svg{width:var(--field-icon-width)}[data-bspk=text-input] label{font:var(--labels-small);color:var(--foreground-neutral-on-surface-variant-01)}[data-bspk=text-input] input{flex:1;background-color:rgba(0,0,0,0) !important;border:none;outline:none;padding:0;pointer-events:all;text-overflow:ellipsis}[data-bspk=text-input] input[type=number]::-webkit-inner-spin-button,[data-bspk=text-input] input[type=number]::-webkit-outer-spin-button{display:none}[data-bspk=text-input] button[data-clear]{display:flex;border:none;background:none;padding:0;cursor:pointer;pointer-events:all;margin-left:var(--spacing-sizing-02);padding-right:var(--field-padding)}[data-bspk=text-input] button[data-clear] svg{pointer-events:none;width:var(--field-clear-width)}[data-bspk=text-input]:not(:focus-within),[data-bspk=text-input][data-empty],[data-bspk=text-input][data-readonly],[data-bspk=text-input][data-disabled]{padding-right:var(--field-padding)}[data-bspk=text-input]:not(:focus-within) button[data-clear],[data-bspk=text-input][data-empty] button[data-clear],[data-bspk=text-input][data-readonly] button[data-clear],[data-bspk=text-input][data-disabled] button[data-clear]{display:none}[data-bspk=text-input]:focus-within{--border-color: var(--stroke-brand-primary)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"children.js","sourceRoot":"","sources":["../../src/utils/children.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"children.js","sourceRoot":"","sources":["../../src/utils/children.ts"],"names":[],"mappings":"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"}
|
package/meta-types.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* This file is used to build the meta types for the project. It's used in the build-meta.ts file and also copied in to
|
|
3
3
|
* the meta output file.
|
|
4
4
|
*/
|
|
5
|
+
|
|
5
6
|
export type BaseMeta = {
|
|
6
7
|
name: string;
|
|
7
8
|
description?: string;
|
|
@@ -27,6 +28,7 @@ export type TypeProperty = {
|
|
|
27
28
|
references?: string[];
|
|
28
29
|
minimum?: number;
|
|
29
30
|
maximum?: number;
|
|
31
|
+
example?: string;
|
|
30
32
|
};
|
|
31
33
|
|
|
32
34
|
export type ComponentMeta = BaseMeta & {
|
package/meta.ts
CHANGED
|
@@ -19,6 +19,12 @@ import { ComponentMeta, TypeProperty, UtilityMeta, TypeMeta } from './meta-types
|
|
|
19
19
|
const __filename = fileURLToPath(import.meta.url);
|
|
20
20
|
const __dirname = dirname(__filename);
|
|
21
21
|
|
|
22
|
+
const { componentsDir, hooksDir, rootPath } = {
|
|
23
|
+
componentsDir: path.resolve(__dirname, 'src'),
|
|
24
|
+
hooksDir: path.resolve(__dirname, 'src', 'hooks'),
|
|
25
|
+
rootPath: path.resolve(__dirname),
|
|
26
|
+
} as const;
|
|
27
|
+
|
|
22
28
|
function jsDocParse(content: string) {
|
|
23
29
|
try {
|
|
24
30
|
const contentTrimmed = content
|
|
@@ -43,7 +49,8 @@ function jsDocParse(content: string) {
|
|
|
43
49
|
data[key] = value
|
|
44
50
|
.replace(/\n[ ]+\*([ ]*)/g, '\n')
|
|
45
51
|
.replace(/^\s+\*\s+/, '')
|
|
46
|
-
.trim()
|
|
52
|
+
.trim()
|
|
53
|
+
.replace(/;$/, '');
|
|
47
54
|
|
|
48
55
|
return;
|
|
49
56
|
}
|
|
@@ -101,34 +108,34 @@ if (!metaFilePath) {
|
|
|
101
108
|
process.exit(1);
|
|
102
109
|
}
|
|
103
110
|
|
|
104
|
-
const { componentsDir, hooksDir, rootPath } = {
|
|
105
|
-
componentsDir: path.resolve(__dirname, 'src'),
|
|
106
|
-
hooksDir: path.resolve(__dirname, 'src', 'hooks'),
|
|
107
|
-
rootPath: path.resolve(__dirname),
|
|
108
|
-
} as const;
|
|
109
|
-
|
|
110
111
|
const componentFiles = fs
|
|
111
112
|
.readdirSync(componentsDir)
|
|
112
113
|
.filter((f) => f.endsWith('.tsx'))
|
|
113
114
|
.map((fileName) => {
|
|
114
115
|
const filePath = path.resolve(componentsDir, fileName);
|
|
116
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
115
117
|
return {
|
|
116
118
|
filePath,
|
|
117
119
|
name: fileName.replace(/\.[^.]+$/, ''),
|
|
118
120
|
fileName,
|
|
119
|
-
content
|
|
121
|
+
content,
|
|
122
|
+
// eslint-disable-next-line no-useless-escape
|
|
123
|
+
jsDocs: content.match(/\/\*\*\s*\n([^\*]|(\*(?!\/)))*\*\//g)?.map((jsDoc) => jsDocParse(jsDoc)),
|
|
120
124
|
};
|
|
121
125
|
});
|
|
122
126
|
|
|
127
|
+
type ComponentFile = (typeof componentFiles)[0];
|
|
128
|
+
|
|
129
|
+
fs.writeFileSync(path.resolve(__dirname, 'component-files.json'), JSON.stringify(componentFiles, null, 2), {
|
|
130
|
+
encoding: 'utf-8',
|
|
131
|
+
});
|
|
132
|
+
|
|
123
133
|
function generateComponentMeta({
|
|
124
134
|
filePath: componentFile,
|
|
125
135
|
content,
|
|
126
136
|
name,
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
content: string;
|
|
130
|
-
name: string;
|
|
131
|
-
}): ComponentMeta | null {
|
|
137
|
+
jsDocs,
|
|
138
|
+
}: ComponentFile): ComponentMeta | null {
|
|
132
139
|
const stats = fs.statSync(componentFile);
|
|
133
140
|
|
|
134
141
|
const componentFunctionMatch = content.match(new RegExp(`function ${name}[(<]`));
|
|
@@ -142,18 +149,13 @@ function generateComponentMeta({
|
|
|
142
149
|
return null;
|
|
143
150
|
}
|
|
144
151
|
|
|
145
|
-
|
|
146
|
-
const allJSDocMatches = content.match(/\/\*\*\s*\n([^\*]|(\*(?!\/)))*\*\//g);
|
|
147
|
-
|
|
148
|
-
const componentDocStr = [...(allJSDocMatches || [])].find((doc) => doc.includes(`@name ${name}`));
|
|
152
|
+
const componentDoc = [...(jsDocs || [])].find((doc) => doc.name === name);
|
|
149
153
|
|
|
150
|
-
if (!
|
|
154
|
+
if (!componentDoc) {
|
|
151
155
|
console.warn(`No JSDoc found for component ${name} for ${componentFile}`);
|
|
152
156
|
return null;
|
|
153
157
|
}
|
|
154
158
|
|
|
155
|
-
const componentDoc = jsDocParse(componentDocStr);
|
|
156
|
-
|
|
157
159
|
const slug = kebabCase(componentDoc.name);
|
|
158
160
|
|
|
159
161
|
const dependencies = [...content.matchAll(/import { ([^}]+) } from '\.\/([a-zA-Z]+)';/g)]
|
|
@@ -257,11 +259,9 @@ function generateTypes() {
|
|
|
257
259
|
noExtraProps: false,
|
|
258
260
|
})!;
|
|
259
261
|
|
|
260
|
-
const
|
|
262
|
+
const { definitions } = generator.getSchemaForSymbols(generator.getMainFileSymbols(program), true);
|
|
261
263
|
|
|
262
|
-
|
|
263
|
-
[key: string]: TJS.Definition;
|
|
264
|
-
};
|
|
264
|
+
fs.writeFileSync(path.resolve(__dirname, 'types.json'), JSON.stringify(definitions, null, 2));
|
|
265
265
|
|
|
266
266
|
const nextTypes: TypeMeta[] = [];
|
|
267
267
|
|
|
@@ -283,26 +283,42 @@ function generateTypes() {
|
|
|
283
283
|
|
|
284
284
|
const defineProperty = (
|
|
285
285
|
name: string,
|
|
286
|
-
definition: TJS.
|
|
287
|
-
required
|
|
286
|
+
definition: TJS.Definition,
|
|
287
|
+
required: string[],
|
|
288
|
+
context: {
|
|
289
|
+
componentFile: ComponentFile | null;
|
|
290
|
+
parent: string;
|
|
291
|
+
},
|
|
288
292
|
): TypeProperty | undefined => {
|
|
289
|
-
|
|
293
|
+
// the auto-generated types aren't always correct, so we need to fix them
|
|
294
|
+
const jsDoc = definition.description
|
|
295
|
+
? context.componentFile?.jsDocs?.find(
|
|
296
|
+
(doc) =>
|
|
297
|
+
doc.description.includes(definition.description!) ||
|
|
298
|
+
definition.description!.includes(doc.description),
|
|
299
|
+
)
|
|
300
|
+
: undefined;
|
|
290
301
|
|
|
291
302
|
const next: TypeProperty = {
|
|
292
303
|
name,
|
|
293
304
|
required: required?.includes(name),
|
|
294
|
-
description: definition.description,
|
|
305
|
+
description: jsDoc?.description || definition.description,
|
|
295
306
|
default: definition.default === 'undefined' ? undefined : definition.default,
|
|
296
|
-
type: definition.type,
|
|
307
|
+
type: definition.type?.toString(),
|
|
297
308
|
properties:
|
|
298
309
|
definition.properties &&
|
|
299
|
-
Object.entries(definition.properties)?.flatMap(
|
|
300
|
-
|
|
310
|
+
Object.entries(definition.properties)?.flatMap(([name2, definition2]) =>
|
|
311
|
+
typeof definition2 === 'boolean'
|
|
312
|
+
? []
|
|
313
|
+
: defineProperty(name2, definition2, definition.required || [], context) || [],
|
|
301
314
|
),
|
|
302
315
|
minimum: definition.minimum,
|
|
303
316
|
maximum: definition.maximum,
|
|
317
|
+
example: jsDoc?.example,
|
|
304
318
|
};
|
|
305
319
|
|
|
320
|
+
if (next.name.match(/^on[A-Z]/)) next.type = 'function';
|
|
321
|
+
|
|
306
322
|
const defEnum = cleanUpDefinitionEnums(definition);
|
|
307
323
|
|
|
308
324
|
if (defEnum) {
|
|
@@ -313,8 +329,8 @@ function generateTypes() {
|
|
|
313
329
|
if (definition.$ref) {
|
|
314
330
|
next.type = definition.$ref.split('/').pop() as string;
|
|
315
331
|
|
|
316
|
-
if (definitions[next.type]) {
|
|
317
|
-
next.options = cleanUpDefinitionEnums(definitions[next.type]);
|
|
332
|
+
if (definitions && definitions[next.type] && typeof definitions[next.type] !== 'boolean') {
|
|
333
|
+
next.options = cleanUpDefinitionEnums(definitions[next.type] as TJS.Definition);
|
|
318
334
|
}
|
|
319
335
|
}
|
|
320
336
|
|
|
@@ -325,6 +341,15 @@ function generateTypes() {
|
|
|
325
341
|
Object.entries(definitions).forEach(([definitionName, definition]) => {
|
|
326
342
|
if (typeof definition !== 'object') return;
|
|
327
343
|
|
|
344
|
+
let componentFile: ComponentFile | null = null;
|
|
345
|
+
// only care about ComponentProps
|
|
346
|
+
if (definitionName.endsWith('Props')) {
|
|
347
|
+
componentFile =
|
|
348
|
+
componentFiles.find((f) => f.fileName === `${definitionName.replace(/Props$/, '')}.tsx`) || null;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
const context = { componentFile, parent: definitionName };
|
|
352
|
+
|
|
328
353
|
if (!definition?.properties && !definition?.allOf) return;
|
|
329
354
|
|
|
330
355
|
if (['React', 'Omit<'].some((n) => definitionName.startsWith(n))) return;
|
|
@@ -336,9 +361,10 @@ function generateTypes() {
|
|
|
336
361
|
if (typeof ofDefinition !== 'object') return [];
|
|
337
362
|
|
|
338
363
|
if (ofDefinition.properties) {
|
|
339
|
-
return Object.entries(ofDefinition.properties).flatMap(
|
|
340
|
-
|
|
341
|
-
|
|
364
|
+
return Object.entries(ofDefinition.properties).flatMap(([refName, refDefinition]) =>
|
|
365
|
+
typeof refDefinition !== 'object'
|
|
366
|
+
? []
|
|
367
|
+
: defineProperty(refName, refDefinition, ofDefinition.required || [], context) || [],
|
|
342
368
|
);
|
|
343
369
|
}
|
|
344
370
|
|
|
@@ -348,12 +374,13 @@ function generateTypes() {
|
|
|
348
374
|
|
|
349
375
|
const defReference = definitions[reference];
|
|
350
376
|
|
|
351
|
-
if (
|
|
377
|
+
if (typeof defReference === 'boolean') return [];
|
|
352
378
|
|
|
353
|
-
return Object.entries(defReference.properties || {}).flatMap(
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
379
|
+
return Object.entries(defReference.properties || {}).flatMap(([refName, refDefinition]) => {
|
|
380
|
+
return typeof refDefinition !== 'object'
|
|
381
|
+
? []
|
|
382
|
+
: defineProperty(refName, refDefinition, defReference.required || [], context) || [];
|
|
383
|
+
});
|
|
357
384
|
});
|
|
358
385
|
}
|
|
359
386
|
|
|
@@ -366,7 +393,7 @@ function generateTypes() {
|
|
|
366
393
|
return;
|
|
367
394
|
}
|
|
368
395
|
properties = Object.entries(props).flatMap(
|
|
369
|
-
([propName, prop]) => defineProperty(propName, prop, definition.required) || [],
|
|
396
|
+
([propName, prop]) => defineProperty(propName, prop, definition.required || [], context) || [],
|
|
370
397
|
);
|
|
371
398
|
}
|
|
372
399
|
|
|
@@ -432,11 +459,16 @@ async function createMeta() {
|
|
|
432
459
|
const typesMeta = generateTypes();
|
|
433
460
|
typesMeta.sort((a, b) => a.name.localeCompare(b.name));
|
|
434
461
|
|
|
462
|
+
const componentImport = (name: string) =>
|
|
463
|
+
`${name}: React.lazy(() => import('@bspk/ui/${name}').then((module) => ({ default: module.${name} })))`;
|
|
464
|
+
|
|
435
465
|
fs.writeFileSync(
|
|
436
466
|
metaFilePath,
|
|
437
467
|
[
|
|
438
468
|
`/** This file is generated by the @bspk/ui/meta.ts script with data scraped from the library. */`,
|
|
439
469
|
|
|
470
|
+
`import React from 'react';`,
|
|
471
|
+
|
|
440
472
|
fs.readFileSync(path.resolve(__dirname, 'meta-types.ts'), { encoding: 'utf-8' }),
|
|
441
473
|
|
|
442
474
|
`export const componentsMeta: ComponentMeta[] = ${JSON.stringify(componentsMeta, null, 2)} as const;`,
|
|
@@ -448,6 +480,8 @@ async function createMeta() {
|
|
|
448
480
|
`export type MetaTypeName = '${typesMeta.map((t) => t.name).join("' | '")}';`,
|
|
449
481
|
|
|
450
482
|
`export type MetaComponentName = '${metaComponentNames.join("' | '")}';`,
|
|
483
|
+
|
|
484
|
+
`export const components: Partial<Record<MetaComponentName, React.LazyExoticComponent<any>>> = {${metaComponentNames.map(componentImport).join(',')}\n};`,
|
|
451
485
|
].join('\n\n'),
|
|
452
486
|
);
|
|
453
487
|
|
package/package.json
CHANGED
package/src/Avatar.tsx
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import './avatar.scss';
|
|
2
2
|
import { ReactNode, useMemo } from 'react';
|
|
3
3
|
|
|
4
|
+
import { Tooltip } from './Tooltip';
|
|
5
|
+
import { isValidIcon } from './utils/children';
|
|
4
6
|
import { ColorVariant } from './utils/colorVariants';
|
|
5
7
|
|
|
6
|
-
|
|
8
|
+
const DEFAULT = {
|
|
9
|
+
size: 'small',
|
|
10
|
+
color: 'grey',
|
|
11
|
+
showTooltip: true,
|
|
12
|
+
} as const;
|
|
7
13
|
|
|
8
14
|
export type SizeVariant =
|
|
9
15
|
| 'large'
|
|
@@ -16,7 +22,16 @@ export type SizeVariant =
|
|
|
16
22
|
| 'xxxx-large'
|
|
17
23
|
| 'xxxxx-large';
|
|
18
24
|
|
|
19
|
-
export type AvatarProps =
|
|
25
|
+
export type AvatarProps = {
|
|
26
|
+
/**
|
|
27
|
+
* The name of the person or entity represented by the avatar. This is used for accessibility purposes.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* Jane Doe
|
|
31
|
+
*
|
|
32
|
+
* @required
|
|
33
|
+
*/
|
|
34
|
+
name: string;
|
|
20
35
|
/**
|
|
21
36
|
* The size of the avatar.
|
|
22
37
|
*
|
|
@@ -29,48 +44,86 @@ export type AvatarProps = CommonProps<'aria-label'> & {
|
|
|
29
44
|
* @default grey
|
|
30
45
|
*/
|
|
31
46
|
color?: ColorVariant;
|
|
32
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* The initials to display in the avatar limited to 2 characters.
|
|
49
|
+
*
|
|
50
|
+
* If not provided, the first two letters of the name will be used as initials.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* JD;
|
|
54
|
+
*/
|
|
33
55
|
initials?: string;
|
|
34
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* The icon to display in the avatar. This needs to be an icon from the @bspk/icons library.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* <SvgPerson />;
|
|
61
|
+
*
|
|
62
|
+
* @type BspkIcon
|
|
63
|
+
*/
|
|
35
64
|
icon?: ReactNode;
|
|
36
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* The url to the image to display in the avatar.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* /profile.jpg
|
|
70
|
+
*/
|
|
37
71
|
image?: string;
|
|
38
|
-
/**
|
|
39
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Whether to show the represeneetd user's name as a tooltip.
|
|
74
|
+
*
|
|
75
|
+
* @default true
|
|
76
|
+
*/
|
|
77
|
+
showTooltip?: boolean;
|
|
40
78
|
};
|
|
41
79
|
|
|
42
80
|
/**
|
|
43
|
-
* An avatar is a visual representation of a user or entity. It can be used to display an initials, icon, image
|
|
44
|
-
*
|
|
81
|
+
* An avatar is a visual representation of a user or entity. It can be used to display an initials, icon, image.
|
|
82
|
+
*
|
|
83
|
+
* The image if provided is displayed first, followed by the icon if provided, and finally the initials.
|
|
84
|
+
*
|
|
85
|
+
* If no initials are provided, the first two letters of the name will be used as initials.
|
|
45
86
|
*
|
|
46
87
|
* @name Avatar
|
|
47
88
|
*/
|
|
48
89
|
function Avatar({
|
|
49
|
-
initials,
|
|
50
|
-
color =
|
|
51
|
-
size =
|
|
90
|
+
initials: initialsProp,
|
|
91
|
+
color = DEFAULT.color,
|
|
92
|
+
size = DEFAULT.size,
|
|
52
93
|
icon,
|
|
53
94
|
image,
|
|
54
|
-
|
|
55
|
-
|
|
95
|
+
name: ariaLabel,
|
|
96
|
+
showTooltip = DEFAULT.showTooltip,
|
|
56
97
|
}: AvatarProps) {
|
|
57
98
|
const children = useMemo(() => {
|
|
58
|
-
if (initials) return <span data-initials>{initials}</span>;
|
|
59
|
-
if (icon) return <span data-icon>{icon}</span>;
|
|
60
99
|
if (image) return <img alt={ariaLabel} src={image} />;
|
|
61
|
-
|
|
100
|
+
|
|
101
|
+
if (isValidIcon(icon)) return <span data-icon>{icon}</span>;
|
|
102
|
+
|
|
103
|
+
let initials = initialsProp;
|
|
104
|
+
|
|
105
|
+
if (ariaLabel && !initials)
|
|
106
|
+
initials = ariaLabel
|
|
107
|
+
.split(' ')
|
|
108
|
+
.map((word) => word.charAt(0))
|
|
109
|
+
.slice(0, 2)
|
|
110
|
+
.join('')
|
|
111
|
+
.toUpperCase();
|
|
112
|
+
|
|
113
|
+
if (initials) return <span data-initials>{initials.slice(0, 2)}</span>;
|
|
114
|
+
|
|
62
115
|
return null;
|
|
63
|
-
}, [ariaLabel, icon, image,
|
|
64
|
-
|
|
65
|
-
return
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
)}
|
|
72
|
-
</>
|
|
116
|
+
}, [ariaLabel, icon, image, initialsProp]);
|
|
117
|
+
|
|
118
|
+
if (!children) return null;
|
|
119
|
+
|
|
120
|
+
const avatar = (
|
|
121
|
+
<div aria-label={ariaLabel} data-bspk="avatar" data-color={color} data-size={size}>
|
|
122
|
+
{children}
|
|
123
|
+
</div>
|
|
73
124
|
);
|
|
125
|
+
|
|
126
|
+
return showTooltip ? <Tooltip label={ariaLabel}>{avatar}</Tooltip> : avatar;
|
|
74
127
|
}
|
|
75
128
|
|
|
76
129
|
Avatar.bspkName = 'Avatar';
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Avatar, AvatarProps, SizeVariant } from './Avatar';
|
|
2
|
+
import './avatar-group.scss';
|
|
3
|
+
|
|
4
|
+
export type AvatarItem = Pick<AvatarProps, 'color' | 'icon' | 'image' | 'initials' | 'name'>;
|
|
5
|
+
|
|
6
|
+
export type AvatarGroupProps = {
|
|
7
|
+
/**
|
|
8
|
+
* The avatars to display in the group.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* [
|
|
12
|
+
* { name: 'Jane Doe', image: '/path/to/image.jpg' },
|
|
13
|
+
* { name: 'John Smith', initials: 'JS' },
|
|
14
|
+
* ];
|
|
15
|
+
*
|
|
16
|
+
* @type Array<AvatarItem>
|
|
17
|
+
* @required
|
|
18
|
+
*/
|
|
19
|
+
items: AvatarItem[];
|
|
20
|
+
/**
|
|
21
|
+
* Size of the avatar group.
|
|
22
|
+
*
|
|
23
|
+
* @default small
|
|
24
|
+
*/
|
|
25
|
+
size?: Extract<SizeVariant, 'large' | 'medium' | 'small' | 'x-small'>;
|
|
26
|
+
/**
|
|
27
|
+
* The maximum number of avatars to display before showing the overflowCount.
|
|
28
|
+
*
|
|
29
|
+
* This is used to limit the number of avatars displayed in the group.
|
|
30
|
+
*
|
|
31
|
+
* @minimum 3
|
|
32
|
+
* @maximum 5
|
|
33
|
+
*/
|
|
34
|
+
max?: number;
|
|
35
|
+
/**
|
|
36
|
+
* The variant of the avatar group.
|
|
37
|
+
*
|
|
38
|
+
* @default spread
|
|
39
|
+
*/
|
|
40
|
+
variant?: 'spread' | 'stacked';
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* AvatarGroup component displays a group of avatars.
|
|
45
|
+
*
|
|
46
|
+
* @name AvatarGroup
|
|
47
|
+
*/
|
|
48
|
+
function AvatarGroup({ items, size = 'small', max = 5, variant }: AvatarGroupProps) {
|
|
49
|
+
if (!Array.isArray(items) || !items?.length) return null;
|
|
50
|
+
|
|
51
|
+
const overFlowCount = items.length - max;
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<div data-bspk="avatar-group" data-max={max} data-size={size} data-variant={variant}>
|
|
55
|
+
<div data-wrap>
|
|
56
|
+
{items.map((item, index) => (
|
|
57
|
+
<Avatar key={index} {...item} size={size} />
|
|
58
|
+
))}
|
|
59
|
+
{overFlowCount > 0 && (
|
|
60
|
+
<div aria-hidden data-bspk="avatar" data-size={size}>
|
|
61
|
+
<span data-overflow-count>+{overFlowCount}</span>
|
|
62
|
+
</div>
|
|
63
|
+
)}
|
|
64
|
+
</div>
|
|
65
|
+
</div>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
AvatarGroup.bspkName = 'AvatarGroup';
|
|
70
|
+
|
|
71
|
+
export { AvatarGroup };
|
package/src/Button.tsx
CHANGED
|
@@ -9,10 +9,18 @@ import { ButtonSize, CommonProps, ElementProps } from './';
|
|
|
9
9
|
|
|
10
10
|
export type ButtonVariant = 'primary' | 'secondary' | 'tertiary';
|
|
11
11
|
|
|
12
|
-
export type ButtonProps<As extends ElementType = 'button'> = CommonProps<'disabled'
|
|
13
|
-
/**
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
export type ButtonProps<As extends ElementType = 'button'> = CommonProps<'disabled'> & {
|
|
13
|
+
/**
|
|
14
|
+
* The label of the button.
|
|
15
|
+
*
|
|
16
|
+
* @required
|
|
17
|
+
*/
|
|
18
|
+
label: string;
|
|
19
|
+
/**
|
|
20
|
+
* The icon of the button.
|
|
21
|
+
*
|
|
22
|
+
* @type BspkIcon
|
|
23
|
+
*/
|
|
16
24
|
icon?: ReactNode;
|
|
17
25
|
/**
|
|
18
26
|
* Shows the button label. When label isn't showing it is used in a tooltip and as the aria-label prop.
|
|
@@ -59,6 +67,8 @@ export type ButtonProps<As extends ElementType = 'button'> = CommonProps<'disabl
|
|
|
59
67
|
children?: ReactNode;
|
|
60
68
|
/** The tool tip text that appears when hovered. */
|
|
61
69
|
toolTip?: string;
|
|
70
|
+
/** The function to call when the button is clicked. */
|
|
71
|
+
onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
|
62
72
|
};
|
|
63
73
|
|
|
64
74
|
/**
|
package/src/Checkbox.tsx
CHANGED
|
@@ -1,17 +1,31 @@
|
|
|
1
1
|
import './checkbox.scss';
|
|
2
|
-
import { useEffect, useRef } from 'react';
|
|
2
|
+
import { ChangeEvent, useEffect, useRef } from 'react';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { CommonProps, ElementProps, InvalidPropsLibrary } from './';
|
|
5
5
|
|
|
6
|
-
export type CheckboxProps =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
export type CheckboxProps = CommonProps<'aria-label' | 'disabled' | 'name'> &
|
|
7
|
+
InvalidPropsLibrary &
|
|
8
|
+
Required<CommonProps<'value'>> & {
|
|
9
|
+
/**
|
|
10
|
+
* If the checkbox is partially checked or
|
|
11
|
+
* [indeterminate](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#indeterminate_state_checkboxes).
|
|
12
|
+
*
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
indeterminate?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Marks the checkbox as checked.
|
|
18
|
+
*
|
|
19
|
+
* @default false
|
|
20
|
+
*/
|
|
21
|
+
checked?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* The function to call when the checkbox is checked or unchecked.
|
|
24
|
+
*
|
|
25
|
+
* @required
|
|
26
|
+
*/
|
|
27
|
+
onChange: (checked: boolean, event: ChangeEvent<HTMLInputElement>) => void;
|
|
28
|
+
};
|
|
15
29
|
|
|
16
30
|
/**
|
|
17
31
|
* A control that allows users to choose one or more items from a list or turn an feature on or off. This is the base
|
package/src/CheckboxGroup.tsx
CHANGED
|
@@ -9,9 +9,12 @@ export type CheckboxGroupProps = CommonProps<'aria-label'> & {
|
|
|
9
9
|
/**
|
|
10
10
|
* The function to call when the checkboxes are changed.
|
|
11
11
|
*
|
|
12
|
+
* @example
|
|
13
|
+
* (values) => setState({ values });
|
|
14
|
+
*
|
|
12
15
|
* @required
|
|
13
16
|
*/
|
|
14
|
-
onChange: (
|
|
17
|
+
onChange: (values: string[]) => void;
|
|
15
18
|
/**
|
|
16
19
|
* The input control name of the checkboxes.
|
|
17
20
|
*
|
|
@@ -21,14 +24,14 @@ export type CheckboxGroupProps = CommonProps<'aria-label'> & {
|
|
|
21
24
|
/**
|
|
22
25
|
* The options for the checkboxes.
|
|
23
26
|
*
|
|
24
|
-
* @type CheckboxGroupOption
|
|
27
|
+
* @type Array<CheckboxGroupOption>
|
|
25
28
|
* @required
|
|
26
29
|
*/
|
|
27
30
|
options: CheckboxGroupOption[];
|
|
28
31
|
/**
|
|
29
32
|
* The values of the checked checkboxes.
|
|
30
33
|
*
|
|
31
|
-
* @type string
|
|
34
|
+
* @type Array<string>
|
|
32
35
|
*/
|
|
33
36
|
values?: CheckboxGroupProps['options'][number]['value'][];
|
|
34
37
|
/**
|
package/src/CheckboxOption.tsx
CHANGED
|
@@ -4,8 +4,15 @@ import { ToggleOptionProps, ToggleOption } from './ToggleOption';
|
|
|
4
4
|
import { InvalidPropsLibrary } from '.';
|
|
5
5
|
|
|
6
6
|
export type CheckboxOptionProps = InvalidPropsLibrary &
|
|
7
|
-
Pick<CheckboxProps, 'checked' | 'disabled' | 'indeterminate' | 'name' | '
|
|
8
|
-
Pick<ToggleOptionProps, 'description' | 'label'
|
|
7
|
+
Pick<CheckboxProps, 'checked' | 'disabled' | 'indeterminate' | 'name' | 'value'> &
|
|
8
|
+
Pick<ToggleOptionProps, 'description' | 'label'> & {
|
|
9
|
+
/**
|
|
10
|
+
* The function to call when the checkbox is checked or unchecked.
|
|
11
|
+
*
|
|
12
|
+
* @required
|
|
13
|
+
*/
|
|
14
|
+
onChange: (checked: boolean, event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
15
|
+
};
|
|
9
16
|
|
|
10
17
|
/**
|
|
11
18
|
* A control that allows users to choose one or more items from a list or turn an feature on or off.
|
package/src/Chip.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import { CSSProperties, ReactNode } from 'react';
|
|
|
3
3
|
|
|
4
4
|
import { CommonProps } from '.';
|
|
5
5
|
|
|
6
|
-
export type ChipProps = CommonProps<'disabled'
|
|
6
|
+
export type ChipProps = CommonProps<'disabled'> & {
|
|
7
7
|
/**
|
|
8
8
|
* The content of the chip.
|
|
9
9
|
*
|
|
@@ -39,6 +39,8 @@ export type ChipProps = CommonProps<'disabled' | 'onClick'> & {
|
|
|
39
39
|
selected?: boolean;
|
|
40
40
|
/** The style of the chip. */
|
|
41
41
|
style?: CSSProperties;
|
|
42
|
+
/** The function to call when the chip is clicked. */
|
|
43
|
+
onClick?: (event: React.MouseEvent<HTMLSpanElement, MouseEvent>) => void;
|
|
42
44
|
};
|
|
43
45
|
|
|
44
46
|
/**
|