@vev/silke 1.1.6 → 1.1.7

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 (157) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/index.js +35 -35
  3. package/dist/index.js.LEGAL.txt +12 -12
  4. package/dist/styles.css +4416 -4020
  5. package/dist/types/components/index.d.ts +3 -2
  6. package/dist/types/components/silke-button/silke-dropdown-button.d.ts +8 -13
  7. package/dist/types/components/silke-card/silke-card-grid.d.ts +33 -1
  8. package/dist/types/components/silke-command-text-field/image-utils.d.ts +20 -0
  9. package/dist/types/components/silke-command-text-field/index.d.ts +4 -0
  10. package/dist/types/components/silke-command-text-field/silke-command-parser.d.ts +3 -0
  11. package/dist/types/components/silke-command-text-field/silke-command-parser.spec.d.ts +1 -0
  12. package/dist/types/components/silke-command-text-field/silke-command-text-field.d.ts +46 -0
  13. package/dist/types/components/silke-command-text-field/utils.d.ts +61 -0
  14. package/dist/types/components/silke-command-text-field/utils.spec.d.ts +1 -0
  15. package/dist/types/components/silke-form-schema/silke-schema-fields.d.ts +1 -0
  16. package/dist/types/components/silke-image/silke-image.d.ts +2 -1
  17. package/dist/types/components/silke-list/index.d.ts +1 -0
  18. package/dist/types/components/silke-list/silke-list-item.d.ts +24 -6
  19. package/dist/types/components/silke-list/silke-list.d.ts +9 -9
  20. package/dist/types/components/silke-list/types.d.ts +19 -0
  21. package/dist/types/components/silke-list/utils.d.ts +3 -0
  22. package/dist/types/components/silke-navigation-link/silke-navigation-link.d.ts +1 -0
  23. package/dist/types/components/silke-overflow-menu/silke-overflow-menu.d.ts +6 -1
  24. package/dist/types/components/silke-popover-native/silke-popover-native.d.ts +3 -1
  25. package/dist/types/components/silke-shortcut-button/index.d.ts +1 -0
  26. package/dist/types/components/silke-shortcut-button/silke-shortcut-button.d.ts +15 -0
  27. package/dist/types/components/silke-tag/silke-tag.d.ts +1 -1
  28. package/dist/types/icons.d.ts +30 -0
  29. package/jest.config.js +2 -3
  30. package/package.json +7 -2
  31. package/src/_variables.scss +125 -129
  32. package/src/components/index.ts +3 -2
  33. package/src/components/silke-action-box/silke-action-box.scss +2 -3
  34. package/src/components/silke-alert-banner/silke-alert-banner.scss +9 -10
  35. package/src/components/silke-autocomplete-field/autocomplete-item.tsx +2 -2
  36. package/src/components/silke-autocomplete-field/silke-autocomplete-field.scss +18 -12
  37. package/src/components/silke-autocomplete-field/silke-autocomplete-popup-native.tsx +3 -2
  38. package/src/components/silke-autocomplete-field/silke-autocomplete-popup.tsx +63 -44
  39. package/src/components/silke-box/silke-box.mdx +321 -21
  40. package/src/components/silke-box/silke-box.scss +5 -5
  41. package/src/components/silke-breadcrumbs/silke-breadcrumb.mdx +147 -9
  42. package/src/components/silke-breadcrumbs/silke-breadcrumb.scss +3 -3
  43. package/src/components/silke-button/silke-big-button.scss +1 -1
  44. package/src/components/silke-button/silke-button.scss +24 -15
  45. package/src/components/silke-button/silke-dropdown-button.mdx +67 -0
  46. package/src/components/silke-button/silke-dropdown-button.tsx +40 -122
  47. package/src/components/silke-card/silke-card-grid.tsx +5 -3
  48. package/src/components/silke-card/silke-card.scss +8 -7
  49. package/src/components/silke-card/silke-card.tsx +7 -1
  50. package/src/components/silke-checkbox/silke-checkbox.mdx +139 -14
  51. package/src/components/silke-checkbox/silke-checkbox.scss +11 -11
  52. package/src/components/silke-color-picker/color-picker.scss +8 -8
  53. package/src/components/silke-color-swatches/silke-color-swatches.mdx +130 -0
  54. package/src/components/silke-command-text-field/image-utils.ts +71 -0
  55. package/src/components/silke-command-text-field/index.ts +12 -0
  56. package/src/components/silke-command-text-field/silke-command-parser.spec.ts +89 -0
  57. package/src/components/silke-command-text-field/silke-command-parser.ts +47 -0
  58. package/src/components/silke-command-text-field/silke-command-text-field.mdx +301 -0
  59. package/src/components/silke-command-text-field/silke-command-text-field.module.scss +119 -0
  60. package/src/components/silke-command-text-field/silke-command-text-field.tsx +665 -0
  61. package/src/components/silke-command-text-field/utils.spec.ts +366 -0
  62. package/src/components/silke-command-text-field/utils.ts +287 -0
  63. package/src/components/silke-conditions-input/silke-conditions-input.scss +4 -4
  64. package/src/components/silke-content-column/silke-content-column.scss +1 -1
  65. package/src/components/silke-context-menu/silke-context-menu.scss +3 -4
  66. package/src/components/silke-context-menu/silke-context-menu.tsx +1 -1
  67. package/src/components/silke-css-number-field/silke-css-number-field.scss +14 -12
  68. package/src/components/silke-divider/silke-divider.mdx +154 -32
  69. package/src/components/silke-divider/silke-divider.scss +3 -2
  70. package/src/components/silke-drawer/silke-drawer.scss +6 -2
  71. package/src/components/silke-form/silke-form.mdx +254 -27
  72. package/src/components/silke-form-schema/fields/array-field-inline.tsx +1 -0
  73. package/src/components/silke-form-schema/fields/array-field-modal.tsx +1 -0
  74. package/src/components/silke-form-schema/fields/styles.scss +34 -35
  75. package/src/components/silke-form-schema/silke-schema-fields.tsx +4 -3
  76. package/src/components/silke-gradient-picker/silke-gradient-picker.module.scss +2 -2
  77. package/src/components/silke-icon/silke-icon.mdx +212 -8
  78. package/src/components/silke-icon/silke-icon.scss +10 -2
  79. package/src/components/silke-icon/silke-icon.tsx +1 -0
  80. package/src/components/silke-icon/silke-stacked-icon.scss +42 -45
  81. package/src/components/silke-icon-browser/silke-icon-browser.mdx +143 -0
  82. package/src/components/silke-image/silke-image-color-backdrop.scss +6 -6
  83. package/src/components/silke-image/silke-image.mdx +189 -41
  84. package/src/components/silke-image/silke-image.scss +3 -3
  85. package/src/components/silke-image/silke-image.tsx +14 -1
  86. package/src/components/silke-link/silke-link.scss +3 -5
  87. package/src/components/silke-list/index.ts +1 -0
  88. package/src/components/silke-list/silke-list-item.mdx +83 -0
  89. package/src/components/silke-list/silke-list-item.scss +119 -0
  90. package/src/components/silke-list/silke-list-item.tsx +137 -12
  91. package/src/components/silke-list/silke-list.mdx +108 -13
  92. package/src/components/silke-list/silke-list.scss +8 -15
  93. package/src/components/silke-list/silke-list.tsx +63 -9
  94. package/src/components/silke-list/types.ts +22 -0
  95. package/src/components/silke-list/utils.ts +24 -0
  96. package/src/components/silke-loader/silke-loader.mdx +139 -5
  97. package/src/components/silke-loader/silke-loader.scss +1 -1
  98. package/src/components/silke-modal/silke-modal.scss +9 -9
  99. package/src/components/silke-navigation-link/silke-navigation-link.mdx +27 -2
  100. package/src/components/silke-navigation-link/silke-navigation-link.scss +34 -40
  101. package/src/components/silke-navigation-link/silke-navigation-link.tsx +7 -6
  102. package/src/components/silke-overflow-menu/silke-overflow-menu.mdx +228 -31
  103. package/src/components/silke-overflow-menu/silke-overflow-menu.scss +8 -8
  104. package/src/components/silke-overflow-menu/silke-overflow-menu.tsx +14 -8
  105. package/src/components/silke-popover/silke-popover.scss +5 -5
  106. package/src/components/silke-popover-native/silke-popover-native.scss +93 -78
  107. package/src/components/silke-popover-native/silke-popover-native.tsx +4 -0
  108. package/src/components/silke-popover-native/use-popover-positioning.ts +1 -3
  109. package/src/components/silke-progress-indicator/silke-progress-indicator.scss +1 -1
  110. package/src/components/silke-radio-button/silke-radio-button.scss +18 -11
  111. package/src/components/silke-search-field/silke-search-field.mdx +161 -7
  112. package/src/components/silke-shortcut-button/index.ts +1 -0
  113. package/src/components/silke-shortcut-button/silke-shortcut-button.mdx +89 -0
  114. package/src/components/silke-shortcut-button/silke-shortcut-button.scss +145 -0
  115. package/src/components/silke-shortcut-button/silke-shortcut-button.tsx +55 -0
  116. package/src/components/silke-skeleton/silke-skeleton.mdx +109 -0
  117. package/src/components/silke-skeleton/silke-skeleton.scss +1 -1
  118. package/src/components/silke-slider/silke-slider.module.scss +19 -19
  119. package/src/components/silke-sortable-list/silke-nested-sortable-list.scss +3 -3
  120. package/src/components/silke-sortable-list/silke-sortable-list.scss +4 -5
  121. package/src/components/silke-table/silke-table.scss +1 -1
  122. package/src/components/silke-tabs/silke-tabs.scss +3 -3
  123. package/src/components/silke-tag/silke-tag.mdx +179 -43
  124. package/src/components/silke-tag/silke-tag.scss +49 -12
  125. package/src/components/silke-tag/silke-tag.tsx +17 -7
  126. package/src/components/silke-text/silke-text.scss +6 -4
  127. package/src/components/silke-text/silke-title.scss +7 -14
  128. package/src/components/silke-text-field/silke-text-field.scss +9 -9
  129. package/src/components/silke-text-field/silke-text-field.tsx +1 -1
  130. package/src/components/silke-tile/silke-tile.scss +7 -3
  131. package/src/components/silke-toast-notification/silke-toast-notification.scss +4 -5
  132. package/src/components/silke-toggle/silke-toggle.mdx +163 -33
  133. package/src/components/silke-toggle/silke-toggle.scss +4 -4
  134. package/src/components/silke-toolbar/silke-toolbar.scss +1 -1
  135. package/src/components/silke-tooltip/silke-shortcuts.tsx +3 -3
  136. package/src/components/silke-tooltip/silke-tooltip.scss +11 -16
  137. package/src/components/silke-variables-wrapper/silke-variables-wrapper.scss +9 -7
  138. package/src/components/silke-virtual/silke-virtual.mdx +161 -0
  139. package/src/components/silke-virtual/silke-virtual.scss +8 -8
  140. package/src/icons.tsx +43 -1
  141. package/src/styles/core.scss +42 -45
  142. package/src/styles/math.scss +66 -66
  143. package/tsconfig.build.json +2 -6
  144. package/tsconfig.build.tsbuildinfo +1 -1
  145. package/tsconfig.json +3 -14
  146. package/dist/types/components/silke-action-list/index.d.ts +0 -1
  147. package/dist/types/components/silke-action-list/silke-action-list.d.ts +0 -11
  148. package/dist/types/components/silke-list-card/index.d.ts +0 -1
  149. package/dist/types/components/silke-list-card/silke-list-card.d.ts +0 -14
  150. package/src/components/silke-action-list/index.ts +0 -1
  151. package/src/components/silke-action-list/silke-action-list.mdx +0 -48
  152. package/src/components/silke-action-list/silke-action-list.scss +0 -21
  153. package/src/components/silke-action-list/silke-action-list.tsx +0 -85
  154. package/src/components/silke-list-card/index.ts +0 -1
  155. package/src/components/silke-list-card/silke-list-card.mdx +0 -46
  156. package/src/components/silke-list-card/silke-list-card.scss +0 -57
  157. package/src/components/silke-list-card/silke-list-card.tsx +0 -63
@@ -126,7 +126,7 @@ export function SilkeContextMenu({
126
126
  )}
127
127
  {(isFunction(items) ? items() : items)?.map((item, index) => {
128
128
  return !item ? null : React.isValidElement(item) ? (
129
- item
129
+ <React.Fragment key={index}>{item}</React.Fragment>
130
130
  ) : item === 'divider' ? (
131
131
  <SilkeBox key={index} vPad="xs" column>
132
132
  <SilkeDivider dark />
@@ -1,4 +1,4 @@
1
- @use "../../variables" as *;
1
+ @use '../../variables' as *;
2
2
 
3
3
  .root {
4
4
  overflow: hidden;
@@ -10,7 +10,7 @@
10
10
  }
11
11
  }
12
12
 
13
- &.openFormat.openFormat{
13
+ &.openFormat.openFormat {
14
14
  --text-field-bg: var(--color-neutral-20);
15
15
  --text-field-hover-bg: var(--color-neutral-20);
16
16
  --text-field-focus-border-color: transparent;
@@ -27,25 +27,25 @@
27
27
  justify-self: end;
28
28
  overflow: hidden;
29
29
  min-width: 1px;
30
-
31
- padding:0 !important;
30
+
31
+ padding: 0 !important;
32
32
  flex: none !important;
33
33
  text-align: right;
34
34
  position: relative;
35
35
  // width: auto !important;
36
-
36
+
37
37
  &.hasFormats,
38
38
  &.hasVariables {
39
39
  max-width: calc(100% - 16px);
40
40
  }
41
41
  }
42
42
 
43
- .inputHolder{
44
- &:first-child{
43
+ .inputHolder {
44
+ &:first-child {
45
45
  padding: 0 4px;
46
46
  }
47
- &:not(:first-child){
48
- padding:0;
47
+ &:not(:first-child) {
48
+ padding: 0;
49
49
  }
50
50
  }
51
51
 
@@ -58,7 +58,7 @@
58
58
  }
59
59
 
60
60
  .noneValue:not(.disabled) {
61
- .field{
61
+ .field {
62
62
  color: var(--color-neutral-70);
63
63
  }
64
64
  }
@@ -88,10 +88,12 @@
88
88
  font-size: 0.845em;
89
89
  transform: translateX(4px);
90
90
  color: var(--text-field-placeholder-color);
91
- transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;
91
+ transition:
92
+ opacity 0.2s ease-in-out,
93
+ transform 0.2s ease-in-out;
92
94
  }
93
95
 
94
96
  .downIcon:hover,
95
97
  .openFormat .downIcon {
96
98
  color: var(--text-field-color);
97
- }
99
+ }
@@ -1,50 +1,172 @@
1
- # Divider
1
+ # SilkeDivider
2
+
3
+ A visual separator component for dividing content sections. Supports horizontal and vertical orientations with configurable spacing.
4
+
5
+ ## Features
6
+
7
+ - **Horizontal/Vertical**: Separate content in either direction
8
+ - **Configurable spacing**: Add space before, after, or both sides
9
+ - **Light/Dark modes**: Match your design context
10
+ - **Flexible spacing sizes**: From xxs to xxxl
11
+
12
+ ## Basic Usage
13
+
14
+ ```js
15
+ <SilkeBox column gap="s">
16
+ <SilkeText>Content above</SilkeText>
17
+ <SilkeDivider />
18
+ <SilkeText>Content below</SilkeText>
19
+ </SilkeBox>
20
+ ```
2
21
 
3
22
  ## Horizontal Divider
4
23
 
24
+ The default divider is horizontal:
25
+
5
26
  ```js
6
27
  <SilkeBox column>
7
- Simple divider no space
8
- <SilkeDivider />
9
- Line under should have space before and after
10
- <SilkeDivider vSpace="l" />
11
- Line under has only space before
12
- <SilkeDivider vSpace="before-l" />
13
- Line under has only space after
28
+ <SilkeText>Section 1</SilkeText>
29
+ <SilkeDivider space="m" />
30
+ <SilkeText>Section 2</SilkeText>
31
+ <SilkeDivider space="m" />
32
+ <SilkeText>Section 3</SilkeText>
33
+ </SilkeBox>
34
+ ```
35
+
36
+ ## Vertical Divider
37
+
38
+ Use `vertical` to separate content horizontally:
39
+
40
+ ```js
41
+ <SilkeBox vAlign="center">
42
+ <SilkeText>Left</SilkeText>
43
+ <SilkeDivider vertical space="m" />
44
+ <SilkeText>Middle</SilkeText>
45
+ <SilkeDivider vertical space="m" />
46
+ <SilkeText>Right</SilkeText>
47
+ </SilkeBox>
48
+ ```
49
+
50
+ ## Spacing Options
51
+
52
+ ### Uniform Spacing
53
+
54
+ Add equal spacing on both sides:
55
+
56
+ ```js
57
+ <SilkeBox column bg="neutral-10" pad="s" rounded>
58
+ {['xxs', 'xs', 's', 'm', 'l', 'xl'].map((size) => (
59
+ <React.Fragment key={size}>
60
+ <SilkeText size="s">space="{size}"</SilkeText>
61
+ <SilkeDivider space={size} />
62
+ </React.Fragment>
63
+ ))}
64
+ <SilkeText size="s">End</SilkeText>
65
+ </SilkeBox>
66
+ ```
67
+
68
+ ### Asymmetric Spacing
69
+
70
+ Add space only before or after the divider:
71
+
72
+ ```js
73
+ <SilkeBox column bg="neutral-10" pad="s" rounded>
74
+ <SilkeText>No space below</SilkeText>
14
75
  <SilkeDivider vSpace="after-l" />
15
- You can do all of this with hSpace
16
- <SilkeDivider hSpace="before-xxl" />
17
- Or with both
18
- <SilkeDivider space="xl" />
76
+ <SilkeText>Space above, no space below</SilkeText>
77
+ <SilkeDivider vSpace="before-l" />
78
+ <SilkeText>Space above only</SilkeText>
19
79
  </SilkeBox>
20
80
  ```
21
81
 
22
- ## Vertical divider
82
+ ### Separate Horizontal and Vertical Spacing
23
83
 
24
84
  ```js
25
- <SilkeBox>
26
- You can do all the same things as we did with horizontal divider, just vertically
27
- <SilkeDivider vertical />
28
- Line on right should have space before and after
29
- <SilkeDivider vertical hSpace="l" />
30
- Line on right has only space before
31
- <SilkeDivider vertical hSpace="before-l" />
32
- Line on right has only space after
33
- <SilkeDivider vertical hSpace="after-l" />
34
- You can do all of this with hSpace
35
- <SilkeDivider vertical vSpace="before-xxl" />
36
- Or with both
37
- <SilkeDivider vertical space="xl" />
85
+ <SilkeBox column bg="neutral-10" rounded>
86
+ <SilkeText>Horizontal and vertical spacing</SilkeText>
87
+ <SilkeDivider vSpace="m" hSpace="xl" />
88
+ <SilkeText>Notice the indented divider</SilkeText>
38
89
  </SilkeBox>
39
90
  ```
40
91
 
41
- ## Make it dark if you want
92
+ ## Dark Mode
93
+
94
+ Use `dark` for a more prominent divider:
42
95
 
43
96
  ```js
44
- <SilkeBox column>
45
- Simple divider no space
46
- <SilkeDivider dark />
47
- Line under should have space before and after
48
- <SilkeDivider dark vSpace="l" />
97
+ <SilkeBox column gap="m">
98
+ <SilkeBox column bg="neutral-10" pad="s" rounded>
99
+ <SilkeText>Light divider (default)</SilkeText>
100
+ <SilkeDivider space="s" />
101
+ <SilkeText>Subtle separation</SilkeText>
102
+ </SilkeBox>
103
+ <SilkeBox column bg="neutral-10" pad="s" rounded>
104
+ <SilkeText>Dark divider</SilkeText>
105
+ <SilkeDivider dark space="s" />
106
+ <SilkeText>More prominent separation</SilkeText>
107
+ </SilkeBox>
108
+ </SilkeBox>
109
+ ```
110
+
111
+ ## In a Navigation
112
+
113
+ ```js
114
+ <SilkeBox column gap="xs" style={{ width: 200 }}>
115
+ <SilkeButton kind="ghost" label="Dashboard" icon="home" />
116
+ <SilkeButton kind="ghost" label="Projects" icon="folder" />
117
+ <SilkeDivider space="xs" />
118
+ <SilkeButton kind="ghost" label="Settings" icon="settings" />
119
+ <SilkeButton kind="ghost" label="Help" icon="help" />
120
+ </SilkeBox>
121
+ ```
122
+
123
+ ## In a Toolbar
124
+
125
+ ```js
126
+ <SilkeBox gap="xs" vAlign="center" pad="xs" bg="neutral-10" rounded>
127
+ <SilkeButton kind="ghost" icon="bold" />
128
+ <SilkeButton kind="ghost" icon="italic" />
129
+ <SilkeButton kind="ghost" icon="underline" />
130
+ <SilkeDivider vertical space="xs" />
131
+ <SilkeButton kind="ghost" icon="align.left" />
132
+ <SilkeButton kind="ghost" icon="align.center" />
133
+ <SilkeButton kind="ghost" icon="align.right" />
134
+ <SilkeDivider vertical space="xs" />
135
+ <SilkeButton kind="ghost" icon="list.bullet" />
136
+ <SilkeButton kind="ghost" icon="list.number" />
49
137
  </SilkeBox>
50
138
  ```
139
+
140
+ ## Props
141
+
142
+ | Prop | Type | Default | Description |
143
+ | ---------- | --------------------- | ------- | ------------------------------------------ |
144
+ | `vertical` | `boolean` | `false` | Render as vertical divider |
145
+ | `dark` | `boolean` | `false` | Use darker/more prominent line |
146
+ | `space` | `DividerSpace` | - | Spacing on both axes |
147
+ | `vSpace` | `DividerSpace` | - | Vertical spacing (top/bottom) |
148
+ | `hSpace` | `DividerSpace` | - | Horizontal spacing (left/right) |
149
+
150
+ ## Types
151
+
152
+ ```typescript
153
+ type DividerSpaceSize = 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl' | 'xxxl';
154
+
155
+ type SpacePlacement = 'before' | 'after';
156
+
157
+ // Use size for uniform spacing, or 'before-size'/'after-size' for asymmetric
158
+ type DividerSpace = DividerSpaceSize | `${SpacePlacement}-${DividerSpaceSize}`;
159
+ ```
160
+
161
+ ## Spacing Reference
162
+
163
+ | Size | Pixels |
164
+ | ------ | ------ |
165
+ | `xxs` | 2px |
166
+ | `xs` | 4px |
167
+ | `s` | 8px |
168
+ | `m` | 16px |
169
+ | `l` | 24px |
170
+ | `xl` | 32px |
171
+ | `xxl` | 48px |
172
+ | `xxxl` | 64px |
@@ -1,4 +1,4 @@
1
- @use "../../variables" as *;
1
+ @use '../../variables' as *;
2
2
 
3
3
  .light {
4
4
  background-color: rgba(var(--color-neutral-70-rgb), var(--opacity-level-light));
@@ -11,12 +11,13 @@
11
11
  width: 1px;
12
12
  min-width: 1px;
13
13
  max-width: 1px;
14
- height:100%;
14
+ height: 100%;
15
15
  }
16
16
  .horizontal {
17
17
  height: 1px;
18
18
  max-height: 1px;
19
19
  min-height: 1px;
20
+ width: 100%;
20
21
  }
21
22
 
22
23
  @each $name, $size in $space {
@@ -23,12 +23,16 @@
23
23
 
24
24
  &.fader:after {
25
25
  position: absolute;
26
- content: "";
26
+ content: '';
27
27
  width: 100%;
28
28
  height: 90px;
29
29
  bottom: 0;
30
30
  left: 0;
31
- background: linear-gradient(180deg, rgba(var(--color-neutral-5-rgb), 0) 0%, rgba(var(--color-neutral-5-rgb), var(--opacity-level-semiopaque)) 100%);
31
+ background: linear-gradient(
32
+ 180deg,
33
+ rgba(var(--color-neutral-5-rgb), 0) 0%,
34
+ rgba(var(--color-neutral-5-rgb), var(--opacity-level-semiopaque)) 100%
35
+ );
32
36
  }
33
37
  }
34
38
 
@@ -1,34 +1,261 @@
1
- # Form component
1
+ # SilkeForm
2
2
 
3
- you need forms
3
+ A form container component that manages form state, validation, and submission. It automatically connects child form fields by their `name` prop, handling value binding and error propagation.
4
+
5
+ ## Features
6
+
7
+ - **Automatic state management**: Child fields connect via `name` prop
8
+ - **Type-safe**: Generic type support for form values
9
+ - **Validation**: Built-in validation with error tracking
10
+ - **Submit handling**: Prevents default form submission
11
+ - **External errors**: Inject errors from API responses
12
+ - **Nested objects**: Support for nested form structures
13
+
14
+ ## Basic Usage
15
+
16
+ ```js
17
+ const [formData, setFormData] = React.useState({
18
+ username: '',
19
+ email: '',
20
+ });
21
+
22
+ <SilkeForm value={formData} onChange={setFormData}>
23
+ <SilkeTextField name="username" label="Username" required />
24
+ <SilkeTextField name="email" label="Email" />
25
+ <SilkeButton type="submit" label="Submit" />
26
+ </SilkeForm>;
27
+ ```
28
+
29
+ ## With Submit Handler
30
+
31
+ Handle form submission with validation status:
32
+
33
+ ```js
34
+ const [formData, setFormData] = React.useState({ name: '', agree: false });
35
+ const [submitted, setSubmitted] = React.useState(null);
36
+
37
+ <SilkeBox column gap="m">
38
+ <SilkeForm
39
+ value={formData}
40
+ onChange={setFormData}
41
+ onSubmit={(data, isValid) => {
42
+ if (isValid) setSubmitted(data);
43
+ }}
44
+ >
45
+ <SilkeTextField name="name" label="Your name" required />
46
+ <SilkeCheckbox name="agree" label="I agree to terms" required />
47
+ <SilkeButton type="submit" label="Submit" />
48
+ </SilkeForm>
49
+ {submitted && (
50
+ <SilkeBox bg="success-10" pad="s" rounded>
51
+ <SilkeText>Submitted: {JSON.stringify(submitted)}</SilkeText>
52
+ </SilkeBox>
53
+ )}
54
+ </SilkeBox>;
55
+ ```
56
+
57
+ ## Tracking Errors
58
+
59
+ Monitor validation errors with `onErrors`:
4
60
 
5
61
  ```js
6
- const [change, setChange] = React.useState({});
7
- const [submit, setSubmit] = React.useState({});
62
+ const [formData, setFormData] = React.useState({ email: '' });
8
63
  const [errors, setErrors] = React.useState({});
9
- const [items] = React.useState(ipsum.list((i) => ({ value: i, label: ipsum.name() })));
10
-
11
- <SilkeForm value={change} onSubmit={setSubmit} onChange={setChange} onErrors={setErrors}>
12
- <SilkeTextField name="text" required />
13
- <SilkeIconPicker name="icon" />
14
- <SilkeCheckbox name="checkbox1" label="Checkbox" />
15
- <SilkeCheckbox name="checkbox2" label="Checkbox 2" required />
16
- <SilkeSelectField name="select" required items={items} />
17
- <SilkeRadioButtonGroup name="select" required items={items} />
18
- <SilkeAutocompleteField name="autocomplete" multiple maxItems={2} items={items}>
19
- <SilkeTextFieldItem>
20
- <SilkeButton label="Send" icon="arrow.right" />
21
- </SilkeTextFieldItem>
22
- </SilkeAutocompleteField>
23
- <SilkeObjectField name="object">
24
- <SilkeTextField name="item" />
64
+
65
+ <SilkeBox column gap="m">
66
+ <SilkeForm value={formData} onChange={setFormData} onErrors={setErrors}>
67
+ <SilkeTextField name="email" label="Email" required />
68
+ </SilkeForm>
69
+ {Object.keys(errors).length > 0 && (
70
+ <SilkeBox bg="error-10" pad="s" rounded>
71
+ <SilkeText size="s">Errors: {JSON.stringify(errors)}</SilkeText>
72
+ </SilkeBox>
73
+ )}
74
+ </SilkeBox>;
75
+ ```
76
+
77
+ ## External Errors
78
+
79
+ Inject errors from API responses (e.g., server-side validation):
80
+
81
+ ```js
82
+ const [formData, setFormData] = React.useState({ username: 'taken_name' });
83
+ const [externalErrors, setExternalErrors] = React.useState({});
84
+
85
+ <SilkeBox column gap="m">
86
+ <SilkeForm value={formData} onChange={setFormData} errors={externalErrors}>
87
+ <SilkeTextField name="username" label="Username" />
88
+ <SilkeBox gap="s">
89
+ <SilkeButton
90
+ label="Simulate API Error"
91
+ onClick={() => setExternalErrors({ username: 'Username already taken' })}
92
+ />
93
+ <SilkeButton label="Clear Error" kind="secondary" onClick={() => setExternalErrors({})} />
94
+ </SilkeBox>
95
+ </SilkeForm>
96
+ </SilkeBox>;
97
+ ```
98
+
99
+ ## Mixed Field Types
100
+
101
+ Combine different field types in a single form:
102
+
103
+ ```js
104
+ const [formData, setFormData] = React.useState({
105
+ name: '',
106
+ role: '',
107
+ notifications: false,
108
+ });
109
+ const roleOptions = [
110
+ { value: 'admin', label: 'Administrator' },
111
+ { value: 'user', label: 'User' },
112
+ { value: 'guest', label: 'Guest' },
113
+ ];
114
+
115
+ <SilkeForm value={formData} onChange={setFormData}>
116
+ <SilkeTextField name="name" label="Full Name" required />
117
+ <SilkeSelectField name="role" label="Role" items={roleOptions} required />
118
+ <SilkeCheckbox name="notifications" label="Enable email notifications" />
119
+ <SilkeButton type="submit" label="Save Settings" />
120
+ </SilkeForm>;
121
+ ```
122
+
123
+ ## Nested Objects
124
+
125
+ Use `SilkeObjectField` for nested form structures:
126
+
127
+ ```js
128
+ const [formData, setFormData] = React.useState({
129
+ user: { firstName: '', lastName: '' },
130
+ address: { city: '', country: '' },
131
+ });
132
+
133
+ <SilkeForm value={formData} onChange={setFormData}>
134
+ <SilkeObjectField name="user">
135
+ <SilkeBox gap="s">
136
+ <SilkeTextField name="firstName" label="First Name" />
137
+ <SilkeTextField name="lastName" label="Last Name" />
138
+ </SilkeBox>
25
139
  </SilkeObjectField>
26
- <SilkeButtonSet>
27
- <SilkeButton label="Reset" kind="secondary" />
28
- <SilkeButton type="submit" label="Submit automatic disables" />
29
- </SilkeButtonSet>
30
- <pre>Errors:{JSON.stringify(errors, null, 1)}</pre>
31
- <pre>Change:{JSON.stringify(change, null, 1)}</pre>
32
- <pre>Submit:{JSON.stringify(submit, null, 1)}</pre>
140
+ <SilkeObjectField name="address">
141
+ <SilkeBox gap="s">
142
+ <SilkeTextField name="city" label="City" />
143
+ <SilkeTextField name="country" label="Country" />
144
+ </SilkeBox>
145
+ </SilkeObjectField>
146
+ <SilkeButton type="submit" label="Submit" />
147
+ </SilkeForm>;
148
+ ```
149
+
150
+ ## Using SilkeFormFields
151
+
152
+ Wrap fields in `SilkeFormFields` for consistent spacing:
153
+
154
+ ```js
155
+ const [formData, setFormData] = React.useState({});
156
+
157
+ <SilkeForm value={formData} onChange={setFormData}>
158
+ <SilkeFormFields>
159
+ <SilkeTextField name="field1" label="Field 1" />
160
+ <SilkeTextField name="field2" label="Field 2" />
161
+ <SilkeTextField name="field3" label="Field 3" />
162
+ </SilkeFormFields>
163
+ <SilkeButton type="submit" label="Submit" />
33
164
  </SilkeForm>;
34
165
  ```
166
+
167
+ ## Live Form Data Preview
168
+
169
+ ```js
170
+ const [formData, setFormData] = React.useState({
171
+ title: '',
172
+ description: '',
173
+ priority: 'medium',
174
+ isPublic: false,
175
+ });
176
+ const priorityOptions = [
177
+ { value: 'low', label: 'Low' },
178
+ { value: 'medium', label: 'Medium' },
179
+ { value: 'high', label: 'High' },
180
+ ];
181
+
182
+ <SilkeBox gap="l">
183
+ <SilkeBox flex>
184
+ <SilkeForm value={formData} onChange={setFormData}>
185
+ <SilkeFormFields>
186
+ <SilkeTextField name="title" label="Title" required />
187
+ <SilkeTextField name="description" label="Description" />
188
+ <SilkeSelectField name="priority" label="Priority" items={priorityOptions} />
189
+ <SilkeCheckbox name="isPublic" label="Make public" />
190
+ </SilkeFormFields>
191
+ </SilkeForm>
192
+ </SilkeBox>
193
+ <SilkeBox flex>
194
+ <SilkeCodeSnippet code={JSON.stringify(formData, null, 2)} />
195
+ </SilkeBox>
196
+ </SilkeBox>;
197
+ ```
198
+
199
+ ## Props
200
+
201
+ | Prop | Type | Default | Description |
202
+ | ----------- | --------------------------------------------- | ------- | ------------------------------------------------ |
203
+ | `value` | `T` | `{}` | Current form values |
204
+ | `onChange` | `(value: T, valid?: boolean) => void` | - | Called on any field change |
205
+ | `onSubmit` | `(value: T, valid?: boolean) => void` | - | Called on form submission |
206
+ | `onErrors` | `(errors: ErrorMap<T>) => void` | - | Called when error map changes |
207
+ | `errors` | `{ [key in keyof T]?: string }` | - | External errors to inject |
208
+ | `className` | `string` | - | Additional CSS class names |
209
+ | `styles` | `React.CSSProperties` | - | Inline styles |
210
+
211
+ Also accepts all `SilkeBox` props (except `tag`, `onChange`, `onSubmit`).
212
+
213
+ ## SilkeFormFields
214
+
215
+ A wrapper component that applies consistent vertical spacing between form fields:
216
+
217
+ ```typescript
218
+ <SilkeFormFields>
219
+ {children}
220
+ </SilkeFormFields>
221
+ ```
222
+
223
+ Renders children in a column with `gap="l"` spacing.
224
+
225
+ ## Types
226
+
227
+ ```typescript
228
+ interface SilkeFormProps<T extends { [key: string]: any }> {
229
+ children?: React.ReactNode;
230
+ value?: T;
231
+ errors?: { [key in keyof T]?: string };
232
+ onChange?: (change: T, valid?: boolean) => void;
233
+ onSubmit?: (form: T, valid?: boolean) => void;
234
+ onErrors?: (errors: ErrorMap<T>) => void;
235
+ }
236
+
237
+ interface FormFieldProps<T = any> {
238
+ name?: string;
239
+ label?: React.ReactNode;
240
+ value?: T;
241
+ error?: string;
242
+ readOnly?: boolean;
243
+ disabled?: boolean;
244
+ placeholder?: string;
245
+ onChange?: (change: T) => void;
246
+ onError?: (message?: string) => void;
247
+ onFocus?: (e: FocusEvent) => void;
248
+ onBlur?: (e: FocusEvent) => void;
249
+ validator?: FormValidator<FormFieldProps<T>>;
250
+ }
251
+
252
+ type ErrorMap<T> = { [key in keyof T]?: string };
253
+ ```
254
+
255
+ ## Form Field Connection
256
+
257
+ Form fields connect to SilkeForm through their `name` prop:
258
+ 1. The form provides a context with the current value and change handlers
259
+ 2. Fields with a `name` prop automatically receive their value from `form.value[name]`
260
+ 3. Changes from fields update the form's state automatically
261
+ 4. Validation errors are tracked by field name
@@ -76,6 +76,7 @@ export function ArrayFieldInline({
76
76
  value={(selected && value[selected]) || {}}
77
77
  noPad
78
78
  disabled={disabled}
79
+ itemIndex={selected}
79
80
  />
80
81
  </FormObjectProvider>
81
82
  )}
@@ -90,6 +90,7 @@ export function ArrayFieldModal({
90
90
  schema={Array.isArray(schema) ? schema : [schema]}
91
91
  value={(selected && value[selected]) || {}}
92
92
  noPad
93
+ itemIndex={selected}
93
94
  />
94
95
  </FormObjectProvider>
95
96
  )}