@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.
Files changed (89) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/chunk-SOFGXMET.js +22 -0
  3. package/dist/{chunk-LAB2YEXC.js.map → chunk-SOFGXMET.js.map} +3 -3
  4. package/dist/index.js +43 -8
  5. package/dist/index.js.LEGAL.txt +6 -10
  6. package/dist/index.js.map +4 -4
  7. package/dist/silke-code-editor-LBP2WDX3.js +25 -0
  8. package/dist/silke-code-editor-LBP2WDX3.js.map +7 -0
  9. package/dist/styles.css +593 -618
  10. package/package.json +6 -6
  11. package/src/components/silke-autocomplete-field/autocomplete-item.tsx +33 -7
  12. package/src/components/silke-autocomplete-field/autocomplete-tags.tsx +8 -4
  13. package/src/components/silke-autocomplete-field/autocomplete-types.ts +4 -0
  14. package/src/components/silke-autocomplete-field/silke-autocomplete-field.mdx +67 -24
  15. package/src/components/silke-autocomplete-field/silke-autocomplete-field.scss +32 -13
  16. package/src/components/silke-autocomplete-field/silke-autocomplete-field.spec.tsx +24 -109
  17. package/src/components/silke-autocomplete-field/silke-autocomplete-field.tsx +304 -220
  18. package/src/components/silke-box/silke-box.mdx +2 -1
  19. package/src/components/silke-box/silke-box.scss +9 -10
  20. package/src/components/silke-box/silke-box.tsx +9 -0
  21. package/src/components/silke-breadcrumbs/silke-breadcrumb.mdx +5 -1
  22. package/src/components/silke-button/silke-button.scss +3 -3
  23. package/src/components/silke-checkbox/silke-checkbox.mdx +11 -2
  24. package/src/components/silke-color-palettes/silke-color-palette.mdx +2 -2
  25. package/src/components/silke-color-picker/color.ts +12 -0
  26. package/src/components/silke-color-picker/index.ts +1 -0
  27. package/src/components/silke-color-picker/silke-color-info.tsx +2 -18
  28. package/src/components/silke-color-picker/silke-color-picker.mdx +19 -9
  29. package/src/components/silke-color-picker/silke-color-picker.tsx +4 -13
  30. package/src/components/silke-context-menu/silke-context-menu-item.tsx +5 -1
  31. package/src/components/silke-context-menu/silke-context-menu.scss +5 -1
  32. package/src/components/silke-context-menu/silke-context-menu.tsx +4 -2
  33. package/src/components/silke-css-number-field/silke-css-number-field.mdx +43 -4
  34. package/src/components/silke-css-number-field/silke-css-number-field.scss +47 -14
  35. package/src/components/silke-css-number-field/silke-css-number-field.tsx +114 -186
  36. package/src/components/silke-css-number-field/utils.ts +25 -0
  37. package/src/components/silke-drawer/silke-drawer.mdx +13 -13
  38. package/src/components/silke-drawer/silke-drawer.tsx +0 -14
  39. package/src/components/silke-form/silke-form.mdx +15 -3
  40. package/src/components/silke-form/silke-form.tsx +1 -1
  41. package/src/components/silke-form-schema/fields/event-field.tsx +1 -1
  42. package/src/components/silke-form-schema/fields/utils/generate-title.ts +14 -6
  43. package/src/components/silke-form-schema/silke-schema-field.tsx +12 -11
  44. package/src/components/silke-form-schema/silke-schema-fields.tsx +2 -2
  45. package/src/components/silke-icon/silke-icon.tsx +3 -1
  46. package/src/components/silke-image/silke-image.scss +2 -2
  47. package/src/components/silke-loader/silke-loader.mdx +3 -4
  48. package/src/components/silke-modal/silke-modal.tsx +11 -2
  49. package/src/components/silke-navigation-link/silke-navigation-link.mdx +6 -1
  50. package/src/components/silke-navigation-link/silke-navigation-link.scss +12 -2
  51. package/src/components/silke-navigation-link/silke-navigation-link.tsx +21 -17
  52. package/src/components/silke-notification/silke-notification.scss +1 -1
  53. package/src/components/silke-object-field/silke-object-field.mdx +10 -3
  54. package/src/components/silke-overflow-menu/silke-overflow-menu.tsx +1 -2
  55. package/src/components/silke-popover/silke-popover.tsx +1 -20
  56. package/src/components/silke-progress-indicator/silke-progress-indicator.mdx +9 -3
  57. package/src/components/silke-radio-button/silke-radio-button.mdx +7 -1
  58. package/src/components/silke-search-field/silke-search-field.mdx +12 -4
  59. package/src/components/silke-select-field/silke-select-field.mdx +137 -7
  60. package/src/components/silke-select-field/silke-select-field.spec.tsx +44 -126
  61. package/src/components/silke-sortable-list/silke-nested-sortable-item.tsx +17 -2
  62. package/src/components/silke-sortable-list/silke-nested-sortable-list.tsx +6 -2
  63. package/src/components/silke-sortable-list/silke-nested-sortable-utils.ts +6 -0
  64. package/src/components/silke-table/silke-table.tsx +1 -1
  65. package/src/components/silke-tabs/silke-tabs.mdx +2 -2
  66. package/src/components/silke-tag/silke-tag.mdx +51 -13
  67. package/src/components/silke-tag/silke-tag.scss +52 -10
  68. package/src/components/silke-tag/silke-tag.tsx +48 -24
  69. package/src/components/silke-text-field/silke-text-field-item.tsx +12 -7
  70. package/src/components/silke-text-field/silke-text-field-outline.tsx +39 -42
  71. package/src/components/silke-text-field/silke-text-field.mdx +73 -6
  72. package/src/components/silke-text-field/silke-text-field.scss +153 -247
  73. package/src/components/silke-text-field/silke-text-field.tsx +4 -3
  74. package/src/components/silke-tile/silke-tile.mdx +39 -8
  75. package/src/components/silke-toggle/silke-toggle.mdx +29 -5
  76. package/src/components/silke-toolbar/silke-toolbar.mdx +35 -15
  77. package/src/components/silke-tooltip/silke-icon-tooltip.tsx +2 -1
  78. package/src/docs/app.tsx +9 -16
  79. package/src/docs/parser.ts +1 -1
  80. package/src/hooks/form/use-form-field.ts +1 -1
  81. package/src/hooks/hooks.mdx +3 -3
  82. package/src/hooks/index.ts +1 -0
  83. package/src/hooks/use-uniq-id.ts +6 -0
  84. package/src/icons.tsx +10 -2
  85. package/dist/chunk-LAB2YEXC.js +0 -22
  86. package/dist/silke-code-editor-WEBZ7JXL.js +0 -25
  87. package/dist/silke-code-editor-WEBZ7JXL.js.map +0 -7
  88. /package/dist/{chunk-LAB2YEXC.js.LEGAL.txt → chunk-SOFGXMET.js.LEGAL.txt} +0 -0
  89. /package/dist/{silke-code-editor-WEBZ7JXL.js.LEGAL.txt → silke-code-editor-LBP2WDX3.js.LEGAL.txt} +0 -0
@@ -3,55 +3,79 @@ import { BoxProps, BoxSpace, SilkeBox } from '../silke-box';
3
3
  import { SilkeText } from '../silke-text';
4
4
  import styles from './silke-tag.scss';
5
5
  import { SilkeIcon, SilkeIcons } from '../silke-icon';
6
+ import { SilkeColor } from '../../silke-theme-provider';
7
+
8
+ export type SilkeTagKind = 'primary' | 'secondary' | 'outlined';
9
+
10
+ export type SilkeTagColor =
11
+ | 'sand'
12
+ | 'yellow'
13
+ | 'green'
14
+ | 'red'
15
+ | 'gray'
16
+ | 'blue'
17
+ | 'brandYellow'
18
+ | 'dark';
6
19
 
7
- export type SilkeTagKind = 'sand' | 'yellow' | 'green' | 'red' | 'gray' | 'blue';
8
20
  export type SilkeTagSize = 'tiny';
9
21
 
10
22
  export type SilkeTagProps = {
11
23
  disabled?: boolean;
12
- label: React.ReactNode;
24
+ label?: React.ReactNode;
13
25
  kind?: SilkeTagKind;
14
26
  size?: SilkeTagSize;
15
- outline?: boolean;
16
27
  icon?: SilkeIcons;
17
28
  innerGap?: BoxSpace;
29
+ iconColor?: SilkeColor;
30
+ color?: SilkeTagColor;
18
31
  /**
19
32
  * Will add a remove button to tag
20
33
  */
21
34
  onRemove?: (e: React.MouseEvent) => void;
22
- } & Omit<BoxProps, 'size'>;
35
+ } & Omit<BoxProps, 'size' | 'color'>;
23
36
 
24
37
  function SilkeTagComp(
25
38
  {
26
39
  className,
27
40
  disabled,
28
- kind,
41
+ kind = 'primary',
29
42
  label,
30
- outline,
31
43
  onRemove,
32
44
  size,
33
45
  icon,
34
46
  innerGap = 'xs',
47
+ color = 'gray',
35
48
  ...rest
36
49
  }: SilkeTagProps,
37
50
  ref: any,
38
51
  ) {
39
- const cl = [styles.tag, disabled ? styles.disabled : styles[kind || 'gray']];
52
+ const cl = [
53
+ styles.tag,
54
+ styles[kind || 'primary'],
55
+ disabled ? styles.disabled : styles[color || 'gray'],
56
+ ];
40
57
  if (className) cl.push(className);
41
- if (outline) cl.push(styles.outline);
42
58
  if (size) cl.push(styles[size]);
43
59
  if (rest?.onClick) cl.push(styles.selectable);
44
60
 
61
+ const iconOnly = !!icon && !label;
62
+
45
63
  return (
46
- <SilkeBox {...(rest as BoxProps)} className={cl.join(' ')} hPad="xs" vAlign="center" ref={ref}>
64
+ <SilkeBox
65
+ {...(rest as BoxProps)}
66
+ className={cl.join(' ')}
67
+ hPad={iconOnly ? 'xxs' : 'xs'}
68
+ vAlign="center"
69
+ ref={ref}
70
+ >
47
71
  <SilkeText overflow flex className={styles.label}>
48
72
  <SilkeBox gap={innerGap} align="center">
49
- {icon && <SilkeIcon icon={icon} />}
50
- <span>{label}</span>
73
+ {icon && <SilkeIcon icon={icon} className={styles.tagIcon} />}
74
+ {label && <span>{label}</span>}
51
75
  </SilkeBox>
52
76
  </SilkeText>
53
77
  {!disabled && onRemove && (
54
- <SilkeBox tag="button" vAlign="center" hAlign="center" onClick={onRemove}>
78
+ <SilkeBox tag="button" vAlign="center" hAlign="center" onMouseDown={onRemove}>
55
79
  <SilkeIcon icon="close" />
56
80
  </SilkeBox>
57
81
  )}
@@ -62,26 +86,26 @@ function SilkeTagComp(
62
86
  export const SilkeTag = React.forwardRef(SilkeTagComp);
63
87
  SilkeBox.displayName = 'SilkeTag';
64
88
 
65
- export const SilkeTagSand = ({ kind, ...rest }: SilkeTagProps) => {
66
- return <SilkeTag {...rest} kind="sand" />;
89
+ export const SilkeTagSand = ({ color, ...rest }: SilkeTagProps) => {
90
+ return <SilkeTag {...rest} color="sand" />;
67
91
  };
68
92
 
69
- export const SilkeTagYellow = ({ kind, ...rest }: SilkeTagProps) => {
70
- return <SilkeTag {...rest} kind="yellow" />;
93
+ export const SilkeTagYellow = ({ color, ...rest }: SilkeTagProps) => {
94
+ return <SilkeTag {...rest} color="yellow" />;
71
95
  };
72
96
 
73
- export const SilkeTagGreen = ({ kind, ...rest }: SilkeTagProps) => {
74
- return <SilkeTag {...rest} kind="green" />;
97
+ export const SilkeTagGreen = ({ color, ...rest }: SilkeTagProps) => {
98
+ return <SilkeTag {...rest} color="green" />;
75
99
  };
76
100
 
77
- export const SilkeTagRed = ({ kind, ...rest }: SilkeTagProps) => {
78
- return <SilkeTag {...rest} kind="red" />;
101
+ export const SilkeTagRed = ({ color, ...rest }: SilkeTagProps) => {
102
+ return <SilkeTag {...rest} color="red" />;
79
103
  };
80
104
 
81
- export const SilkeTagGray = ({ kind, ...rest }: SilkeTagProps) => {
82
- return <SilkeTag {...rest} kind="gray" />;
105
+ export const SilkeTagGray = ({ color, ...rest }: SilkeTagProps) => {
106
+ return <SilkeTag {...rest} color="gray" />;
83
107
  };
84
108
 
85
- export const SilkeTagBlue = ({ kind, ...rest }: SilkeTagProps) => {
86
- return <SilkeTag {...rest} kind="blue" />;
109
+ export const SilkeTagBlue = ({ color, ...rest }: SilkeTagProps) => {
110
+ return <SilkeTag {...rest} color="blue" />;
87
111
  };
@@ -7,17 +7,22 @@ type SilkeTextFieldItemProps = {
7
7
  before?: boolean;
8
8
  } & BoxProps;
9
9
 
10
- export function SilkeTextFieldItem({
11
- before,
12
- children,
13
- className,
14
- ...rest
15
- }: SilkeTextFieldItemProps) {
10
+ function TextFieldItem(
11
+ { before, children, className, ...rest }: SilkeTextFieldItemProps,
12
+ ref: any,
13
+ ) {
16
14
  let cl = before ? styles.itemBefore : styles.itemAfter;
17
15
  if (className) cl += ' ' + className;
18
16
  return (
19
- <SilkeBox className={cl} align="center" {...rest}>
17
+ <SilkeBox
18
+ ref={ref}
19
+ className={cl}
20
+ align={rest.hAlign || rest.vAlign ? undefined : 'center'}
21
+ {...rest}
22
+ >
20
23
  {children}
21
24
  </SilkeBox>
22
25
  );
23
26
  }
27
+ export const SilkeTextFieldItem = React.forwardRef(TextFieldItem);
28
+ SilkeTextFieldItem.displayName = 'SilkeTextFieldItem';
@@ -5,6 +5,7 @@ import { SilkeIcon } from '../silke-icon';
5
5
  import { SilkeText } from '../silke-text/silke-text';
6
6
  import styles from './silke-text-field.scss';
7
7
  import { useTextFieldContext } from './text-field-context';
8
+ import { SilkeTextFieldItem } from './silke-text-field-item';
8
9
 
9
10
  type InputSize = 'tiny' | 'small' | 'base' | 'large';
10
11
 
@@ -28,15 +29,16 @@ export type SilkeTextFieldOutlineProps = {
28
29
  // Makes text field flex
29
30
  flex?: boolean;
30
31
  size?: BoxSize;
31
- kind?: 'default' | 'ghost' | 'secondary';
32
+ kind?: 'default' | 'ghost' | 'zombie';
32
33
  width?: number;
33
34
  /** Flex gap added to the container with the children */
34
35
  gap?: BoxSpace;
35
36
  /** Horizontal padding added to the container with the children */
36
37
  hPad?: BoxSpace;
37
38
  hAlign?: BoxProps['hAlign'];
39
+ vAlign?: BoxProps['vAlign'];
38
40
  /** Inline will add the label before the input field */
39
- inline?: boolean;
41
+ inline?: boolean | 'label-inside';
40
42
  /** Width of the inline label */
41
43
  inlineLabelWidth?: number;
42
44
  /** Field required input (if string the string will be used as error msg) */
@@ -49,6 +51,7 @@ export type SilkeTextFieldOutlineProps = {
49
51
  /** Id to link help label with (input should have aria-describedby) */
50
52
  helpId?: string;
51
53
  labelId?: string;
54
+ labelUsingAria?: boolean;
52
55
  onClick?: (e: React.MouseEvent<HTMLElement>) => void;
53
56
  onMouseDown?: (e: React.MouseEvent<HTMLElement>) => void;
54
57
  disabled?: boolean;
@@ -64,6 +67,7 @@ export const SilkeTextFieldOutline = React.forwardRef<HTMLDivElement, SilkeTextF
64
67
  gap,
65
68
  hPad,
66
69
  hAlign,
70
+ vAlign,
67
71
  inline,
68
72
  children,
69
73
  help,
@@ -71,6 +75,7 @@ export const SilkeTextFieldOutline = React.forwardRef<HTMLDivElement, SilkeTextF
71
75
  helpId,
72
76
  label,
73
77
  labelId,
78
+ labelUsingAria,
74
79
  width,
75
80
  flex,
76
81
  onClick,
@@ -96,6 +101,20 @@ export const SilkeTextFieldOutline = React.forwardRef<HTMLDivElement, SilkeTextF
96
101
 
97
102
  const showError = Boolean(error);
98
103
  const showHelp = Boolean((help || helpRight) && !error);
104
+ const boxSize: BoxSize = size === 'xs' ? 's' : size === 's' ? 'base' : 'm';
105
+
106
+ const labelComponent = label && (
107
+ <SilkeText
108
+ className={styles.label}
109
+ tag="label"
110
+ id={labelUsingAria ? labelId : undefined}
111
+ htmlFor={!labelUsingAria ? labelId : undefined}
112
+ color="neutral-100"
113
+ style={inlineLabelWidth ? { width: `${inlineLabelWidth}px` } : undefined}
114
+ >
115
+ {label}
116
+ </SilkeText>
117
+ );
99
118
  return (
100
119
  <SilkeBox
101
120
  data-size={`data-input-${mappedSize}`}
@@ -108,63 +127,41 @@ export const SilkeTextFieldOutline = React.forwardRef<HTMLDivElement, SilkeTextF
108
127
  onClick={onClick}
109
128
  onMouseDown={onMouseDown}
110
129
  >
111
- {label && (
112
- <SilkeText
113
- className={styles.label}
114
- tag="label"
115
- htmlFor={labelId}
116
- color="neutral-100"
117
- style={inlineLabelWidth ? { width: `${inlineLabelWidth}px` } : undefined}
118
- >
119
- {label}
120
- </SilkeText>
121
- )}
130
+ {inline !== 'label-inside' && labelComponent}
122
131
 
123
132
  <ButtonContext kind="ghost" size="base">
124
133
  <SilkeBox
125
134
  gap={gap}
126
135
  hPad={hPad}
127
136
  hAlign={hAlign}
137
+ vAlign={vAlign}
128
138
  className={styles.field}
129
- flex={inline}
139
+ flex={!!inline}
130
140
  ref={ref}
131
141
  >
142
+ {labelComponent && inline === 'label-inside' && (
143
+ <SilkeTextFieldItem before minWidth={boxSize} hPad="xs">
144
+ {labelComponent}
145
+ </SilkeTextFieldItem>
146
+ )}
132
147
  {children}
133
- <div className={styles.border} />
134
148
  </SilkeBox>
135
149
  </ButtonContext>
136
150
 
137
151
  {!inline && (
138
- <>
139
- {showHelp && (
140
- <SilkeBox hAlign="spread" className={styles.help}>
141
- {help && (
142
- <SilkeText tag="span" flex color="neutral-80" id={helpId}>
143
- {help}
144
- </SilkeText>
145
- )}
146
- {helpRight && <SilkeText>{helpRight}</SilkeText>}
147
- </SilkeBox>
152
+ <SilkeBox hAlign="spread" className={styles.help}>
153
+ {showHelp && help && (
154
+ <SilkeText flex id={helpId}>
155
+ {help}
156
+ </SilkeText>
148
157
  )}
158
+ {showHelp && helpRight && <SilkeText>{helpRight}</SilkeText>}
149
159
  {showError && (
150
- <SilkeBox height="s">
151
- <SilkeText
152
- flex
153
- tag="small"
154
- className={styles.formErrorMessage}
155
- color="error-30"
156
- aria-live="polite"
157
- role="alert"
158
- >
159
- {error}{' '}
160
- <SilkeIcon
161
- icon="error.circle"
162
- style={{ fontSize: '1.25rem', paddingLeft: '4px', verticalAlign: 'middle' }}
163
- />
164
- </SilkeText>
165
- </SilkeBox>
160
+ <SilkeText flex aria-live="polite" role="alert">
161
+ {error}
162
+ </SilkeText>
166
163
  )}
167
- </>
164
+ </SilkeBox>
168
165
  )}
169
166
  </SilkeBox>
170
167
  );
@@ -6,9 +6,9 @@
6
6
  const [value, setValue] = React.useState("");
7
7
 
8
8
  <SilkeBox column gap="l">
9
- {["default", "secondary", "ghost"].map((kind) => (
10
- <SilkeBox key={kind} gap="l" vAlign="end">
11
- {["xs", "s", "base", "l", undefined].map((size) => (
9
+ {["default", "zombie", "ghost"].map((kind) =>
10
+ ["base", "s", "xs"].map((size) => (
11
+ <SilkeBox key={kind} gap="l" vAlign="end">
12
12
  <SilkeTextField
13
13
  flex
14
14
  key={size || "default"}
@@ -20,9 +20,75 @@ const [value, setValue] = React.useState("");
20
20
  value={value}
21
21
  onChange={setValue}
22
22
  />
23
- ))}
24
- </SilkeBox>
25
- ))}
23
+ <SilkeTextField
24
+ flex
25
+ error="Got error"
26
+ key={size || "default"}
27
+ label={`${kind || "default"} - ${size}`}
28
+ placeholder={kind || "default" + " " + size}
29
+ size={size}
30
+ kind={kind}
31
+ value={value}
32
+ onChange={setValue}
33
+ />
34
+ <SilkeTextField
35
+ flex
36
+ disabled
37
+ key={size || "default"}
38
+ label={`${kind || "default"} - ${size}`}
39
+ placeholder={kind || "default" + " " + size}
40
+ size={size}
41
+ kind={kind}
42
+ help={kind + " -- " + "help"}
43
+ value={value}
44
+ onChange={setValue}
45
+ />
46
+ </SilkeBox>
47
+ ))
48
+ )}
49
+ </SilkeBox>;
50
+ ```
51
+
52
+ ## Inline fields
53
+
54
+ ```js
55
+ const [value, setValue] = React.useState("");
56
+
57
+ <SilkeBox column gap="l">
58
+ {["default", "zombie", "ghost"].map((kind) =>
59
+ ["base", "s", "xs"].map((size) => (
60
+ <SilkeBox key={kind} gap="l" vAlign="center">
61
+ <SilkeBox width="xxl">
62
+ {kind}/{size}
63
+ </SilkeBox>
64
+ <SilkeTextField
65
+ flex
66
+ inline
67
+ key={size || "default"}
68
+ label={`${kind || "default"} - ${size}`}
69
+ placeholder={kind || "default" + " " + size}
70
+ size={size}
71
+ kind={kind}
72
+ help={kind + " -- " + "help"}
73
+ value={value}
74
+ onChange={setValue}
75
+ />
76
+ <SilkeTextField
77
+ flex
78
+ inline="label-inside"
79
+ key={size || "default"}
80
+ label={`${kind || "default"} - ${size}`}
81
+ placeholder={kind || "default" + " " + size}
82
+ size={size}
83
+ kind={kind}
84
+ error="Testing"
85
+ help={kind + " -- " + "help"}
86
+ value={value}
87
+ onChange={setValue}
88
+ />
89
+ </SilkeBox>
90
+ ))
91
+ )}
26
92
  </SilkeBox>;
27
93
  ```
28
94
 
@@ -92,6 +158,7 @@ const items = ipsum.list((i) => ({
92
158
  <SilkeTextFieldItem>
93
159
  <SilkeSelectField
94
160
  kind="ghost"
161
+ inline
95
162
  onChange={() => console.log("selected")}
96
163
  value={items[1].value}
97
164
  items={items}