@knkcs/anker 0.0.1 → 0.0.3

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.
@@ -1,9 +1,9 @@
1
- import { LeavePageConfirmation, NumberInputRoot, NumberInputField, Radio } from '../chunk-4T32UC26.js';
1
+ import { Popover, PopoverTrigger, PopoverContent, PopoverBody, LeavePageConfirmation, NumberInputRoot, NumberInputField, Radio, NativeSelect } from '../chunk-C4JI3JNA.js';
2
2
  import { Switch } from '../chunk-RJPEVNMJ.js';
3
3
  import { text_input_default } from '../chunk-PZCL4M6I.js';
4
4
  export { SearchInput } from '../chunk-PZCL4M6I.js';
5
- import { Stack, Grid, GridItem, Text, Input, IconButton, Box, ButtonGroup, Button, Field, HStack, Checkbox, Popover, Square, Editable, Flex, RadioGroup, Menu, Portal, NativeSelect, Textarea, useEditableContext } from '@chakra-ui/react';
6
- import { Trash2, Plus, Upload, ChevronDown, Pencil } from 'lucide-react';
5
+ import { Stack, Grid, GridItem, Text, Input, IconButton, Box, ButtonGroup, Button, Field, HStack, Checkbox, Square, Editable, Flex, RadioGroup, Textarea, useEditableContext } from '@chakra-ui/react';
6
+ import { Trash2, Plus, Upload, Pencil } from 'lucide-react';
7
7
  import React, { useId, useCallback, useEffect } from 'react';
8
8
  import { useFormContext, useFieldArray, Controller } from 'react-hook-form';
9
9
  import { jsxs, jsx } from 'react/jsx-runtime';
@@ -74,7 +74,7 @@ function ArrayField(props) {
74
74
  emptyState,
75
75
  ...rest
76
76
  } = props;
77
- return /* @__PURE__ */ jsx(FormField, { name, label, readOnly, ...rest, children: (_field) => /* @__PURE__ */ jsx(Box, { py: 4, px: 4, bg: "bg", rounded: "md", children: mode === "dynamic" ? /* @__PURE__ */ jsx(
77
+ return /* @__PURE__ */ jsx(FormField, { name, label, readOnly, ...rest, children: () => /* @__PURE__ */ jsx(Box, { py: 4, px: 4, bg: "bg", rounded: "md", children: mode === "dynamic" ? /* @__PURE__ */ jsx(
78
78
  DynamicArray,
79
79
  {
80
80
  name,
@@ -185,7 +185,7 @@ function CheckboxField({
185
185
  ref,
186
186
  ...props
187
187
  }) {
188
- const { name, label, value, disabled, children } = props;
188
+ const { name, label, value, disabled, helperText, children } = props;
189
189
  const { control } = useFormContext();
190
190
  return /* @__PURE__ */ jsx(
191
191
  Controller,
@@ -212,28 +212,32 @@ function CheckboxField({
212
212
  }
213
213
  };
214
214
  const uniqueId = isArrayMode ? `${name}-${String(value)}` : name;
215
- return /* @__PURE__ */ jsxs(
216
- Checkbox.Root,
217
- {
218
- id: uniqueId,
219
- name: field.name,
220
- value: isArrayMode ? String(value) : void 0,
221
- invalid: !!fieldState.error,
222
- ref,
223
- checked: isChecked,
224
- onCheckedChange: handleCheckedChange,
225
- onBlur: field.onBlur,
226
- disabled,
227
- children: [
228
- /* @__PURE__ */ jsx(Checkbox.HiddenInput, {}),
229
- /* @__PURE__ */ jsx(Checkbox.Control, { children: /* @__PURE__ */ jsx(Checkbox.Indicator, {}) }),
230
- (label || children) && /* @__PURE__ */ jsxs(Checkbox.Label, { children: [
231
- label,
232
- children
233
- ] })
234
- ]
235
- }
236
- );
215
+ return /* @__PURE__ */ jsxs(Field.Root, { invalid: !!fieldState.error, disabled, children: [
216
+ /* @__PURE__ */ jsxs(
217
+ Checkbox.Root,
218
+ {
219
+ id: uniqueId,
220
+ name: field.name,
221
+ value: isArrayMode ? String(value) : void 0,
222
+ invalid: !!fieldState.error,
223
+ ref,
224
+ checked: isChecked,
225
+ onCheckedChange: handleCheckedChange,
226
+ onBlur: field.onBlur,
227
+ disabled,
228
+ children: [
229
+ /* @__PURE__ */ jsx(Checkbox.HiddenInput, {}),
230
+ /* @__PURE__ */ jsx(Checkbox.Control, { children: /* @__PURE__ */ jsx(Checkbox.Indicator, {}) }),
231
+ (label || children) && /* @__PURE__ */ jsxs(Checkbox.Label, { children: [
232
+ label,
233
+ children
234
+ ] })
235
+ ]
236
+ }
237
+ ),
238
+ helperText && /* @__PURE__ */ jsx(Field.HelperText, { children: helperText }),
239
+ fieldState.error && /* @__PURE__ */ jsx(Field.ErrorText, { "aria-live": "polite", children: fieldState.error.message })
240
+ ] });
237
241
  }
238
242
  }
239
243
  );
@@ -289,6 +293,7 @@ function CodeField({
289
293
  onChange: (e) => field.onChange(e.target.value),
290
294
  onBlur: field.onBlur,
291
295
  readOnly,
296
+ "aria-describedby": field["aria-describedby"],
292
297
  style: {
293
298
  fontFamily: "monospace",
294
299
  fontSize: "0.875rem",
@@ -308,8 +313,8 @@ function ColorPickerField({
308
313
  ...props
309
314
  }) {
310
315
  const { name, label, size = "md", readOnly, ColorPicker, ...rest } = props;
311
- return /* @__PURE__ */ jsx(FormField, { name, label, readOnly, ...rest, children: (field) => /* @__PURE__ */ jsxs(Popover.Root, { children: [
312
- /* @__PURE__ */ jsx(Popover.Trigger, { asChild: true, children: /* @__PURE__ */ jsx(
316
+ return /* @__PURE__ */ jsx(FormField, { name, label, readOnly, ...rest, children: (field) => /* @__PURE__ */ jsxs(Popover, { children: [
317
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
313
318
  IconButton,
314
319
  {
315
320
  ref,
@@ -321,32 +326,30 @@ function ColorPickerField({
321
326
  variant: "outline",
322
327
  disabled: readOnly,
323
328
  "aria-label": `Color: ${field.value || "none"}`,
329
+ "aria-describedby": field["aria-describedby"],
324
330
  children: /* @__PURE__ */ jsx(Square, { rounded: "sm", bg: field.value, size: 6 })
325
331
  }
326
332
  ) }),
327
- /* @__PURE__ */ jsx(Popover.Positioner, { children: /* @__PURE__ */ jsxs(Popover.Content, { width: "auto", children: [
328
- /* @__PURE__ */ jsx(Popover.Arrow, {}),
329
- /* @__PURE__ */ jsx(Popover.Body, { children: ColorPicker ? /* @__PURE__ */ jsx(
330
- ColorPicker,
331
- {
332
- color: field.value,
333
- onChange: (color) => field.onChange(color)
334
- }
335
- ) : /* @__PURE__ */ jsx(
336
- "input",
337
- {
338
- type: "color",
339
- value: field.value || "#000000",
340
- onChange: (e) => field.onChange(e.target.value),
341
- style: {
342
- width: 200,
343
- height: 200,
344
- border: "none",
345
- cursor: "pointer"
346
- }
333
+ /* @__PURE__ */ jsx(PopoverContent, { width: "auto", showArrow: true, children: /* @__PURE__ */ jsx(PopoverBody, { children: ColorPicker ? /* @__PURE__ */ jsx(
334
+ ColorPicker,
335
+ {
336
+ color: field.value,
337
+ onChange: (color) => field.onChange(color)
338
+ }
339
+ ) : /* @__PURE__ */ jsx(
340
+ "input",
341
+ {
342
+ type: "color",
343
+ value: field.value || "#000000",
344
+ onChange: (e) => field.onChange(e.target.value),
345
+ style: {
346
+ width: 200,
347
+ height: 200,
348
+ border: "none",
349
+ cursor: "pointer"
347
350
  }
348
- ) })
349
- ] }) })
351
+ }
352
+ ) }) })
350
353
  ] }) });
351
354
  }
352
355
  ColorPickerField.displayName = "ColorPickerField";
@@ -523,6 +526,7 @@ function FileField(props) {
523
526
  accept: accept ? Object.values(accept).flat().join(",") : void 0,
524
527
  multiple,
525
528
  disabled,
529
+ "aria-describedby": field["aria-describedby"],
526
530
  onChange: (e) => {
527
531
  const files = e.target.files;
528
532
  if (!files) return;
@@ -703,6 +707,7 @@ function MarkdownField(props) {
703
707
  onChange: (e) => field.onChange(e.target.value),
704
708
  onBlur: field.onBlur,
705
709
  readOnly,
710
+ "aria-describedby": field["aria-describedby"],
706
711
  style: {
707
712
  padding: "0.75rem",
708
713
  border: "1px solid var(--chakra-colors-border)",
@@ -758,7 +763,15 @@ function NumberInputField2({
758
763
  showStepper: showStepper && !readOnly,
759
764
  opacity: readOnly ? 0.8 : 1,
760
765
  ...numberInputProps,
761
- children: /* @__PURE__ */ jsx(NumberInputField, { name: field.name, ref, onBlur: field.onBlur })
766
+ children: /* @__PURE__ */ jsx(
767
+ NumberInputField,
768
+ {
769
+ name: field.name,
770
+ ref,
771
+ onBlur: field.onBlur,
772
+ "aria-describedby": field["aria-describedby"]
773
+ }
774
+ )
762
775
  }
763
776
  )
764
777
  }
@@ -772,61 +785,13 @@ function RadioGroupField(props) {
772
785
  {
773
786
  value: String(field.value ?? ""),
774
787
  onValueChange: (e) => field.onChange(e.value),
788
+ "aria-describedby": field["aria-describedby"],
775
789
  ...radioGroupProps,
776
790
  children: /* @__PURE__ */ jsx(Stack, { direction: "row", ...stackProps, children: options.map((option) => /* @__PURE__ */ jsx(Radio, { value: option.value, children: option.label }, option.value)) })
777
791
  }
778
792
  ) });
779
793
  }
780
794
  RadioGroupField.displayName = "RadioGroupField";
781
- var SelectActionField = (props) => {
782
- const { label, menuItems, onClick, ...rest } = props;
783
- const hasMenuItems = menuItems && menuItems.length > 0;
784
- return /* @__PURE__ */ jsxs(HStack, { gap: 0.5, children: [
785
- onClick && /* @__PURE__ */ jsxs(
786
- Button,
787
- {
788
- ...rest,
789
- colorPalette: "blue",
790
- onClick,
791
- size: "lg",
792
- roundedRight: hasMenuItems ? "none" : void 0,
793
- children: [
794
- /* @__PURE__ */ jsx(Plus, { size: 16 }),
795
- label
796
- ]
797
- }
798
- ),
799
- hasMenuItems && /* @__PURE__ */ jsxs(Menu.Root, { children: [
800
- /* @__PURE__ */ jsx(Menu.Trigger, { asChild: true, children: /* @__PURE__ */ jsxs(
801
- Button,
802
- {
803
- ...rest,
804
- size: "lg",
805
- colorPalette: "blue",
806
- roundedLeft: onClick ? "none" : void 0,
807
- children: [
808
- /* @__PURE__ */ jsx(ChevronDown, { size: 16 }),
809
- onClick ? null : label
810
- ]
811
- }
812
- ) }),
813
- /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx(Menu.Positioner, { children: /* @__PURE__ */ jsx(Menu.Content, { children: menuItems.map((menuItem) => /* @__PURE__ */ jsxs(
814
- Menu.Item,
815
- {
816
- value: menuItem.label,
817
- onClick: menuItem.onClick,
818
- color: menuItem.color,
819
- children: [
820
- menuItem.icon,
821
- menuItem.label
822
- ]
823
- },
824
- menuItem.label
825
- )) }) }) })
826
- ] })
827
- ] });
828
- };
829
- SelectActionField.displayName = "SelectActionField";
830
795
  function SelectField({
831
796
  ref,
832
797
  ...props
@@ -849,23 +814,19 @@ function SelectField({
849
814
  readOnly,
850
815
  disabled,
851
816
  ...rest,
852
- children: (field) => /* @__PURE__ */ jsxs(NativeSelect.Root, { disabled: readOnly || disabled, children: [
853
- /* @__PURE__ */ jsxs(
854
- NativeSelect.Field,
855
- {
856
- ...field,
857
- value: String(field.value ?? ""),
858
- id: name,
859
- ref,
860
- ...selectProps,
861
- children: [
862
- placeholder && /* @__PURE__ */ jsx("option", { value: "", disabled: true, children: placeholder }),
863
- children
864
- ]
865
- }
866
- ),
867
- /* @__PURE__ */ jsx(NativeSelect.Indicator, {})
868
- ] })
817
+ children: (field) => /* @__PURE__ */ jsx(
818
+ NativeSelect,
819
+ {
820
+ disabled: readOnly || disabled,
821
+ placeholder,
822
+ ...field,
823
+ value: String(field.value ?? ""),
824
+ id: name,
825
+ ref,
826
+ ...selectProps,
827
+ children
828
+ }
829
+ )
869
830
  }
870
831
  );
871
832
  }
@@ -894,6 +855,7 @@ function SwitchField({
894
855
  disabled,
895
856
  readOnly,
896
857
  opacity: readOnly ? 0.8 : 1,
858
+ "aria-describedby": field["aria-describedby"],
897
859
  ref,
898
860
  ...switchProps
899
861
  }
@@ -942,6 +904,6 @@ function TextareaField({
942
904
  }
943
905
  TextareaField.displayName = "TextareaField";
944
906
 
945
- export { ArrayField, CheckboxField, CodeField, ColorPickerField, ControlledFormField, DatePickerField, DirtyFormGuard, EditableHeading, FileField, FormField, InputField, MarkdownField, NumberInputField2 as NumberInputField, RadioGroupField, SelectActionField, SelectField, SwitchField, TextareaField };
907
+ export { ArrayField, CheckboxField, CodeField, ColorPickerField, ControlledFormField, DatePickerField, DirtyFormGuard, EditableHeading, FileField, FormField, InputField, MarkdownField, NumberInputField2 as NumberInputField, RadioGroupField, SelectField, SwitchField, TextareaField };
946
908
  //# sourceMappingURL=index.js.map
947
909
  //# sourceMappingURL=index.js.map