@vev/silke 1.0.27 → 1.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/index.js +49 -48
- package/dist/silke/src/components/index.d.ts +1 -1
- package/dist/silke/src/components/silke-autocomplete-field/autocomplete-item.d.ts +2 -1
- package/dist/silke/src/components/silke-autocomplete-field/autocomplete-tags.d.ts +2 -1
- package/dist/silke/src/components/silke-autocomplete-field/silke-autocomplete-field.d.ts +3 -1
- package/dist/silke/src/components/silke-autocomplete-field/silke-autocomplete-popup.d.ts +1 -0
- package/dist/silke/src/components/silke-box/silke-box.d.ts +3 -2
- package/dist/silke/src/components/silke-breadcrumbs/silke-breadcrumb.d.ts +1 -1
- package/dist/silke/src/components/silke-button/silke-big-button.d.ts +4 -1
- package/dist/silke/src/components/silke-button/silke-button.d.ts +1 -1
- package/dist/silke/src/components/silke-button/silke-dropdown-button.d.ts +2 -1
- package/dist/silke/src/components/silke-color-picker/color.d.ts +5 -0
- package/dist/silke/src/components/silke-color-picker/silke-color-info.d.ts +3 -1
- package/dist/silke/src/components/silke-color-swatches/silke-swatches.d.ts +2 -1
- package/dist/silke/src/components/silke-conditions-input/index.d.ts +2 -0
- package/dist/silke/src/components/silke-conditions-input/silke-conditions-input-options.d.ts +8 -0
- package/dist/silke/src/components/silke-conditions-input/silke-conditions-input.d.ts +19 -0
- package/dist/silke/src/components/silke-conditions-input/silke-conditions-tag.d.ts +11 -0
- package/dist/silke/src/components/silke-conditions-input/types.d.ts +13 -0
- package/dist/silke/src/components/silke-conditions-input/utils.d.ts +11 -0
- package/dist/silke/src/components/silke-context-menu/silke-context-menu-item.d.ts +1 -1
- package/dist/silke/src/components/silke-css-number-field/silke-css-context.d.ts +5 -1
- package/dist/silke/src/components/silke-css-number-field/silke-css-number-field.d.ts +3 -1
- package/dist/silke/src/components/silke-form/form-types.d.ts +3 -3
- package/dist/silke/src/components/silke-form-schema/fields/array-field-inline.d.ts +2 -1
- package/dist/silke/src/components/silke-form-schema/fields/array-field-modal.d.ts +3 -2
- package/dist/silke/src/components/silke-form-schema/fields/array-field.d.ts +1 -1
- package/dist/silke/src/components/silke-form-schema/fields/event-field.d.ts +1 -1
- package/dist/silke/src/components/silke-form-schema/fields/icon-field.d.ts +1 -1
- package/dist/silke/src/components/silke-form-schema/fields/image-field.d.ts +1 -1
- package/dist/silke/src/components/silke-form-schema/fields/layout-field.d.ts +1 -1
- package/dist/silke/src/components/silke-form-schema/fields/number-field.d.ts +1 -0
- package/dist/silke/src/components/silke-form-schema/fields/object-field.d.ts +1 -1
- package/dist/silke/src/components/silke-form-schema/fields/string-field.d.ts +1 -1
- package/dist/silke/src/components/silke-form-schema/fields/toggle-field.d.ts +1 -1
- package/dist/silke/src/components/silke-form-schema/fields/utils/generate-image.d.ts +1 -1
- package/dist/silke/src/components/silke-form-schema/fields/utils/generate-title.d.ts +1 -1
- package/dist/silke/src/components/silke-form-schema/fields/video-field.d.ts +1 -1
- package/dist/silke/src/components/silke-form-schema/silke-form-schema.d.ts +9 -1
- package/dist/silke/src/components/silke-form-schema/silke-schema-field.d.ts +3 -1
- package/dist/silke/src/components/silke-form-schema/silke-schema-fields.d.ts +2 -0
- package/dist/silke/src/components/silke-modal/silke-modal.d.ts +2 -1
- package/dist/silke/src/components/silke-notification/silke-notification.d.ts +1 -1
- package/dist/silke/src/components/silke-radio-button/silke-radio-button-group.d.ts +1 -1
- package/dist/silke/src/components/silke-slider/silke-slider.d.ts +1 -0
- package/dist/silke/src/components/silke-sortable-list/silke-nested-sortable-utils.d.ts +1 -0
- package/dist/silke/src/components/silke-sortable-list/silke-sortable-item-wrapper.d.ts +2 -1
- package/dist/silke/src/components/silke-sortable-list/silke-sortable-list.d.ts +2 -1
- package/dist/silke/src/components/silke-table/silke-table.d.ts +2 -1
- package/dist/silke/src/components/silke-table/table-row.d.ts +3 -1
- package/dist/silke/src/components/silke-table/table-types.d.ts +1 -1
- package/dist/silke/src/components/silke-tag/silke-tag.d.ts +1 -1
- package/dist/silke/src/components/silke-text-field/silke-text-field-outline.d.ts +4 -2
- package/dist/silke/src/components/silke-text-field/text-field-context.d.ts +4 -1
- package/dist/silke/src/components/silke-tile/index.d.ts +0 -1
- package/dist/silke/src/components/silke-tooltip/silke-definition-tooltip.d.ts +2 -1
- package/dist/silke/src/components/silke-tooltip/silke-icon-tooltip.d.ts +2 -1
- package/dist/silke/src/components/silke-tooltip/silke-tooltip.d.ts +6 -1
- package/dist/silke/src/components/silke-variables-wrapper/silke-variables-wrapper-form.d.ts +4 -3
- package/dist/silke/src/components/silke-variables-wrapper/silke-variables-wrapper.d.ts +5 -1
- package/dist/silke/src/icons.d.ts +76 -2
- package/dist/silke/src/silke-theme-provider.d.ts +1 -1
- package/dist/styles.css +1411 -1149
- package/dist/utils/src/types/context.d.ts +1 -0
- package/dist/utils/src/types/index.d.ts +1 -0
- package/dist/utils/src/types/manifest.d.ts +2 -0
- package/dist/utils/src/types/qwiker.d.ts +46 -0
- package/dist/utils/src/types/vev-plugin.d.ts +12 -0
- package/dist/utils/src/types/vev-props.d.ts +23 -2
- package/dist/utils/src/types/widget-manifest.d.ts +1 -0
- package/dist/utils/src/utils/index.d.ts +1 -0
- package/dist/utils/src/utils/variable.d.ts +3 -0
- package/package.json +15 -8
- package/project.json +21 -0
- package/public/index.html +2 -2
- package/src/_variables.scss +19 -5
- package/src/components/index.ts +1 -1
- package/src/components/silke-autocomplete-field/autocomplete-item.tsx +18 -12
- package/src/components/silke-autocomplete-field/autocomplete-tags.tsx +3 -0
- package/src/components/silke-autocomplete-field/silke-autocomplete-field.mdx +15 -15
- package/src/components/silke-autocomplete-field/silke-autocomplete-field.tsx +33 -25
- package/src/components/silke-autocomplete-field/silke-autocomplete-popup.tsx +40 -20
- package/src/components/silke-box/silke-box.mdx +13 -9
- package/src/components/silke-box/silke-box.scss +12 -3
- package/src/components/silke-box/silke-box.tsx +18 -2
- package/src/components/silke-breadcrumbs/silke-breadcrumb.tsx +2 -2
- package/src/components/silke-button/silke-big-button.scss +0 -5
- package/src/components/silke-button/silke-big-button.tsx +15 -4
- package/src/components/silke-button/silke-button.mdx +34 -17
- package/src/components/silke-button/silke-button.scss +28 -31
- package/src/components/silke-button/silke-button.tsx +2 -2
- package/src/components/silke-button/silke-dropdown-button.tsx +7 -3
- package/src/components/silke-button/silke-file-select-button.tsx +1 -0
- package/src/components/silke-card/silke-card-grid.tsx +1 -1
- package/src/components/silke-card/silke-card.mdx +16 -26
- package/src/components/silke-card/silke-card.scss +10 -3
- package/src/components/silke-card/silke-card.tsx +7 -4
- package/src/components/silke-checkbox/silke-checkbox.mdx +2 -11
- package/src/components/silke-code-snippet/silke-code-snippet.mdx +27 -22
- package/src/components/silke-color-palettes/silke-color-palette.mdx +2 -2
- package/src/components/silke-color-picker/color.ts +12 -0
- package/src/components/silke-color-picker/silke-color-info.tsx +27 -8
- package/src/components/silke-color-picker/silke-color-picker-button.tsx +1 -1
- package/src/components/silke-color-picker/silke-color-picker.mdx +9 -13
- package/src/components/silke-color-picker/silke-color-picker.tsx +23 -6
- package/src/components/silke-color-swatches/silke-color-swatch-button.tsx +1 -1
- package/src/components/silke-color-swatches/silke-swatches.tsx +10 -7
- package/src/components/silke-conditions-input/index.ts +2 -0
- package/src/components/silke-conditions-input/silke-conditions-input-options.tsx +87 -0
- package/src/components/silke-conditions-input/silke-conditions-input.mdx +88 -0
- package/src/components/silke-conditions-input/silke-conditions-input.scss +29 -0
- package/src/components/silke-conditions-input/silke-conditions-input.tsx +290 -0
- package/src/components/silke-conditions-input/silke-conditions-tag.tsx +80 -0
- package/src/components/silke-conditions-input/types.ts +23 -0
- package/src/components/silke-conditions-input/utils.ts +181 -0
- package/src/components/silke-content-column/silke-content-column.scss +1 -1
- package/src/components/silke-context-menu/silke-context-menu-item.tsx +3 -0
- package/src/components/silke-context-menu/silke-context-menu.mdx +4 -4
- package/src/components/silke-context-menu/silke-context-menu.scss +9 -7
- package/src/components/silke-context-menu/silke-context-menu.tsx +1 -1
- package/src/components/silke-css-number-field/silke-css-context.tsx +6 -1
- package/src/components/silke-css-number-field/silke-css-number-field.mdx +221 -91
- package/src/components/silke-css-number-field/silke-css-number-field.scss +10 -3
- package/src/components/silke-css-number-field/silke-css-number-field.tsx +52 -8
- package/src/components/silke-css-number-field/utils.ts +2 -1
- package/src/components/silke-divider/silke-divider.mdx +1 -2
- package/src/components/silke-drawer/silke-drawer.mdx +4 -11
- package/src/components/silke-form/form-types.ts +5 -3
- package/src/components/silke-form/silke-form.mdx +4 -16
- package/src/components/silke-form-schema/fields/array-field-inline.tsx +12 -2
- package/src/components/silke-form-schema/fields/array-field-modal.tsx +10 -6
- package/src/components/silke-form-schema/fields/array-field.tsx +25 -6
- package/src/components/silke-form-schema/fields/event-field.tsx +18 -7
- package/src/components/silke-form-schema/fields/icon-field.tsx +21 -3
- package/src/components/silke-form-schema/fields/image-field.tsx +21 -3
- package/src/components/silke-form-schema/fields/layout-field.tsx +8 -1
- package/src/components/silke-form-schema/fields/link-field.tsx +5 -1
- package/src/components/silke-form-schema/fields/number-field.tsx +169 -22
- package/src/components/silke-form-schema/fields/object-field.tsx +10 -1
- package/src/components/silke-form-schema/fields/select-field.tsx +15 -1
- package/src/components/silke-form-schema/fields/string-field.tsx +115 -20
- package/src/components/silke-form-schema/fields/toggle-field.tsx +14 -2
- package/src/components/silke-form-schema/fields/upload-field.tsx +3 -1
- package/src/components/silke-form-schema/fields/utils/generate-image.ts +4 -1
- package/src/components/silke-form-schema/fields/utils/generate-title.ts +2 -1
- package/src/components/silke-form-schema/fields/video-field.tsx +22 -4
- package/src/components/silke-form-schema/silke-form-schema.mdx +227 -160
- package/src/components/silke-form-schema/silke-form-schema.tsx +10 -1
- package/src/components/silke-form-schema/silke-schema-field.tsx +23 -6
- package/src/components/silke-form-schema/silke-schema-fields.tsx +3 -1
- package/src/components/silke-gradient-picker/silke-gradient-picker.mdx +1 -1
- package/src/components/silke-icon/silke-icon.mdx +3 -6
- package/src/components/silke-icon/silke-icon.scss +2 -0
- package/src/components/silke-icon-picker/silke-icon-picker.tsx +5 -5
- package/src/components/silke-iframe-portal/silke-iframe-portal.mdx +6 -15
- package/src/components/silke-image/silke-image.mdx +28 -0
- package/src/components/silke-image/silke-image.scss +1 -0
- package/src/components/silke-link/silke-link.mdx +62 -39
- package/src/components/silke-link/silke-link.scss +3 -2
- package/src/components/silke-list/silke-list.mdx +12 -10
- package/src/components/silke-list-card/silke-list-card.mdx +7 -11
- package/src/components/silke-loader/silke-loader.mdx +1 -1
- package/src/components/silke-loader/silke-loader.tsx +1 -4
- package/src/components/silke-modal/silke-modal.mdx +1 -5
- package/src/components/silke-modal/silke-modal.scss +0 -2
- package/src/components/silke-modal/silke-modal.tsx +3 -1
- package/src/components/silke-navigation-link/silke-navigation-link.mdx +21 -22
- package/src/components/silke-navigation-link/silke-navigation-link.scss +2 -2
- package/src/components/silke-notification/silke-notification.mdx +35 -67
- package/src/components/silke-notification/silke-notification.tsx +2 -1
- package/src/components/silke-object-field/silke-object-field.mdx +3 -10
- package/src/components/silke-object-field/silke-object-field.tsx +2 -2
- package/src/components/silke-overflow-menu/silke-overflow-menu.mdx +2 -2
- package/src/components/silke-overflow-menu/silke-overflow-menu.tsx +2 -1
- package/src/components/silke-popover/silke-popover.mdx +14 -22
- package/src/components/silke-popover/silke-popover.tsx +21 -15
- package/src/components/silke-progress-indicator/silke-progress-indicator.mdx +33 -36
- package/src/components/silke-radio-button/silke-radio-button-group.tsx +1 -1
- package/src/components/silke-radio-button/silke-radio-button.mdx +1 -7
- package/src/components/silke-radio-button/silke-radio-button.scss +1 -0
- package/src/components/silke-search-field/silke-search-field.mdx +4 -12
- package/src/components/silke-select-field/silke-select-field.mdx +10 -10
- package/src/components/silke-slider/silke-slider.mdx +59 -22
- package/src/components/silke-slider/silke-slider.tsx +23 -10
- package/src/components/silke-sortable-list/silke-nested-sortable-item.tsx +3 -3
- package/src/components/silke-sortable-list/silke-nested-sortable-utils.ts +1 -0
- package/src/components/silke-sortable-list/silke-sortable-item-wrapper.tsx +4 -1
- package/src/components/silke-sortable-list/silke-sortable-list.mdx +54 -58
- package/src/components/silke-sortable-list/silke-sortable-list.scss +2 -2
- package/src/components/silke-sortable-list/silke-sortable-list.tsx +3 -0
- package/src/components/silke-table/silke-table.mdx +75 -75
- package/src/components/silke-table/silke-table.scss +27 -13
- package/src/components/silke-table/silke-table.tsx +13 -3
- package/src/components/silke-table/table-row.tsx +6 -1
- package/src/components/silke-table/table-types.ts +1 -1
- package/src/components/silke-tabs/silke-tabs.mdx +2 -2
- package/src/components/silke-tag/silke-tag.mdx +38 -79
- package/src/components/silke-tag/silke-tag.scss +12 -5
- package/src/components/silke-tag/silke-tag.tsx +1 -0
- package/src/components/silke-text/silke-text.mdx +50 -48
- package/src/components/silke-text/silke-text.scss +4 -2
- package/src/components/silke-text/silke-title.scss +29 -15
- package/src/components/silke-text-field/silke-text-field-outline.tsx +15 -3
- package/src/components/silke-text-field/silke-text-field.mdx +67 -71
- package/src/components/silke-text-field/silke-text-field.scss +4 -3
- package/src/components/silke-text-field/silke-text-field.tsx +16 -16
- package/src/components/silke-text-field/text-field-context.tsx +7 -2
- package/src/components/silke-tile/index.ts +0 -1
- package/src/components/silke-tile/silke-tile.mdx +6 -63
- package/src/components/silke-tile/silke-tile.tsx +4 -4
- package/src/components/silke-toggle/silke-toggle.mdx +5 -29
- package/src/components/silke-toggle/silke-toggle.scss +3 -2
- package/src/components/silke-toolbar/silke-toolbar.mdx +6 -6
- package/src/components/silke-tooltip/silke-definition-tooltip.tsx +3 -0
- package/src/components/silke-tooltip/silke-icon-tooltip.tsx +5 -2
- package/src/components/silke-tooltip/silke-tooltip.mdx +16 -34
- package/src/components/silke-tooltip/silke-tooltip.scss +3 -2
- package/src/components/silke-tooltip/silke-tooltip.tsx +15 -4
- package/src/components/silke-upload-field/silke-upload-field.tsx +1 -0
- package/src/components/silke-variables-wrapper/silke-variables-wrapper-form.tsx +30 -50
- package/src/components/silke-variables-wrapper/silke-variables-wrapper.mdx +56 -15
- package/src/components/silke-variables-wrapper/silke-variables-wrapper.scss +0 -2
- package/src/components/silke-variables-wrapper/silke-variables-wrapper.tsx +107 -44
- package/src/docs/data/flux/store.ts +0 -1
- package/src/hooks/drag-and-drop/use-drop.tsx +1 -1
- package/src/hooks/hooks.mdx +3 -3
- package/src/icons.tsx +106 -4
- package/src/index.mdx +30 -31
- package/src/playground.mdx +58 -47
- package/src/silke-theme-provider.tsx +1 -0
- package/src/styles/core.scss +10 -14
- package/dist/silke/src/components/silke-steps/index.d.ts +0 -1
- package/dist/silke/src/components/silke-steps/silke-steps.d.ts +0 -12
- package/dist/silke/src/components/silke-tile/silke-tile-select.d.ts +0 -26
- package/src/components/silke-steps/index.ts +0 -1
- package/src/components/silke-steps/silke-steps.mdx +0 -60
- package/src/components/silke-steps/silke-steps.scss +0 -14
- package/src/components/silke-steps/silke-steps.tsx +0 -53
- package/src/components/silke-tile/silke-tile-select.tsx +0 -100
|
@@ -3,24 +3,24 @@
|
|
|
3
3
|
## Wrapping SilkeCssNumberField
|
|
4
4
|
|
|
5
5
|
```js
|
|
6
|
-
const [value, setValue] = React.useState(
|
|
6
|
+
const [value, setValue] = React.useState('0px');
|
|
7
7
|
|
|
8
|
-
const formats = [
|
|
8
|
+
const formats = ['px', '%'];
|
|
9
9
|
|
|
10
10
|
<SilkeCSSContext
|
|
11
11
|
viewport={[1920, 1080]}
|
|
12
12
|
fontSize={18}
|
|
13
13
|
container={[200, 150]}
|
|
14
14
|
variablesv2={[
|
|
15
|
-
{ key:
|
|
16
|
-
{ key:
|
|
17
|
-
{ key:
|
|
15
|
+
{ key: 'A', name: 'size-xs', value: '10', unit: 'px' },
|
|
16
|
+
{ key: 'B', name: 'size-s', value: '50', unit: 'px' },
|
|
17
|
+
{ key: 'C', name: 'size-m', value: '100', unit: 'px' },
|
|
18
18
|
]}
|
|
19
19
|
>
|
|
20
20
|
<SilkeBox>
|
|
21
21
|
<SilkeBox column gap="xl">
|
|
22
22
|
<SilkeBox gap="l">
|
|
23
|
-
{[
|
|
23
|
+
{['default', 'zombie', 'ghost'].map((kind) => (
|
|
24
24
|
<SilkeVariablesWrapper
|
|
25
25
|
key={kind}
|
|
26
26
|
component={SilkeCssNumberField}
|
|
@@ -35,7 +35,7 @@ const formats = ["px", "%"];
|
|
|
35
35
|
))}
|
|
36
36
|
</SilkeBox>
|
|
37
37
|
<SilkeBox gap="l">
|
|
38
|
-
{[
|
|
38
|
+
{['default', 'zombie', 'ghost'].map((kind) => (
|
|
39
39
|
<TextFieldContext inline="label-inside" size="xs" key={kind}>
|
|
40
40
|
<SilkeVariablesWrapper
|
|
41
41
|
component={SilkeCssNumberField}
|
|
@@ -51,7 +51,7 @@ const formats = ["px", "%"];
|
|
|
51
51
|
))}
|
|
52
52
|
</SilkeBox>
|
|
53
53
|
<SilkeBox gap="l">
|
|
54
|
-
{[
|
|
54
|
+
{['default', 'zombie', 'ghost'].map((kind) => (
|
|
55
55
|
<TextFieldContext size="xs" key={kind}>
|
|
56
56
|
<SilkeVariablesWrapper
|
|
57
57
|
component={SilkeCssNumberField}
|
|
@@ -75,24 +75,24 @@ const formats = ["px", "%"];
|
|
|
75
75
|
## Wrapping SilkeInput
|
|
76
76
|
|
|
77
77
|
```js
|
|
78
|
-
const [value, setValue] = React.useState(
|
|
78
|
+
const [value, setValue] = React.useState('0px');
|
|
79
79
|
|
|
80
|
-
const formats = [
|
|
80
|
+
const formats = ['px', '%'];
|
|
81
81
|
|
|
82
82
|
<SilkeCSSContext
|
|
83
83
|
viewport={[1920, 1080]}
|
|
84
84
|
fontSize={18}
|
|
85
85
|
container={[200, 150]}
|
|
86
86
|
variablesv2={[
|
|
87
|
-
{ key:
|
|
88
|
-
{ key:
|
|
89
|
-
{ key:
|
|
87
|
+
{ key: 'D', name: 'size-xs', value: '10', unit: 'px' },
|
|
88
|
+
{ key: 'E', name: 'size-s', value: '50', unit: 'px' },
|
|
89
|
+
{ key: 'F', name: 'size-m', value: '100', unit: 'px' },
|
|
90
90
|
]}
|
|
91
91
|
>
|
|
92
92
|
<SilkeBox>
|
|
93
93
|
<SilkeBox column gap="xl">
|
|
94
94
|
<SilkeBox gap="l" style={{ width: 400 }}>
|
|
95
|
-
{[
|
|
95
|
+
{['default', 'zombie', 'ghost'].map((kind) => (
|
|
96
96
|
<SilkeVariablesWrapper
|
|
97
97
|
key={kind}
|
|
98
98
|
component={SilkeTextField}
|
|
@@ -106,7 +106,7 @@ const formats = ["px", "%"];
|
|
|
106
106
|
))}
|
|
107
107
|
</SilkeBox>
|
|
108
108
|
<SilkeBox gap="l">
|
|
109
|
-
{[
|
|
109
|
+
{['default', 'zombie', 'ghost'].map((kind) => (
|
|
110
110
|
<TextFieldContext inline="label-inside" size="xs" key={kind}>
|
|
111
111
|
<SilkeVariablesWrapper
|
|
112
112
|
value={value}
|
|
@@ -124,3 +124,44 @@ const formats = ["px", "%"];
|
|
|
124
124
|
</SilkeBox>
|
|
125
125
|
</SilkeCSSContext>;
|
|
126
126
|
```
|
|
127
|
+
|
|
128
|
+
## Wrapping text
|
|
129
|
+
|
|
130
|
+
```js
|
|
131
|
+
const [value, setValue] = React.useState('value');
|
|
132
|
+
|
|
133
|
+
<>
|
|
134
|
+
<div style={{ padding: '10px', margin: '20px 0', background: '#000' }}>
|
|
135
|
+
{JSON.stringify(value, null, 2)}
|
|
136
|
+
</div>
|
|
137
|
+
<SilkeCSSContext
|
|
138
|
+
viewport={[1920, 1080]}
|
|
139
|
+
fontSize={18}
|
|
140
|
+
container={[200, 150]}
|
|
141
|
+
variablesv2={[
|
|
142
|
+
{ key: 'D', name: 'text-1', value: '10', type: 'text' },
|
|
143
|
+
{ key: 'E', name: 'text-2', value: '50', type: 'text' },
|
|
144
|
+
{ key: 'F', name: 'text-3', value: '100', type: 'text' },
|
|
145
|
+
]}
|
|
146
|
+
>
|
|
147
|
+
<SilkeBox>
|
|
148
|
+
<SilkeBox column gap="xl">
|
|
149
|
+
<SilkeBox gap="l">
|
|
150
|
+
{['default', 'zombie', 'ghost'].map((kind) => (
|
|
151
|
+
<SilkeVariablesWrapper
|
|
152
|
+
key={kind}
|
|
153
|
+
component={SilkeTextField}
|
|
154
|
+
value={value}
|
|
155
|
+
kind={kind}
|
|
156
|
+
onChange={setValue}
|
|
157
|
+
label={kind}
|
|
158
|
+
hasLabelTop
|
|
159
|
+
variableType="text"
|
|
160
|
+
/>
|
|
161
|
+
))}
|
|
162
|
+
</SilkeBox>
|
|
163
|
+
</SilkeBox>
|
|
164
|
+
</SilkeBox>
|
|
165
|
+
</SilkeCSSContext>
|
|
166
|
+
</>;
|
|
167
|
+
```
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useRef, useState } from 'react';
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { SilkeAutocompleteField } from '../silke-autocomplete-field';
|
|
3
3
|
import { useSilkeCSSContext } from '../silke-css-number-field';
|
|
4
4
|
import { SilkeBox } from '../silke-box';
|
|
@@ -11,6 +11,7 @@ import { getCSSNumberFormat } from '@vev/utils';
|
|
|
11
11
|
import { SilkeIcon } from '../silke-icon';
|
|
12
12
|
import { capitalize } from 'lodash';
|
|
13
13
|
import { SilkeVariablesWrapperForm } from './silke-variables-wrapper-form';
|
|
14
|
+
import { SilkeTooltip } from '../silke-tooltip';
|
|
14
15
|
|
|
15
16
|
export type LocalVariable = {
|
|
16
17
|
key: string;
|
|
@@ -18,6 +19,9 @@ export type LocalVariable = {
|
|
|
18
19
|
type: string;
|
|
19
20
|
value?: string;
|
|
20
21
|
unit?: string;
|
|
22
|
+
metadata?: {
|
|
23
|
+
label?: string;
|
|
24
|
+
};
|
|
21
25
|
};
|
|
22
26
|
|
|
23
27
|
const getRelevantVariables = (
|
|
@@ -59,19 +63,32 @@ export type SilkeVariablesWrapperProps<T extends React.ElementType> = {
|
|
|
59
63
|
formats?: string[];
|
|
60
64
|
variableType?: string;
|
|
61
65
|
fullWidthWrapper?: boolean;
|
|
66
|
+
templateVariable?: boolean;
|
|
62
67
|
onChange: (value: string) => void; // return key?
|
|
63
68
|
onVariableAdd?: (variable: LocalVariable) => Promise<string>;
|
|
64
69
|
onVariableEdit?: (key: string) => void;
|
|
65
70
|
} & React.ComponentProps<T>;
|
|
66
71
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
72
|
+
const DROPDOWN_WIDTH = 189;
|
|
73
|
+
|
|
74
|
+
const SUPPORTED_TYPES = ['text', 'number', 'color', 'image', 'video'];
|
|
75
|
+
|
|
76
|
+
export function SilkeVariablesWrapper<T extends React.ElementType>({
|
|
77
|
+
component,
|
|
78
|
+
formats,
|
|
79
|
+
variableType,
|
|
80
|
+
fullWidthWrapper,
|
|
81
|
+
templateVariable,
|
|
82
|
+
onVariableAdd,
|
|
83
|
+
onVariableEdit,
|
|
84
|
+
...rest
|
|
85
|
+
}: SilkeVariablesWrapperProps<T>) {
|
|
70
86
|
const [openVariables, setOpenVariables] = useState(false);
|
|
71
87
|
const [showAddNewForm, setShowAddNewForm] = useState(false);
|
|
72
|
-
const [
|
|
88
|
+
const [hovering, setHovering] = useState(false);
|
|
89
|
+
|
|
90
|
+
if (!formats) formats = [];
|
|
73
91
|
|
|
74
|
-
const { value, formats = [], variableType, onChange, component, ...rest } = props;
|
|
75
92
|
const rootRef = useRef<HTMLDivElement>(null);
|
|
76
93
|
const context = useSilkeCSSContext();
|
|
77
94
|
const textFieldContext = useTextFieldContext();
|
|
@@ -85,29 +102,60 @@ export function SilkeVariablesWrapper<T extends React.ElementType>(
|
|
|
85
102
|
return variables.map((v) => ({
|
|
86
103
|
label: v.name,
|
|
87
104
|
value: v.key,
|
|
88
|
-
subLabel: `${v.value}${v.unit ? `${v.unit}` : ''}`,
|
|
105
|
+
subLabel: `${v.metadata?.label || v.value}${v.unit ? `${v.unit}` : ''}`,
|
|
89
106
|
icon: getVariableIcon(v.type),
|
|
90
107
|
}));
|
|
91
108
|
}, [variables]);
|
|
92
109
|
|
|
93
|
-
const isVariable =
|
|
110
|
+
const isVariable =
|
|
111
|
+
typeof rest.value === 'string' &&
|
|
112
|
+
(rest.value?.startsWith('var(--vev-') || rest.value?.startsWith('{{'));
|
|
113
|
+
|
|
114
|
+
const supportedType = !variableType || SUPPORTED_TYPES.includes(variableType || '');
|
|
94
115
|
const hasVariables = variables.length > 0;
|
|
95
|
-
const currentVariable = variables.find(
|
|
116
|
+
const currentVariable = variables.find(
|
|
117
|
+
(v) => typeof rest.value === 'string' && rest.value?.includes(v.key),
|
|
118
|
+
);
|
|
96
119
|
const hasLabelTop =
|
|
97
120
|
rest.label && rest.inline !== 'label-inside' && textFieldContext.inline !== 'label-inside';
|
|
98
121
|
const offsetPx = rest.size === 'xs' || textFieldContext.size === 'xs' ? 16 : 18;
|
|
99
122
|
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
const el = rootRef.current;
|
|
125
|
+
if (el) {
|
|
126
|
+
let timeout = 0;
|
|
127
|
+
const handleMouseOver = () => {
|
|
128
|
+
clearTimeout(timeout);
|
|
129
|
+
timeout = self.setTimeout(() => setHovering(true), 300);
|
|
130
|
+
};
|
|
131
|
+
const handleMouseOut = () => {
|
|
132
|
+
clearTimeout(timeout);
|
|
133
|
+
setHovering(false);
|
|
134
|
+
};
|
|
135
|
+
el.addEventListener('mouseover', handleMouseOver, { passive: true });
|
|
136
|
+
el.addEventListener('mouseleave', handleMouseOut, { passive: true });
|
|
137
|
+
|
|
138
|
+
return () => {
|
|
139
|
+
el.removeEventListener('mouseover', handleMouseOver);
|
|
140
|
+
el.removeEventListener('mouseleave', handleMouseOver);
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
}, []);
|
|
144
|
+
|
|
100
145
|
const handleVariablesDotClicked = (e: React.MouseEvent) => {
|
|
101
146
|
e.preventDefault();
|
|
102
147
|
|
|
103
148
|
// If active variable, remove link and set to native value
|
|
104
149
|
if (isVariable) {
|
|
105
|
-
const variable = variables.find((v) => value?.includes(v.key));
|
|
106
|
-
onChange(variable ? `${variable.value}${variable.unit || ''}` : '0');
|
|
150
|
+
const variable = variables.find((v) => rest.value?.includes(v.key));
|
|
151
|
+
rest.onChange(variable ? `${variable.value}${variable.unit || ''}` : '0');
|
|
107
152
|
return;
|
|
108
153
|
}
|
|
109
|
-
|
|
110
|
-
|
|
154
|
+
if (hasVariables) {
|
|
155
|
+
setOpenVariables(true);
|
|
156
|
+
} else {
|
|
157
|
+
setShowAddNewForm(true);
|
|
158
|
+
}
|
|
111
159
|
};
|
|
112
160
|
|
|
113
161
|
const onShowAddForm = () => {
|
|
@@ -120,31 +168,41 @@ export function SilkeVariablesWrapper<T extends React.ElementType>(
|
|
|
120
168
|
setOpenVariables(true);
|
|
121
169
|
};
|
|
122
170
|
|
|
123
|
-
const
|
|
171
|
+
const handleVariableChange = (key: string) => {
|
|
172
|
+
// Tracking (if implemented)
|
|
173
|
+
const variable = variables.find((v) => v.key === key);
|
|
174
|
+
context?.onVariableAttached?.(variable?.type || '');
|
|
175
|
+
|
|
176
|
+
// Change the value
|
|
177
|
+
return variableType === 'text' || templateVariable
|
|
178
|
+
? rest.onChange(`{{${key}}}`)
|
|
179
|
+
: rest.onChange(`var(--vev-${key})`);
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
const handleVariableAdd = async ({ variableName }: { variableName: string }) => {
|
|
124
183
|
const newVariable = {
|
|
125
184
|
type: variableType,
|
|
126
|
-
name:
|
|
127
|
-
value: isVariable ? getVariableValue(value, context.variablesv2) || '0' : value,
|
|
185
|
+
name: variableName ? variableName : capitalize(variableType),
|
|
186
|
+
value: isVariable ? getVariableValue(rest.value, context.variablesv2) || '0' : rest.value,
|
|
128
187
|
unit: '',
|
|
129
188
|
};
|
|
130
189
|
|
|
131
190
|
if (variableType === 'number') {
|
|
132
191
|
newVariable.value = isVariable
|
|
133
|
-
? getVariableValue(value, context.variablesv2) || '0'
|
|
134
|
-
: String(parseFloat(value || '0'));
|
|
192
|
+
? getVariableValue(rest.value, context.variablesv2) || '0'
|
|
193
|
+
: String(parseFloat(rest.value || '0'));
|
|
135
194
|
newVariable.unit = isVariable
|
|
136
|
-
? getVariableUnit(value, context.variablesv2) || ''
|
|
137
|
-
: getCSSNumberFormat(value);
|
|
195
|
+
? getVariableUnit(rest.value, context.variablesv2) || ''
|
|
196
|
+
: getCSSNumberFormat(rest.value);
|
|
138
197
|
}
|
|
139
198
|
|
|
140
|
-
const newKey = await
|
|
199
|
+
const newKey = await onVariableAdd?.(newVariable);
|
|
141
200
|
|
|
142
201
|
if (newKey) {
|
|
143
|
-
|
|
202
|
+
handleVariableChange(newKey);
|
|
144
203
|
}
|
|
145
204
|
|
|
146
205
|
setShowAddNewForm(false);
|
|
147
|
-
setNewVariableName('');
|
|
148
206
|
};
|
|
149
207
|
|
|
150
208
|
const itemRender = (item: any) => (
|
|
@@ -169,13 +227,15 @@ export function SilkeVariablesWrapper<T extends React.ElementType>(
|
|
|
169
227
|
</SilkeBox>
|
|
170
228
|
|
|
171
229
|
<SilkeBox column style={{ minWidth: '0', flex: 1 }}>
|
|
172
|
-
<SilkeTextSmall overflow
|
|
230
|
+
<SilkeTextSmall overflow style={{ marginBottom: '-2px' }}>
|
|
231
|
+
{item.label}
|
|
232
|
+
</SilkeTextSmall>
|
|
173
233
|
<SilkeTextMicro overflow color="neutral-60">
|
|
174
234
|
{item.subLabel}
|
|
175
235
|
</SilkeTextMicro>
|
|
176
236
|
</SilkeBox>
|
|
177
237
|
|
|
178
|
-
{hoveredItem === item.value &&
|
|
238
|
+
{hoveredItem === item.value && onVariableEdit && (
|
|
179
239
|
<SilkeBox>
|
|
180
240
|
<SilkeButton
|
|
181
241
|
icon="settings"
|
|
@@ -184,7 +244,7 @@ export function SilkeVariablesWrapper<T extends React.ElementType>(
|
|
|
184
244
|
onMouseDown={(e) => {
|
|
185
245
|
e.preventDefault;
|
|
186
246
|
e.stopPropagation();
|
|
187
|
-
|
|
247
|
+
onVariableEdit?.(item.value);
|
|
188
248
|
}}
|
|
189
249
|
/>
|
|
190
250
|
</SilkeBox>
|
|
@@ -198,9 +258,9 @@ export function SilkeVariablesWrapper<T extends React.ElementType>(
|
|
|
198
258
|
ref={rootRef}
|
|
199
259
|
data-open={openVariables || showAddNewForm}
|
|
200
260
|
data-is-variable={isVariable}
|
|
201
|
-
data-full-width={
|
|
261
|
+
data-full-width={fullWidthWrapper}
|
|
202
262
|
>
|
|
203
|
-
{
|
|
263
|
+
{supportedType && (
|
|
204
264
|
<div
|
|
205
265
|
className={styles.variableDot}
|
|
206
266
|
data-icon={isVariable ? '−' : '+'}
|
|
@@ -208,47 +268,50 @@ export function SilkeVariablesWrapper<T extends React.ElementType>(
|
|
|
208
268
|
style={{ top: hasLabelTop ? offsetPx : 0 }}
|
|
209
269
|
/>
|
|
210
270
|
)}
|
|
271
|
+
{hovering && isVariable && currentVariable && (
|
|
272
|
+
<SilkeTooltip show anchor={rootRef} anchorOrigin="top-center" targetOrigin="bottom-center">
|
|
273
|
+
{currentVariable?.name}
|
|
274
|
+
</SilkeTooltip>
|
|
275
|
+
)}
|
|
211
276
|
{isVariable ? (
|
|
212
277
|
<SilkeAutocompleteField
|
|
213
|
-
{...
|
|
278
|
+
{...rest}
|
|
214
279
|
isVariable
|
|
215
280
|
items={variableItems}
|
|
281
|
+
searchPlaceholder="Search variables"
|
|
216
282
|
renderItem={({ item }) => itemRender(item)}
|
|
217
283
|
value={getVariableDisplayText(variableType, currentVariable)}
|
|
218
284
|
selectedVariableKey={currentVariable?.key}
|
|
219
|
-
dropDownMinWidth={
|
|
220
|
-
dropDownMaxWidth={
|
|
221
|
-
width={
|
|
222
|
-
onChange={
|
|
285
|
+
dropDownMinWidth={DROPDOWN_WIDTH}
|
|
286
|
+
dropDownMaxWidth={DROPDOWN_WIDTH}
|
|
287
|
+
width={rest.width}
|
|
288
|
+
onChange={handleVariableChange}
|
|
289
|
+
hideListArrow
|
|
223
290
|
disableAddFromList
|
|
224
291
|
/>
|
|
225
292
|
) : (
|
|
226
|
-
<div>
|
|
227
|
-
{component && React.createElement(component, { value, formats, onChange, ...rest })}
|
|
228
|
-
</div>
|
|
293
|
+
<div>{component && React.createElement(component, { ...rest, formats })}</div>
|
|
229
294
|
)}
|
|
230
|
-
|
|
231
295
|
{openVariables && (
|
|
232
296
|
<SilkeAutocompletePopup
|
|
233
297
|
containerRef={rootRef}
|
|
234
298
|
renderItem={({ item }) => itemRender(item)}
|
|
235
|
-
dropDownMinWidth={
|
|
236
|
-
dropDownMaxWidth={
|
|
299
|
+
dropDownMinWidth={DROPDOWN_WIDTH}
|
|
300
|
+
dropDownMaxWidth={DROPDOWN_WIDTH}
|
|
237
301
|
items={variableItems}
|
|
238
302
|
value={currentVariable?.name}
|
|
239
303
|
onAdd={onShowAddForm}
|
|
240
|
-
onChange={
|
|
304
|
+
onChange={handleVariableChange}
|
|
241
305
|
onRequestClose={() => setOpenVariables(false)}
|
|
242
|
-
showAddIcon={!!
|
|
306
|
+
showAddIcon={!!onVariableAdd}
|
|
307
|
+
searchPlaceholder="Search variables"
|
|
243
308
|
disableAddFromList
|
|
244
309
|
/>
|
|
245
310
|
)}
|
|
246
|
-
|
|
247
311
|
{showAddNewForm && (
|
|
248
312
|
<SilkeVariablesWrapperForm
|
|
249
313
|
containerRef={rootRef}
|
|
250
|
-
|
|
251
|
-
onChange={(value) => setNewVariableName(value)}
|
|
314
|
+
variableValue={rest.value}
|
|
252
315
|
onSubmit={handleVariableAdd}
|
|
253
316
|
onClose={onHideAddForm}
|
|
254
317
|
/>
|
|
@@ -36,7 +36,6 @@ export class Store extends QueuedModel {
|
|
|
36
36
|
const listeners = actions[type];
|
|
37
37
|
if (listeners) {
|
|
38
38
|
for (const funcName of listeners) {
|
|
39
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
40
39
|
// @ts-ignore don know how to make typescript support this
|
|
41
40
|
this[funcName](type, payload);
|
|
42
41
|
}
|
package/src/hooks/hooks.mdx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# Silke React Hooks
|
|
2
2
|
|
|
3
3
|
```js
|
|
4
|
-
const ref = useHTMLElement(
|
|
4
|
+
const ref = useHTMLElement('div', {}, document.body);
|
|
5
5
|
return ReactDOM.createPortal(
|
|
6
|
-
<h1 style={{ position:
|
|
7
|
-
ref.current
|
|
6
|
+
<h1 style={{ position: 'absolute', top: 200, left: 300 }}>In a portal</h1>,
|
|
7
|
+
ref.current,
|
|
8
8
|
);
|
|
9
9
|
```
|