@bitrise/bitkit-v2 0.3.514 → 0.3.515

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.
@@ -13,6 +13,7 @@ export interface BitkitFieldProps extends Omit<Field.RootProps, 'disabled' | 'in
13
13
  * Badge, counter and tooltip are omitted in this mode, since they are purely visual.
14
14
  */
15
15
  labelHidden?: boolean;
16
+ /** Mark the field as not required. A `readOnly` field is never filled in, so it is neither required nor labelled optional. */
16
17
  optional?: boolean;
17
18
  state?: 'disabled' | 'error' | 'readOnly' | 'warning';
18
19
  tooltip?: string;
@@ -7,6 +7,7 @@ import { VisuallyHidden } from "@chakra-ui/react/visually-hidden";
7
7
  var BitkitField = forwardRef((props, ref) => {
8
8
  const { badge, counterText, children, errorText, helperText, label, labelHidden, optional, state, tooltip, warningText, ...rest } = props;
9
9
  const isInvalid = state === "error" || !!errorText;
10
+ const isReadOnly = state === "readOnly";
10
11
  let labelNode = null;
11
12
  if (labelHidden) labelNode = label ? /* @__PURE__ */ jsx(VisuallyHidden, {
12
13
  asChild: true,
@@ -17,7 +18,7 @@ var BitkitField = forwardRef((props, ref) => {
17
18
  children: /* @__PURE__ */ jsx(BitkitLabel, {
18
19
  badge,
19
20
  counterText,
20
- optional,
21
+ optional: isReadOnly ? false : optional,
21
22
  tooltip,
22
23
  children: label
23
24
  })
@@ -25,8 +26,8 @@ var BitkitField = forwardRef((props, ref) => {
25
26
  return /* @__PURE__ */ jsxs(Field.Root, {
26
27
  disabled: state === "disabled",
27
28
  invalid: isInvalid,
28
- readOnly: state === "readOnly",
29
- required: !optional,
29
+ readOnly: isReadOnly,
30
+ required: !optional && !isReadOnly,
30
31
  ref,
31
32
  ...rest,
32
33
  children: [
@@ -1 +1 @@
1
- {"version":3,"file":"BitkitField.js","names":[],"sources":["../../../lib/components/BitkitField/BitkitField.tsx"],"sourcesContent":["import { Field } from '@chakra-ui/react/field';\nimport { VisuallyHidden } from '@chakra-ui/react/visually-hidden';\nimport { forwardRef, type ReactNode } from 'react';\n\nimport BitkitLabel from '../BitkitLabel/BitkitLabel';\n\nexport interface BitkitFieldProps extends Omit<Field.RootProps, 'disabled' | 'invalid' | 'readOnly'> {\n badge?: ReactNode;\n children: ReactNode;\n counterText?: string;\n errorText?: ReactNode;\n helperText?: ReactNode;\n label?: string;\n /**\n * Keep the label in the accessibility tree (associated with the control) but hide it visually.\n * For fields whose purpose is already visually obvious — e.g. a search input with a magnifier icon.\n * Badge, counter and tooltip are omitted in this mode, since they are purely visual.\n */\n labelHidden?: boolean;\n optional?: boolean;\n state?: 'disabled' | 'error' | 'readOnly' | 'warning';\n tooltip?: string;\n warningText?: ReactNode;\n}\n\nconst BitkitField = forwardRef<HTMLDivElement, BitkitFieldProps>((props, ref) => {\n const {\n badge,\n counterText,\n children,\n errorText,\n helperText,\n label,\n labelHidden,\n optional,\n state,\n tooltip,\n warningText,\n ...rest\n } = props;\n\n const isInvalid = state === 'error' || !!errorText;\n\n let labelNode: ReactNode = null;\n if (labelHidden) {\n // Field.Label still wires `htmlFor` to the control; VisuallyHidden only strips it from view.\n labelNode = label ? (\n <VisuallyHidden asChild>\n <Field.Label>{label}</Field.Label>\n </VisuallyHidden>\n ) : null;\n } else if (label || badge || counterText) {\n labelNode = (\n <Field.Label asChild>\n <BitkitLabel badge={badge} counterText={counterText} optional={optional} tooltip={tooltip}>\n {label}\n </BitkitLabel>\n </Field.Label>\n );\n }\n\n return (\n <Field.Root\n disabled={state === 'disabled'}\n invalid={isInvalid}\n readOnly={state === 'readOnly'}\n required={!optional}\n ref={ref}\n {...rest}\n >\n {labelNode}\n {children}\n {!!helperText && !errorText && !warningText && <Field.HelperText>{helperText}</Field.HelperText>}\n {!!warningText && !errorText && <Field.HelperText color=\"text/body\">{warningText}</Field.HelperText>}\n {!!errorText && <Field.ErrorText>{errorText}</Field.ErrorText>}\n </Field.Root>\n );\n});\n\nBitkitField.displayName = 'BitkitField';\n\nexport default BitkitField;\n"],"mappings":";;;;;;AAyBA,IAAM,cAAc,YAA8C,OAAO,QAAQ;CAC/E,MAAM,EACJ,OACA,aACA,UACA,WACA,YACA,OACA,aACA,UACA,OACA,SACA,aACA,GAAG,SACD;CAEJ,MAAM,YAAY,UAAU,WAAW,CAAC,CAAC;CAEzC,IAAI,YAAuB;CAC3B,IAAI,aAEF,YAAY,QACV,oBAAC,gBAAD;EAAgB,SAAA;EACd,UAAA,oBAAC,MAAM,OAAP,EAAA,UAAc,MAAmB,CAAA;CACnB,CAAA,IACd;MACC,IAAI,SAAS,SAAS,aAC3B,YACE,oBAAC,MAAM,OAAP;EAAa,SAAA;EACX,UAAA,oBAAC,aAAD;GAAoB;GAAoB;GAAuB;GAAmB;GAC/E,UAAA;EACU,CAAA;CACF,CAAA;CAIjB,OACE,qBAAC,MAAM,MAAP;EACE,UAAU,UAAU;EACpB,SAAS;EACT,UAAU,UAAU;EACpB,UAAU,CAAC;EACN;EACL,GAAI;EANN,UAAA;GAQG;GACA;GACA,CAAC,CAAC,cAAc,CAAC,aAAa,CAAC,eAAe,oBAAC,MAAM,YAAP,EAAA,UAAmB,WAA6B,CAAA;GAC9F,CAAC,CAAC,eAAe,CAAC,aAAa,oBAAC,MAAM,YAAP;IAAkB,OAAM;IAAa,UAAA;GAA8B,CAAA;GAClG,CAAC,CAAC,aAAa,oBAAC,MAAM,WAAP,EAAA,UAAkB,UAA2B,CAAA;EACnD;;AAEhB,CAAC;AAED,YAAY,cAAc"}
1
+ {"version":3,"file":"BitkitField.js","names":[],"sources":["../../../lib/components/BitkitField/BitkitField.tsx"],"sourcesContent":["import { Field } from '@chakra-ui/react/field';\nimport { VisuallyHidden } from '@chakra-ui/react/visually-hidden';\nimport { forwardRef, type ReactNode } from 'react';\n\nimport BitkitLabel from '../BitkitLabel/BitkitLabel';\n\nexport interface BitkitFieldProps extends Omit<Field.RootProps, 'disabled' | 'invalid' | 'readOnly'> {\n badge?: ReactNode;\n children: ReactNode;\n counterText?: string;\n errorText?: ReactNode;\n helperText?: ReactNode;\n label?: string;\n /**\n * Keep the label in the accessibility tree (associated with the control) but hide it visually.\n * For fields whose purpose is already visually obvious — e.g. a search input with a magnifier icon.\n * Badge, counter and tooltip are omitted in this mode, since they are purely visual.\n */\n labelHidden?: boolean;\n /** Mark the field as not required. A `readOnly` field is never filled in, so it is neither required nor labelled optional. */\n optional?: boolean;\n state?: 'disabled' | 'error' | 'readOnly' | 'warning';\n tooltip?: string;\n warningText?: ReactNode;\n}\n\nconst BitkitField = forwardRef<HTMLDivElement, BitkitFieldProps>((props, ref) => {\n const {\n badge,\n counterText,\n children,\n errorText,\n helperText,\n label,\n labelHidden,\n optional,\n state,\n tooltip,\n warningText,\n ...rest\n } = props;\n\n const isInvalid = state === 'error' || !!errorText;\n const isReadOnly = state === 'readOnly';\n\n let labelNode: ReactNode = null;\n if (labelHidden) {\n // Field.Label still wires `htmlFor` to the control; VisuallyHidden only strips it from view.\n labelNode = label ? (\n <VisuallyHidden asChild>\n <Field.Label>{label}</Field.Label>\n </VisuallyHidden>\n ) : null;\n } else if (label || badge || counterText) {\n labelNode = (\n <Field.Label asChild>\n <BitkitLabel badge={badge} counterText={counterText} optional={isReadOnly ? false : optional} tooltip={tooltip}>\n {label}\n </BitkitLabel>\n </Field.Label>\n );\n }\n\n return (\n <Field.Root\n disabled={state === 'disabled'}\n invalid={isInvalid}\n readOnly={isReadOnly}\n required={!optional && !isReadOnly}\n ref={ref}\n {...rest}\n >\n {labelNode}\n {children}\n {!!helperText && !errorText && !warningText && <Field.HelperText>{helperText}</Field.HelperText>}\n {!!warningText && !errorText && <Field.HelperText color=\"text/body\">{warningText}</Field.HelperText>}\n {!!errorText && <Field.ErrorText>{errorText}</Field.ErrorText>}\n </Field.Root>\n );\n});\n\nBitkitField.displayName = 'BitkitField';\n\nexport default BitkitField;\n"],"mappings":";;;;;;AA0BA,IAAM,cAAc,YAA8C,OAAO,QAAQ;CAC/E,MAAM,EACJ,OACA,aACA,UACA,WACA,YACA,OACA,aACA,UACA,OACA,SACA,aACA,GAAG,SACD;CAEJ,MAAM,YAAY,UAAU,WAAW,CAAC,CAAC;CACzC,MAAM,aAAa,UAAU;CAE7B,IAAI,YAAuB;CAC3B,IAAI,aAEF,YAAY,QACV,oBAAC,gBAAD;EAAgB,SAAA;EACd,UAAA,oBAAC,MAAM,OAAP,EAAA,UAAc,MAAmB,CAAA;CACnB,CAAA,IACd;MACC,IAAI,SAAS,SAAS,aAC3B,YACE,oBAAC,MAAM,OAAP;EAAa,SAAA;EACX,UAAA,oBAAC,aAAD;GAAoB;GAAoB;GAAa,UAAU,aAAa,QAAQ;GAAmB;GACpG,UAAA;EACU,CAAA;CACF,CAAA;CAIjB,OACE,qBAAC,MAAM,MAAP;EACE,UAAU,UAAU;EACpB,SAAS;EACT,UAAU;EACV,UAAU,CAAC,YAAY,CAAC;EACnB;EACL,GAAI;EANN,UAAA;GAQG;GACA;GACA,CAAC,CAAC,cAAc,CAAC,aAAa,CAAC,eAAe,oBAAC,MAAM,YAAP,EAAA,UAAmB,WAA6B,CAAA;GAC9F,CAAC,CAAC,eAAe,CAAC,aAAa,oBAAC,MAAM,YAAP;IAAkB,OAAM;IAAa,UAAA;GAA8B,CAAA;GAClG,CAAC,CAAC,aAAa,oBAAC,MAAM,WAAP,EAAA,UAAkB,UAA2B,CAAA;EACnD;;AAEhB,CAAC;AAED,YAAY,cAAc"}
@@ -65,7 +65,7 @@ var BitkitTagsInput = forwardRef((props, ref) => {
65
65
  children: /* @__PURE__ */ jsx(BitkitLabel, {
66
66
  badge,
67
67
  counterText: max !== void 0 ? `${tagValues.length}/${max}` : void 0,
68
- optional,
68
+ optional: isReadOnly ? false : optional,
69
69
  tooltip,
70
70
  children: label
71
71
  })
@@ -1 +1 @@
1
- {"version":3,"file":"BitkitTagsInput.js","names":[],"sources":["../../../lib/components/BitkitTagsInput/BitkitTagsInput.tsx"],"sourcesContent":["import { useControllableState } from '@chakra-ui/react/hooks';\nimport { chakra, useSlotRecipe } from '@chakra-ui/react/styled-system';\nimport { TagsInput } from '@chakra-ui/react/tags-input';\nimport { forwardRef } from 'react';\n\nimport { IconCross, IconErrorCircleFilled, IconWarningYellow } from '../../icons';\nimport BitkitField, { type BitkitFieldProps } from '../BitkitField/BitkitField';\nimport BitkitLabel from '../BitkitLabel/BitkitLabel';\n\n// `counterText` is derived from `max`, so it isn't a public prop here.\nexport interface BitkitTagsInputProps extends Omit<BitkitFieldProps, 'children' | 'counterText' | 'state'> {\n addOnPaste?: TagsInput.RootProps['addOnPaste'];\n blurBehavior?: TagsInput.RootProps['blurBehavior'];\n defaultValue?: string[];\n delimiter?: TagsInput.RootProps['delimiter'];\n /**\n * Predicate that marks individual tags as invalid: a tag whose value returns `true` is rendered\n * in the red color set (like BitkitTag `colorVariant=\"red\"`). Unlike `validate` — which gates\n * whether a tag can be *added* — this styles tags that are already in the list (e.g. a pasted\n * or pre-filled value that fails a format check). While any tag is invalid the whole field flips\n * to the error state automatically; pass `errorText` to surface the accompanying message.\n */\n isValueInvalid?: (value: string) => boolean;\n max?: number;\n onValueChange?: TagsInput.RootProps['onValueChange'];\n placeholder?: string;\n size?: 'md' | 'lg';\n state?: 'disabled' | 'error' | 'readOnly' | 'warning';\n validate?: TagsInput.RootProps['validate'];\n value?: string[];\n}\n\nconst rejectEmpty: NonNullable<TagsInput.RootProps['validate']> = ({ inputValue }) => inputValue.trim().length > 0;\n\n/**\n * A field for entering a list of short string tags: type and commit a tag with Enter or a delimiter\n * (comma or whitespace by default); pasting splits on the same delimiter. Tags can be removed one at\n * a time or cleared all at once, and empty/whitespace-only input is rejected. Pass `max` to cap the\n * number of tags — a live counter is then shown next to the label.\n */\nconst BitkitTagsInput = forwardRef<HTMLDivElement, BitkitTagsInputProps>((props, ref) => {\n const {\n addOnPaste = true,\n blurBehavior = 'add',\n defaultValue,\n // Greedy `+` collapses runs of whitespace/commas into a single delimiter so pasting\n // \"alpha, beta\" doesn't spawn an empty tag between the alpha and beta.\n delimiter = /[\\s,]+/,\n isValueInvalid,\n max,\n onValueChange,\n placeholder,\n size = 'lg',\n state,\n validate,\n value,\n // Label chrome is rendered via TagsInput.Label (see below), not BitkitField, so it\n // associates with TagsInput.Input. Pull these out of the props forwarded to BitkitField.\n badge,\n label,\n optional,\n tooltip,\n ...fieldProps\n } = props;\n\n // Always reject empty/whitespace-only input (covers leading/trailing delimiters on paste\n // and blurBehavior=\"add\" with an empty input). Chain with a user-supplied validate if any.\n const effectiveValidate: NonNullable<TagsInput.RootProps['validate']> = (details) =>\n rejectEmpty(details) && (validate?.(details) ?? true);\n\n const styles = useSlotRecipe({ key: 'tagsInput' })({ size });\n\n const [currentValues, setCurrentValues] = useControllableState<Array<string>>({\n value,\n defaultValue: defaultValue ?? [],\n });\n const isInteractive = state !== 'disabled' && state !== 'readOnly';\n const hasInvalidValue = isInteractive && !!isValueInvalid && currentValues.some(isValueInvalid);\n const effectiveState = hasInvalidValue ? 'error' : state;\n const handleValueChange: NonNullable<TagsInput.RootProps['onValueChange']> = (details) => {\n setCurrentValues(details.value);\n onValueChange?.(details);\n };\n\n const hasWarning = effectiveState === 'warning' || !!fieldProps.warningText;\n const isInvalid = effectiveState === 'error' || !!fieldProps.errorText;\n const isDisabled = effectiveState === 'disabled';\n const isReadOnly = effectiveState === 'readOnly';\n\n let statusIcon = undefined;\n if (isInvalid) {\n statusIcon = <IconErrorCircleFilled color=\"icon/negative\" size={size === 'lg' ? '24' : '16'} />;\n } else if (hasWarning) {\n statusIcon = <IconWarningYellow size={size === 'lg' ? '24' : '16'} />;\n }\n\n return (\n <TagsInput.Root\n addOnPaste={addOnPaste}\n blurBehavior={blurBehavior}\n defaultValue={defaultValue}\n delimiter={delimiter}\n disabled={isDisabled}\n invalid={isInvalid}\n max={max}\n onValueChange={handleValueChange}\n readOnly={isReadOnly}\n size={size}\n validate={effectiveValidate}\n value={value}\n >\n <TagsInput.Context>\n {({ value: tagValues }) => (\n // Strip any stray runtime `counterText` (not a public prop) so it can't slip through\n // `fieldProps` into BitkitField and resurrect an orphaned Field.Label; the counter is\n // rendered via TagsInput.Label instead.\n <BitkitField optional={optional} ref={ref} state={effectiveState} {...fieldProps} counterText={undefined}>\n {(!!label || !!badge || max !== undefined) && (\n // Chakra's Field.Label wires htmlFor to the Field machine's control, which the\n // TagsInput input never claims (separate Ark machine). TagsInput.Label is the\n // documented composition — it associates with TagsInput.Input.\n <TagsInput.Label asChild>\n <BitkitLabel\n badge={badge}\n counterText={max !== undefined ? `${tagValues.length}/${max}` : undefined}\n optional={optional}\n tooltip={tooltip}\n >\n {label}\n </BitkitLabel>\n </TagsInput.Label>\n )}\n <TagsInput.Control>\n <chakra.div css={styles.tagsBlock}>\n {tagValues.map((tagValue, index) => (\n <TagsInput.Item index={index} key={tagValue} value={tagValue}>\n <TagsInput.ItemPreview data-invalid={(hasInvalidValue && isValueInvalid?.(tagValue)) || undefined}>\n <TagsInput.ItemText>{tagValue}</TagsInput.ItemText>\n {!isReadOnly && (\n <TagsInput.ItemDeleteTrigger>\n <IconCross size=\"16\" />\n </TagsInput.ItemDeleteTrigger>\n )}\n </TagsInput.ItemPreview>\n <TagsInput.ItemInput />\n </TagsInput.Item>\n ))}\n <TagsInput.Input placeholder={placeholder} />\n </chakra.div>\n {(statusIcon || (tagValues.length > 0 && !isDisabled && !isReadOnly)) && (\n <chakra.div css={styles.suffixBlock}>\n {statusIcon}\n {tagValues.length > 0 && !isDisabled && !isReadOnly && (\n <TagsInput.ClearTrigger css={styles.clearTrigger}>\n <IconCross size={size === 'lg' ? '24' : '16'} />\n </TagsInput.ClearTrigger>\n )}\n </chakra.div>\n )}\n </TagsInput.Control>\n <TagsInput.HiddenInput />\n </BitkitField>\n )}\n </TagsInput.Context>\n </TagsInput.Root>\n );\n});\n\nBitkitTagsInput.displayName = 'BitkitTagsInput';\nexport default BitkitTagsInput;\n"],"mappings":";;;;;;;;;;;AAgCA,IAAM,eAA6D,EAAE,iBAAiB,WAAW,KAAK,CAAC,CAAC,SAAS;;;;;;;AAQjH,IAAM,kB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["../../../lib/components/BitkitTagsInput/BitkitTagsInput.tsx"],"sourcesContent":["import { useControllableState } from '@chakra-ui/react/hooks';\nimport { chakra, useSlotRecipe } from '@chakra-ui/react/styled-system';\nimport { TagsInput } from '@chakra-ui/react/tags-input';\nimport { forwardRef } from 'react';\n\nimport { IconCross, IconErrorCircleFilled, IconWarningYellow } from '../../icons';\nimport BitkitField, { type BitkitFieldProps } from '../BitkitField/BitkitField';\nimport BitkitLabel from '../BitkitLabel/BitkitLabel';\n\n// `counterText` is derived from `max`, so it isn't a public prop here.\nexport interface BitkitTagsInputProps extends Omit<BitkitFieldProps, 'children' | 'counterText' | 'state'> {\n addOnPaste?: TagsInput.RootProps['addOnPaste'];\n blurBehavior?: TagsInput.RootProps['blurBehavior'];\n defaultValue?: string[];\n delimiter?: TagsInput.RootProps['delimiter'];\n /**\n * Predicate that marks individual tags as invalid: a tag whose value returns `true` is rendered\n * in the red color set (like BitkitTag `colorVariant=\"red\"`). Unlike `validate` — which gates\n * whether a tag can be *added* — this styles tags that are already in the list (e.g. a pasted\n * or pre-filled value that fails a format check). While any tag is invalid the whole field flips\n * to the error state automatically; pass `errorText` to surface the accompanying message.\n */\n isValueInvalid?: (value: string) => boolean;\n max?: number;\n onValueChange?: TagsInput.RootProps['onValueChange'];\n placeholder?: string;\n size?: 'md' | 'lg';\n state?: 'disabled' | 'error' | 'readOnly' | 'warning';\n validate?: TagsInput.RootProps['validate'];\n value?: string[];\n}\n\nconst rejectEmpty: NonNullable<TagsInput.RootProps['validate']> = ({ inputValue }) => inputValue.trim().length > 0;\n\n/**\n * A field for entering a list of short string tags: type and commit a tag with Enter or a delimiter\n * (comma or whitespace by default); pasting splits on the same delimiter. Tags can be removed one at\n * a time or cleared all at once, and empty/whitespace-only input is rejected. Pass `max` to cap the\n * number of tags — a live counter is then shown next to the label.\n */\nconst BitkitTagsInput = forwardRef<HTMLDivElement, BitkitTagsInputProps>((props, ref) => {\n const {\n addOnPaste = true,\n blurBehavior = 'add',\n defaultValue,\n // Greedy `+` collapses runs of whitespace/commas into a single delimiter so pasting\n // \"alpha, beta\" doesn't spawn an empty tag between the alpha and beta.\n delimiter = /[\\s,]+/,\n isValueInvalid,\n max,\n onValueChange,\n placeholder,\n size = 'lg',\n state,\n validate,\n value,\n // Label chrome is rendered via TagsInput.Label (see below), not BitkitField, so it\n // associates with TagsInput.Input. Pull these out of the props forwarded to BitkitField.\n badge,\n label,\n optional,\n tooltip,\n ...fieldProps\n } = props;\n\n // Always reject empty/whitespace-only input (covers leading/trailing delimiters on paste\n // and blurBehavior=\"add\" with an empty input). Chain with a user-supplied validate if any.\n const effectiveValidate: NonNullable<TagsInput.RootProps['validate']> = (details) =>\n rejectEmpty(details) && (validate?.(details) ?? true);\n\n const styles = useSlotRecipe({ key: 'tagsInput' })({ size });\n\n const [currentValues, setCurrentValues] = useControllableState<Array<string>>({\n value,\n defaultValue: defaultValue ?? [],\n });\n const isInteractive = state !== 'disabled' && state !== 'readOnly';\n const hasInvalidValue = isInteractive && !!isValueInvalid && currentValues.some(isValueInvalid);\n const effectiveState = hasInvalidValue ? 'error' : state;\n const handleValueChange: NonNullable<TagsInput.RootProps['onValueChange']> = (details) => {\n setCurrentValues(details.value);\n onValueChange?.(details);\n };\n\n const hasWarning = effectiveState === 'warning' || !!fieldProps.warningText;\n const isInvalid = effectiveState === 'error' || !!fieldProps.errorText;\n const isDisabled = effectiveState === 'disabled';\n const isReadOnly = effectiveState === 'readOnly';\n\n let statusIcon = undefined;\n if (isInvalid) {\n statusIcon = <IconErrorCircleFilled color=\"icon/negative\" size={size === 'lg' ? '24' : '16'} />;\n } else if (hasWarning) {\n statusIcon = <IconWarningYellow size={size === 'lg' ? '24' : '16'} />;\n }\n\n return (\n <TagsInput.Root\n addOnPaste={addOnPaste}\n blurBehavior={blurBehavior}\n defaultValue={defaultValue}\n delimiter={delimiter}\n disabled={isDisabled}\n invalid={isInvalid}\n max={max}\n onValueChange={handleValueChange}\n readOnly={isReadOnly}\n size={size}\n validate={effectiveValidate}\n value={value}\n >\n <TagsInput.Context>\n {({ value: tagValues }) => (\n // Strip any stray runtime `counterText` (not a public prop) so it can't slip through\n // `fieldProps` into BitkitField and resurrect an orphaned Field.Label; the counter is\n // rendered via TagsInput.Label instead.\n <BitkitField optional={optional} ref={ref} state={effectiveState} {...fieldProps} counterText={undefined}>\n {(!!label || !!badge || max !== undefined) && (\n // Chakra's Field.Label wires htmlFor to the Field machine's control, which the\n // TagsInput input never claims (separate Ark machine). TagsInput.Label is the\n // documented composition — it associates with TagsInput.Input.\n <TagsInput.Label asChild>\n <BitkitLabel\n badge={badge}\n counterText={max !== undefined ? `${tagValues.length}/${max}` : undefined}\n optional={isReadOnly ? false : optional}\n tooltip={tooltip}\n >\n {label}\n </BitkitLabel>\n </TagsInput.Label>\n )}\n <TagsInput.Control>\n <chakra.div css={styles.tagsBlock}>\n {tagValues.map((tagValue, index) => (\n <TagsInput.Item index={index} key={tagValue} value={tagValue}>\n <TagsInput.ItemPreview data-invalid={(hasInvalidValue && isValueInvalid?.(tagValue)) || undefined}>\n <TagsInput.ItemText>{tagValue}</TagsInput.ItemText>\n {!isReadOnly && (\n <TagsInput.ItemDeleteTrigger>\n <IconCross size=\"16\" />\n </TagsInput.ItemDeleteTrigger>\n )}\n </TagsInput.ItemPreview>\n <TagsInput.ItemInput />\n </TagsInput.Item>\n ))}\n <TagsInput.Input placeholder={placeholder} />\n </chakra.div>\n {(statusIcon || (tagValues.length > 0 && !isDisabled && !isReadOnly)) && (\n <chakra.div css={styles.suffixBlock}>\n {statusIcon}\n {tagValues.length > 0 && !isDisabled && !isReadOnly && (\n <TagsInput.ClearTrigger css={styles.clearTrigger}>\n <IconCross size={size === 'lg' ? '24' : '16'} />\n </TagsInput.ClearTrigger>\n )}\n </chakra.div>\n )}\n </TagsInput.Control>\n <TagsInput.HiddenInput />\n </BitkitField>\n )}\n </TagsInput.Context>\n </TagsInput.Root>\n );\n});\n\nBitkitTagsInput.displayName = 'BitkitTagsInput';\n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oBAAC,UAAU,aAAX,CAAwB,CAAA;GACb;EAEE,CAAA,EAAA,CAAA;CACL,CAAA;AAEpB,CAAC;AAED,gBAAgB,cAAc"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bitrise/bitkit-v2",
3
3
  "private": false,
4
- "version": "0.3.514",
4
+ "version": "0.3.515",
5
5
  "description": "Bitrise Design System Components built with Chakra UI V3",
6
6
  "keywords": [
7
7
  "react",