@manafishrov/ui 1.3.3 → 1.3.5

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 (59) hide show
  1. package/dist/components/form/AutoSubmit.js +9 -9
  2. package/dist/components/form/AutoSubmit.js.map +1 -1
  3. package/dist/components/form/ComboboxField.d.ts +2 -1
  4. package/dist/components/form/ComboboxField.js +55 -47
  5. package/dist/components/form/ComboboxField.js.map +1 -1
  6. package/dist/components/form/DatePickerField.d.ts +2 -1
  7. package/dist/components/form/DatePickerField.js +36 -28
  8. package/dist/components/form/DatePickerField.js.map +1 -1
  9. package/dist/components/form/Form.js +37 -37
  10. package/dist/components/form/Form.js.map +1 -1
  11. package/dist/components/form/NumberInputField.d.ts +2 -1
  12. package/dist/components/form/NumberInputField.js +63 -55
  13. package/dist/components/form/NumberInputField.js.map +1 -1
  14. package/dist/components/form/PasswordInputField.d.ts +2 -1
  15. package/dist/components/form/PasswordInputField.js +72 -60
  16. package/dist/components/form/PasswordInputField.js.map +1 -1
  17. package/dist/components/form/PinInputField.d.ts +2 -1
  18. package/dist/components/form/PinInputField.js +48 -40
  19. package/dist/components/form/PinInputField.js.map +1 -1
  20. package/dist/components/form/RadioGroupField.d.ts +2 -1
  21. package/dist/components/form/RadioGroupField.js +50 -34
  22. package/dist/components/form/RadioGroupField.js.map +1 -1
  23. package/dist/components/form/SelectField.d.ts +2 -1
  24. package/dist/components/form/SelectField.js +43 -35
  25. package/dist/components/form/SelectField.js.map +1 -1
  26. package/dist/components/form/SliderField.d.ts +2 -1
  27. package/dist/components/form/SliderField.js +42 -34
  28. package/dist/components/form/SliderField.js.map +1 -1
  29. package/dist/components/form/TagsInputField.d.ts +2 -1
  30. package/dist/components/form/TagsInputField.js +45 -37
  31. package/dist/components/form/TagsInputField.js.map +1 -1
  32. package/dist/components/form/TextInputField.d.ts +2 -1
  33. package/dist/components/form/TextInputField.js +38 -30
  34. package/dist/components/form/TextInputField.js.map +1 -1
  35. package/dist/components/form/TextareaField.d.ts +2 -1
  36. package/dist/components/form/TextareaField.js +36 -28
  37. package/dist/components/form/TextareaField.js.map +1 -1
  38. package/dist/components/form/WithTrailingAddon.d.ts +6 -0
  39. package/dist/components/form/WithTrailingAddon.js +18 -0
  40. package/dist/components/form/WithTrailingAddon.js.map +1 -0
  41. package/dist/components/form/index.d.ts +2 -0
  42. package/dist/components/form/index.js +42 -40
  43. package/dist/components/form/index.js.map +1 -1
  44. package/package.json +1 -1
  45. package/src/components/form/AutoSubmit.tsx +6 -11
  46. package/src/components/form/ComboboxField.tsx +27 -22
  47. package/src/components/form/DatePickerField.tsx +25 -20
  48. package/src/components/form/Form.tsx +3 -2
  49. package/src/components/form/NumberInputField.tsx +25 -20
  50. package/src/components/form/PasswordInputField.tsx +53 -33
  51. package/src/components/form/PinInputField.tsx +24 -19
  52. package/src/components/form/RadioGroupField.tsx +32 -17
  53. package/src/components/form/SelectField.tsx +21 -16
  54. package/src/components/form/SliderField.tsx +24 -19
  55. package/src/components/form/TagsInputField.tsx +26 -21
  56. package/src/components/form/TextInputField.tsx +18 -13
  57. package/src/components/form/TextareaField.tsx +18 -13
  58. package/src/components/form/WithTrailingAddon.tsx +15 -0
  59. package/src/components/form/index.ts +2 -0
@@ -1,5 +1,5 @@
1
1
  import type { DatePickerInputProps, DateValue } from '@ark-ui/solid';
2
- import type { Component, ComponentProps } from 'solid-js';
2
+ import type { Component, ComponentProps, JSXElement } from 'solid-js';
3
3
 
4
4
  import {
5
5
  DatePicker,
@@ -13,6 +13,7 @@ import {
13
13
  import { Field, FieldContent, FieldDescription, FieldError, FieldLabel } from '@/components/Field';
14
14
 
15
15
  import { useFieldContext } from './context';
16
+ import { WithTrailingAddon } from './WithTrailingAddon';
16
17
 
17
18
  const DATE_PICKER_ROOT_PROPS = [
18
19
  'min',
@@ -63,6 +64,7 @@ export type DatePickerFieldProps = DatePickerInputProps &
63
64
  label?: string;
64
65
  description?: string;
65
66
  showTrigger?: boolean;
67
+ trailingAddon?: JSXElement;
66
68
  };
67
69
 
68
70
  const DatePickerInputGroup: Component<DatePickerInputProps & { showTrigger?: boolean }> = (
@@ -95,6 +97,7 @@ const DATE_PICKER_FIELD_PROPS = [
95
97
  'readOnly',
96
98
  'placeholder',
97
99
  'showTrigger',
100
+ 'trailingAddon',
98
101
  ] as const;
99
102
 
100
103
  export const DatePickerField: Component<DatePickerFieldProps> = (props) => {
@@ -111,25 +114,27 @@ export const DatePickerField: Component<DatePickerFieldProps> = (props) => {
111
114
  >
112
115
  <FieldLabel>{local.label}</FieldLabel>
113
116
  <FieldContent>
114
- <DatePicker
115
- value={field().state.value}
116
- onValueChange={(details) => {
117
- field().handleChange(details.value);
118
- }}
119
- onBlur={() => {
120
- field().handleBlur();
121
- }}
122
- invalid={field().state.meta.errors.length > 0}
123
- disabled={local.disabled ?? false}
124
- readOnly={local.readOnly ?? false}
125
- {...rootProps}
126
- >
127
- <DatePickerInputGroup
128
- {...inputProps}
129
- placeholder={local.placeholder}
130
- {...(typeof local.showTrigger === 'boolean' && { showTrigger: local.showTrigger })}
131
- />
132
- </DatePicker>
117
+ <WithTrailingAddon addon={local.trailingAddon}>
118
+ <DatePicker
119
+ value={field().state.value}
120
+ onValueChange={(details) => {
121
+ field().handleChange(details.value);
122
+ }}
123
+ onBlur={() => {
124
+ field().handleBlur();
125
+ }}
126
+ invalid={field().state.meta.errors.length > 0}
127
+ disabled={local.disabled ?? false}
128
+ readOnly={local.readOnly ?? false}
129
+ {...rootProps}
130
+ >
131
+ <DatePickerInputGroup
132
+ {...inputProps}
133
+ placeholder={local.placeholder}
134
+ {...(typeof local.showTrigger === 'boolean' && { showTrigger: local.showTrigger })}
135
+ />
136
+ </DatePicker>
137
+ </WithTrailingAddon>
133
138
  <FieldError errors={field().state.meta.errors} />
134
139
  <FieldDescription>{local.description}</FieldDescription>
135
140
  </FieldContent>
@@ -1,5 +1,6 @@
1
+ import type { Component, ComponentProps } from 'solid-js';
2
+
1
3
  import { createFormHook } from '@tanstack/solid-form';
2
- import { splitProps, type Component, type ComponentProps } from 'solid-js';
3
4
  import { cn } from 'tailwind-variants';
4
5
 
5
6
  import { AutoSubmit } from './AutoSubmit';
@@ -27,7 +28,7 @@ export const Form: Component<FormProps> = (props) => {
27
28
 
28
29
  return (
29
30
  <form
30
- class={cn('space-y-6 relative', local.class)}
31
+ class={cn('space-y-8 relative', local.class)}
31
32
  onSubmit={(submitEvent) => {
32
33
  submitEvent.preventDefault();
33
34
  submitEvent.stopPropagation();
@@ -1,4 +1,4 @@
1
- import type { Component, ComponentProps, JSX } from 'solid-js';
1
+ import type { Component, ComponentProps, JSX, JSXElement } from 'solid-js';
2
2
 
3
3
  import { Field, FieldLabel, FieldContent, FieldError, FieldDescription } from '@/components/Field';
4
4
  import {
@@ -9,6 +9,7 @@ import {
9
9
  } from '@/components/NumberInput';
10
10
 
11
11
  import { useFieldContext } from './context';
12
+ import { WithTrailingAddon } from './WithTrailingAddon';
12
13
 
13
14
  const NUMBER_INPUT_ROOT_PROPS = [
14
15
  'min',
@@ -34,6 +35,7 @@ export type NumberInputFieldProps = ComponentProps<typeof NumberInputInput> &
34
35
  label?: string;
35
36
  description?: string;
36
37
  showTriggers?: boolean;
38
+ trailingAddon?: JSXElement;
37
39
  };
38
40
 
39
41
  const toNumberInputValue = (value: number | undefined): string => {
@@ -46,7 +48,7 @@ const toNumberInputValue = (value: number | undefined): string => {
46
48
 
47
49
  type NumberInputFieldLocalProps = Pick<
48
50
  NumberInputFieldProps,
49
- 'label' | 'description' | 'required' | 'disabled' | 'readOnly' | 'showTriggers'
51
+ 'label' | 'description' | 'required' | 'disabled' | 'readOnly' | 'showTriggers' | 'trailingAddon'
50
52
  >;
51
53
 
52
54
  type NumberInputFieldRootProps = Pick<
@@ -122,24 +124,26 @@ const renderNumberInputField = (props: RenderNumberInputFieldProps): JSX.Element
122
124
  >
123
125
  <FieldLabel>{props.local.label}</FieldLabel>
124
126
  <FieldContent>
125
- <NumberInput
126
- value={props.inputValue()}
127
- onValueChange={props.onValueChange}
128
- onValueCommit={props.onValueCommit}
129
- onBlur={props.onBlur}
130
- invalid={props.field().state.meta.errors.length > 0}
131
- disabled={props.local.disabled ?? false}
132
- readOnly={props.local.readOnly ?? false}
133
- required={props.local.required ?? false}
134
- {...props.rootProps}
135
- >
136
- <NumberInputControl>
137
- <NumberInputInput {...props.inputProps} />
138
- <Show when={props.local.showTriggers !== false}>
139
- <NumberInputTriggers />
140
- </Show>
141
- </NumberInputControl>
142
- </NumberInput>
127
+ <WithTrailingAddon addon={props.local.trailingAddon}>
128
+ <NumberInput
129
+ value={props.inputValue()}
130
+ onValueChange={props.onValueChange}
131
+ onValueCommit={props.onValueCommit}
132
+ onBlur={props.onBlur}
133
+ invalid={props.field().state.meta.errors.length > 0}
134
+ disabled={props.local.disabled ?? false}
135
+ readOnly={props.local.readOnly ?? false}
136
+ required={props.local.required ?? false}
137
+ {...props.rootProps}
138
+ >
139
+ <NumberInputControl>
140
+ <NumberInputInput {...props.inputProps} />
141
+ <Show when={props.local.showTriggers !== false}>
142
+ <NumberInputTriggers />
143
+ </Show>
144
+ </NumberInputControl>
145
+ </NumberInput>
146
+ </WithTrailingAddon>
143
147
  <FieldError errors={props.field().state.meta.errors} />
144
148
  <FieldDescription>{props.local.description}</FieldDescription>
145
149
  </FieldContent>
@@ -155,6 +159,7 @@ export const NumberInputField: Component<NumberInputFieldProps> = (props) => {
155
159
  'disabled',
156
160
  'readOnly',
157
161
  'showTriggers',
162
+ 'trailingAddon',
158
163
  ]);
159
164
  const [rootProps, inputProps] = splitProps(others, NUMBER_INPUT_ROOT_PROPS);
160
165
  const state = createNumberInputFieldState(field);
@@ -1,4 +1,4 @@
1
- import { splitProps, type Component, type ComponentProps } from 'solid-js';
1
+ import type { Component, ComponentProps, JSXElement } from 'solid-js';
2
2
 
3
3
  import { Field, FieldLabel, FieldContent, FieldError, FieldDescription } from '@/components/Field';
4
4
  import {
@@ -10,23 +10,66 @@ import {
10
10
  } from '@/components/PasswordInput';
11
11
 
12
12
  import { useFieldContext } from './context';
13
+ import { WithTrailingAddon } from './WithTrailingAddon';
13
14
 
14
15
  export type PasswordInputFieldProps = ComponentProps<typeof PasswordInputInput> & {
15
16
  label?: string;
16
17
  description?: string;
17
18
  showVisibilityTrigger?: boolean;
19
+ trailingAddon?: JSXElement;
18
20
  };
19
21
 
22
+ const PASSWORD_INPUT_FIELD_PROPS = [
23
+ 'label',
24
+ 'description',
25
+ 'required',
26
+ 'disabled',
27
+ 'readOnly',
28
+ 'showVisibilityTrigger',
29
+ 'trailingAddon',
30
+ ] as const;
31
+
32
+ type PasswordInputFieldLocalProps = Pick<
33
+ PasswordInputFieldProps,
34
+ (typeof PASSWORD_INPUT_FIELD_PROPS)[number]
35
+ >;
36
+
37
+ const PasswordInputFieldControl: Component<{
38
+ field: ReturnType<typeof useFieldContext<string>>;
39
+ local: PasswordInputFieldLocalProps;
40
+ others: Omit<PasswordInputFieldProps, keyof PasswordInputFieldLocalProps>;
41
+ }> = (props) => (
42
+ <WithTrailingAddon addon={props.local.trailingAddon}>
43
+ <PasswordInput
44
+ invalid={props.field().state.meta.errors.length > 0}
45
+ disabled={props.local.disabled ?? false}
46
+ readOnly={props.local.readOnly ?? false}
47
+ required={props.local.required ?? false}
48
+ >
49
+ <PasswordInputControl>
50
+ <PasswordInputInput
51
+ value={props.field().state.value}
52
+ onInput={(event) => {
53
+ props.field().handleChange(event.target.value);
54
+ }}
55
+ onBlur={() => {
56
+ props.field().handleBlur();
57
+ }}
58
+ {...props.others}
59
+ />
60
+ <Show when={props.local.showVisibilityTrigger !== false}>
61
+ <PasswordInputVisibilityTrigger>
62
+ <PasswordInputIndicator />
63
+ </PasswordInputVisibilityTrigger>
64
+ </Show>
65
+ </PasswordInputControl>
66
+ </PasswordInput>
67
+ </WithTrailingAddon>
68
+ );
69
+
20
70
  export const PasswordInputField: Component<PasswordInputFieldProps> = (props) => {
21
71
  const field = useFieldContext<string>();
22
- const [local, others] = splitProps(props, [
23
- 'label',
24
- 'description',
25
- 'required',
26
- 'disabled',
27
- 'readOnly',
28
- 'showVisibilityTrigger',
29
- ]);
72
+ const [local, others] = splitProps(props, PASSWORD_INPUT_FIELD_PROPS);
30
73
 
31
74
  return (
32
75
  <Field
@@ -37,30 +80,7 @@ export const PasswordInputField: Component<PasswordInputFieldProps> = (props) =>
37
80
  >
38
81
  <FieldLabel>{local.label}</FieldLabel>
39
82
  <FieldContent>
40
- <PasswordInput
41
- invalid={field().state.meta.errors.length > 0}
42
- disabled={local.disabled ?? false}
43
- readOnly={local.readOnly ?? false}
44
- required={local.required ?? false}
45
- >
46
- <PasswordInputControl>
47
- <PasswordInputInput
48
- value={field().state.value}
49
- onInput={(event) => {
50
- field().handleChange(event.target.value);
51
- }}
52
- onBlur={() => {
53
- field().handleBlur();
54
- }}
55
- {...others}
56
- />
57
- <Show when={local.showVisibilityTrigger !== false}>
58
- <PasswordInputVisibilityTrigger>
59
- <PasswordInputIndicator />
60
- </PasswordInputVisibilityTrigger>
61
- </Show>
62
- </PasswordInputControl>
63
- </PasswordInput>
83
+ <PasswordInputFieldControl field={field} local={local} others={others} />
64
84
  <FieldError errors={field().state.meta.errors} />
65
85
  <FieldDescription>{local.description}</FieldDescription>
66
86
  </FieldContent>
@@ -1,4 +1,4 @@
1
- import { splitProps, type Component, type ComponentProps, Index } from 'solid-js';
1
+ import type { Component, ComponentProps, JSXElement } from 'solid-js';
2
2
 
3
3
  import { Field, FieldLabel, FieldContent, FieldError, FieldDescription } from '@/components/Field';
4
4
  import {
@@ -10,11 +10,13 @@ import {
10
10
  } from '@/components/PinInput';
11
11
 
12
12
  import { useFieldContext } from './context';
13
+ import { WithTrailingAddon } from './WithTrailingAddon';
13
14
 
14
15
  export type PinInputFieldProps = ComponentProps<typeof PinInput> & {
15
16
  label?: string;
16
17
  description?: string;
17
18
  count?: number;
19
+ trailingAddon?: JSXElement;
18
20
  };
19
21
 
20
22
  const DEFAULT_PIN_COUNT = 6;
@@ -25,6 +27,7 @@ const PIN_INPUT_FIELD_PROPS = [
25
27
  'disabled',
26
28
  'readOnly',
27
29
  'count',
30
+ 'trailingAddon',
28
31
  ] as const;
29
32
 
30
33
  const PinInputDigits: Component<{ count: number }> = (props) => (
@@ -51,24 +54,26 @@ export const PinInputField: Component<PinInputFieldProps> = (props) => {
51
54
  >
52
55
  <FieldLabel>{local.label}</FieldLabel>
53
56
  <FieldContent>
54
- <PinInput
55
- value={field().state.value}
56
- onValueChange={(details) => {
57
- field().handleChange(details.value);
58
- }}
59
- onBlur={() => {
60
- field().handleBlur();
61
- }}
62
- invalid={field().state.meta.errors.length > 0}
63
- disabled={local.disabled ?? false}
64
- readOnly={local.readOnly ?? false}
65
- required={local.required ?? false}
66
- count={pinCount}
67
- {...others}
68
- >
69
- <PinInputDigits count={pinCount} />
70
- <PinInputHiddenInput />
71
- </PinInput>
57
+ <WithTrailingAddon addon={local.trailingAddon}>
58
+ <PinInput
59
+ value={field().state.value}
60
+ onValueChange={(details) => {
61
+ field().handleChange(details.value);
62
+ }}
63
+ onBlur={() => {
64
+ field().handleBlur();
65
+ }}
66
+ invalid={field().state.meta.errors.length > 0}
67
+ disabled={local.disabled ?? false}
68
+ readOnly={local.readOnly ?? false}
69
+ required={local.required ?? false}
70
+ count={pinCount}
71
+ {...others}
72
+ >
73
+ <PinInputDigits count={pinCount} />
74
+ <PinInputHiddenInput />
75
+ </PinInput>
76
+ </WithTrailingAddon>
72
77
  <FieldError errors={field().state.meta.errors} />
73
78
  <FieldDescription>{local.description}</FieldDescription>
74
79
  </FieldContent>
@@ -1,18 +1,28 @@
1
- import type { Component, ComponentProps } from 'solid-js';
1
+ import type { Component, ComponentProps, JSXElement } from 'solid-js';
2
2
 
3
3
  import { Field, FieldContent, FieldError, FieldDescription } from '@/components/Field';
4
- import { RadioGroup } from '@/components/RadioGroup';
4
+ import { RadioGroup, RadioGroupLabel } from '@/components/RadioGroup';
5
5
 
6
6
  import { useFieldContext } from './context';
7
+ import { WithTrailingAddon } from './WithTrailingAddon';
7
8
 
8
9
  export type RadioGroupFieldProps = ComponentProps<typeof RadioGroup> & {
9
10
  label?: string;
10
11
  description?: string;
12
+ trailingAddon?: JSXElement;
11
13
  };
12
14
 
13
15
  export const RadioGroupField: Component<RadioGroupFieldProps> = (props) => {
14
16
  const field = useFieldContext<string>();
15
- const [local, others] = splitProps(props, ['description', 'required', 'disabled', 'readOnly']);
17
+ const [local, others] = splitProps(props, [
18
+ 'label',
19
+ 'description',
20
+ 'required',
21
+ 'disabled',
22
+ 'readOnly',
23
+ 'children',
24
+ 'trailingAddon',
25
+ ]);
16
26
 
17
27
  return (
18
28
  <Field
@@ -22,20 +32,25 @@ export const RadioGroupField: Component<RadioGroupFieldProps> = (props) => {
22
32
  readOnly={local.readOnly ?? false}
23
33
  >
24
34
  <FieldContent>
25
- <RadioGroup
26
- value={field().state.value}
27
- onValueChange={(details) => {
28
- field().handleChange(details.value ?? '');
29
- }}
30
- onBlur={() => {
31
- field().handleBlur();
32
- }}
33
- invalid={field().state.meta.errors.length > 0}
34
- disabled={local.disabled ?? false}
35
- readOnly={local.readOnly ?? false}
36
- required={local.required ?? false}
37
- {...others}
38
- />
35
+ <WithTrailingAddon addon={local.trailingAddon}>
36
+ <RadioGroup
37
+ value={field().state.value}
38
+ onValueChange={(details) => {
39
+ field().handleChange(details.value ?? '');
40
+ }}
41
+ onBlur={() => {
42
+ field().handleBlur();
43
+ }}
44
+ invalid={field().state.meta.errors.length > 0}
45
+ disabled={local.disabled ?? false}
46
+ readOnly={local.readOnly ?? false}
47
+ required={local.required ?? false}
48
+ {...others}
49
+ >
50
+ <RadioGroupLabel>{local.label}</RadioGroupLabel>
51
+ {local.children}
52
+ </RadioGroup>
53
+ </WithTrailingAddon>
39
54
  <FieldError errors={field().state.meta.errors} />
40
55
  <FieldDescription>{local.description}</FieldDescription>
41
56
  </FieldContent>
@@ -1,4 +1,4 @@
1
- import type { Component, ComponentProps, JSX } from 'solid-js';
1
+ import type { Component, ComponentProps, JSX, JSXElement } from 'solid-js';
2
2
 
3
3
  import { Field, FieldContent, FieldDescription, FieldError, FieldLabel } from '@/components/Field';
4
4
  import {
@@ -11,6 +11,7 @@ import {
11
11
  } from '@/components/Select';
12
12
 
13
13
  import { useFieldContext } from './context';
14
+ import { WithTrailingAddon } from './WithTrailingAddon';
14
15
 
15
16
  const SelectInput: Component<{ placeholder: string; children: JSX.Element }> = (props) => (
16
17
  <>
@@ -29,6 +30,7 @@ export type SelectFieldProps = ComponentProps<typeof Select> & {
29
30
  label?: string;
30
31
  description?: string;
31
32
  placeholder?: string;
33
+ trailingAddon?: JSXElement;
32
34
  };
33
35
 
34
36
  export const SelectField: Component<SelectFieldProps> = (props) => {
@@ -41,6 +43,7 @@ export const SelectField: Component<SelectFieldProps> = (props) => {
41
43
  'readOnly',
42
44
  'placeholder',
43
45
  'children',
46
+ 'trailingAddon',
44
47
  ]);
45
48
 
46
49
  return (
@@ -52,21 +55,23 @@ export const SelectField: Component<SelectFieldProps> = (props) => {
52
55
  >
53
56
  <FieldLabel>{local.label}</FieldLabel>
54
57
  <FieldContent>
55
- <Select
56
- value={field().state.value}
57
- onValueChange={(details) => {
58
- field().handleChange(details.value);
59
- }}
60
- onBlur={() => {
61
- field().handleBlur();
62
- }}
63
- invalid={field().state.meta.errors.length > 0}
64
- disabled={local.disabled ?? false}
65
- readOnly={local.readOnly ?? false}
66
- {...others}
67
- >
68
- <SelectInput placeholder={local.placeholder ?? ''}>{local.children}</SelectInput>
69
- </Select>
58
+ <WithTrailingAddon addon={local.trailingAddon}>
59
+ <Select
60
+ value={field().state.value}
61
+ onValueChange={(details) => {
62
+ field().handleChange(details.value);
63
+ }}
64
+ onBlur={() => {
65
+ field().handleBlur();
66
+ }}
67
+ invalid={field().state.meta.errors.length > 0}
68
+ disabled={local.disabled ?? false}
69
+ readOnly={local.readOnly ?? false}
70
+ {...others}
71
+ >
72
+ <SelectInput placeholder={local.placeholder ?? ''}>{local.children}</SelectInput>
73
+ </Select>
74
+ </WithTrailingAddon>
70
75
  <FieldError errors={field().state.meta.errors} />
71
76
  <FieldDescription>{local.description}</FieldDescription>
72
77
  </FieldContent>
@@ -1,4 +1,4 @@
1
- import type { Component, ComponentProps } from 'solid-js';
1
+ import type { Component, ComponentProps, JSXElement } from 'solid-js';
2
2
 
3
3
  import { Field, FieldDescription, FieldError } from '@/components/Field';
4
4
  import {
@@ -14,6 +14,7 @@ import {
14
14
  } from '@/components/Slider';
15
15
 
16
16
  import { useFieldContext } from './context';
17
+ import { WithTrailingAddon } from './WithTrailingAddon';
17
18
 
18
19
  const SliderInput: Component<{
19
20
  value: number[];
@@ -48,6 +49,7 @@ export type SliderFieldProps = ComponentProps<typeof Slider> & {
48
49
  description?: string;
49
50
  marks?: { value: number; label?: string }[];
50
51
  required?: boolean;
52
+ trailingAddon?: JSXElement;
51
53
  };
52
54
 
53
55
  export const SliderField: Component<SliderFieldProps> = (props) => {
@@ -59,6 +61,7 @@ export const SliderField: Component<SliderFieldProps> = (props) => {
59
61
  'disabled',
60
62
  'readOnly',
61
63
  'marks',
64
+ 'trailingAddon',
62
65
  ]);
63
66
 
64
67
  return (
@@ -68,25 +71,27 @@ export const SliderField: Component<SliderFieldProps> = (props) => {
68
71
  readOnly={local.readOnly ?? false}
69
72
  required={local.required ?? false}
70
73
  >
71
- <Slider
72
- value={field().state.value}
73
- onValueChange={(details) => {
74
- field().handleChange(details.value);
75
- }}
76
- onFocusChange={() => {
77
- field().handleBlur();
78
- }}
79
- invalid={field().state.meta.errors.length > 0}
80
- disabled={local.disabled ?? false}
81
- readOnly={local.readOnly ?? false}
82
- {...others}
83
- >
84
- <SliderInput
74
+ <WithTrailingAddon addon={local.trailingAddon}>
75
+ <Slider
85
76
  value={field().state.value}
86
- {...(typeof local.label === 'string' && { label: local.label })}
87
- {...(Array.isArray(local.marks) && { marks: local.marks })}
88
- />
89
- </Slider>
77
+ onValueChange={(details) => {
78
+ field().handleChange(details.value);
79
+ }}
80
+ onFocusChange={() => {
81
+ field().handleBlur();
82
+ }}
83
+ invalid={field().state.meta.errors.length > 0}
84
+ disabled={local.disabled ?? false}
85
+ readOnly={local.readOnly ?? false}
86
+ {...others}
87
+ >
88
+ <SliderInput
89
+ value={field().state.value}
90
+ {...(typeof local.label === 'string' && { label: local.label })}
91
+ {...(Array.isArray(local.marks) && { marks: local.marks })}
92
+ />
93
+ </Slider>
94
+ </WithTrailingAddon>
90
95
  <FieldError errors={field().state.meta.errors} />
91
96
  <FieldDescription>{local.description}</FieldDescription>
92
97
  </Field>
@@ -1,4 +1,4 @@
1
- import { type Component, type ComponentProps, splitProps, For } from 'solid-js';
1
+ import type { Component, ComponentProps, JSXElement } from 'solid-js';
2
2
 
3
3
  import { Field, FieldContent, FieldDescription, FieldError, FieldLabel } from '@/components/Field';
4
4
  import {
@@ -16,6 +16,7 @@ import {
16
16
  } from '@/components/TagsInput';
17
17
 
18
18
  import { useFieldContext } from './context';
19
+ import { WithTrailingAddon } from './WithTrailingAddon';
19
20
 
20
21
  const TAGS_INPUT_ROOT_PROPS = [
21
22
  'max',
@@ -42,6 +43,7 @@ export type TagsInputFieldProps = ComponentProps<typeof TagsInputInput> &
42
43
  label?: string;
43
44
  description?: string;
44
45
  showClearTrigger?: boolean;
46
+ trailingAddon?: JSXElement;
45
47
  };
46
48
 
47
49
  const TagsInputGroup: Component<
@@ -85,6 +87,7 @@ const TAGS_INPUT_FIELD_PROPS = [
85
87
  'disabled',
86
88
  'readOnly',
87
89
  'showClearTrigger',
90
+ 'trailingAddon',
88
91
  ] as const;
89
92
 
90
93
  export const TagsInputField: Component<TagsInputFieldProps> = (props) => {
@@ -101,26 +104,28 @@ export const TagsInputField: Component<TagsInputFieldProps> = (props) => {
101
104
  >
102
105
  <FieldLabel>{local.label}</FieldLabel>
103
106
  <FieldContent>
104
- <TagsInput
105
- value={field().state.value}
106
- onValueChange={(details) => {
107
- field().handleChange(details.value);
108
- }}
109
- onBlur={() => {
110
- field().handleBlur();
111
- }}
112
- invalid={field().state.meta.errors.length > 0}
113
- disabled={local.disabled ?? false}
114
- readOnly={local.readOnly ?? false}
115
- {...rootProps}
116
- >
117
- <TagsInputGroup
118
- {...inputProps}
119
- {...(typeof local.showClearTrigger === 'boolean' && {
120
- showClearTrigger: local.showClearTrigger,
121
- })}
122
- />
123
- </TagsInput>
107
+ <WithTrailingAddon addon={local.trailingAddon}>
108
+ <TagsInput
109
+ value={field().state.value}
110
+ onValueChange={(details) => {
111
+ field().handleChange(details.value);
112
+ }}
113
+ onBlur={() => {
114
+ field().handleBlur();
115
+ }}
116
+ invalid={field().state.meta.errors.length > 0}
117
+ disabled={local.disabled ?? false}
118
+ readOnly={local.readOnly ?? false}
119
+ {...rootProps}
120
+ >
121
+ <TagsInputGroup
122
+ {...inputProps}
123
+ {...(typeof local.showClearTrigger === 'boolean' && {
124
+ showClearTrigger: local.showClearTrigger,
125
+ })}
126
+ />
127
+ </TagsInput>
128
+ </WithTrailingAddon>
124
129
  <FieldError errors={field().state.meta.errors} />
125
130
  <FieldDescription>{local.description}</FieldDescription>
126
131
  </FieldContent>