@vev/silke 1.0.19 → 1.0.20

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 (69) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/{chunk-FIPWO3IB.js → chunk-PP74IZDW.js} +2 -2
  3. package/dist/{chunk-FIPWO3IB.js.map → chunk-PP74IZDW.js.map} +2 -2
  4. package/dist/index.js +20 -20
  5. package/dist/index.js.map +4 -4
  6. package/dist/silke/src/components/silke-box/silke-box.d.ts +1 -2
  7. package/dist/silke/src/components/silke-card/silke-card.d.ts +2 -0
  8. package/dist/silke/src/components/silke-form-schema/fields/number-field.d.ts +3 -1
  9. package/dist/silke/src/components/silke-form-schema/silke-schema-field.d.ts +2 -2
  10. package/dist/silke/src/components/silke-tabs/silke-tab.d.ts +4 -7
  11. package/dist/silke/src/components/silke-tabs/silke-tabs.d.ts +4 -6
  12. package/dist/silke/src/components/silke-text-field/silke-text-field-outline.d.ts +1 -2
  13. package/dist/silke/src/components/silke-tooltip/silke-shortcuts.d.ts +1 -1
  14. package/dist/silke/src/components/silke-upload-field/silke-upload-field.d.ts +1 -0
  15. package/dist/silke/src/icons.d.ts +3 -0
  16. package/dist/{silke-code-editor-HB2Z4Q5W.js → silke-code-editor-4TSQ5KJ3.js} +12 -12
  17. package/dist/silke-code-editor-4TSQ5KJ3.js.map +7 -0
  18. package/dist/styles.css +386 -411
  19. package/dist/utils/src/interactions/get-interaction-map.d.ts +3 -0
  20. package/dist/utils/src/interactions/index.d.ts +2 -0
  21. package/dist/utils/src/interactions/interaction-map-to-array.d.ts +2 -0
  22. package/dist/utils/src/types/context.d.ts +1 -1
  23. package/dist/utils/src/types/index.d.ts +1 -0
  24. package/dist/utils/src/types/interaction.d.ts +9 -0
  25. package/dist/utils/src/types/oauth.d.ts +13 -0
  26. package/dist/utils/src/types/vev-plugin.d.ts +37 -6
  27. package/package.json +5 -4
  28. package/src/components/silke-autocomplete-field/autocomplete-item.tsx +1 -0
  29. package/src/components/silke-autocomplete-field/silke-autocomplete-field.scss +18 -4
  30. package/src/components/silke-autocomplete-field/silke-autocomplete-field.tsx +10 -8
  31. package/src/components/silke-box/silke-box.mdx +2 -2
  32. package/src/components/silke-box/silke-box.scss +2 -1
  33. package/src/components/silke-box/silke-box.tsx +1 -2
  34. package/src/components/silke-button/silke-button.scss +2 -2
  35. package/src/components/silke-card/silke-card-grid.tsx +1 -3
  36. package/src/components/silke-card/silke-card.scss +28 -3
  37. package/src/components/silke-card/silke-card.tsx +27 -9
  38. package/src/components/silke-code-snippet/silke-code-snippet.tsx +2 -2
  39. package/src/components/silke-form-schema/fields/image-field.tsx +4 -2
  40. package/src/components/silke-form-schema/fields/link-field.tsx +2 -6
  41. package/src/components/silke-form-schema/fields/number-field.tsx +47 -43
  42. package/src/components/silke-form-schema/fields/object-field.tsx +1 -1
  43. package/src/components/silke-form-schema/fields/select-field.tsx +37 -49
  44. package/src/components/silke-form-schema/fields/string-field.tsx +13 -28
  45. package/src/components/silke-form-schema/fields/toggle-field.tsx +8 -10
  46. package/src/components/silke-form-schema/silke-form-schema.mdx +14 -26
  47. package/src/components/silke-form-schema/silke-form-schema.tsx +4 -1
  48. package/src/components/silke-form-schema/silke-schema-field.tsx +8 -8
  49. package/src/components/silke-form-schema/silke-schema-fields.tsx +2 -2
  50. package/src/components/silke-icon-picker/silke-icon-picker.tsx +1 -1
  51. package/src/components/silke-list-card/silke-list-card.tsx +0 -2
  52. package/src/components/silke-overflow-menu/silke-overflow-menu.tsx +1 -1
  53. package/src/components/silke-tabs/silke-tab.tsx +17 -50
  54. package/src/components/silke-tabs/silke-tabs.mdx +4 -16
  55. package/src/components/silke-tabs/silke-tabs.scss +24 -81
  56. package/src/components/silke-tabs/silke-tabs.tsx +12 -10
  57. package/src/components/silke-tag/silke-tag.mdx +78 -24
  58. package/src/components/silke-tag/silke-tag.scss +4 -1
  59. package/src/components/silke-text/silke-title.scss +0 -2
  60. package/src/components/silke-text-field/silke-text-field-outline.tsx +28 -16
  61. package/src/components/silke-text-field/silke-text-field.mdx +12 -0
  62. package/src/components/silke-text-field/silke-text-field.scss +8 -1
  63. package/src/components/silke-text-field/silke-text-field.tsx +2 -2
  64. package/src/components/silke-upload-field/silke-upload-field.tsx +5 -1
  65. package/src/icons.tsx +9 -19
  66. package/src/styles/core.scss +6 -0
  67. package/dist/silke-code-editor-HB2Z4Q5W.js.map +0 -7
  68. /package/dist/{chunk-FIPWO3IB.js.LEGAL.txt → chunk-PP74IZDW.js.LEGAL.txt} +0 -0
  69. /package/dist/{silke-code-editor-HB2Z4Q5W.js.LEGAL.txt → silke-code-editor-4TSQ5KJ3.js.LEGAL.txt} +0 -0
@@ -4,21 +4,22 @@ import { SilkeCssNumberField } from '../../silke-css-number-field';
4
4
  import { SilkeBox } from '../../silke-box';
5
5
  import { SilkeSlider } from '../../silke-slider';
6
6
  import { SilkeTextSmall } from '../../silke-text';
7
- import { SilkeTextField } from '../../silke-text-field';
7
+ import { SilkeTextField, SilkeTextFieldItem } from '../../silke-text-field';
8
8
 
9
9
  import { getTitle } from './utils/schema-util';
10
10
  import { SilkeIconTooltip } from '../../silke-tooltip';
11
11
 
12
- const NumberField = (props: SchemaFieldProps<NumberFieldType>) => {
12
+ const NumberField = (
13
+ props: SchemaFieldProps<Omit<NumberFieldType, 'format'>> & {
14
+ format?: string;
15
+ },
16
+ ) => {
13
17
  const [errorMessage, setErrorMessage] = useState<string>();
14
18
  const {
15
19
  value,
16
20
  onChange,
17
21
  schema,
18
22
  schema: {
19
- name = '',
20
- title = '',
21
- description = '',
22
23
  options: {
23
24
  min = Number.NEGATIVE_INFINITY,
24
25
  max = Number.POSITIVE_INFINITY,
@@ -37,17 +38,17 @@ const NumberField = (props: SchemaFieldProps<NumberFieldType>) => {
37
38
  }, [value, min, max]);
38
39
 
39
40
  const scale = props.schema?.options?.scale || 1;
40
- const format = props.schema?.options?.format;
41
+ const format = props.schema?.options?.format || '';
41
42
 
42
43
  if (display === 'slider') {
43
44
  const sliderValue = value ?? 0;
44
45
  return (
45
46
  <SilkeBox column flex>
46
47
  <SilkeBox vAlign="center" flex>
47
- <SilkeTextSmall weight="strong">{getTitle(schema)}</SilkeTextSmall>
48
+ <SilkeTextSmall>{getTitle(schema)}</SilkeTextSmall>
48
49
  {schema.description && <SilkeIconTooltip tooltip={schema.description} icon="tooltip" />}
49
50
  </SilkeBox>
50
- <SilkeBox vPad="s">
51
+ <SilkeBox vPad="s" gap="s">
51
52
  <SilkeSlider
52
53
  value={(sliderValue - min) / (max - min)}
53
54
  onChange={(percentage) => {
@@ -55,58 +56,61 @@ const NumberField = (props: SchemaFieldProps<NumberFieldType>) => {
55
56
  onChange(value);
56
57
  }}
57
58
  />
59
+ <SilkeBox width="l">
60
+ <SilkeTextField
61
+ value={(sliderValue * scale).toFixed(0).toString() + format}
62
+ onChange={(value: string) => onChange(parseFloat(value) / scale)}
63
+ size="xs"
64
+ />
65
+ </SilkeBox>
58
66
  </SilkeBox>
59
67
  </SilkeBox>
60
68
  );
61
69
  }
62
70
 
63
- if (format) {
71
+ if (format && scale !== 1) {
64
72
  return (
65
73
  <SilkeCssNumberField
66
74
  {...rest}
67
75
  value={(value || 0) * scale + format}
68
76
  error={errorMessage}
69
77
  onChange={(value) => onChange(parseFloat(value) / scale)}
70
- size="s"
78
+ size="xs"
71
79
  />
72
80
  );
73
81
  }
74
82
 
75
83
  const scaledValue = value ? value * scale : value;
76
84
  return (
77
- <SilkeBox column>
78
- <SilkeBox flex>
79
- <SilkeBox align="center" style={{ width: '80px' }}>
80
- <SilkeBox vAlign="center" flex>
81
- <SilkeTextSmall weight="strong">{getTitle(schema)}</SilkeTextSmall>
82
- {schema.description && <SilkeIconTooltip tooltip={schema.description} icon="tooltip" />}
83
- </SilkeBox>
84
- </SilkeBox>
85
- <SilkeBox flex pad="xs">
86
- <SilkeTextField
87
- type="number"
88
- value={scaledValue}
89
- error={errorMessage}
90
- placeholder={schema.options?.placeholder}
91
- onChange={(value: number) => {
92
- if (value) {
93
- onChange(value / scale);
94
- } else {
95
- onChange(value);
96
- }
97
- }}
98
- onBlur={() => {
99
- if (!value) {
100
- onChange(0);
101
- }
102
- }}
103
- inline
104
- inlineLabelWidth={80}
105
- size="xs"
106
- flex
107
- />
108
- </SilkeBox>
109
- </SilkeBox>
85
+ <SilkeBox flex>
86
+ <SilkeTextField
87
+ type="number"
88
+ size="xs"
89
+ label={getTitle(schema)}
90
+ tooltip={schema.description}
91
+ value={scaledValue}
92
+ error={errorMessage}
93
+ placeholder={schema.options?.placeholder}
94
+ onChange={(value: number) => {
95
+ if (value) {
96
+ onChange(value / scale);
97
+ } else {
98
+ onChange(value);
99
+ }
100
+ }}
101
+ onBlur={() => {
102
+ if (!value) {
103
+ onChange(0);
104
+ }
105
+ }}
106
+ flex
107
+ >
108
+ {format && (
109
+ <SilkeTextFieldItem hPad="s">
110
+ <SilkeTextSmall color="neutral-60">{format}</SilkeTextSmall>
111
+ </SilkeTextFieldItem>
112
+ )}
113
+ </SilkeTextField>
110
114
  </SilkeBox>
111
115
  );
112
116
  };
@@ -13,7 +13,7 @@ export default function ObjectField({
13
13
  onChange,
14
14
  }: SchemaFieldProps<ObjectFieldType>) {
15
15
  return (
16
- <SilkeBox column flex style={{ paddingBottom: '16px' }}>
16
+ <SilkeBox column flex style={{ paddingTop: '16px' }} gap="xs">
17
17
  <SilkeTextSmall weight="strong">{getTitle(schema)}</SilkeTextSmall>
18
18
  {schema.description && (
19
19
  <SilkeTextSmall color="neutral-80">{schema.description}</SilkeTextSmall>
@@ -37,11 +37,13 @@ const SelectField = (props: SchemaFieldProps<SelectFieldType>) => {
37
37
  if (multiselect && (!display || display === 'checkbox')) {
38
38
  const values = (value as string[]) || [];
39
39
  return (
40
- <SilkeBox column gap="xs">
40
+ <SilkeBox column flex>
41
+ <SilkeTextSmall>{getTitle(schema)}</SilkeTextSmall>
41
42
  {items.map((item, index) => (
42
43
  <SilkeCheckbox
43
44
  key={index}
44
45
  label={item.label}
46
+ size="s"
45
47
  value={values.includes(item.value) || false}
46
48
  onChange={(checked: boolean) =>
47
49
  checked
@@ -56,62 +58,48 @@ const SelectField = (props: SchemaFieldProps<SelectFieldType>) => {
56
58
 
57
59
  if (display === 'dropdown') {
58
60
  return (
59
- <SilkeBox gap="xs" style={{ alignItems: 'center' }}>
60
- <SilkeTextSmall weight="strong" style={{ width: '80px' }}>
61
- {getTitle(schema)}
62
- </SilkeTextSmall>
63
- <SilkeBox style={{ width: '130px' }}>
64
- <SilkeSelectField
65
- value={props.value}
66
- multiple={multiselect}
67
- name={name}
68
- items={items}
69
- inline
70
- label=""
71
- onChange={onChange}
72
- size="xs"
73
- renderItem={(item) => {
74
- return (
75
- <SilkeTextSmall style={{ paddingLeft: '4px' }} title={item.item.label} overflow>
76
- {item.item.label}
77
- </SilkeTextSmall>
78
- );
79
- }}
80
- />
81
- </SilkeBox>
82
- </SilkeBox>
61
+ <SilkeSelectField
62
+ label={getTitle(schema)}
63
+ value={props.value}
64
+ multiple={multiselect}
65
+ name={name}
66
+ items={items}
67
+ onChange={onChange}
68
+ size="xs"
69
+ renderItem={(item) => {
70
+ return (
71
+ <SilkeTextSmall style={{ paddingLeft: '4px' }} title={item.item.label} overflow>
72
+ {item.item.label}
73
+ </SilkeTextSmall>
74
+ );
75
+ }}
76
+ />
83
77
  );
84
78
  }
85
79
  if (display === 'autocomplete') {
86
80
  return (
87
- <SilkeBox gap="xs" style={{ alignItems: 'center' }}>
88
- <SilkeTextSmall weight="strong" style={{ width: '80px' }}>
89
- {getTitle(schema)}
90
- </SilkeTextSmall>
91
- <SilkeBox style={{ width: '140px' }}>
92
- <SilkeAutocompleteField
93
- value={props.value}
94
- multiple={multiselect}
95
- name={name}
96
- label=""
97
- items={items}
98
- onChange={onChange}
99
- size="xs"
100
- inline
101
- inlineLabelWidth={80}
102
- />
103
- </SilkeBox>
104
- </SilkeBox>
81
+ <SilkeAutocompleteField
82
+ value={props.value}
83
+ multiple={multiselect}
84
+ name={name}
85
+ label={getTitle(schema)}
86
+ items={items}
87
+ onChange={onChange}
88
+ size="xs"
89
+ />
105
90
  );
106
91
  }
92
+
107
93
  return (
108
- <SilkeBox gap="xs">
109
- <SilkeTextSmall weight="strong" style={{ width: '80px' }}>
110
- {getTitle(schema)}
111
- </SilkeTextSmall>
112
- <SilkeBox column style={{ width: '100px' }}>
94
+ <SilkeBox gap="xs" flex column>
95
+ <SilkeBox flex>
96
+ <SilkeTextSmall>{getTitle(schema)}</SilkeTextSmall>
97
+ </SilkeBox>
98
+ <SilkeBox column>
113
99
  {items?.map((item, i) => (
114
- <SilkeRadioButton key={i} {...item} name={name} size="small" />
100
+ <SilkeBox key={i} column>
101
+ <SilkeRadioButton {...item} name={name} size="small" />
102
+ </SilkeBox>
115
103
  ))}
116
104
  </SilkeBox>
117
105
  </SilkeBox>
@@ -2,39 +2,24 @@ import { SchemaFieldProps, StringField as StringFieldType } from '@vev/utils';
2
2
  import React from 'react';
3
3
  import { SilkeTextField } from '../../silke-text-field';
4
4
  import { getTitle } from './utils/schema-util';
5
- import { SilkeBox } from '../../silke-box';
6
- import { SilkeTextSmall } from '../../silke-text';
7
- import { SilkeIconTooltip } from '../../silke-tooltip';
8
5
 
9
6
  const StringField = ({ schema, value, onChange }: SchemaFieldProps<StringFieldType>) => {
10
7
  const { options } = schema;
11
8
 
12
9
  return (
13
- <SilkeBox column>
14
- <SilkeBox flex>
15
- <SilkeBox align="center" style={{ width: '80px' }}>
16
- <SilkeBox vAlign="center" flex>
17
- <SilkeTextSmall weight="strong">{getTitle(schema)}</SilkeTextSmall>
18
- {schema.description && <SilkeIconTooltip tooltip={schema.description} icon="tooltip" />}
19
- </SilkeBox>
20
- </SilkeBox>
21
- <SilkeBox flex pad="xs">
22
- <SilkeTextField
23
- inline
24
- value={value}
25
- multiline={!!options?.multiline}
26
- inlineLabelWidth={80}
27
- type={options?.type || 'text'}
28
- minLength={options?.minLength}
29
- maxLength={options?.maxLength}
30
- onChange={onChange}
31
- size="xs"
32
- placeholder={options?.placeholder}
33
- flex
34
- />
35
- </SilkeBox>
36
- </SilkeBox>
37
- </SilkeBox>
10
+ <SilkeTextField
11
+ value={value}
12
+ multiline={!!options?.multiline}
13
+ label={getTitle(schema)}
14
+ type={options?.type || 'text'}
15
+ minLength={options?.minLength}
16
+ maxLength={options?.maxLength}
17
+ onChange={onChange}
18
+ size="xs"
19
+ placeholder={options?.placeholder}
20
+ flex
21
+ tooltip={schema?.description}
22
+ />
38
23
  );
39
24
  };
40
25
 
@@ -8,18 +8,16 @@ import { SilkeIconTooltip } from '../../silke-tooltip';
8
8
 
9
9
  const Toggle = ({ schema, value, onChange }: SchemaFieldProps<BooleanField>) => {
10
10
  return (
11
- <SilkeBox column>
12
- <SilkeBox flex>
13
- <SilkeBox align="center" style={{ width: '80px' }}>
14
- <SilkeBox vAlign="center" flex>
15
- <SilkeTextSmall weight="strong">{getTitle(schema)}</SilkeTextSmall>
16
- {schema.description && <SilkeIconTooltip tooltip={schema.description} icon="tooltip" />}
17
- </SilkeBox>
18
- </SilkeBox>
19
- <SilkeBox flex pad="xs">
20
- <SilkeToggle value={value || false} onChange={onChange} small />
11
+ <SilkeBox flex>
12
+ <SilkeBox align="center" fill>
13
+ <SilkeBox vAlign="center" flex>
14
+ <SilkeTextSmall>{getTitle(schema)}</SilkeTextSmall>
15
+ {schema.description && <SilkeIconTooltip tooltip={schema.description} icon="tooltip" />}
21
16
  </SilkeBox>
22
17
  </SilkeBox>
18
+ <SilkeBox flex pad="xs">
19
+ <SilkeToggle value={value || false} onChange={onChange} small />
20
+ </SilkeBox>
23
21
  </SilkeBox>
24
22
  );
25
23
  };
@@ -26,6 +26,15 @@ const schema = [
26
26
  title: "Number field",
27
27
  description: "Field for entering numbers",
28
28
  },
29
+ {
30
+ type: "number",
31
+ name: "numberMs",
32
+ title: "Number Seconds",
33
+ description: "Field with format",
34
+ options: {
35
+ format: "ms",
36
+ },
37
+ },
29
38
  {
30
39
  type: "number",
31
40
  name: "sliderKey",
@@ -35,6 +44,7 @@ const schema = [
35
44
  min: -10,
36
45
  max: 10,
37
46
  display: "slider",
47
+ format: "s",
38
48
  },
39
49
  },
40
50
  {
@@ -139,42 +149,20 @@ const schema = [
139
149
  {
140
150
  type: "select",
141
151
  title: "Select field",
142
- name: "multiSelectField",
143
- description: "Select field for component",
144
- options: {
145
- items: [
146
- {
147
- name: "Option 1",
148
- value: "one",
149
- },
150
- {
151
- name: "Option 2",
152
- value: "two",
153
- },
154
- {
155
- name: "Option 3",
156
- value: "three",
157
- },
158
- ],
159
- },
160
- },
161
- {
162
- type: "select",
163
- title: "Multi select field",
164
152
  name: "selectField",
165
153
  description: "Select field for component",
166
154
  options: {
167
155
  items: [
168
156
  {
169
- name: "Option 1",
157
+ label: "Option 1",
170
158
  value: "one",
171
159
  },
172
160
  {
173
- name: "Option 2",
161
+ label: "Option 2",
174
162
  value: "two",
175
163
  },
176
164
  {
177
- name: "Option 3",
165
+ label: "Option 3",
178
166
  value: "three",
179
167
  },
180
168
  ],
@@ -183,7 +171,7 @@ const schema = [
183
171
  {
184
172
  type: "select",
185
173
  title: "Multi select field",
186
- name: "multipleSelectField",
174
+ name: "multiSelectField",
187
175
  description: "Select field for component",
188
176
  options: {
189
177
  multiselect: true,
@@ -1,6 +1,7 @@
1
1
  import { Schema, SchemaContextModel } from '@vev/utils';
2
2
  import React from 'react';
3
3
  import { SilkeForm, SilkeFormProps } from '../silke-form';
4
+ import TextFieldContext from '../silke-text-field/text-field-context';
4
5
  import { SilkeSchemaContext } from './silke-schema-context';
5
6
  import { SilkeSchemaFields } from './silke-schema-fields';
6
7
 
@@ -21,7 +22,9 @@ export function SilkeFormSchema<T extends { [key: string]: any }>({
21
22
  return (
22
23
  <SilkeSchemaContext context={context}>
23
24
  <SilkeForm {...rest} value={value}>
24
- <SilkeSchemaFields schema={schema} value={value} {...rest} />
25
+ <TextFieldContext size="xs" kind="default" inline={false}>
26
+ <SilkeSchemaFields schema={schema} value={value} {...rest} />
27
+ </TextFieldContext>
25
28
  </SilkeForm>
26
29
  </SilkeSchemaContext>
27
30
  );
@@ -25,7 +25,7 @@ type SilkeSchemaFieldProps = {
25
25
  field: VevProps;
26
26
  value?: any;
27
27
  noPad?: boolean;
28
- isLast?: boolean;
28
+ isFirst?: boolean;
29
29
  };
30
30
 
31
31
  const SCHEMA_FIELD_COMPONENTS: Partial<SchemaFieldComponents> = {
@@ -47,7 +47,7 @@ export function SilkeSchemaField({
47
47
  field,
48
48
  value: fieldValue,
49
49
  noPad,
50
- isLast,
50
+ isFirst,
51
51
  }: SilkeSchemaFieldProps) {
52
52
  const extendedFields = useExtendedFields();
53
53
 
@@ -80,6 +80,11 @@ export function SilkeSchemaField({
80
80
 
81
81
  return (
82
82
  <>
83
+ {['object', 'array', 'image'].includes(field?.type) && !isFirst && (
84
+ <SilkeBox column flex>
85
+ <SilkeDivider dark />
86
+ </SilkeBox>
87
+ )}
83
88
  <SilkeBox hPad={!noPad ? 'm' : undefined} flex>
84
89
  <Field
85
90
  label={field.title || field.name}
@@ -91,18 +96,13 @@ export function SilkeSchemaField({
91
96
  if (isEvalCallback(field.onChange)) {
92
97
  value = await safeEvalFunction(field.onChange.value, value, context);
93
98
  } else if (isFunction(field.onChange)) {
94
- // @ts-expect-error - ignore
99
+ // @ts-ignore TODO: fix this
95
100
  value = (await field.onChange(value as any, context)) as any;
96
101
  }
97
102
  onChange(value);
98
103
  }}
99
104
  />
100
105
  </SilkeBox>
101
- {['object', 'array', 'image'].includes(field?.type) && !isLast && (
102
- <SilkeBox column flex>
103
- <SilkeDivider dark />
104
- </SilkeBox>
105
- )}
106
106
  </>
107
107
  );
108
108
  }
@@ -45,11 +45,11 @@ export function SilkeSchemaFields<T extends { [key: string]: any }>(
45
45
  }, [context, schema]);
46
46
 
47
47
  return (
48
- <SilkeBox flex column={!row} gap="m" vPad="m" style={{ width: '100%' }}>
48
+ <SilkeBox flex column={!row} gap="s" vPad="s" style={{ width: '100%' }}>
49
49
  {filteredSchema.map((field, index) => {
50
50
  return (
51
51
  <span style={{ overflow: 'hidden' }} key={(field?.name || 'field') + index}>
52
- <SilkeSchemaField field={field} {...rest} isLast={index === schema.length - 1} />
52
+ <SilkeSchemaField field={field} {...rest} isFirst={index === 0} />
53
53
  </span>
54
54
  );
55
55
  })}
@@ -66,7 +66,7 @@ export function SilkeIconPicker(props: SilkeIconPickerProps) {
66
66
  targetOrigin="top-left"
67
67
  onToggleOpen={setOpen}
68
68
  >
69
- <SilkeBox column bg="neutral-20" style={{ width: 456, height: 320, borderRadius: 8 }}>
69
+ <SilkeBox column bg="blur" style={{ width: 456, height: 320, borderRadius: 8 }}>
70
70
  {!singleType && (
71
71
  <SilkeTabs>
72
72
  <SilkeTab
@@ -30,8 +30,6 @@ export function SilkeListCard({
30
30
  }: SilkeListItemsProps) {
31
31
  const tagProps = { ...tag, size: 'tiny' } as SilkeTagProps;
32
32
 
33
- console.log('state', state);
34
-
35
33
  return (
36
34
  <SilkeBox
37
35
  pad="m"
@@ -104,7 +104,7 @@ export function SilkeOverflowMenu({
104
104
  onRequestClose={handleToggleOpen}
105
105
  >
106
106
  <ButtonContext size="base">
107
- {items && (
107
+ {(isFunction(items) || items?.length > 0) && (
108
108
  <SilkeBox
109
109
  tabIndex={-1}
110
110
  column
@@ -1,63 +1,30 @@
1
- import classnames from 'classnames/bind';
2
- import React, { useCallback } from 'react';
3
- import { Link } from 'react-router-dom';
1
+ import React from 'react';
2
+ import { BoxButtonProps, SilkeBox } from '../silke-box';
4
3
  import styles from './silke-tabs.scss';
5
4
 
6
- const cl = classnames.bind(styles);
7
-
8
5
  export type SilkeTabProps = {
9
- label: string;
6
+ label: React.ReactNode;
10
7
  active?: boolean;
11
8
  disabled?: boolean;
12
- error?: boolean;
13
9
  href?: string;
14
- className?: string;
15
- style?: React.CSSProperties;
16
- onClick?: () => void;
17
- };
10
+ } & Omit<BoxButtonProps, 'size' | 'height' | 'width' | 'rounded' | 'children'>;
18
11
 
19
- export function SilkeTab({
20
- label,
21
- active,
22
- href,
23
- className,
24
- error,
25
- style,
26
- onClick,
27
- ...rest
28
- }: SilkeTabProps) {
29
- const classNames = cl('tab', className, { 'tab--active': active, 'tab-error': error });
30
- const onClickProxy = useCallback(
31
- (e: React.MouseEvent<HTMLAnchorElement>) => {
32
- e.preventDefault();
33
- if (onClick) {
34
- onClick();
35
- }
36
- },
37
- [onClick],
38
- );
39
- return href ? (
40
- <Link
41
- to={href}
42
- style={style}
43
- rel="button"
44
- className={classNames}
45
- onClick={onClick ? onClickProxy : undefined}
46
- {...rest}
47
- >
48
- {label}
49
- </Link>
50
- ) : (
51
- <a
52
- aria-selected={active}
12
+ export function SilkeTab({ label, active, href, className, ...rest }: SilkeTabProps) {
13
+ let cl = styles.tab;
14
+ if (active) cl += ' ' + styles.active;
15
+ if (className) cl += ' ' + className;
16
+
17
+ return (
18
+ <SilkeBox
19
+ tag="button"
53
20
  role="tab"
54
- style={style}
55
- href="#"
56
- className={classNames}
57
- onClick={onClickProxy}
21
+ hPad="s"
22
+ hAlign="center"
23
+ vAlign="center"
24
+ className={cl}
58
25
  {...rest}
59
26
  >
60
27
  {label}
61
- </a>
28
+ </SilkeBox>
62
29
  );
63
30
  }
@@ -2,7 +2,7 @@
2
2
 
3
3
  ```js
4
4
  const [active, setActive] = React.useState(1);
5
- <>
5
+ <SilkeBox column gap="m">
6
6
  <SilkeTabs>
7
7
  {[1, 2, 3, 4].map((tab) => (
8
8
  <SilkeTab
@@ -14,18 +14,7 @@ const [active, setActive] = React.useState(1);
14
14
  />
15
15
  ))}
16
16
  </SilkeTabs>
17
- <SilkeBox pad>
18
- <h1>Active tab {active}</h1>
19
- </SilkeBox>
20
- </>;
21
- ```
22
-
23
- ## Container Tabs
24
-
25
- ```js
26
- const [active, setActive] = React.useState(1);
27
- <SilkeBox bg="ui-1" column>
28
- <SilkeTabs container>
17
+ <SilkeTabs size="s">
29
18
  {[1, 2, 3, 4].map((tab) => (
30
19
  <SilkeTab
31
20
  key={tab}
@@ -36,8 +25,7 @@ const [active, setActive] = React.useState(1);
36
25
  />
37
26
  ))}
38
27
  </SilkeTabs>
39
- <SilkeBox pad>
40
- <h1>Active tab {active}</h1>
41
- </SilkeBox>
28
+
29
+ <h1>Active tab {active}</h1>
42
30
  </SilkeBox>;
43
31
  ```