@vev/silke 1.0.16 → 1.0.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/CHANGELOG.md +16 -0
- package/dist/chunk-SOFGXMET.js +22 -0
- package/dist/{chunk-LAB2YEXC.js.map → chunk-SOFGXMET.js.map} +3 -3
- package/dist/index.js +43 -8
- package/dist/index.js.LEGAL.txt +6 -10
- package/dist/index.js.map +4 -4
- package/dist/silke-code-editor-LBP2WDX3.js +25 -0
- package/dist/silke-code-editor-LBP2WDX3.js.map +7 -0
- package/dist/styles.css +593 -618
- package/package.json +6 -6
- package/src/components/silke-autocomplete-field/autocomplete-item.tsx +33 -7
- package/src/components/silke-autocomplete-field/autocomplete-tags.tsx +8 -4
- package/src/components/silke-autocomplete-field/autocomplete-types.ts +4 -0
- package/src/components/silke-autocomplete-field/silke-autocomplete-field.mdx +67 -24
- package/src/components/silke-autocomplete-field/silke-autocomplete-field.scss +32 -13
- package/src/components/silke-autocomplete-field/silke-autocomplete-field.spec.tsx +24 -109
- package/src/components/silke-autocomplete-field/silke-autocomplete-field.tsx +304 -220
- package/src/components/silke-box/silke-box.mdx +2 -1
- package/src/components/silke-box/silke-box.scss +9 -10
- package/src/components/silke-box/silke-box.tsx +9 -0
- package/src/components/silke-breadcrumbs/silke-breadcrumb.mdx +5 -1
- package/src/components/silke-button/silke-button.scss +3 -3
- package/src/components/silke-checkbox/silke-checkbox.mdx +11 -2
- 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/index.ts +1 -0
- package/src/components/silke-color-picker/silke-color-info.tsx +2 -18
- package/src/components/silke-color-picker/silke-color-picker.mdx +19 -9
- package/src/components/silke-color-picker/silke-color-picker.tsx +4 -13
- package/src/components/silke-context-menu/silke-context-menu-item.tsx +5 -1
- package/src/components/silke-context-menu/silke-context-menu.scss +5 -1
- package/src/components/silke-context-menu/silke-context-menu.tsx +4 -2
- package/src/components/silke-css-number-field/silke-css-number-field.mdx +43 -4
- package/src/components/silke-css-number-field/silke-css-number-field.scss +47 -14
- package/src/components/silke-css-number-field/silke-css-number-field.tsx +114 -186
- package/src/components/silke-css-number-field/utils.ts +25 -0
- package/src/components/silke-drawer/silke-drawer.mdx +13 -13
- package/src/components/silke-drawer/silke-drawer.tsx +0 -14
- package/src/components/silke-form/silke-form.mdx +15 -3
- package/src/components/silke-form/silke-form.tsx +1 -1
- package/src/components/silke-form-schema/fields/event-field.tsx +1 -1
- package/src/components/silke-form-schema/fields/utils/generate-title.ts +14 -6
- package/src/components/silke-form-schema/silke-schema-field.tsx +12 -11
- package/src/components/silke-form-schema/silke-schema-fields.tsx +2 -2
- package/src/components/silke-icon/silke-icon.tsx +3 -1
- package/src/components/silke-image/silke-image.scss +2 -2
- package/src/components/silke-loader/silke-loader.mdx +3 -4
- package/src/components/silke-modal/silke-modal.tsx +11 -2
- package/src/components/silke-navigation-link/silke-navigation-link.mdx +6 -1
- package/src/components/silke-navigation-link/silke-navigation-link.scss +12 -2
- package/src/components/silke-navigation-link/silke-navigation-link.tsx +21 -17
- package/src/components/silke-notification/silke-notification.scss +1 -1
- package/src/components/silke-object-field/silke-object-field.mdx +10 -3
- package/src/components/silke-overflow-menu/silke-overflow-menu.tsx +1 -2
- package/src/components/silke-popover/silke-popover.tsx +1 -20
- package/src/components/silke-progress-indicator/silke-progress-indicator.mdx +9 -3
- package/src/components/silke-radio-button/silke-radio-button.mdx +7 -1
- package/src/components/silke-search-field/silke-search-field.mdx +12 -4
- package/src/components/silke-select-field/silke-select-field.mdx +137 -7
- package/src/components/silke-select-field/silke-select-field.spec.tsx +44 -126
- package/src/components/silke-sortable-list/silke-nested-sortable-item.tsx +17 -2
- package/src/components/silke-sortable-list/silke-nested-sortable-list.tsx +6 -2
- package/src/components/silke-sortable-list/silke-nested-sortable-utils.ts +6 -0
- package/src/components/silke-table/silke-table.tsx +1 -1
- package/src/components/silke-tabs/silke-tabs.mdx +2 -2
- package/src/components/silke-tag/silke-tag.mdx +51 -13
- package/src/components/silke-tag/silke-tag.scss +52 -10
- package/src/components/silke-tag/silke-tag.tsx +48 -24
- package/src/components/silke-text-field/silke-text-field-item.tsx +12 -7
- package/src/components/silke-text-field/silke-text-field-outline.tsx +39 -42
- package/src/components/silke-text-field/silke-text-field.mdx +73 -6
- package/src/components/silke-text-field/silke-text-field.scss +153 -247
- package/src/components/silke-text-field/silke-text-field.tsx +4 -3
- package/src/components/silke-tile/silke-tile.mdx +39 -8
- package/src/components/silke-toggle/silke-toggle.mdx +29 -5
- package/src/components/silke-toolbar/silke-toolbar.mdx +35 -15
- package/src/components/silke-tooltip/silke-icon-tooltip.tsx +2 -1
- package/src/docs/app.tsx +9 -16
- package/src/docs/parser.ts +1 -1
- package/src/hooks/form/use-form-field.ts +1 -1
- package/src/hooks/hooks.mdx +3 -3
- package/src/hooks/index.ts +1 -0
- package/src/hooks/use-uniq-id.ts +6 -0
- package/src/icons.tsx +10 -2
- package/dist/chunk-LAB2YEXC.js +0 -22
- package/dist/silke-code-editor-WEBZ7JXL.js +0 -25
- package/dist/silke-code-editor-WEBZ7JXL.js.map +0 -7
- /package/dist/{chunk-LAB2YEXC.js.LEGAL.txt → chunk-SOFGXMET.js.LEGAL.txt} +0 -0
- /package/dist/{silke-code-editor-WEBZ7JXL.js.LEGAL.txt → silke-code-editor-LBP2WDX3.js.LEGAL.txt} +0 -0
|
@@ -15,9 +15,10 @@
|
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
## Different gaps to mind
|
|
18
|
+
|
|
18
19
|
```jsx
|
|
19
20
|
<SilkeBox gap>
|
|
20
|
-
{[
|
|
21
|
+
{["xxs", "xs", "s", "m", "l", "xl", "xxl", "xxxl"].map((gap) => (
|
|
21
22
|
<SilkeBox gap={gap} column hAlign>
|
|
22
23
|
<SilkeButton label={gap} />
|
|
23
24
|
<SilkeButton label={gap} />
|
|
@@ -138,16 +138,6 @@ button.box {
|
|
|
138
138
|
padding-right: $size;
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
.height-#{$name} {
|
|
142
|
-
height: #{$size * 2};
|
|
143
|
-
min-height: #{$size * 2};
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
.width-#{$name} {
|
|
147
|
-
width: #{$size * 2};
|
|
148
|
-
min-width: #{$size * 2};
|
|
149
|
-
}
|
|
150
|
-
|
|
151
141
|
.gap-#{$name} {
|
|
152
142
|
gap: $size;
|
|
153
143
|
}
|
|
@@ -165,6 +155,15 @@ button.box {
|
|
|
165
155
|
width: $size;
|
|
166
156
|
min-width: $size;
|
|
167
157
|
}
|
|
158
|
+
|
|
159
|
+
.minHeight-#{$name} {
|
|
160
|
+
min-height: #{$size};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.minWidth-#{$name} {
|
|
164
|
+
min-width: #{$size};
|
|
165
|
+
}
|
|
166
|
+
|
|
168
167
|
}
|
|
169
168
|
|
|
170
169
|
.overflow-hidden{
|
|
@@ -53,6 +53,10 @@ type BaseProps = {
|
|
|
53
53
|
height?: BoxSize;
|
|
54
54
|
/** Width of the box (x2 of the spaceing, example: 'm' = 32px wide) */
|
|
55
55
|
width?: BoxSize;
|
|
56
|
+
/** Width of the box (x2 of the spaceing, example: 'm' = 32px wide) */
|
|
57
|
+
minHeight?: BoxSize;
|
|
58
|
+
/** Width of the box (x2 of the spaceing, example: 'm' = 32px wide) */
|
|
59
|
+
minWidth?: BoxSize;
|
|
56
60
|
/** Background color */
|
|
57
61
|
bg?: SilkeColor;
|
|
58
62
|
/** Background color on hover */
|
|
@@ -190,6 +194,8 @@ function BoxComp(
|
|
|
190
194
|
size,
|
|
191
195
|
width = size,
|
|
192
196
|
height = size,
|
|
197
|
+
minWidth,
|
|
198
|
+
minHeight,
|
|
193
199
|
children,
|
|
194
200
|
color,
|
|
195
201
|
colorHover,
|
|
@@ -240,6 +246,9 @@ function BoxComp(
|
|
|
240
246
|
if (width) cl.push(styles['width-' + width]);
|
|
241
247
|
if (height) cl.push(styles['height-' + height]);
|
|
242
248
|
|
|
249
|
+
if (minWidth) cl.push(styles['minWidth-' + minWidth]);
|
|
250
|
+
if (minHeight) cl.push(styles['minHeight-' + minHeight]);
|
|
251
|
+
|
|
243
252
|
if (color) cl.push('color-' + color);
|
|
244
253
|
if (colorHover) cl.push('color-hover-' + colorHover);
|
|
245
254
|
if (bg) cl.push('bg-' + bg);
|
|
@@ -6,7 +6,11 @@ const [len, setLen] = React.useState(9);
|
|
|
6
6
|
<>
|
|
7
7
|
<SilkeBreadcrumbs>
|
|
8
8
|
{ipsum.list(len, (i) => (
|
|
9
|
-
<SilkeBreadcrumb
|
|
9
|
+
<SilkeBreadcrumb
|
|
10
|
+
key={i}
|
|
11
|
+
label={ipsum.name()}
|
|
12
|
+
onClick={[2, 4].includes(i) ? null : () => setLen(i + 1)}
|
|
13
|
+
/>
|
|
10
14
|
))}
|
|
11
15
|
</SilkeBreadcrumbs>
|
|
12
16
|
<SilkeButton label="Reset" onClick={() => setLen(9)} />
|
|
@@ -3,9 +3,18 @@
|
|
|
3
3
|
```js
|
|
4
4
|
const [checked, setChecked] = React.useState(false);
|
|
5
5
|
<>
|
|
6
|
-
<SilkeCheckbox
|
|
6
|
+
<SilkeCheckbox
|
|
7
|
+
label="Checkbox not checked"
|
|
8
|
+
value={checked}
|
|
9
|
+
onChange={setChecked}
|
|
10
|
+
/>
|
|
7
11
|
<SilkeCheckbox label="Checkbox checked" value={true} />
|
|
8
|
-
<SilkeCheckbox
|
|
12
|
+
<SilkeCheckbox
|
|
13
|
+
label="Checkbox disabled"
|
|
14
|
+
disabled
|
|
15
|
+
value={checked}
|
|
16
|
+
onChange={setChecked}
|
|
17
|
+
/>
|
|
9
18
|
<SilkeCheckbox label="Checkbox checked and disabled" value={true} disabled />
|
|
10
19
|
<SilkeCheckbox
|
|
11
20
|
label="Required checkbox with error"
|
|
@@ -19,6 +19,18 @@ export function rgbToHex(color: RGBA | string | number[]): string {
|
|
|
19
19
|
return hex;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
export function getColorVariableValue(
|
|
23
|
+
color: string,
|
|
24
|
+
variables: { [varName: string]: string },
|
|
25
|
+
): string {
|
|
26
|
+
const varName = color.trim().replace(/^var\((.*)\)$/, '$1');
|
|
27
|
+
return variables[varName];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function isColorVariable(color: string): boolean {
|
|
31
|
+
return !!color && /^var\(/.test(color.trim());
|
|
32
|
+
}
|
|
33
|
+
|
|
22
34
|
export function rgbaToString(rgba: RGBA | number[] | string): string {
|
|
23
35
|
if (!rgba) {
|
|
24
36
|
return '';
|
|
@@ -63,26 +63,10 @@ export function ColorInfo({ rgba, noTransparency, onChange }: ColorInfoProps) {
|
|
|
63
63
|
{ value: 'HEX', label: 'HEX' },
|
|
64
64
|
{ value: 'RGB', label: 'RGB' },
|
|
65
65
|
]}
|
|
66
|
-
renderItem={({ item, selected }) => {
|
|
67
|
-
return (
|
|
68
|
-
<SilkeBox
|
|
69
|
-
hPad="xs"
|
|
70
|
-
bgHover="brand-secondary-30"
|
|
71
|
-
flex
|
|
72
|
-
vAlign="center"
|
|
73
|
-
gap="xs"
|
|
74
|
-
align="center"
|
|
75
|
-
>
|
|
76
|
-
<SilkeText size="small" flex color={selected ? 'accent-50' : 'neutral-80'}>
|
|
77
|
-
{item.label}
|
|
78
|
-
</SilkeText>
|
|
79
|
-
</SilkeBox>
|
|
80
|
-
);
|
|
81
|
-
}}
|
|
82
66
|
/>
|
|
83
67
|
</SilkeBox>
|
|
84
68
|
|
|
85
|
-
<SilkeBox style={{ width:
|
|
69
|
+
<SilkeBox style={{ width: 82 }} flex gap="s">
|
|
86
70
|
{format === 'HEX' ? (
|
|
87
71
|
<SilkeTextField
|
|
88
72
|
flex
|
|
@@ -109,7 +93,7 @@ export function ColorInfo({ rgba, noTransparency, onChange }: ColorInfoProps) {
|
|
|
109
93
|
)}
|
|
110
94
|
</SilkeBox>
|
|
111
95
|
|
|
112
|
-
<SilkeBox style={{ width:
|
|
96
|
+
<SilkeBox style={{ width: 62 }}>
|
|
113
97
|
<SilkeCssNumberField
|
|
114
98
|
min={0}
|
|
115
99
|
max={100}
|
|
@@ -7,13 +7,16 @@ pick color plz
|
|
|
7
7
|
```js
|
|
8
8
|
const [value, setValue] = React.useState(``);
|
|
9
9
|
const [variables, setVariabels] = React.useState({
|
|
10
|
-
primary:
|
|
11
|
-
accent:
|
|
12
|
-
bg:
|
|
10
|
+
primary: "rgba(0, 150, 136, 1)",
|
|
11
|
+
accent: "rgba(233, 30, 99, 1)",
|
|
12
|
+
bg: "rgba(250, 250, 250, 1)",
|
|
13
13
|
text: false,
|
|
14
14
|
});
|
|
15
15
|
const handleAddVariable = () => {
|
|
16
|
-
setVariabels({
|
|
16
|
+
setVariabels({
|
|
17
|
+
...variables,
|
|
18
|
+
["--swatch" + Object.keys(variables).length]: value,
|
|
19
|
+
});
|
|
17
20
|
};
|
|
18
21
|
|
|
19
22
|
<SilkeCSSContext variables={variables} onVariableAdd={handleAddVariable}>
|
|
@@ -26,13 +29,16 @@ const handleAddVariable = () => {
|
|
|
26
29
|
```js
|
|
27
30
|
const [value, setValue] = React.useState(`rgba(10, 10, 10, 100`);
|
|
28
31
|
const [variables, setVariabels] = React.useState({
|
|
29
|
-
primary:
|
|
30
|
-
accent:
|
|
31
|
-
bg:
|
|
32
|
+
primary: "rgba(0, 150, 136, 1)",
|
|
33
|
+
accent: "rgba(233, 30, 99, 1)",
|
|
34
|
+
bg: "rgba(250, 250, 250, 1)",
|
|
32
35
|
text: false,
|
|
33
36
|
});
|
|
34
37
|
const handleAddVariable = () => {
|
|
35
|
-
setVariabels({
|
|
38
|
+
setVariabels({
|
|
39
|
+
...variables,
|
|
40
|
+
["--swatch" + Object.keys(variables).length]: value,
|
|
41
|
+
});
|
|
36
42
|
};
|
|
37
43
|
<SilkeCSSContext variables={variables} onVariableAdd={handleAddVariable}>
|
|
38
44
|
<SilkeBox gap="m" vAlign="center">
|
|
@@ -42,7 +48,11 @@ const handleAddVariable = () => {
|
|
|
42
48
|
|
|
43
49
|
<SilkeColorPickerButton value={value} size="s" onChange={setValue} />
|
|
44
50
|
|
|
45
|
-
<SilkeColorPickerButton
|
|
51
|
+
<SilkeColorPickerButton
|
|
52
|
+
value={value}
|
|
53
|
+
label="Some random label"
|
|
54
|
+
onChange={setValue}
|
|
55
|
+
/>
|
|
46
56
|
</SilkeBox>
|
|
47
57
|
</SilkeCSSContext>;
|
|
48
58
|
```
|
|
@@ -8,7 +8,7 @@ import { SilkeSwatches } from '../silke-color-swatches';
|
|
|
8
8
|
import { useSilkeCSSContext } from '../silke-css-number-field';
|
|
9
9
|
import { SilkeModal, SilkeModalActions, SilkeModalContent } from '../silke-modal';
|
|
10
10
|
import { TextFieldContext } from '../silke-text-field';
|
|
11
|
-
import { hsvToRgb, rgbToHsv } from './color';
|
|
11
|
+
import { getColorVariableValue, hsvToRgb, isColorVariable, rgbToHsv } from './color';
|
|
12
12
|
import styles from './color-picker.scss';
|
|
13
13
|
import { ColorInfo } from './silke-color-info';
|
|
14
14
|
import { ColorSpace } from './silke-color-space';
|
|
@@ -30,15 +30,6 @@ export type SilkeColorPickerProps = {
|
|
|
30
30
|
onChange: (color: string) => void;
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
function isVariable(color: string): boolean {
|
|
34
|
-
return !!color && /^var\(/.test(color.trim());
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function getVariableValue(color: string, variables: { [varName: string]: string }): string {
|
|
38
|
-
const varName = color.trim().replace(/^var\((.*)\)$/, '$1');
|
|
39
|
-
return variables[varName];
|
|
40
|
-
}
|
|
41
|
-
|
|
42
33
|
export function SilkeColorPicker({
|
|
43
34
|
value,
|
|
44
35
|
hidePalettes,
|
|
@@ -51,14 +42,14 @@ export function SilkeColorPicker({
|
|
|
51
42
|
const [eyeDropperActive, setEyeDropperActive] = useState(false);
|
|
52
43
|
const [showEyeDropUnsupported, setShowEyeDropUnsupported] = useState(false);
|
|
53
44
|
const { variables } = useSilkeCSSContext();
|
|
54
|
-
const isValueVariable =
|
|
45
|
+
const isValueVariable = isColorVariable(value);
|
|
55
46
|
|
|
56
47
|
const rgba = React.useMemo(() => {
|
|
57
48
|
if (!value) {
|
|
58
49
|
return TRANSPARENT;
|
|
59
50
|
}
|
|
60
51
|
if (isValueVariable) {
|
|
61
|
-
return tinycolor(
|
|
52
|
+
return tinycolor(getColorVariableValue(value, variables)).toRgb();
|
|
62
53
|
}
|
|
63
54
|
|
|
64
55
|
return tinycolor(value).toRgb();
|
|
@@ -77,7 +68,7 @@ export function SilkeColorPicker({
|
|
|
77
68
|
|
|
78
69
|
const handleChange = (v: string | RGBA) => {
|
|
79
70
|
if (isString(v) && /\$|var/.test(v)) {
|
|
80
|
-
if (noVariables) onChange(
|
|
71
|
+
if (noVariables) onChange(getColorVariableValue(v, variables));
|
|
81
72
|
else onChange(v);
|
|
82
73
|
} else {
|
|
83
74
|
const color = tinycolor(v);
|
|
@@ -25,12 +25,16 @@ export const SilkeContextMenuItem = ({
|
|
|
25
25
|
icon,
|
|
26
26
|
subItem,
|
|
27
27
|
onClick,
|
|
28
|
+
selected,
|
|
28
29
|
...rest
|
|
29
30
|
}: SilkeContextMenuItemProps) => {
|
|
31
|
+
const cl = [styles.item];
|
|
30
32
|
const ref = useRef<HTMLButtonElement>(null);
|
|
31
33
|
const requestCloseMenu = usePopoverRequestClose('contextmenu');
|
|
32
34
|
const requestCloseSub = usePopoverRequestClose('contextmenu.sub');
|
|
33
35
|
|
|
36
|
+
if (selected) cl.push(styles.selected);
|
|
37
|
+
|
|
34
38
|
const [showSub, setShowSub] = useState(false);
|
|
35
39
|
return (
|
|
36
40
|
<SilkeBox column hPad="xs">
|
|
@@ -59,7 +63,7 @@ export const SilkeContextMenuItem = ({
|
|
|
59
63
|
setShowSub(true);
|
|
60
64
|
}
|
|
61
65
|
}}
|
|
62
|
-
className={
|
|
66
|
+
className={cl.join(' ')}
|
|
63
67
|
{...rest}
|
|
64
68
|
/>
|
|
65
69
|
{showSub && items && (
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isFunction } from 'lodash';
|
|
2
2
|
import React, { useEffect, useRef, useState } from 'react';
|
|
3
|
-
import { SilkeBox } from '../silke-box';
|
|
3
|
+
import { BoxSpace, SilkeBox } from '../silke-box';
|
|
4
4
|
import { ButtonContext } from '../silke-button';
|
|
5
5
|
import { SilkePopover, SilkePopoverProps } from '../silke-popover';
|
|
6
6
|
import { usePopoverRequestClose } from '../silke-popover/popover-context';
|
|
@@ -20,6 +20,7 @@ export type SilkeContextMenuProps = {
|
|
|
20
20
|
target?: React.MutableRefObject<HTMLElement>;
|
|
21
21
|
/** Used internally to keep track of menu and closing */
|
|
22
22
|
subMenu?: boolean;
|
|
23
|
+
gap?: BoxSpace;
|
|
23
24
|
} & Omit<SilkePopoverProps, 'children' | 'kind'>;
|
|
24
25
|
|
|
25
26
|
export function SilkeContextMenu({
|
|
@@ -29,6 +30,7 @@ export function SilkeContextMenu({
|
|
|
29
30
|
anchor,
|
|
30
31
|
width,
|
|
31
32
|
subMenu,
|
|
33
|
+
gap,
|
|
32
34
|
onRequestClose,
|
|
33
35
|
...rest
|
|
34
36
|
}: SilkeContextMenuProps) {
|
|
@@ -66,7 +68,6 @@ export function SilkeContextMenu({
|
|
|
66
68
|
onRequestClose?.();
|
|
67
69
|
}}
|
|
68
70
|
{...rest}
|
|
69
|
-
focusRef={boxRef}
|
|
70
71
|
>
|
|
71
72
|
<ButtonContext size="base">
|
|
72
73
|
{items && (
|
|
@@ -80,6 +81,7 @@ export function SilkeContextMenu({
|
|
|
80
81
|
shadow="level4"
|
|
81
82
|
onMouseDown={(e: React.MouseEvent) => e.stopPropagation()}
|
|
82
83
|
vPad="xs"
|
|
84
|
+
gap={gap}
|
|
83
85
|
onKeyDown={(e: React.KeyboardEvent) => {
|
|
84
86
|
if (e.key === 'ArrowLeft' && !subMenu) {
|
|
85
87
|
e.stopPropagation();
|
|
@@ -9,11 +9,50 @@ You can wrap the filed in a css context to enable automatic convertion between f
|
|
|
9
9
|
const [value, setValue] = React.useState('20px');
|
|
10
10
|
const formats = ['px', '%', 'em', 'vh', 'vw']
|
|
11
11
|
|
|
12
|
-
<SilkeBox column>
|
|
12
|
+
<SilkeBox column gap="s">
|
|
13
13
|
<h1>{value}</h1>
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
{["default", "zombie", "ghost"].map((kind) => (
|
|
15
|
+
<SilkeBox gap="s" key={kind} style={{width: 380}}>
|
|
16
|
+
<SilkeCssNumberField kind={kind} label="Label" allowAuto value={value} size="xs" formats={formats} onChange={setValue} />
|
|
17
|
+
<SilkeCssNumberField kind={kind} label="Label" allowAuto value={value} size="s" formats={formats} onChange={setValue} />
|
|
18
|
+
<SilkeCssNumberField kind={kind} value={value} label="Label" formats={formats} onChange={setValue}/>
|
|
19
|
+
<SilkeCssNumberField kind={kind} label="Label" value={value} inline formats={formats} onChange={setValue} />
|
|
20
|
+
</SilkeBox>
|
|
21
|
+
))}
|
|
22
|
+
</SilkeBox>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
```js
|
|
26
|
+
const [value, setValue] = React.useState('20px');
|
|
27
|
+
const formats = ['px', '%', 'em', 'vh', 'vw']
|
|
28
|
+
|
|
29
|
+
<TextFieldContext inline="label-inside" size="xs">
|
|
30
|
+
<SilkeBox column gap="s">
|
|
31
|
+
<h1>{value}</h1>
|
|
32
|
+
{["default", "zombie", "ghost"].map((kind) => (
|
|
33
|
+
<SilkeBox gap="s" key={kind} style={{width: 256}}>
|
|
34
|
+
<SilkeCssNumberField kind={kind} label="Label" allowAuto value={value} formats={formats} onChange={setValue} />
|
|
35
|
+
<SilkeCssNumberField kind={kind} value={value} label="Label" formats={formats} onChange={setValue}/>
|
|
36
|
+
<SilkeCssNumberField kind={kind} label="Label" value={value} formats={formats} onChange={setValue} />
|
|
37
|
+
</SilkeBox>
|
|
38
|
+
))}
|
|
39
|
+
</SilkeBox>
|
|
40
|
+
</TextFieldContext>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Validation
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
const [value, setValue] = React.useState('20%');
|
|
47
|
+
const formats = ['px', '%', 'em', 'vh', 'vw']
|
|
48
|
+
|
|
49
|
+
<SilkeBox column gap="s">
|
|
50
|
+
<h1>{value}</h1>
|
|
51
|
+
{["default", "zombie", "ghost"].map((kind) => (
|
|
52
|
+
<SilkeBox gap="s" key={kind}>
|
|
53
|
+
<SilkeCssNumberField kind={kind} value={value} label="Label" onChange={setValue} min={0} max={100}/>
|
|
54
|
+
</SilkeBox>
|
|
55
|
+
))}
|
|
17
56
|
</SilkeBox>
|
|
18
57
|
```
|
|
19
58
|
|
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
@use "../../variables" as *;
|
|
2
2
|
|
|
3
3
|
.root {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
overflow: hidden;
|
|
5
|
+
&:hover,
|
|
6
|
+
&.openFormat {
|
|
7
|
+
.downIcon {
|
|
8
|
+
opacity: 1;
|
|
9
|
+
transform: translateX(0);
|
|
8
10
|
}
|
|
9
11
|
}
|
|
12
|
+
|
|
13
|
+
&.openFormat.openFormat{
|
|
14
|
+
--text-field-bg: var(--color-neutral-20);
|
|
15
|
+
--text-field-hover-bg: var(--color-neutral-20);
|
|
16
|
+
--text-field-focus-border-color: transparent;
|
|
17
|
+
}
|
|
18
|
+
|
|
10
19
|
}
|
|
11
20
|
|
|
12
21
|
.field {
|
|
@@ -17,17 +26,25 @@
|
|
|
17
26
|
white-space: nowrap;
|
|
18
27
|
align-self: center;
|
|
19
28
|
justify-self: end;
|
|
20
|
-
min-width: 1ch;
|
|
21
|
-
padding: 0 1px;
|
|
22
|
-
text-align: right;
|
|
23
|
-
flex: 1;
|
|
24
29
|
overflow: hidden;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
min-width: 1px;
|
|
31
|
+
|
|
32
|
+
padding:0 !important;
|
|
33
|
+
// width: auto !important;
|
|
34
|
+
&.hasFormats{
|
|
35
|
+
max-width: calc(100% - 16px);
|
|
36
|
+
}
|
|
37
|
+
flex: none !important;
|
|
38
|
+
text-align: right;
|
|
39
|
+
position: relative;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.inputHolder{
|
|
43
|
+
&:first-child{
|
|
44
|
+
padding: 0 4px;
|
|
45
|
+
}
|
|
46
|
+
&:not(:first-child){
|
|
47
|
+
padding:0;
|
|
31
48
|
}
|
|
32
49
|
}
|
|
33
50
|
|
|
@@ -55,3 +72,19 @@
|
|
|
55
72
|
width: 100%;
|
|
56
73
|
cursor: ew-resize;
|
|
57
74
|
}
|
|
75
|
+
|
|
76
|
+
.downIcon {
|
|
77
|
+
background: transparent;
|
|
78
|
+
outline: none;
|
|
79
|
+
border: none;
|
|
80
|
+
opacity: 0;
|
|
81
|
+
font-size: 0.845em;
|
|
82
|
+
transform: translateX(4px);
|
|
83
|
+
color: var(--text-field-placeholder-color);
|
|
84
|
+
transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.downIcon:hover,
|
|
88
|
+
.openFormat .downIcon {
|
|
89
|
+
color: var(--text-field-color);
|
|
90
|
+
}
|