@bitrise/bitkit-v2 0.3.475-beta.3012 → 0.3.475

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 (106) hide show
  1. package/dist/components/BitkitCalendar/BitkitCalendar.d.ts +0 -12
  2. package/dist/components/BitkitCalendar/BitkitCalendar.js +1 -7
  3. package/dist/components/BitkitCalendar/BitkitCalendar.js.map +1 -1
  4. package/dist/components/BitkitCalendar/components/CalendarContent.d.ts +1 -5
  5. package/dist/components/BitkitCalendar/components/CalendarContent.js +43 -60
  6. package/dist/components/BitkitCalendar/components/CalendarContent.js.map +1 -1
  7. package/dist/components/BitkitCalendar/components/CalendarMonth.d.ts +2 -4
  8. package/dist/components/BitkitCalendar/components/CalendarMonth.js +5 -15
  9. package/dist/components/BitkitCalendar/components/CalendarMonth.js.map +1 -1
  10. package/dist/components/BitkitCalendar/components/CalendarMonthSelect.d.ts +1 -2
  11. package/dist/components/BitkitCalendar/components/CalendarMonthSelect.js +2 -3
  12. package/dist/components/BitkitCalendar/components/CalendarMonthSelect.js.map +1 -1
  13. package/dist/components/BitkitCalendar/components/CalendarNextTrigger.d.ts +1 -3
  14. package/dist/components/BitkitCalendar/components/CalendarNextTrigger.js +3 -3
  15. package/dist/components/BitkitCalendar/components/CalendarNextTrigger.js.map +1 -1
  16. package/dist/components/BitkitCalendar/components/CalendarPrevTrigger.d.ts +1 -3
  17. package/dist/components/BitkitCalendar/components/CalendarPrevTrigger.js +3 -3
  18. package/dist/components/BitkitCalendar/components/CalendarPrevTrigger.js.map +1 -1
  19. package/dist/components/BitkitCalendar/components/CalendarSelect.d.ts +0 -1
  20. package/dist/components/BitkitCalendar/components/CalendarSelect.js +2 -4
  21. package/dist/components/BitkitCalendar/components/CalendarSelect.js.map +1 -1
  22. package/dist/components/BitkitCalendar/components/CalendarYearSelect.d.ts +1 -2
  23. package/dist/components/BitkitCalendar/components/CalendarYearSelect.js +2 -3
  24. package/dist/components/BitkitCalendar/components/CalendarYearSelect.js.map +1 -1
  25. package/dist/components/BitkitDatePicker/BitkitDatePicker.d.ts +0 -2
  26. package/dist/components/BitkitDatePicker/BitkitDatePicker.js +1 -2
  27. package/dist/components/BitkitDatePicker/BitkitDatePicker.js.map +1 -1
  28. package/dist/components/BitkitMarkdown/BitkitMarkdown.js +1 -1
  29. package/dist/components/BitkitNoteCard/BitkitNoteCard.js +1 -1
  30. package/dist/components/index.d.ts +0 -6
  31. package/dist/main.js +7 -8
  32. package/dist/theme/recipes/Spinner.recipe.d.ts +4 -4
  33. package/dist/theme/recipes/Spinner.recipe.js +4 -4
  34. package/dist/theme/recipes/Spinner.recipe.js.map +1 -1
  35. package/dist/theme/recipes/index.d.ts +4 -4
  36. package/dist/theme/semantic-tokens/index.d.ts +5 -0
  37. package/dist/theme/semantic-tokens/semanticColors.d.ts +5 -0
  38. package/dist/theme/semantic-tokens/semanticColors.js +1 -0
  39. package/dist/theme/semantic-tokens/semanticColors.js.map +1 -1
  40. package/dist/theme/slot-recipes/DatePicker.recipe.d.ts +0 -15
  41. package/dist/theme/slot-recipes/DatePicker.recipe.js +22 -72
  42. package/dist/theme/slot-recipes/DatePicker.recipe.js.map +1 -1
  43. package/dist/theme/slot-recipes/DatePickerSelect.recipe.d.ts +0 -82
  44. package/dist/theme/slot-recipes/DatePickerSelect.recipe.js +10 -28
  45. package/dist/theme/slot-recipes/DatePickerSelect.recipe.js.map +1 -1
  46. package/dist/theme/slot-recipes/Menu.recipe.js +1 -6
  47. package/dist/theme/slot-recipes/Menu.recipe.js.map +1 -1
  48. package/dist/theme/slot-recipes/NoteCard.recipe.d.ts +1 -1
  49. package/dist/theme/slot-recipes/NoteCard.recipe.js +1 -1
  50. package/dist/theme/slot-recipes/NoteCard.recipe.js.map +1 -1
  51. package/dist/theme/slot-recipes/PageFooter.recipe.d.ts +5 -3
  52. package/dist/theme/slot-recipes/PageFooter.recipe.js +5 -3
  53. package/dist/theme/slot-recipes/PageFooter.recipe.js.map +1 -1
  54. package/dist/theme/slot-recipes/Tag.recipe.d.ts +1 -1
  55. package/dist/theme/slot-recipes/index.d.ts +7 -159
  56. package/dist/theme/slot-recipes/index.js +0 -4
  57. package/dist/theme/slot-recipes/index.js.map +1 -1
  58. package/dist/utilities/BitkitPortalContext.js +2 -3
  59. package/dist/utilities/BitkitPortalContext.js.map +1 -1
  60. package/docs/v1-to-v2-migration-guide.md +1 -48
  61. package/package.json +1 -1
  62. package/dist/components/BitkitFilter/BitkitFilter.context.d.ts +0 -65
  63. package/dist/components/BitkitFilter/BitkitFilter.context.js +0 -82
  64. package/dist/components/BitkitFilter/BitkitFilter.context.js.map +0 -1
  65. package/dist/components/BitkitFilter/BitkitFilter.d.ts +0 -55
  66. package/dist/components/BitkitFilter/BitkitFilter.js +0 -240
  67. package/dist/components/BitkitFilter/BitkitFilter.js.map +0 -1
  68. package/dist/components/BitkitFilter/BitkitFilter.utils.d.ts +0 -18
  69. package/dist/components/BitkitFilter/BitkitFilter.utils.js +0 -42
  70. package/dist/components/BitkitFilter/BitkitFilter.utils.js.map +0 -1
  71. package/dist/components/BitkitFilter/BitkitFilterAdd.d.ts +0 -18
  72. package/dist/components/BitkitFilter/BitkitFilterAdd.js +0 -188
  73. package/dist/components/BitkitFilter/BitkitFilterAdd.js.map +0 -1
  74. package/dist/components/BitkitFilter/BitkitFilterDateRange.d.ts +0 -26
  75. package/dist/components/BitkitFilter/BitkitFilterDateRange.js +0 -118
  76. package/dist/components/BitkitFilter/BitkitFilterDateRange.js.map +0 -1
  77. package/dist/components/BitkitFilter/BitkitFilterSearch.d.ts +0 -23
  78. package/dist/components/BitkitFilter/BitkitFilterSearch.js +0 -70
  79. package/dist/components/BitkitFilter/BitkitFilterSearch.js.map +0 -1
  80. package/dist/components/BitkitFilter/BitkitFilterSelect.d.ts +0 -61
  81. package/dist/components/BitkitFilter/BitkitFilterSelect.js +0 -140
  82. package/dist/components/BitkitFilter/BitkitFilterSelect.js.map +0 -1
  83. package/dist/components/BitkitFilter/BitkitFilterSwitch.d.ts +0 -28
  84. package/dist/components/BitkitFilter/BitkitFilterSwitch.js +0 -87
  85. package/dist/components/BitkitFilter/BitkitFilterSwitch.js.map +0 -1
  86. package/dist/components/BitkitFilter/components/FilterChip.d.ts +0 -23
  87. package/dist/components/BitkitFilter/components/FilterChip.js +0 -64
  88. package/dist/components/BitkitFilter/components/FilterChip.js.map +0 -1
  89. package/dist/components/BitkitFilter/components/FilterField.d.ts +0 -15
  90. package/dist/components/BitkitFilter/components/FilterField.js +0 -58
  91. package/dist/components/BitkitFilter/components/FilterField.js.map +0 -1
  92. package/dist/components/BitkitFilter/components/FilterPanel.d.ts +0 -42
  93. package/dist/components/BitkitFilter/components/FilterPanel.js +0 -126
  94. package/dist/components/BitkitFilter/components/FilterPanel.js.map +0 -1
  95. package/dist/components/BitkitFilter/components/FilterSearchInput.d.ts +0 -15
  96. package/dist/components/BitkitFilter/components/FilterSearchInput.js +0 -41
  97. package/dist/components/BitkitFilter/components/FilterSearchInput.js.map +0 -1
  98. package/dist/components/BitkitFilter/components/FilterSelectForm.d.ts +0 -39
  99. package/dist/components/BitkitFilter/components/FilterSelectForm.js +0 -278
  100. package/dist/components/BitkitFilter/components/FilterSelectForm.js.map +0 -1
  101. package/dist/theme/slot-recipes/Filter.recipe.d.ts +0 -37
  102. package/dist/theme/slot-recipes/Filter.recipe.js +0 -636
  103. package/dist/theme/slot-recipes/Filter.recipe.js.map +0 -1
  104. package/dist/theme/slot-recipes/Listbox.recipe.d.ts +0 -22
  105. package/dist/theme/slot-recipes/Listbox.recipe.js +0 -97
  106. package/dist/theme/slot-recipes/Listbox.recipe.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"FilterPanel.js","names":[],"sources":["../../../../lib/components/BitkitFilter/components/FilterPanel.tsx"],"sourcesContent":["import { Box } from '@chakra-ui/react/box';\nimport { Drawer } from '@chakra-ui/react/drawer';\nimport { Popover } from '@chakra-ui/react/popover';\nimport { Portal } from '@chakra-ui/react/portal';\nimport { Text } from '@chakra-ui/react/text';\nimport { type ReactNode } from 'react';\n\nimport { IconArrowLeft } from '../../../icons';\nimport { usePortalContext } from '../../../utilities/BitkitPortalContext';\nimport BitkitBadge from '../../BitkitBadge/BitkitBadge';\nimport BitkitButton from '../../BitkitButton/BitkitButton';\nimport BitkitControlButton from '../../BitkitControlButton/BitkitControlButton';\nimport { useFilterContext } from '../BitkitFilter.context';\n\nexport interface FilterPanelProps {\n children: ReactNode;\n /** Where focus goes on close, for a panel without a trigger to return it to. */\n finalFocusEl?: () => HTMLElement | null;\n /** Anchors the desktop popover to an element it has no trigger for — the \"Add filter\" button. */\n getAnchorElement?: () => HTMLElement | null;\n onOpenChange: (open: boolean) => void;\n open: boolean;\n /**\n * What opens the panel: on desktop a `FilterChip`, which renders the popover's trigger; on mobile a\n * `FilterField`, which opens it through its own `onClick`.\n */\n trigger?: ReactNode;\n}\n\n/**\n * Where a filter edits its value: an anchored popover on desktop, a full-screen view stacked over the\n * filters dialog on mobile. The content unmounts on close, so the draft state of the form inside\n * starts over from the applied value each time it opens.\n */\nconst FilterPanel = (props: FilterPanelProps) => {\n const { children, finalFocusEl, getAnchorElement, onOpenChange: onOpenChangeProp, open, trigger } = props;\n const { isDisabled, isMobile, styles } = useFilterContext();\n // While the page loads the triggers are only `aria-disabled`, so opening is refused here.\n const onOpenChange = (isOpen: boolean) => {\n if (!isOpen || !isDisabled) onOpenChangeProp(isOpen);\n };\n const { disablePortal } = usePortalContext();\n\n if (isMobile) {\n return (\n <>\n {trigger}\n <Drawer.Root\n finalFocusEl={finalFocusEl}\n lazyMount\n onOpenChange={({ open: isOpen }) => onOpenChange(isOpen)}\n open={open}\n unmountOnExit\n >\n <Portal disabled={disablePortal}>\n <Drawer.Positioner>\n <Drawer.Content>{children}</Drawer.Content>\n </Drawer.Positioner>\n </Portal>\n </Drawer.Root>\n </>\n );\n }\n\n return (\n <Popover.Root\n finalFocusEl={finalFocusEl}\n lazyMount\n onOpenChange={({ open: isOpen }) => onOpenChange(isOpen)}\n open={open}\n positioning={{\n getAnchorElement,\n gutter: 8,\n placement: 'bottom-start',\n }}\n unmountOnExit\n >\n {trigger}\n <Portal disabled={disablePortal}>\n <Popover.Positioner>\n <Popover.Content css={styles.popoverContent}>{children}</Popover.Content>\n </Popover.Positioner>\n </Portal>\n </Popover.Root>\n );\n};\n\nexport interface FilterPanelHeaderProps {\n /** Desktop only: a multi-select's selection count, shown as a badge next to the title. */\n count?: number;\n title: string;\n}\n\nexport const FilterPanelHeader = ({ count, title }: FilterPanelHeaderProps) => {\n const { isMobile, styles } = useFilterContext();\n\n if (isMobile) {\n return (\n <Box css={styles.mobilePanelHeader}>\n <Drawer.CloseTrigger asChild unstyled>\n <BitkitControlButton icon={IconArrowLeft} label=\"Back\" />\n </Drawer.CloseTrigger>\n <Box>\n <Text css={styles.mobilePanelOverline}>Filter</Text>\n <Drawer.Title css={styles.mobilePanelTitle} unstyled>\n {title}\n </Drawer.Title>\n </Box>\n </Box>\n );\n }\n\n return (\n <Popover.Header>\n <Popover.Title>{title}</Popover.Title>\n {count !== undefined && <BitkitBadge>{count}</BitkitBadge>}\n </Popover.Header>\n );\n};\n\nexport interface FilterPanelFooterProps {\n /** Mobile only: the Apply button's label, e.g. \"Apply (2)\". */\n applyLabel?: string;\n isApplyDisabled: boolean;\n onApply: () => void;\n /** Desktop only: adds a \"Cancel\" button. On mobile the header's back button cancels. */\n onCancel?: () => void;\n /** The action before Apply: \"Clear\", or the wildcard-mode switch. */\n start?: { label: string; onClick: () => void };\n}\n\nexport const FilterPanelFooter = ({\n applyLabel,\n isApplyDisabled,\n onApply,\n onCancel,\n start,\n}: FilterPanelFooterProps) => {\n const { isMobile, styles } = useFilterContext();\n const applyState = isApplyDisabled ? 'disabled' : undefined;\n\n if (isMobile) {\n return (\n <Drawer.Footer>\n <Box css={styles.mobileFooter}>\n {!!start && (\n <BitkitButton onClick={start.onClick} size=\"md\" variant=\"secondary\">\n {start.label}\n </BitkitButton>\n )}\n <BitkitButton onClick={onApply} size=\"md\" state={applyState}>\n {applyLabel ?? 'Apply'}\n </BitkitButton>\n </Box>\n </Drawer.Footer>\n );\n }\n\n return (\n <Box css={styles.popoverFooter}>\n <Box css={styles.popoverFooterStart}>\n {!!start && (\n <BitkitButton onClick={start.onClick} size=\"sm\" variant=\"tertiary\">\n {start.label}\n </BitkitButton>\n )}\n </Box>\n {!!onCancel && (\n <BitkitButton onClick={onCancel} size=\"sm\" variant=\"secondary\">\n Cancel\n </BitkitButton>\n )}\n <BitkitButton onClick={onApply} size=\"sm\" state={applyState}>\n Apply\n </BitkitButton>\n </Box>\n );\n};\n\nexport default FilterPanel;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkCA,IAAM,eAAe,UAA4B;CAC/C,MAAM,EAAE,UAAU,cAAc,kBAAkB,cAAc,kBAAkB,MAAM,YAAY;CACpG,MAAM,EAAE,YAAY,UAAU,WAAW,iBAAiB;CAE1D,MAAM,gBAAgB,WAAoB;EACxC,IAAI,CAAC,UAAU,CAAC,YAAY,iBAAiB,MAAM;CACrD;CACA,MAAM,EAAE,kBAAkB,iBAAiB;CAE3C,IAAI,UACF,OACE,qBAAA,UAAA,EAAA,UAAA,CACG,SACD,oBAAC,OAAO,MAAR;EACgB;EACd,WAAA;EACA,eAAe,EAAE,MAAM,aAAa,aAAa,MAAM;EACjD;EACN,eAAA;EAEA,UAAA,oBAAC,QAAD;GAAQ,UAAU;GAChB,UAAA,oBAAC,OAAO,YAAR,EAAA,UACE,oBAAC,OAAO,SAAR,EAAiB,SAAyB,CAAA,EACzB,CAAA;EACb,CAAA;CACG,CAAA,CACb,EAAA,CAAA;CAIN,OACE,qBAAC,QAAQ,MAAT;EACgB;EACd,WAAA;EACA,eAAe,EAAE,MAAM,aAAa,aAAa,MAAM;EACjD;EACN,aAAa;GACX;GACA,QAAQ;GACR,WAAW;EACb;EACA,eAAA;EAVF,UAAA,CAYG,SACD,oBAAC,QAAD;GAAQ,UAAU;GAChB,UAAA,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;CAInB,OACE,qBAAC,KAAD;EAAK,KAAK,OAAO;EAAjB,UAAA;GACE,oBAAC,KAAD;IAAK,KAAK,OAAO;IACd,UAAA,CAAC,CAAC,SACD,oBAAC,cAAD;KAAc,SAAS,MAAM;KAAS,MAAK;KAAK,SAAQ;KACrD,UAAA,MAAM;IACK,CAAA;GAEb,CAAA;GACJ,CAAC,CAAC,YACD,oBAAC,cAAD;IAAc,SAAS;IAAU,MAAK;IAAK,SAAQ;IAAY,UAAA;GAEjD,CAAA;GAEhB,oBAAC,cAAD;IAAc,SAAS;IAAS,MAAK;IAAK,OAAO;IAAY,UAAA;GAE/C,CAAA;EACX;;AAET"}
@@ -1,15 +0,0 @@
1
- import { BoxProps } from '@chakra-ui/react/box';
2
- import { ReactElement } from 'react';
3
- export interface FilterSearchInputProps extends Omit<BoxProps, 'children' | 'defaultValue' | 'onChange'> {
4
- /** Extra hint read out with the field, e.g. what the search matches. */
5
- description?: string;
6
- label: string;
7
- onValueChange: (value: string) => void;
8
- placeholder: string;
9
- /** Wraps the input, e.g. in a tooltip. */
10
- renderInput?: (input: ReactElement) => ReactElement;
11
- value: string;
12
- }
13
- /** The borderless search field of the bar — and, on mobile, of each filter's view too. */
14
- declare const FilterSearchInput: import('react').ForwardRefExoticComponent<FilterSearchInputProps & import('react').RefAttributes<HTMLInputElement>>;
15
- export default FilterSearchInput;
@@ -1,41 +0,0 @@
1
- import IconMagnifier from "../../../icons/IconMagnifier.js";
2
- import BitkitCloseButton from "../../BitkitCloseButton/BitkitCloseButton.js";
3
- import { useFilterContext } from "../BitkitFilter.context.js";
4
- import { Box } from "@chakra-ui/react/box";
5
- import { chakra } from "@chakra-ui/react/styled-system";
6
- import { forwardRef } from "react";
7
- import { jsx, jsxs } from "react/jsx-runtime";
8
- //#region lib/components/BitkitFilter/components/FilterSearchInput.tsx
9
- /** The borderless search field of the bar — and, on mobile, of each filter's view too. */
10
- var FilterSearchInput = forwardRef((props, ref) => {
11
- const { css, description, label, onValueChange, placeholder, renderInput = (input) => input, value, ...rest } = props;
12
- const { isMobile, styles } = useFilterContext();
13
- return /* @__PURE__ */ jsxs(Box, {
14
- css: [isMobile ? styles.mobileSearch : styles.search, css],
15
- ...rest,
16
- children: [
17
- /* @__PURE__ */ jsx(IconMagnifier, { size: isMobile ? "24" : "16" }),
18
- renderInput(/* @__PURE__ */ jsx(chakra.input, {
19
- "aria-description": description,
20
- "aria-label": label,
21
- css: isMobile ? styles.mobileSearchInput : styles.searchInput,
22
- onChange: (event) => onValueChange(event.target.value),
23
- placeholder,
24
- ref,
25
- type: "search",
26
- value
27
- })),
28
- !!value && /* @__PURE__ */ jsx(BitkitCloseButton, {
29
- "aria-label": "Clear search",
30
- colorVariant: "neutral",
31
- onClick: () => onValueChange(""),
32
- size: "sm"
33
- })
34
- ]
35
- });
36
- });
37
- FilterSearchInput.displayName = "FilterSearchInput";
38
- //#endregion
39
- export { FilterSearchInput as default };
40
-
41
- //# sourceMappingURL=FilterSearchInput.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FilterSearchInput.js","names":[],"sources":["../../../../lib/components/BitkitFilter/components/FilterSearchInput.tsx"],"sourcesContent":["import { Box, type BoxProps } from '@chakra-ui/react/box';\n// `chakra.input`: the filter's search fields are borderless rows from the filter recipe, unlike the\n// bordered BitkitSearchInput.\nimport { chakra } from '@chakra-ui/react/styled-system';\nimport { forwardRef, type ReactElement } from 'react';\n\nimport { IconMagnifier } from '../../../icons';\nimport BitkitCloseButton from '../../BitkitCloseButton/BitkitCloseButton';\nimport { useFilterContext } from '../BitkitFilter.context';\n\nexport interface FilterSearchInputProps extends Omit<BoxProps, 'children' | 'defaultValue' | 'onChange'> {\n /** Extra hint read out with the field, e.g. what the search matches. */\n description?: string;\n label: string;\n onValueChange: (value: string) => void;\n placeholder: string;\n /** Wraps the input, e.g. in a tooltip. */\n renderInput?: (input: ReactElement) => ReactElement;\n value: string;\n}\n\n/** The borderless search field of the bar — and, on mobile, of each filter's view too. */\nconst FilterSearchInput = forwardRef<HTMLInputElement, FilterSearchInputProps>((props, ref) => {\n const { css, description, label, onValueChange, placeholder, renderInput = (input) => input, value, ...rest } = props;\n const { isMobile, styles } = useFilterContext();\n\n return (\n <Box css={[isMobile ? styles.mobileSearch : styles.search, css]} {...rest}>\n <IconMagnifier size={isMobile ? '24' : '16'} />\n {renderInput(\n <chakra.input\n aria-description={description}\n aria-label={label}\n css={isMobile ? styles.mobileSearchInput : styles.searchInput}\n onChange={(event) => onValueChange(event.target.value)}\n placeholder={placeholder}\n ref={ref}\n type=\"search\"\n value={value}\n />,\n )}\n {!!value && (\n <BitkitCloseButton\n aria-label=\"Clear search\"\n colorVariant=\"neutral\"\n onClick={() => onValueChange('')}\n size=\"sm\"\n />\n )}\n </Box>\n );\n});\n\nFilterSearchInput.displayName = 'FilterSearchInput';\n\nexport default FilterSearchInput;\n"],"mappings":";;;;;;;;;AAsBA,IAAM,oBAAoB,YAAsD,OAAO,QAAQ;CAC7F,MAAM,EAAE,KAAK,aAAa,OAAO,eAAe,aAAa,eAAe,UAAU,OAAO,OAAO,GAAG,SAAS;CAChH,MAAM,EAAE,UAAU,WAAW,iBAAiB;CAE9C,OACE,qBAAC,KAAD;EAAK,KAAK,CAAC,WAAW,OAAO,eAAe,OAAO,QAAQ,GAAG;EAAG,GAAI;EAArE,UAAA;GACE,oBAAC,eAAD,EAAe,MAAM,WAAW,OAAO,KAAO,CAAA;GAC7C,YACC,oBAAC,OAAO,OAAR;IACE,oBAAkB;IAClB,cAAY;IACZ,KAAK,WAAW,OAAO,oBAAoB,OAAO;IAClD,WAAW,UAAU,cAAc,MAAM,OAAO,KAAK;IACxC;IACR;IACL,MAAK;IACE;GACR,CAAA,CACH;GACC,CAAC,CAAC,SACD,oBAAC,mBAAD;IACE,cAAW;IACX,cAAa;IACb,eAAe,cAAc,EAAE;IAC/B,MAAK;GACN,CAAA;EAEA;;AAET,CAAC;AAED,kBAAkB,cAAc"}
@@ -1,39 +0,0 @@
1
- import { BitkitIconComponent } from '../../../icons';
2
- import { BitkitColorToken } from '../../../theme/themeUtils';
3
- export interface BitkitFilterSelectItem {
4
- icon?: BitkitIconComponent;
5
- /** Colors the icon, e.g. a status: `icon/positive` for "Passed". */
6
- iconColor?: BitkitColorToken<'icon'>;
7
- label: string;
8
- value: string;
9
- }
10
- /** The list renders at most this many options; search narrows down the rest. */
11
- export declare const MAX_VISIBLE_ITEMS = 100;
12
- export interface FilterSelectFormProps {
13
- /** The filter holds a value: the footer offers "Clear" instead of the wildcard-mode switch. */
14
- isEditing: boolean;
15
- /** Keeps `items` in their own order instead of listing the applied ones first — for a switch's fixed options. */
16
- isOrderFixed?: boolean;
17
- /** A value is always applied: no "Clear" in the footer. */
18
- isRequired?: boolean;
19
- items: BitkitFilterSelectItem[];
20
- label: string;
21
- loading?: boolean;
22
- loadingLabel?: string;
23
- multiple?: boolean;
24
- onApply: (value: string[]) => void;
25
- onCancel: () => void;
26
- onSearchChange?: (searchText: string) => void;
27
- pattern?: boolean;
28
- pluralLabel: string;
29
- searchPlaceholder?: string;
30
- /**
31
- * The applied selection with its labels. Without a search, any of it missing from `items` — e.g.
32
- * left behind by a server search — is listed first, so it can still be unchecked.
33
- */
34
- selectedItems?: BitkitFilterSelectItem[];
35
- value: string[];
36
- }
37
- /** The body of a select filter's panel: search, the option list or wildcard pattern, and the footer. */
38
- declare const FilterSelectForm: (props: FilterSelectFormProps) => import('react').JSX.Element;
39
- export default FilterSelectForm;
@@ -1,278 +0,0 @@
1
- import IconCheck from "../../../icons/IconCheck.js";
2
- import BitkitCheckbox from "../../BitkitCheckbox/BitkitCheckbox.js";
3
- import BitkitCheckboxGroup from "../../BitkitCheckboxGroup/BitkitCheckboxGroup.js";
4
- import { compilePattern, isEqualFilterValue, isPattern, toRunningText } from "../BitkitFilter.utils.js";
5
- import { useFilterContext } from "../BitkitFilter.context.js";
6
- import { FilterPanelFooter, FilterPanelHeader } from "./FilterPanel.js";
7
- import FilterSearchInput from "./FilterSearchInput.js";
8
- import BitkitInlineLoading from "../../BitkitInlineLoading/BitkitInlineLoading.js";
9
- import BitkitList_default from "../../BitkitList/BitkitList.js";
10
- import BitkitTextInput from "../../BitkitTextInput/BitkitTextInput.js";
11
- import BitkitSearchInput from "../../BitkitSearchInput/BitkitSearchInput.js";
12
- import { Box } from "@chakra-ui/react/box";
13
- import { useSlotRecipe } from "@chakra-ui/react/styled-system";
14
- import { useEffect, useMemo, useRef, useState } from "react";
15
- import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
16
- import { Text } from "@chakra-ui/react/text";
17
- import { createListCollection } from "@chakra-ui/react/collection";
18
- import { HStack } from "@chakra-ui/react/stack";
19
- import { Listbox } from "@chakra-ui/react/listbox";
20
- /** Below this many options the list is short enough to scan, so there is no search input. */
21
- var SEARCH_THRESHOLD = 5;
22
- /** The body of a select filter's panel: search, the option list or wildcard pattern, and the footer. */
23
- var FilterSelectForm = (props) => {
24
- const { isEditing, isOrderFixed, isRequired, items, label, loading, loadingLabel = "Loading...", multiple, onApply, onCancel, onSearchChange, pattern, pluralLabel, searchPlaceholder = "Search for options", selectedItems = [], value } = props;
25
- const { isMobile, styles } = useFilterContext();
26
- const [draft, setDraft] = useState(value);
27
- const [mode, setMode] = useState(pattern && value[0] && isPattern(value[0]) ? "pattern" : "list");
28
- const [searchText, setSearchText] = useState("");
29
- const [hasLoaded, setHasLoaded] = useState(!loading);
30
- if (!loading && !hasLoaded) setHasLoaded(true);
31
- const onSearchTextChange = (text) => {
32
- setSearchText(text);
33
- onSearchChange?.(text);
34
- };
35
- const matchingItems = useMemo(() => {
36
- if (!searchText) {
37
- if (isOrderFixed) return items;
38
- return [...value.flatMap((selected) => {
39
- return items.find((option) => option.value === selected) ?? selectedItems.find((option) => option.value === selected) ?? [];
40
- }), ...items.filter((item) => !value.includes(item.value))];
41
- }
42
- if (onSearchChange) return items;
43
- const query = searchText.toLowerCase();
44
- return items.filter((item) => item.label.toLowerCase().includes(query));
45
- }, [
46
- isOrderFixed,
47
- items,
48
- onSearchChange,
49
- searchText,
50
- selectedItems,
51
- value
52
- ]);
53
- const visibleItems = matchingItems.slice(0, 100);
54
- const isInitialLoading = !!loading && !hasLoaded;
55
- const showSearch = !isInitialLoading && (!!onSearchChange || items.length > SEARCH_THRESHOLD);
56
- const searchLabel = `Search ${toRunningText(pluralLabel)}`;
57
- const showLimitHelper = matchingItems.length > 100;
58
- const patternValue = draft[0] ?? "";
59
- const isApplyDisabled = isEqualFilterValue(draft, value) || mode === "pattern" && !(patternValue && isPattern(patternValue)) || !!isRequired && !draft.length;
60
- const bodyRef = useRef(null);
61
- const hasSwitchedMode = useRef(false);
62
- useEffect(() => {
63
- if (!hasSwitchedMode.current) return;
64
- bodyRef.current?.querySelector("input:not([type=hidden]), [role=listbox], input[type=checkbox]")?.focus();
65
- }, [mode]);
66
- let start;
67
- if (isEditing && !isRequired) start = {
68
- label: multiple && isMobile ? "Clear all" : "Clear",
69
- onClick: () => onApply([])
70
- };
71
- else if (pattern && !isEditing) start = {
72
- label: mode === "list" ? "Use wildcard pattern" : "Select from list",
73
- onClick: () => {
74
- hasSwitchedMode.current = true;
75
- setMode(mode === "list" ? "pattern" : "list");
76
- setDraft([]);
77
- }
78
- };
79
- let list;
80
- if (loading) list = /* @__PURE__ */ jsx(BitkitInlineLoading, {
81
- css: styles.loading,
82
- label: loadingLabel,
83
- size: isMobile ? "lg" : "md"
84
- });
85
- else if (!visibleItems.length) list = /* @__PURE__ */ jsx(Text, {
86
- css: styles.loading,
87
- color: "text/secondary",
88
- textStyle: isMobile ? "body/lg/regular" : "body/md/regular",
89
- children: searchText ? "No result. Refine your search term." : "No options available."
90
- });
91
- else if (multiple && !isMobile) list = /* @__PURE__ */ jsxs(Box, {
92
- css: styles.checkboxList,
93
- children: [/* @__PURE__ */ jsx(BitkitCheckboxGroup, {
94
- "aria-label": label,
95
- onValueChange: setDraft,
96
- size: "md",
97
- value: draft,
98
- children: visibleItems.map((item) => /* @__PURE__ */ jsx(BitkitCheckbox, {
99
- labelText: item.icon ? /* @__PURE__ */ jsxs(HStack, {
100
- gap: "4",
101
- children: [/* @__PURE__ */ jsx(item.icon, {
102
- color: item.iconColor,
103
- size: "16"
104
- }), item.label]
105
- }) : item.label,
106
- value: item.value
107
- }, item.value))
108
- }), showLimitHelper && /* @__PURE__ */ jsx(LimitHelper, { marginBlockStart: "16" })]
109
- });
110
- else list = /* @__PURE__ */ jsx(FilterListbox, {
111
- items: visibleItems,
112
- label,
113
- multiple,
114
- onValueChange: setDraft,
115
- showLimitHelper,
116
- value: draft
117
- });
118
- let search = null;
119
- if (showSearch && isMobile) search = /* @__PURE__ */ jsx(FilterSearchInput, {
120
- label: searchLabel,
121
- onValueChange: onSearchTextChange,
122
- placeholder: searchPlaceholder,
123
- value: searchText
124
- });
125
- else if (showSearch) search = /* @__PURE__ */ jsx(Box, {
126
- css: styles.popoverSearch,
127
- children: /* @__PURE__ */ jsx(BitkitSearchInput, {
128
- label: searchLabel,
129
- onChange: onSearchTextChange,
130
- placeholder: searchPlaceholder,
131
- size: "md",
132
- value: searchText
133
- })
134
- });
135
- const body = /* @__PURE__ */ jsx(Box, {
136
- css: styles.popoverBody,
137
- ref: bodyRef,
138
- children: mode === "pattern" ? /* @__PURE__ */ jsx(FilterPatternBody, {
139
- items,
140
- onValueChange: setDraft,
141
- pluralLabel,
142
- value: patternValue
143
- }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [search, list] })
144
- });
145
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [
146
- /* @__PURE__ */ jsx(FilterPanelHeader, {
147
- count: multiple && mode === "list" ? draft.length : void 0,
148
- title: multiple ? pluralLabel : label
149
- }),
150
- isMobile ? /* @__PURE__ */ jsx(Box, {
151
- flex: "1",
152
- overflowY: "auto",
153
- children: body
154
- }) : body,
155
- !isInitialLoading && /* @__PURE__ */ jsx(FilterPanelFooter, {
156
- applyLabel: multiple && mode === "list" && draft.length ? `Apply (${draft.length})` : void 0,
157
- isApplyDisabled,
158
- onApply: () => onApply(mode === "pattern" ? [patternValue] : draft),
159
- onCancel,
160
- start
161
- })
162
- ] });
163
- };
164
- var LimitHelper = ({ marginBlockStart }) => {
165
- const { styles } = useFilterContext();
166
- return /* @__PURE__ */ jsxs(Text, {
167
- css: styles.listHelperText,
168
- marginBlockStart,
169
- children: [
170
- "Showing the first ",
171
- 100,
172
- " options. Search to find more."
173
- ]
174
- });
175
- };
176
- /**
177
- * The option list for a single select, and on mobile for a multiple one too — there the rows are
178
- * full-width and highlighted when selected, with a checkbox drawn in front.
179
- */
180
- var FilterListbox = ({ items, label, multiple, onValueChange, showLimitHelper, value }) => {
181
- const { isMobile, styles } = useFilterContext();
182
- const collection = useMemo(() => createListCollection({ items }), [items]);
183
- const checkboxStyles = useSlotRecipe({ key: "checkbox" })({ size: "lg" });
184
- const checkIndicator = /* @__PURE__ */ jsx(Listbox.ItemIndicator, { children: /* @__PURE__ */ jsx(IconCheck, { size: "16" }) });
185
- return /* @__PURE__ */ jsxs(Listbox.Root, {
186
- collection,
187
- onValueChange: (details) => onValueChange(details.value),
188
- selectionMode: multiple ? "multiple" : "single",
189
- size: isMobile ? "lg" : "md",
190
- value,
191
- children: [/* @__PURE__ */ jsx(Listbox.Label, {
192
- srOnly: true,
193
- children: label
194
- }), /* @__PURE__ */ jsxs(Listbox.Content, { children: [items.map((item) => {
195
- const state = value.includes(item.value) ? "checked" : "unchecked";
196
- const check = multiple ? /* @__PURE__ */ jsx(Box, {
197
- "aria-hidden": true,
198
- css: [checkboxStyles.control, styles.mobileListCheckbox],
199
- "data-state": state,
200
- children: /* @__PURE__ */ jsx(IconCheck, {})
201
- }) : /* @__PURE__ */ jsx(Box, {
202
- "aria-hidden": true,
203
- css: styles.mobileListCheck,
204
- "data-state": state,
205
- children: /* @__PURE__ */ jsx(IconCheck, { size: "16" })
206
- });
207
- return /* @__PURE__ */ jsxs(Listbox.Item, {
208
- item,
209
- children: [
210
- isMobile && check,
211
- !!item.icon && /* @__PURE__ */ jsx(item.icon, {
212
- color: item.iconColor,
213
- size: isMobile ? "24" : "16"
214
- }),
215
- /* @__PURE__ */ jsx(Listbox.ItemText, { children: item.label }),
216
- !isMobile && checkIndicator
217
- ]
218
- }, item.value);
219
- }), showLimitHelper && /* @__PURE__ */ jsx(Box, {
220
- paddingBlockStart: "8",
221
- paddingInline: "24",
222
- children: /* @__PURE__ */ jsx(LimitHelper, {})
223
- })] })]
224
- });
225
- };
226
- var FilterPatternBody = ({ items, onValueChange, pluralLabel, value }) => {
227
- const { isMobile, styles } = useFilterContext();
228
- const noun = toRunningText(pluralLabel);
229
- const matches = useMemo(() => {
230
- if (!isPattern(value)) return null;
231
- const regExp = compilePattern(value);
232
- return items.filter((item) => !isPattern(item.label) && regExp.test(item.label));
233
- }, [items, value]);
234
- let results;
235
- if (!matches) results = /* @__PURE__ */ jsxs(Text, {
236
- color: "text/secondary",
237
- textStyle: "body/md/regular",
238
- children: [
239
- "Enter a pattern with the wildcard ‘*’ to view ",
240
- noun,
241
- " with matching names."
242
- ]
243
- });
244
- else if (!matches.length) results = /* @__PURE__ */ jsxs(Text, {
245
- color: "text/tertiary",
246
- textStyle: "body/md/regular",
247
- children: [
248
- "(no matching ",
249
- noun,
250
- ")"
251
- ]
252
- });
253
- else results = /* @__PURE__ */ jsx(BitkitList_default, {
254
- size: "md",
255
- children: matches.map((item) => /* @__PURE__ */ jsx(BitkitList_default.Item, { children: item.label }, item.value))
256
- });
257
- return /* @__PURE__ */ jsxs(Box, {
258
- css: styles.pattern,
259
- children: [/* @__PURE__ */ jsx(BitkitTextInput, {
260
- helperText: "Allowed wildcard character: *",
261
- label: "Wildcard pattern",
262
- onValueChange: (text) => onValueChange(text ? [text] : []),
263
- placeholder: "(e.g. *main*, release-*)",
264
- size: isMobile ? "lg" : "md",
265
- value
266
- }), /* @__PURE__ */ jsxs(Box, {
267
- css: styles.patternResults,
268
- children: [/* @__PURE__ */ jsxs(Text, {
269
- css: styles.patternResultsLabel,
270
- children: ["Matching results", matches?.length ? ` (${matches.length})` : ""]
271
- }), results]
272
- })]
273
- });
274
- };
275
- //#endregion
276
- export { FilterSelectForm as default };
277
-
278
- //# sourceMappingURL=FilterSelectForm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FilterSelectForm.js","names":[],"sources":["../../../../lib/components/BitkitFilter/components/FilterSelectForm.tsx"],"sourcesContent":["import { Box } from '@chakra-ui/react/box';\nimport { createListCollection } from '@chakra-ui/react/collection';\nimport { Listbox } from '@chakra-ui/react/listbox';\nimport { HStack } from '@chakra-ui/react/stack';\nimport { useSlotRecipe } from '@chakra-ui/react/styled-system';\nimport { Text } from '@chakra-ui/react/text';\nimport { useEffect, useMemo, useRef, useState } from 'react';\n\nimport { type BitkitIconComponent, IconCheck } from '../../../icons';\nimport { type BitkitColorToken } from '../../../theme/themeUtils';\nimport BitkitCheckbox from '../../BitkitCheckbox/BitkitCheckbox';\nimport BitkitCheckboxGroup from '../../BitkitCheckboxGroup/BitkitCheckboxGroup';\nimport BitkitInlineLoading from '../../BitkitInlineLoading/BitkitInlineLoading';\nimport BitkitList from '../../BitkitList/BitkitList';\nimport BitkitSearchInput from '../../BitkitSearchInput/BitkitSearchInput';\nimport BitkitTextInput from '../../BitkitTextInput/BitkitTextInput';\nimport { useFilterContext } from '../BitkitFilter.context';\nimport { compilePattern, isEqualFilterValue, isPattern, toRunningText } from '../BitkitFilter.utils';\nimport { FilterPanelFooter, FilterPanelHeader } from './FilterPanel';\nimport FilterSearchInput from './FilterSearchInput';\n\nexport interface BitkitFilterSelectItem {\n icon?: BitkitIconComponent;\n /** Colors the icon, e.g. a status: `icon/positive` for \"Passed\". */\n iconColor?: BitkitColorToken<'icon'>;\n label: string;\n value: string;\n}\n\n/** The list renders at most this many options; search narrows down the rest. */\nexport const MAX_VISIBLE_ITEMS = 100;\n\n/** Below this many options the list is short enough to scan, so there is no search input. */\nconst SEARCH_THRESHOLD = 5;\n\nexport interface FilterSelectFormProps {\n /** The filter holds a value: the footer offers \"Clear\" instead of the wildcard-mode switch. */\n isEditing: boolean;\n /** Keeps `items` in their own order instead of listing the applied ones first — for a switch's fixed options. */\n isOrderFixed?: boolean;\n /** A value is always applied: no \"Clear\" in the footer. */\n isRequired?: boolean;\n items: BitkitFilterSelectItem[];\n label: string;\n loading?: boolean;\n loadingLabel?: string;\n multiple?: boolean;\n onApply: (value: string[]) => void;\n onCancel: () => void;\n onSearchChange?: (searchText: string) => void;\n pattern?: boolean;\n pluralLabel: string;\n searchPlaceholder?: string;\n /**\n * The applied selection with its labels. Without a search, any of it missing from `items` — e.g.\n * left behind by a server search — is listed first, so it can still be unchecked.\n */\n selectedItems?: BitkitFilterSelectItem[];\n value: string[];\n}\n\n/** The body of a select filter's panel: search, the option list or wildcard pattern, and the footer. */\nconst FilterSelectForm = (props: FilterSelectFormProps) => {\n const {\n isEditing,\n isOrderFixed,\n isRequired,\n items,\n label,\n loading,\n loadingLabel = 'Loading...',\n multiple,\n onApply,\n onCancel,\n onSearchChange,\n pattern,\n pluralLabel,\n searchPlaceholder = 'Search for options',\n selectedItems = [],\n value,\n } = props;\n const { isMobile, styles } = useFilterContext();\n\n const [draft, setDraft] = useState(value);\n const [mode, setMode] = useState<'list' | 'pattern'>(pattern && value[0] && isPattern(value[0]) ? 'pattern' : 'list');\n const [searchText, setSearchText] = useState('');\n // Set once the options have loaded, so a later reload (a search, or clearing it) keeps the search and footer.\n const [hasLoaded, setHasLoaded] = useState(!loading);\n if (!loading && !hasLoaded) setHasLoaded(true);\n\n const onSearchTextChange = (text: string) => {\n setSearchText(text);\n onSearchChange?.(text);\n };\n\n // With `onSearchChange` the consumer filters `items` itself, e.g. on the server. Without a search,\n // the applied options come first. `value` doesn't change while the panel is open, so the order is\n // set when it opens and rows don't jump as options are (un)checked.\n const matchingItems = useMemo(() => {\n if (!searchText) {\n if (isOrderFixed) return items;\n const applied = value.flatMap((selected) => {\n const item = items.find((option) => option.value === selected);\n return item ?? selectedItems.find((option) => option.value === selected) ?? [];\n });\n return [...applied, ...items.filter((item) => !value.includes(item.value))];\n }\n if (onSearchChange) return items;\n const query = searchText.toLowerCase();\n return items.filter((item) => item.label.toLowerCase().includes(query));\n }, [isOrderFixed, items, onSearchChange, searchText, selectedItems, value]);\n\n const visibleItems = matchingItems.slice(0, MAX_VISIBLE_ITEMS);\n // The first load shows only the title and a loading row; later loads keep the input and footer in place.\n const isInitialLoading = !!loading && !hasLoaded;\n const showSearch = !isInitialLoading && (!!onSearchChange || items.length > SEARCH_THRESHOLD);\n const searchLabel = `Search ${toRunningText(pluralLabel)}`;\n const showLimitHelper = matchingItems.length > MAX_VISIBLE_ITEMS;\n\n const patternValue = draft[0] ?? '';\n const isApplyDisabled =\n isEqualFilterValue(draft, value) ||\n (mode === 'pattern' && !(patternValue && isPattern(patternValue))) ||\n (!!isRequired && !draft.length);\n\n // Switching between the list and the pattern moves focus into the new view, so typing goes there.\n const bodyRef = useRef<HTMLDivElement>(null);\n const hasSwitchedMode = useRef(false);\n useEffect(() => {\n if (!hasSwitchedMode.current) return;\n bodyRef.current\n ?.querySelector<HTMLElement>('input:not([type=hidden]), [role=listbox], input[type=checkbox]')\n ?.focus();\n }, [mode]);\n\n let start;\n if (isEditing && !isRequired) {\n start = { label: multiple && isMobile ? 'Clear all' : 'Clear', onClick: () => onApply([]) };\n } else if (pattern && !isEditing) {\n start = {\n label: mode === 'list' ? 'Use wildcard pattern' : 'Select from list',\n onClick: () => {\n hasSwitchedMode.current = true;\n setMode(mode === 'list' ? 'pattern' : 'list');\n setDraft([]);\n },\n };\n }\n\n let list;\n if (loading) {\n list = <BitkitInlineLoading css={styles.loading} label={loadingLabel} size={isMobile ? 'lg' : 'md'} />;\n } else if (!visibleItems.length) {\n list = (\n <Text css={styles.loading} color=\"text/secondary\" textStyle={isMobile ? 'body/lg/regular' : 'body/md/regular'}>\n {searchText ? 'No result. Refine your search term.' : 'No options available.'}\n </Text>\n );\n } else if (multiple && !isMobile) {\n list = (\n <Box css={styles.checkboxList}>\n <BitkitCheckboxGroup aria-label={label} onValueChange={setDraft} size=\"md\" value={draft}>\n {visibleItems.map((item) => (\n <BitkitCheckbox\n key={item.value}\n labelText={\n item.icon ? (\n <HStack gap=\"4\">\n <item.icon color={item.iconColor} size=\"16\" />\n {item.label}\n </HStack>\n ) : (\n item.label\n )\n }\n value={item.value}\n />\n ))}\n </BitkitCheckboxGroup>\n {showLimitHelper && <LimitHelper marginBlockStart=\"16\" />}\n </Box>\n );\n } else {\n list = (\n <FilterListbox\n items={visibleItems}\n label={label}\n multiple={multiple}\n onValueChange={setDraft}\n showLimitHelper={showLimitHelper}\n value={draft}\n />\n );\n }\n\n let search = null;\n if (showSearch && isMobile) {\n search = (\n <FilterSearchInput\n label={searchLabel}\n onValueChange={onSearchTextChange}\n placeholder={searchPlaceholder}\n value={searchText}\n />\n );\n } else if (showSearch) {\n search = (\n <Box css={styles.popoverSearch}>\n <BitkitSearchInput\n label={searchLabel}\n onChange={onSearchTextChange}\n placeholder={searchPlaceholder}\n size=\"md\"\n value={searchText}\n />\n </Box>\n );\n }\n\n const body = (\n <Box css={styles.popoverBody} ref={bodyRef}>\n {mode === 'pattern' ? (\n <FilterPatternBody items={items} onValueChange={setDraft} pluralLabel={pluralLabel} value={patternValue} />\n ) : (\n <>\n {search}\n {list}\n </>\n )}\n </Box>\n );\n\n return (\n <>\n <FilterPanelHeader\n count={multiple && mode === 'list' ? draft.length : undefined}\n title={multiple ? pluralLabel : label}\n />\n {isMobile ? (\n <Box flex=\"1\" overflowY=\"auto\">\n {body}\n </Box>\n ) : (\n body\n )}\n {!isInitialLoading && (\n <FilterPanelFooter\n applyLabel={multiple && mode === 'list' && draft.length ? `Apply (${draft.length})` : undefined}\n isApplyDisabled={isApplyDisabled}\n onApply={() => onApply(mode === 'pattern' ? [patternValue] : draft)}\n onCancel={onCancel}\n start={start}\n />\n )}\n </>\n );\n};\n\nconst LimitHelper = ({ marginBlockStart }: { marginBlockStart?: '16' }) => {\n const { styles } = useFilterContext();\n\n return (\n <Text css={styles.listHelperText} marginBlockStart={marginBlockStart}>\n Showing the first {MAX_VISIBLE_ITEMS} options. Search to find more.\n </Text>\n );\n};\n\ninterface FilterListboxProps {\n items: BitkitFilterSelectItem[];\n label: string;\n multiple?: boolean;\n onValueChange: (value: string[]) => void;\n showLimitHelper: boolean;\n value: string[];\n}\n\n/**\n * The option list for a single select, and on mobile for a multiple one too — there the rows are\n * full-width and highlighted when selected, with a checkbox drawn in front.\n */\nconst FilterListbox = ({ items, label, multiple, onValueChange, showLimitHelper, value }: FilterListboxProps) => {\n const { isMobile, styles } = useFilterContext();\n const collection = useMemo(() => createListCollection({ items }), [items]);\n const checkboxStyles = useSlotRecipe({ key: 'checkbox' })({ size: 'lg' });\n\n const checkIndicator = (\n <Listbox.ItemIndicator>\n <IconCheck size=\"16\" />\n </Listbox.ItemIndicator>\n );\n\n return (\n <Listbox.Root\n collection={collection}\n onValueChange={(details) => onValueChange(details.value)}\n selectionMode={multiple ? 'multiple' : 'single'}\n size={isMobile ? 'lg' : 'md'}\n value={value}\n >\n {/* Zag points the content's aria-labelledby at the label, so it has to exist. */}\n <Listbox.Label srOnly>{label}</Listbox.Label>\n <Listbox.Content>\n {items.map((item) => {\n const state = value.includes(item.value) ? 'checked' : 'unchecked';\n const check = multiple ? (\n // Drawn, not a real checkbox: the option row is the control, and a nested input would be a second one.\n <Box aria-hidden css={[checkboxStyles.control, styles.mobileListCheckbox]} data-state={state}>\n <IconCheck />\n </Box>\n ) : (\n <Box aria-hidden css={styles.mobileListCheck} data-state={state}>\n <IconCheck size=\"16\" />\n </Box>\n );\n return (\n <Listbox.Item item={item} key={item.value}>\n {isMobile && check}\n {!!item.icon && <item.icon color={item.iconColor} size={isMobile ? '24' : '16'} />}\n <Listbox.ItemText>{item.label}</Listbox.ItemText>\n {!isMobile && checkIndicator}\n </Listbox.Item>\n );\n })}\n {showLimitHelper && (\n <Box paddingBlockStart=\"8\" paddingInline=\"24\">\n <LimitHelper />\n </Box>\n )}\n </Listbox.Content>\n </Listbox.Root>\n );\n};\n\ninterface FilterPatternBodyProps {\n items: BitkitFilterSelectItem[];\n onValueChange: (value: string[]) => void;\n pluralLabel: string;\n value: string;\n}\n\nconst FilterPatternBody = ({ items, onValueChange, pluralLabel, value }: FilterPatternBodyProps) => {\n const { isMobile, styles } = useFilterContext();\n const noun = toRunningText(pluralLabel);\n const matches = useMemo(() => {\n if (!isPattern(value)) return null;\n const regExp = compilePattern(value);\n return items.filter((item) => !isPattern(item.label) && regExp.test(item.label));\n }, [items, value]);\n\n let results;\n if (!matches) {\n results = (\n <Text color=\"text/secondary\" textStyle=\"body/md/regular\">\n Enter a pattern with the wildcard &lsquo;*&rsquo; to view {noun} with matching names.\n </Text>\n );\n } else if (!matches.length) {\n results = (\n <Text color=\"text/tertiary\" textStyle=\"body/md/regular\">\n (no matching {noun})\n </Text>\n );\n } else {\n results = (\n <BitkitList size=\"md\">\n {matches.map((item) => (\n <BitkitList.Item key={item.value}>{item.label}</BitkitList.Item>\n ))}\n </BitkitList>\n );\n }\n\n return (\n <Box css={styles.pattern}>\n <BitkitTextInput\n helperText=\"Allowed wildcard character: *\"\n label=\"Wildcard pattern\"\n onValueChange={(text) => onValueChange(text ? [text] : [])}\n placeholder=\"(e.g. *main*, release-*)\"\n size={isMobile ? 'lg' : 'md'}\n value={value}\n />\n <Box css={styles.patternResults}>\n <Text css={styles.patternResultsLabel}>Matching results{matches?.length ? ` (${matches.length})` : ''}</Text>\n {results}\n </Box>\n </Box>\n );\n};\n\nexport default FilterSelectForm;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAiCA,IAAM,mBAAmB;;AA6BzB,IAAM,oBAAoB,UAAiC;CACzD,MAAM,EACJ,WACA,cACA,YACA,OACA,OACA,SACA,eAAe,cACf,UACA,SACA,UACA,gBACA,SACA,aACA,oBAAoB,sBACpB,gBAAgB,CAAC,GACjB,UACE;CACJ,MAAM,EAAE,UAAU,WAAW,iBAAiB;CAE9C,MAAM,CAAC,OAAO,YAAY,SAAS,K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SlotRecipe: import('@chakra-ui/react').SlotRecipeDefinition<"search" | "content" | "pattern" | "switch" | "icon" | "field" | "root" | "loading" | "items" | "searchInput" | "addSheetBackdrop" | "addSheetPositioner" | "addSheet" | "addMenu" | "addMenuLabel" | "addSheetItem" | "addMenuItem" | "addMenuIcon" | "addSheetItemReason" | "chip" | "chipLabel" | "chipTrigger" | "chipRemove" | "chipIcon" | "chipValue" | "chipChevron" | "fieldLabel" | "fieldControl" | "fieldTrigger" | "fieldRemove" | "fieldIcon" | "fieldValue" | "fieldChevron" | "mobilePanelHeader" | "popoverFooter" | "mobileFooter" | "popoverFooterStart" | "mobilePanelOverline" | "mobilePanelTitle" | "popoverContent" | "calendarFooter" | "mobileSearch" | "mobileSearchInput" | "popoverBody" | "checkboxList" | "popoverSearch" | "listHelperText" | "patternResults" | "patternResultsLabel" | "mobileListCheckbox" | "mobileListCheck" | "switchItem" | "switchItemText" | "filters" | "searchBlock" | "mobileBar" | "mobileTrigger" | "mobileHeader" | "mobileTitle" | "mobileBody", {
2
- pageLayout: {
3
- capped: {
4
- root: {
5
- borderBlockEndWidth: "1";
6
- borderColor: "border/regular";
7
- paddingInline: {
8
- base: "16";
9
- tablet: "32";
10
- };
11
- };
12
- };
13
- full: {
14
- root: {
15
- borderBlockEndWidth: "1";
16
- borderColor: "border/regular";
17
- paddingInlineEnd: {
18
- base: "16";
19
- tablet: "32";
20
- };
21
- paddingInlineStart: {
22
- base: "16";
23
- tablet: "24";
24
- };
25
- };
26
- };
27
- };
28
- contentAlign: {
29
- center: {};
30
- start: {
31
- root: {
32
- justifyContent: "flex-start";
33
- };
34
- };
35
- };
36
- }>;
37
- export default filterSlotRecipe;