@wallarm-org/design-system 0.7.0 → 0.8.0-rc-feature-filter-attacks-components-oks.1

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 (150) hide show
  1. package/dist/components/DropdownMenu/DropdownMenu.d.ts +14 -0
  2. package/dist/components/DropdownMenu/DropdownMenu.js +15 -2
  3. package/dist/components/DropdownMenu/DropdownMenuItem.d.ts +2 -0
  4. package/dist/components/DropdownMenu/DropdownMenuItem.js +4 -4
  5. package/dist/components/DropdownMenu/classes.js +1 -1
  6. package/dist/components/QueryBar/QueryBar.d.ts +36 -0
  7. package/dist/components/QueryBar/QueryBar.js +60 -0
  8. package/dist/components/QueryBar/QueryBarContext/QueryBarContext.d.ts +2 -0
  9. package/dist/components/QueryBar/QueryBarContext/QueryBarContext.js +3 -0
  10. package/dist/components/QueryBar/QueryBarContext/QueryBarProvider.d.ts +8 -0
  11. package/dist/components/QueryBar/QueryBarContext/QueryBarProvider.js +8 -0
  12. package/dist/components/QueryBar/QueryBarContext/index.d.ts +4 -0
  13. package/dist/components/QueryBar/QueryBarContext/index.js +4 -0
  14. package/dist/components/QueryBar/QueryBarContext/types.d.ts +38 -0
  15. package/dist/components/QueryBar/QueryBarContext/types.js +0 -0
  16. package/dist/components/QueryBar/QueryBarContext/useQueryBarContext.d.ts +2 -0
  17. package/dist/components/QueryBar/QueryBarContext/useQueryBarContext.js +8 -0
  18. package/dist/components/QueryBar/QueryBarContext/useQueryBarContextValue.d.ts +38 -0
  19. package/dist/components/QueryBar/QueryBarContext/useQueryBarContextValue.js +59 -0
  20. package/dist/components/QueryBar/QueryBarInput/ChipsWithGaps.d.ts +23 -0
  21. package/dist/components/QueryBar/QueryBarInput/ChipsWithGaps.js +63 -0
  22. package/dist/components/QueryBar/QueryBarInput/InsertionGap/InsertionGap.d.ts +7 -0
  23. package/dist/components/QueryBar/QueryBarInput/InsertionGap/InsertionGap.js +17 -0
  24. package/dist/components/QueryBar/QueryBarInput/InsertionGap/classes.d.ts +4 -0
  25. package/dist/components/QueryBar/QueryBarInput/InsertionGap/classes.js +3 -0
  26. package/dist/components/QueryBar/QueryBarInput/InsertionGap/index.d.ts +1 -0
  27. package/dist/components/QueryBar/QueryBarInput/InsertionGap/index.js +2 -0
  28. package/dist/components/QueryBar/QueryBarInput/QueryBarChip/EditingContext.d.ts +14 -0
  29. package/dist/components/QueryBar/QueryBarInput/QueryBarChip/EditingContext.js +9 -0
  30. package/dist/components/QueryBar/QueryBarInput/QueryBarChip/OperatorSegment.d.ts +7 -0
  31. package/dist/components/QueryBar/QueryBarInput/QueryBarChip/OperatorSegment.js +23 -0
  32. package/dist/components/QueryBar/QueryBarInput/QueryBarChip/QueryBarChip.d.ts +13 -0
  33. package/dist/components/QueryBar/QueryBarInput/QueryBarChip/QueryBarChip.js +69 -0
  34. package/dist/components/QueryBar/QueryBarInput/QueryBarChip/QueryBarRemoveButton.d.ts +5 -0
  35. package/dist/components/QueryBar/QueryBarInput/QueryBarChip/QueryBarRemoveButton.js +20 -0
  36. package/dist/components/QueryBar/QueryBarInput/QueryBarChip/Segment.d.ts +13 -0
  37. package/dist/components/QueryBar/QueryBarInput/QueryBarChip/Segment.js +88 -0
  38. package/dist/components/QueryBar/QueryBarInput/QueryBarChip/classes.d.ts +15 -0
  39. package/dist/components/QueryBar/QueryBarInput/QueryBarChip/classes.js +39 -0
  40. package/dist/components/QueryBar/QueryBarInput/QueryBarChip/index.d.ts +5 -0
  41. package/dist/components/QueryBar/QueryBarInput/QueryBarChip/index.js +6 -0
  42. package/dist/components/QueryBar/QueryBarInput/QueryBarConnectorChip/QueryBarConnectorChip.d.ts +9 -0
  43. package/dist/components/QueryBar/QueryBarInput/QueryBarConnectorChip/QueryBarConnectorChip.js +101 -0
  44. package/dist/components/QueryBar/QueryBarInput/QueryBarConnectorChip/classes.d.ts +2 -0
  45. package/dist/components/QueryBar/QueryBarInput/QueryBarConnectorChip/classes.js +2 -0
  46. package/dist/components/QueryBar/QueryBarInput/QueryBarConnectorChip/index.d.ts +1 -0
  47. package/dist/components/QueryBar/QueryBarInput/QueryBarConnectorChip/index.js +2 -0
  48. package/dist/components/QueryBar/QueryBarInput/QueryBarFilterInput.d.ts +6 -0
  49. package/dist/components/QueryBar/QueryBarInput/QueryBarFilterInput.js +28 -0
  50. package/dist/components/QueryBar/QueryBarInput/QueryBarInput.d.ts +4 -0
  51. package/dist/components/QueryBar/QueryBarInput/QueryBarInput.js +133 -0
  52. package/dist/components/QueryBar/QueryBarInput/QueryBarInputActions.d.ts +2 -0
  53. package/dist/components/QueryBar/QueryBarInput/QueryBarInputActions.js +37 -0
  54. package/dist/components/QueryBar/QueryBarInput/classes.d.ts +12 -0
  55. package/dist/components/QueryBar/QueryBarInput/classes.js +35 -0
  56. package/dist/components/QueryBar/QueryBarInput/index.d.ts +2 -0
  57. package/dist/components/QueryBar/QueryBarInput/index.js +3 -0
  58. package/dist/components/QueryBar/QueryBarMenu/MenuEmptyState.d.ts +2 -0
  59. package/dist/components/QueryBar/QueryBarMenu/MenuEmptyState.js +8 -0
  60. package/dist/components/QueryBar/QueryBarMenu/QueryBarDateValueMenu/CalendarNav.d.ts +2 -0
  61. package/dist/components/QueryBar/QueryBarMenu/QueryBarDateValueMenu/CalendarNav.js +22 -0
  62. package/dist/components/QueryBar/QueryBarMenu/QueryBarDateValueMenu/DateCalendar.d.ts +14 -0
  63. package/dist/components/QueryBar/QueryBarMenu/QueryBarDateValueMenu/DateCalendar.js +100 -0
  64. package/dist/components/QueryBar/QueryBarMenu/QueryBarDateValueMenu/DatePresets.d.ts +8 -0
  65. package/dist/components/QueryBar/QueryBarMenu/QueryBarDateValueMenu/DatePresets.js +66 -0
  66. package/dist/components/QueryBar/QueryBarMenu/QueryBarDateValueMenu/DayView.d.ts +2 -0
  67. package/dist/components/QueryBar/QueryBarMenu/QueryBarDateValueMenu/DayView.js +42 -0
  68. package/dist/components/QueryBar/QueryBarMenu/QueryBarDateValueMenu/MonthView.d.ts +2 -0
  69. package/dist/components/QueryBar/QueryBarMenu/QueryBarDateValueMenu/MonthView.js +34 -0
  70. package/dist/components/QueryBar/QueryBarMenu/QueryBarDateValueMenu/QueryBarDateValueMenu.d.ts +24 -0
  71. package/dist/components/QueryBar/QueryBarMenu/QueryBarDateValueMenu/QueryBarDateValueMenu.js +107 -0
  72. package/dist/components/QueryBar/QueryBarMenu/QueryBarDateValueMenu/YearView.d.ts +2 -0
  73. package/dist/components/QueryBar/QueryBarMenu/QueryBarDateValueMenu/YearView.js +33 -0
  74. package/dist/components/QueryBar/QueryBarMenu/QueryBarDateValueMenu/constants.d.ts +14 -0
  75. package/dist/components/QueryBar/QueryBarMenu/QueryBarDateValueMenu/constants.js +46 -0
  76. package/dist/components/QueryBar/QueryBarMenu/QueryBarDateValueMenu/hooks.d.ts +10 -0
  77. package/dist/components/QueryBar/QueryBarMenu/QueryBarDateValueMenu/hooks.js +32 -0
  78. package/dist/components/QueryBar/QueryBarMenu/QueryBarDateValueMenu/index.d.ts +4 -0
  79. package/dist/components/QueryBar/QueryBarMenu/QueryBarDateValueMenu/index.js +4 -0
  80. package/dist/components/QueryBar/QueryBarMenu/QueryBarDateValueMenu/styles.d.ts +4 -0
  81. package/dist/components/QueryBar/QueryBarMenu/QueryBarDateValueMenu/styles.js +4 -0
  82. package/dist/components/QueryBar/QueryBarMenu/QueryBarFieldMenu/FieldMenuSections.d.ts +19 -0
  83. package/dist/components/QueryBar/QueryBarMenu/QueryBarFieldMenu/FieldMenuSections.js +107 -0
  84. package/dist/components/QueryBar/QueryBarMenu/QueryBarFieldMenu/QueryBarFieldMenu.d.ts +23 -0
  85. package/dist/components/QueryBar/QueryBarMenu/QueryBarFieldMenu/QueryBarFieldMenu.js +170 -0
  86. package/dist/components/QueryBar/QueryBarMenu/QueryBarFieldMenu/index.d.ts +1 -0
  87. package/dist/components/QueryBar/QueryBarMenu/QueryBarFieldMenu/index.js +2 -0
  88. package/dist/components/QueryBar/QueryBarMenu/QueryBarMenu.d.ts +30 -0
  89. package/dist/components/QueryBar/QueryBarMenu/QueryBarMenu.js +81 -0
  90. package/dist/components/QueryBar/QueryBarMenu/QueryBarOperatorMenu.d.ts +44 -0
  91. package/dist/components/QueryBar/QueryBarMenu/QueryBarOperatorMenu.js +79 -0
  92. package/dist/components/QueryBar/QueryBarMenu/QueryBarValueMenu/QueryBarValueMenu.d.ts +34 -0
  93. package/dist/components/QueryBar/QueryBarMenu/QueryBarValueMenu/QueryBarValueMenu.js +149 -0
  94. package/dist/components/QueryBar/QueryBarMenu/QueryBarValueMenu/ValueMenuItem.d.ts +11 -0
  95. package/dist/components/QueryBar/QueryBarMenu/QueryBarValueMenu/ValueMenuItem.js +45 -0
  96. package/dist/components/QueryBar/QueryBarMenu/QueryBarValueMenu/index.d.ts +1 -0
  97. package/dist/components/QueryBar/QueryBarMenu/QueryBarValueMenu/index.js +2 -0
  98. package/dist/components/QueryBar/QueryBarMenu/QueryBarValueMenu/useValueMenuState.d.ts +30 -0
  99. package/dist/components/QueryBar/QueryBarMenu/QueryBarValueMenu/useValueMenuState.js +76 -0
  100. package/dist/components/QueryBar/QueryBarMenu/index.d.ts +5 -0
  101. package/dist/components/QueryBar/QueryBarMenu/index.js +6 -0
  102. package/dist/components/QueryBar/QueryBarMenu/useKeyboardNav.d.ts +36 -0
  103. package/dist/components/QueryBar/QueryBarMenu/useKeyboardNav.js +233 -0
  104. package/dist/components/QueryBar/hooks/index.d.ts +3 -0
  105. package/dist/components/QueryBar/hooks/index.js +4 -0
  106. package/dist/components/QueryBar/hooks/useQueryBarAutocomplete/deriveAutocompleteValues.d.ts +21 -0
  107. package/dist/components/QueryBar/hooks/useQueryBarAutocomplete/deriveAutocompleteValues.js +50 -0
  108. package/dist/components/QueryBar/hooks/useQueryBarAutocomplete/index.d.ts +1 -0
  109. package/dist/components/QueryBar/hooks/useQueryBarAutocomplete/index.js +2 -0
  110. package/dist/components/QueryBar/hooks/useQueryBarAutocomplete/useChipEditing.d.ts +28 -0
  111. package/dist/components/QueryBar/hooks/useQueryBarAutocomplete/useChipEditing.js +79 -0
  112. package/dist/components/QueryBar/hooks/useQueryBarAutocomplete/useMenuFlow.d.ts +37 -0
  113. package/dist/components/QueryBar/hooks/useQueryBarAutocomplete/useMenuFlow.js +228 -0
  114. package/dist/components/QueryBar/hooks/useQueryBarAutocomplete/useMenuPositioning.d.ts +35 -0
  115. package/dist/components/QueryBar/hooks/useQueryBarAutocomplete/useMenuPositioning.js +49 -0
  116. package/dist/components/QueryBar/hooks/useQueryBarAutocomplete/useQueryBarAutocomplete.d.ts +70 -0
  117. package/dist/components/QueryBar/hooks/useQueryBarAutocomplete/useQueryBarAutocomplete.js +251 -0
  118. package/dist/components/QueryBar/hooks/useQueryBarExpression/buildChips.d.ts +6 -0
  119. package/dist/components/QueryBar/hooks/useQueryBarExpression/buildChips.js +97 -0
  120. package/dist/components/QueryBar/hooks/useQueryBarExpression/expression.d.ts +15 -0
  121. package/dist/components/QueryBar/hooks/useQueryBarExpression/expression.js +56 -0
  122. package/dist/components/QueryBar/hooks/useQueryBarExpression/index.d.ts +1 -0
  123. package/dist/components/QueryBar/hooks/useQueryBarExpression/index.js +2 -0
  124. package/dist/components/QueryBar/hooks/useQueryBarExpression/useQueryBarExpression.d.ts +18 -0
  125. package/dist/components/QueryBar/hooks/useQueryBarExpression/useQueryBarExpression.js +164 -0
  126. package/dist/components/QueryBar/index.d.ts +4 -0
  127. package/dist/components/QueryBar/index.js +4 -0
  128. package/dist/components/QueryBar/lib/conditions.d.ts +9 -0
  129. package/dist/components/QueryBar/lib/conditions.js +18 -0
  130. package/dist/components/QueryBar/lib/constants.d.ts +37 -0
  131. package/dist/components/QueryBar/lib/constants.js +144 -0
  132. package/dist/components/QueryBar/lib/dom.d.ts +2 -0
  133. package/dist/components/QueryBar/lib/dom.js +2 -0
  134. package/dist/components/QueryBar/lib/filterSort.d.ts +5 -0
  135. package/dist/components/QueryBar/lib/filterSort.js +13 -0
  136. package/dist/components/QueryBar/lib/index.d.ts +7 -0
  137. package/dist/components/QueryBar/lib/index.js +7 -0
  138. package/dist/components/QueryBar/lib/operators.d.ts +15 -0
  139. package/dist/components/QueryBar/lib/operators.js +13 -0
  140. package/dist/components/QueryBar/types.d.ts +117 -0
  141. package/dist/components/QueryBar/types.js +0 -0
  142. package/dist/components/Tabs/Tabs.js +2 -4
  143. package/dist/hooks/useControlled.js +1 -3
  144. package/dist/icons/CircleSlash.d.ts +7 -0
  145. package/dist/icons/CircleSlash.js +28 -0
  146. package/dist/index.d.ts +2 -1
  147. package/dist/index.js +3 -2
  148. package/dist/metadata/components.json +960 -193
  149. package/dist/theme/semantic.css +1 -1
  150. package/package.json +2 -1
@@ -1,10 +1,24 @@
1
1
  import { type FC, type ReactNode } from 'react';
2
+ import { Menu } from '@ark-ui/react/menu';
2
3
  interface DropdownMenuProps {
3
4
  children: ReactNode;
4
5
  open?: boolean;
5
6
  defaultOpen?: boolean;
6
7
  onOpenChange?: (open: boolean) => void;
7
8
  modal?: boolean;
9
+ /** Virtual anchor point for positioning without a trigger element */
10
+ anchorPoint?: {
11
+ x: number;
12
+ y: number;
13
+ };
14
+ /** Override default positioning config */
15
+ positioning?: Menu.RootProps['positioning'];
16
+ /** Programmatically control which item is highlighted */
17
+ highlightedValue?: string | null;
18
+ /** Callback when the highlighted item changes (e.g. on mouse hover) */
19
+ onHighlightChange?: (details: Menu.HighlightChangeDetails) => void;
20
+ /** Whether selecting an item closes the menu (default true) */
21
+ closeOnSelect?: boolean;
8
22
  }
9
23
  export declare const DropdownMenu: FC<DropdownMenuProps>;
10
24
  export {};
@@ -14,9 +14,10 @@ const SUB_POSITIONING = {
14
14
  crossAxis: -9
15
15
  }
16
16
  };
17
- const DropdownMenu = ({ children, open, defaultOpen, onOpenChange, ...props })=>{
17
+ const DropdownMenu = ({ children, open, defaultOpen, onOpenChange, anchorPoint, positioning, highlightedValue, onHighlightChange, closeOnSelect, ...props })=>{
18
18
  const parent = useDropdownMenuContext();
19
19
  const isNested = null !== parent;
20
+ const defaultPositioning = isNested ? SUB_POSITIONING : ROOT_POSITIONING;
20
21
  const handleOpenChange = (details)=>{
21
22
  onOpenChange?.(details.open);
22
23
  };
@@ -27,7 +28,19 @@ const DropdownMenu = ({ children, open, defaultOpen, onOpenChange, ...props })=>
27
28
  value: ctx,
28
29
  children: /*#__PURE__*/ jsx(Menu.Root, {
29
30
  ...props,
30
- positioning: isNested ? SUB_POSITIONING : ROOT_POSITIONING,
31
+ positioning: positioning ?? defaultPositioning,
32
+ ...null != anchorPoint && {
33
+ anchorPoint
34
+ },
35
+ ...null != highlightedValue && {
36
+ highlightedValue
37
+ },
38
+ ...null != closeOnSelect && {
39
+ closeOnSelect
40
+ },
41
+ ...null != onHighlightChange && {
42
+ onHighlightChange
43
+ },
31
44
  open: open,
32
45
  defaultOpen: defaultOpen,
33
46
  onOpenChange: handleOpenChange,
@@ -6,6 +6,8 @@ export interface DropdownMenuItemProps extends Omit<HTMLAttributes<HTMLDivElemen
6
6
  inset?: boolean;
7
7
  disabled?: boolean;
8
8
  onSelect?: () => void;
9
+ /** Explicit value for programmatic highlighting via highlightedValue */
10
+ value?: string;
9
11
  ref?: Ref<HTMLDivElement>;
10
12
  }
11
13
  export declare const DropdownMenuItem: FC<DropdownMenuItemProps>;
@@ -3,17 +3,17 @@ import { useId } from "react";
3
3
  import { Menu } from "@ark-ui/react/menu";
4
4
  import { cn } from "../../utils/cn.js";
5
5
  import { dropdownMenuItemVariants } from "./classes.js";
6
- const DropdownMenuItem = ({ inset = false, variant = 'default', onSelect, disabled, ...props })=>{
7
- const id = useId();
6
+ const DropdownMenuItem = ({ inset = false, variant = 'default', onSelect, disabled, value, className, ...props })=>{
7
+ const autoId = useId();
8
8
  return /*#__PURE__*/ jsx(Menu.Item, {
9
9
  ...props,
10
- value: id,
10
+ value: value ?? autoId,
11
11
  disabled: disabled,
12
12
  onSelect: onSelect,
13
13
  className: cn(dropdownMenuItemVariants({
14
14
  variant,
15
15
  inset
16
- }))
16
+ }), className)
17
17
  });
18
18
  };
19
19
  DropdownMenuItem.displayName = 'DropdownMenuItem';
@@ -1,6 +1,6 @@
1
1
  import { cva } from "class-variance-authority";
2
2
  import { cn } from "../../utils/cn.js";
3
- const dropdownMenuClassNames = cn('flex flex-col gap-1 min-w-128', 'z-50 overflow-y-auto overflow-x-hidden outline-none', 'rounded-12 border border-border-primary-light bg-bg-surface-2 p-8 font-sans text-text-primary shadow-md outline-none', 'data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95', 'data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95', 'data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2');
3
+ const dropdownMenuClassNames = cn('flex flex-col gap-1 min-w-128', 'z-50 overflow-hidden outline-none', 'rounded-12 border border-border-primary-light bg-bg-surface-2 p-8 font-sans text-text-primary shadow-md outline-none', 'data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95', 'data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95', 'data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2');
4
4
  const dropdownMenuItemVariants = cva([
5
5
  'flex items-center gap-8 rounded-6 px-8 py-6 text-sm',
6
6
  'relative cursor-pointer select-none outline-none transition-colors',
@@ -0,0 +1,36 @@
1
+ import type { FC, HTMLAttributes } from 'react';
2
+ import type { ExprNode, FieldMetadata } from './types';
3
+ export interface QueryBarProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'onChange'> {
4
+ /**
5
+ * Available fields from backend API config
6
+ */
7
+ fields?: FieldMetadata[];
8
+ /**
9
+ * Current filter expression value (controlled mode)
10
+ */
11
+ value?: ExprNode | null;
12
+ /**
13
+ * Callback when filter expression changes
14
+ */
15
+ onChange?: (expression: ExprNode | null) => void;
16
+ /**
17
+ * Placeholder text to display when field is empty
18
+ * @default "Type to filter..."
19
+ */
20
+ placeholder?: string;
21
+ /**
22
+ * Whether the field has a validation error
23
+ */
24
+ error?: boolean;
25
+ /**
26
+ * Whether to show the keyboard hint (⌘K or Ctrl+K)
27
+ */
28
+ showKeyboardHint?: boolean;
29
+ }
30
+ /**
31
+ * QueryBar - Self-contained filter component.
32
+ * Handles autocomplete flow (field → operator → value), chip creation, and expression management.
33
+ * Supports multiple conditions joined by AND/OR connectors.
34
+ * Just pass `fields` config from backend API and it works.
35
+ */
36
+ export declare const QueryBar: FC<QueryBarProps>;
@@ -0,0 +1,60 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useRef } from "react";
3
+ import { cn } from "../../utils/cn.js";
4
+ import { useQueryBarAutocomplete, useQueryBarExpression } from "./hooks/index.js";
5
+ import { QueryBarProvider, useQueryBarContextValue } from "./QueryBarContext/index.js";
6
+ import { QueryBarInput } from "./QueryBarInput/index.js";
7
+ import { QueryBarMenu } from "./QueryBarMenu/QueryBarMenu.js";
8
+ const QueryBar = ({ fields = [], value, onChange, placeholder = 'Type to filter...', error = false, showKeyboardHint = false, className, ...props })=>{
9
+ const inputRef = useRef(null);
10
+ const containerRef = useRef(null);
11
+ const buildingChipRef = useRef(null);
12
+ const { conditions, chips, upsertCondition, removeCondition, removeConditionAtIndex, clearAll, setConnectorValue } = useQueryBarExpression({
13
+ fields,
14
+ value,
15
+ onChange,
16
+ error
17
+ });
18
+ const autocomplete = useQueryBarAutocomplete({
19
+ fields,
20
+ conditions,
21
+ chips,
22
+ upsertCondition,
23
+ removeCondition,
24
+ removeConditionAtIndex,
25
+ clearAll,
26
+ setConnectorValue,
27
+ containerRef,
28
+ buildingChipRef,
29
+ inputRef
30
+ });
31
+ const contextValue = useQueryBarContextValue({
32
+ chips,
33
+ autocomplete,
34
+ buildingChipRef,
35
+ inputRef,
36
+ placeholder,
37
+ error,
38
+ showKeyboardHint
39
+ });
40
+ return /*#__PURE__*/ jsxs("div", {
41
+ ref: containerRef,
42
+ className: cn('relative w-full', className),
43
+ onFocus: autocomplete.handleFocus,
44
+ onBlur: autocomplete.handleBlur,
45
+ children: [
46
+ /*#__PURE__*/ jsx(QueryBarProvider, {
47
+ value: contextValue,
48
+ children: /*#__PURE__*/ jsx(QueryBarInput, {
49
+ ...props
50
+ })
51
+ }),
52
+ /*#__PURE__*/ jsx(QueryBarMenu, {
53
+ fields: fields,
54
+ autocomplete: autocomplete
55
+ })
56
+ ]
57
+ });
58
+ };
59
+ QueryBar.displayName = 'QueryBar';
60
+ export { QueryBar };
@@ -0,0 +1,2 @@
1
+ import type { QueryBarContextValue } from './types';
2
+ export declare const QueryBarContext: import("react").Context<QueryBarContextValue | null>;
@@ -0,0 +1,3 @@
1
+ import { createContext } from "react";
2
+ const QueryBarContext = createContext(null);
3
+ export { QueryBarContext };
@@ -0,0 +1,8 @@
1
+ import type { FC, ReactNode } from 'react';
2
+ import type { QueryBarContextValue } from './types';
3
+ interface QueryBarProviderProps {
4
+ value: QueryBarContextValue;
5
+ children: ReactNode;
6
+ }
7
+ export declare const QueryBarProvider: FC<QueryBarProviderProps>;
8
+ export {};
@@ -0,0 +1,8 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { QueryBarContext } from "./QueryBarContext.js";
3
+ const QueryBarProvider = ({ value, children })=>/*#__PURE__*/ jsx(QueryBarContext.Provider, {
4
+ value: value,
5
+ children: children
6
+ });
7
+ QueryBarProvider.displayName = 'QueryBarProvider';
8
+ export { QueryBarProvider };
@@ -0,0 +1,4 @@
1
+ export { QueryBarProvider } from './QueryBarProvider';
2
+ export type { BuildingChipData, QueryBarContextValue } from './types';
3
+ export { useQueryBarContext } from './useQueryBarContext';
4
+ export { useQueryBarContextValue } from './useQueryBarContextValue';
@@ -0,0 +1,4 @@
1
+ import { QueryBarProvider } from "./QueryBarProvider.js";
2
+ import { useQueryBarContext } from "./useQueryBarContext.js";
3
+ import { useQueryBarContextValue } from "./useQueryBarContextValue.js";
4
+ export { QueryBarProvider, useQueryBarContext, useQueryBarContextValue };
@@ -0,0 +1,38 @@
1
+ import type { ChangeEvent, KeyboardEvent, Ref, RefObject } from 'react';
2
+ import type { ChipSegment } from '../QueryBarInput/QueryBarChip';
3
+ import type { QueryBarChipData } from '../types';
4
+ export interface BuildingChipData {
5
+ attribute: string;
6
+ operator?: string;
7
+ value?: string;
8
+ }
9
+ export interface QueryBarContextValue {
10
+ chips: QueryBarChipData[];
11
+ buildingChipData: BuildingChipData | null;
12
+ buildingChipRef: Ref<HTMLDivElement>;
13
+ inputText: string;
14
+ inputRef: Ref<HTMLInputElement>;
15
+ placeholder: string;
16
+ error: boolean;
17
+ showKeyboardHint: boolean;
18
+ menuOpen: boolean;
19
+ insertIndex: number;
20
+ insertAfterConnector: boolean;
21
+ onInputChange: (e: ChangeEvent<HTMLInputElement>) => void;
22
+ onInputKeyDown: (e: KeyboardEvent<HTMLInputElement>) => void;
23
+ onInputClick: () => void;
24
+ onGapClick: (conditionIndex: number, afterConnector: boolean) => void;
25
+ onChipClick: (chipId: string, segment: ChipSegment, anchorRect: DOMRect) => void;
26
+ onConnectorChange: (chipId: string, value: 'and' | 'or') => void;
27
+ onChipRemove: (chipId: string) => void;
28
+ onClear: () => void;
29
+ editingChipId: string | null;
30
+ editingSegment: ChipSegment | null;
31
+ segmentFilterText: string;
32
+ onSegmentFilterChange: (text: string) => void;
33
+ onCancelSegmentEdit: () => void;
34
+ onCustomValueCommit: (customText: string) => void;
35
+ onCustomAttributeCommit: (customText: string) => void;
36
+ /** Ref to the currently open menu content element */
37
+ menuRef: RefObject<HTMLDivElement | null>;
38
+ }
@@ -0,0 +1,2 @@
1
+ import type { QueryBarContextValue } from './types';
2
+ export declare const useQueryBarContext: () => QueryBarContextValue;
@@ -0,0 +1,8 @@
1
+ import { useContext } from "react";
2
+ import { QueryBarContext } from "./QueryBarContext.js";
3
+ const useQueryBarContext = ()=>{
4
+ const ctx = useContext(QueryBarContext);
5
+ if (!ctx) throw new Error('useQueryBarContext must be used within a <QueryBar> component');
6
+ return ctx;
7
+ };
8
+ export { useQueryBarContext };
@@ -0,0 +1,38 @@
1
+ import type { RefObject } from 'react';
2
+ import type { ChipSegment } from '../QueryBarInput/QueryBarChip';
3
+ import type { MenuState, QueryBarChipData } from '../types';
4
+ import type { BuildingChipData, QueryBarContextValue } from './types';
5
+ interface AutocompleteForContext {
6
+ buildingChipData: BuildingChipData | null;
7
+ inputText: string;
8
+ menuState: MenuState;
9
+ handleInputChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
10
+ handleKeyDown: (e: React.KeyboardEvent<HTMLInputElement>) => void;
11
+ handleInputClick: () => void;
12
+ handleChipClick: (chipId: string, segment: ChipSegment, anchorRect: DOMRect) => void;
13
+ handleConnectorChange: (chipId: string, value: 'and' | 'or') => void;
14
+ handleChipRemove: (chipId: string) => void;
15
+ handleClear: () => void;
16
+ handleGapClick: (conditionIndex: number, afterConnector: boolean) => void;
17
+ insertIndex: number;
18
+ insertAfterConnector: boolean;
19
+ editingChipId: string | null;
20
+ editingSegment: ChipSegment | null;
21
+ segmentFilterText: string;
22
+ handleSegmentFilterChange: (text: string) => void;
23
+ cancelSegmentEdit: () => void;
24
+ handleCustomValueCommit: (customText: string) => void;
25
+ handleCustomAttributeCommit: (customText: string) => void;
26
+ menuRef: RefObject<HTMLDivElement | null>;
27
+ }
28
+ interface UseQueryBarContextValueOptions {
29
+ chips: QueryBarChipData[];
30
+ autocomplete: AutocompleteForContext;
31
+ buildingChipRef: RefObject<HTMLDivElement | null>;
32
+ inputRef: RefObject<HTMLInputElement | null>;
33
+ placeholder: string;
34
+ error: boolean;
35
+ showKeyboardHint: boolean;
36
+ }
37
+ export declare const useQueryBarContextValue: ({ chips, autocomplete, buildingChipRef, inputRef, placeholder, error, showKeyboardHint, }: UseQueryBarContextValueOptions) => QueryBarContextValue;
38
+ export {};
@@ -0,0 +1,59 @@
1
+ import { useMemo } from "react";
2
+ const useQueryBarContextValue = ({ chips, autocomplete, buildingChipRef, inputRef, placeholder, error, showKeyboardHint })=>useMemo(()=>({
3
+ chips,
4
+ buildingChipData: autocomplete.buildingChipData,
5
+ buildingChipRef,
6
+ inputText: autocomplete.inputText,
7
+ inputRef,
8
+ placeholder,
9
+ error,
10
+ showKeyboardHint,
11
+ menuOpen: 'closed' !== autocomplete.menuState,
12
+ insertIndex: autocomplete.insertIndex,
13
+ insertAfterConnector: autocomplete.insertAfterConnector,
14
+ onInputChange: autocomplete.handleInputChange,
15
+ onGapClick: autocomplete.handleGapClick,
16
+ onInputKeyDown: autocomplete.handleKeyDown,
17
+ onInputClick: autocomplete.handleInputClick,
18
+ onChipClick: autocomplete.handleChipClick,
19
+ onConnectorChange: autocomplete.handleConnectorChange,
20
+ onChipRemove: autocomplete.handleChipRemove,
21
+ onClear: autocomplete.handleClear,
22
+ editingChipId: autocomplete.editingChipId,
23
+ editingSegment: autocomplete.editingSegment,
24
+ segmentFilterText: autocomplete.segmentFilterText,
25
+ onSegmentFilterChange: autocomplete.handleSegmentFilterChange,
26
+ onCancelSegmentEdit: autocomplete.cancelSegmentEdit,
27
+ onCustomValueCommit: autocomplete.handleCustomValueCommit,
28
+ onCustomAttributeCommit: autocomplete.handleCustomAttributeCommit,
29
+ menuRef: autocomplete.menuRef
30
+ }), [
31
+ chips,
32
+ autocomplete.buildingChipData,
33
+ autocomplete.inputText,
34
+ autocomplete.menuState,
35
+ autocomplete.insertIndex,
36
+ autocomplete.insertAfterConnector,
37
+ autocomplete.handleInputChange,
38
+ autocomplete.handleGapClick,
39
+ autocomplete.handleKeyDown,
40
+ autocomplete.handleInputClick,
41
+ autocomplete.handleChipClick,
42
+ autocomplete.handleConnectorChange,
43
+ autocomplete.handleChipRemove,
44
+ autocomplete.handleClear,
45
+ autocomplete.editingChipId,
46
+ autocomplete.editingSegment,
47
+ autocomplete.segmentFilterText,
48
+ autocomplete.handleSegmentFilterChange,
49
+ autocomplete.cancelSegmentEdit,
50
+ autocomplete.handleCustomValueCommit,
51
+ autocomplete.handleCustomAttributeCommit,
52
+ autocomplete.menuRef,
53
+ buildingChipRef,
54
+ inputRef,
55
+ placeholder,
56
+ error,
57
+ showKeyboardHint
58
+ ]);
59
+ export { useQueryBarContextValue };
@@ -0,0 +1,23 @@
1
+ import type { FC } from 'react';
2
+ import type { QueryBarChipData } from '../types';
3
+ import type { ChipSegment } from './QueryBarChip';
4
+ interface ChipsWithGapsProps {
5
+ chips: QueryBarChipData[];
6
+ hideLeadingGap?: boolean;
7
+ hideTrailingGap?: boolean;
8
+ onChipClick: (chipId: string, segment: ChipSegment, anchorRect: DOMRect) => void;
9
+ onConnectorChange: (chipId: string, value: 'and' | 'or') => void;
10
+ onChipRemove: (chipId: string) => void;
11
+ onGapClick: (conditionIndex: number, afterConnector: boolean) => void;
12
+ }
13
+ /**
14
+ * Renders chips with InsertionGap components around each connector.
15
+ * Trailing gap is handled separately in the parent to avoid duplicates when chips are split.
16
+ */
17
+ export declare const ChipsWithGaps: FC<ChipsWithGapsProps>;
18
+ /** Trailing gap rendered once after chipsAfter in the parent layout. */
19
+ export declare const TrailingGap: FC<{
20
+ chips: QueryBarChipData[];
21
+ onGapClick: (conditionIndex: number, afterConnector: boolean) => void;
22
+ }>;
23
+ export {};
@@ -0,0 +1,63 @@
1
+ import { Fragment, jsx } from "react/jsx-runtime";
2
+ import { InsertionGap } from "./InsertionGap/index.js";
3
+ import { QueryBarChip } from "./QueryBarChip/QueryBarChip.js";
4
+ import { QueryBarConnectorChip } from "./QueryBarConnectorChip/index.js";
5
+ const ChipsWithGaps = ({ chips, hideLeadingGap, hideTrailingGap, onChipClick, onConnectorChange, onChipRemove, onGapClick })=>{
6
+ const elements = [];
7
+ let connectorIndex = 0;
8
+ const connectorCount = chips.filter((c)=>'and' === c.variant || 'or' === c.variant).length;
9
+ for (const chip of chips){
10
+ const isCondition = 'chip' === chip.variant;
11
+ const isConnector = 'and' === chip.variant || 'or' === chip.variant;
12
+ if (isCondition) elements.push(/*#__PURE__*/ jsx("div", {
13
+ className: "shrink-0 cursor-pointer hover:z-10",
14
+ children: /*#__PURE__*/ jsx(QueryBarChip, {
15
+ chipId: chip.id,
16
+ attribute: chip.attribute ?? '',
17
+ operator: chip.operator,
18
+ value: chip.value,
19
+ error: chip.error,
20
+ onRemove: ()=>onChipRemove(chip.id),
21
+ onSegmentClick: (segment, anchorRect)=>onChipClick(chip.id, segment, anchorRect)
22
+ })
23
+ }, chip.id));
24
+ else if (isConnector) {
25
+ const match = chip.id.match(/^connector-(\d+)$/);
26
+ const condIdx = match ? Number(match[1]) : 0;
27
+ const isFirst = 0 === connectorIndex;
28
+ const isLast = connectorIndex === connectorCount - 1;
29
+ if (!(isFirst && hideLeadingGap)) elements.push(/*#__PURE__*/ jsx(InsertionGap, {
30
+ onClick: ()=>onGapClick(condIdx, false)
31
+ }, `gap-before-${chip.id}`));
32
+ elements.push(/*#__PURE__*/ jsx("div", {
33
+ className: "shrink-0",
34
+ children: /*#__PURE__*/ jsx(QueryBarConnectorChip, {
35
+ chipId: chip.id,
36
+ variant: chip.variant,
37
+ onChange: onConnectorChange
38
+ })
39
+ }, chip.id));
40
+ if (!(isLast && hideTrailingGap)) elements.push(/*#__PURE__*/ jsx(InsertionGap, {
41
+ onClick: ()=>onGapClick(condIdx, true)
42
+ }, `gap-after-${chip.id}`));
43
+ connectorIndex++;
44
+ }
45
+ }
46
+ return /*#__PURE__*/ jsx(Fragment, {
47
+ children: elements
48
+ });
49
+ };
50
+ ChipsWithGaps.displayName = 'ChipsWithGaps';
51
+ const TrailingGap = ({ chips, onGapClick })=>{
52
+ const lastCondChip = [
53
+ ...chips
54
+ ].reverse().find((c)=>'chip' === c.variant);
55
+ if (!lastCondChip) return null;
56
+ const match = lastCondChip.id.match(/^chip-(\d+)$/);
57
+ const trailingIdx = match ? Number(match[1]) + 1 : 0;
58
+ return /*#__PURE__*/ jsx(InsertionGap, {
59
+ onClick: ()=>onGapClick(trailingIdx, true)
60
+ });
61
+ };
62
+ TrailingGap.displayName = 'TrailingGap';
63
+ export { ChipsWithGaps, TrailingGap };
@@ -0,0 +1,7 @@
1
+ import type { FC } from 'react';
2
+ interface InsertionGapProps {
3
+ onClick: () => void;
4
+ }
5
+ /** Thin clickable zone between chips for caret placement. */
6
+ export declare const InsertionGap: FC<InsertionGapProps>;
7
+ export {};
@@ -0,0 +1,17 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { insertionGapButton, insertionGapDivider } from "./classes.js";
3
+ const InsertionGap = ({ onClick })=>/*#__PURE__*/ jsx("button", {
4
+ type: "button",
5
+ className: insertionGapButton,
6
+ onClick: (e)=>{
7
+ e.stopPropagation();
8
+ onClick();
9
+ },
10
+ tabIndex: -1,
11
+ "aria-hidden": "true",
12
+ children: /*#__PURE__*/ jsx("div", {
13
+ className: insertionGapDivider
14
+ })
15
+ });
16
+ InsertionGap.displayName = 'InsertionGap';
17
+ export { InsertionGap };
@@ -0,0 +1,4 @@
1
+ /** Insertion gap button */
2
+ export declare const insertionGapButton = "group relative z-20 flex h-28 w-8 shrink-0 cursor-text items-center justify-center";
3
+ /** Insertion gap divider indicator */
4
+ export declare const insertionGapDivider = "h-16 w-1 rounded-full bg-transparent transition-colors group-hover:bg-border-primary/50";
@@ -0,0 +1,3 @@
1
+ const insertionGapButton = 'group relative z-20 flex h-28 w-8 shrink-0 cursor-text items-center justify-center';
2
+ const insertionGapDivider = 'h-16 w-1 rounded-full bg-transparent transition-colors group-hover:bg-border-primary/50';
3
+ export { insertionGapButton, insertionGapDivider };
@@ -0,0 +1 @@
1
+ export { InsertionGap } from './InsertionGap';
@@ -0,0 +1,2 @@
1
+ import { InsertionGap } from "./InsertionGap.js";
2
+ export { InsertionGap };
@@ -0,0 +1,14 @@
1
+ import { type FC, type FocusEvent, type KeyboardEvent, type ReactNode } from 'react';
2
+ import type { ChipSegment } from './QueryBarChip';
3
+ export interface EditingContextValue {
4
+ editingChipId: string | null;
5
+ editingSegment: ChipSegment | null;
6
+ segmentFilterText: string;
7
+ onSegmentFilterChange: (text: string) => void;
8
+ onSegmentEditKeyDown: (e: KeyboardEvent<HTMLInputElement>) => void;
9
+ onSegmentEditBlur: (e: FocusEvent<HTMLInputElement>) => void;
10
+ }
11
+ export declare const EditingProvider: FC<EditingContextValue & {
12
+ children: ReactNode;
13
+ }>;
14
+ export declare const useEditingContext: () => EditingContextValue | null;
@@ -0,0 +1,9 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext } from "react";
3
+ const EditingCtx = /*#__PURE__*/ createContext(null);
4
+ const EditingProvider = ({ children, ...value })=>/*#__PURE__*/ jsx(EditingCtx.Provider, {
5
+ value: value,
6
+ children: children
7
+ });
8
+ const useEditingContext = ()=>useContext(EditingCtx);
9
+ export { EditingProvider, useEditingContext };
@@ -0,0 +1,7 @@
1
+ import type { FC, HTMLAttributes } from 'react';
2
+ type OperatorSegmentProps = HTMLAttributes<HTMLDivElement> & {
3
+ children: string;
4
+ };
5
+ /** Operator segment — click-only (opens dropdown), no inline editing. */
6
+ export declare const OperatorSegment: FC<OperatorSegmentProps>;
7
+ export {};
@@ -0,0 +1,23 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { cn } from "../../../../utils/cn.js";
3
+ import { segmentContainer, segmentTextVariants } from "./classes.js";
4
+ const OperatorSegment = ({ children, className, ...props })=>{
5
+ const isInteractive = !!props.onClick;
6
+ return /*#__PURE__*/ jsx("div", {
7
+ className: cn(segmentContainer, className),
8
+ "data-slot": "segment-operator",
9
+ ...isInteractive && {
10
+ role: 'button',
11
+ 'aria-label': 'Edit filter operator'
12
+ },
13
+ ...props,
14
+ children: /*#__PURE__*/ jsx("p", {
15
+ className: segmentTextVariants({
16
+ variant: 'operator'
17
+ }),
18
+ children: children
19
+ })
20
+ });
21
+ };
22
+ OperatorSegment.displayName = 'OperatorSegment';
23
+ export { OperatorSegment };
@@ -0,0 +1,13 @@
1
+ import type { FC, HTMLAttributes } from 'react';
2
+ export type ChipSegment = 'attribute' | 'operator' | 'value';
3
+ export interface QueryBarChipProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
4
+ chipId?: string;
5
+ attribute: string;
6
+ operator?: string;
7
+ value?: string;
8
+ error?: boolean;
9
+ building?: boolean;
10
+ onRemove?: () => void;
11
+ onSegmentClick?: (segment: ChipSegment, anchorRect: DOMRect) => void;
12
+ }
13
+ export declare const QueryBarChip: FC<QueryBarChipProps>;