@wallarm-org/design-system 4.10.0-rc-feat-parser.1 → 4.10.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/README.md +1 -1
  2. package/dist/components/Badge/generateBadgeVariants.js +9 -28
  3. package/dist/components/Checkbox/CheckboxGroup.d.ts +2 -1
  4. package/dist/components/Checkbox/CheckboxGroup.js +16 -13
  5. package/dist/components/CodeSnippet/internal/FoldToggle.js +1 -1
  6. package/dist/components/DropdownMenu/DropdownMenu.d.ts +0 -2
  7. package/dist/components/DropdownMenu/DropdownMenu.js +71 -84
  8. package/dist/components/DropdownMenu/DropdownMenuItemDescription.js +1 -1
  9. package/dist/components/FilterInput/hooks/useFilterInputAutocomplete/useFilterInputAutocomplete.js +1 -1
  10. package/dist/components/Radio/RadioGroup.d.ts +2 -1
  11. package/dist/components/Radio/RadioGroup.js +16 -13
  12. package/dist/components/SimpleCharts/Chart/classes.js +1 -1
  13. package/dist/components/SimpleCharts/HorizontalBarStack/classes.js +1 -1
  14. package/dist/components/SimpleCharts/Metric/classes.d.ts +2 -2
  15. package/dist/components/SimpleCharts/Metric/classes.js +2 -2
  16. package/dist/components/Table/TableBody/TableBodyCell.js +4 -1
  17. package/dist/guidelines/patterns/complex-drawer.md +1084 -0
  18. package/dist/guidelines/patterns/confirmation-dialogs.md +3 -11
  19. package/dist/guidelines/patterns/detail-drawer.md +31 -13
  20. package/dist/guidelines/patterns/empty-states.md +6 -5
  21. package/dist/guidelines/patterns/entity-table.md +25 -29
  22. package/dist/guidelines/patterns/feedback-toasts.md +3 -11
  23. package/dist/guidelines/patterns/resource-list-page.md +14 -16
  24. package/dist/guidelines/rules.md +6 -5
  25. package/dist/guidelines/templates/ai-assistant.md +1133 -0
  26. package/dist/guidelines/templates/api-inventory.md +905 -0
  27. package/dist/guidelines/templates/attack-events.md +2722 -0
  28. package/dist/guidelines/templates/incident-detail.md +2085 -0
  29. package/dist/guidelines/templates/integrations-settings.md +836 -0
  30. package/dist/guidelines/templates/page-states.md +798 -0
  31. package/dist/guidelines/templates/rule-editor.md +886 -0
  32. package/dist/guidelines/templates/security-dashboard.md +681 -0
  33. package/dist/index.d.ts +0 -2
  34. package/dist/index.js +0 -2
  35. package/dist/metadata/components.json +20 -108
  36. package/dist/metadata/guidelines.json +1204 -37
  37. package/dist/theme/tokens.test.ts +52 -0
  38. package/package.json +1 -4
  39. package/dist/components/Rules/PointSelector/KeyboardShortcutsDialog.d.ts +0 -14
  40. package/dist/components/Rules/PointSelector/KeyboardShortcutsDialog.js +0 -209
  41. package/dist/components/Rules/PointSelector/MatchStep.d.ts +0 -15
  42. package/dist/components/Rules/PointSelector/MatchStep.js +0 -186
  43. package/dist/components/Rules/PointSelector/MenuFooterHints.d.ts +0 -16
  44. package/dist/components/Rules/PointSelector/MenuFooterHints.js +0 -177
  45. package/dist/components/Rules/PointSelector/PointPreview.d.ts +0 -10
  46. package/dist/components/Rules/PointSelector/PointPreview.js +0 -88
  47. package/dist/components/Rules/PointSelector/PointSelector.d.ts +0 -17
  48. package/dist/components/Rules/PointSelector/PointSelector.js +0 -937
  49. package/dist/components/Rules/PointSelector/PointSelectorEmptyState.d.ts +0 -12
  50. package/dist/components/Rules/PointSelector/PointSelectorEmptyState.js +0 -173
  51. package/dist/components/Rules/PointSelector/PointSelectorError.d.ts +0 -31
  52. package/dist/components/Rules/PointSelector/PointSelectorError.js +0 -275
  53. package/dist/components/Rules/PointSelector/PointSelectorInput.d.ts +0 -20
  54. package/dist/components/Rules/PointSelector/PointSelectorInput.js +0 -130
  55. package/dist/components/Rules/PointSelector/PointSelectorMenu.d.ts +0 -31
  56. package/dist/components/Rules/PointSelector/PointSelectorMenu.js +0 -317
  57. package/dist/components/Rules/PointSelector/PointSelectorSkeleton.d.ts +0 -8
  58. package/dist/components/Rules/PointSelector/PointSelectorSkeleton.js +0 -73
  59. package/dist/components/Rules/PointSelector/SampleRequest.d.ts +0 -14
  60. package/dist/components/Rules/PointSelector/SampleRequest.js +0 -116
  61. package/dist/components/Rules/PointSelector/StepMenu.d.ts +0 -40
  62. package/dist/components/Rules/PointSelector/StepMenu.js +0 -210
  63. package/dist/components/Rules/PointSelector/VersionWarning.d.ts +0 -26
  64. package/dist/components/Rules/PointSelector/VersionWarning.js +0 -231
  65. package/dist/components/Rules/PointSelector/WhereBar.d.ts +0 -48
  66. package/dist/components/Rules/PointSelector/WhereBar.js +0 -263
  67. package/dist/components/Rules/PointSelector/classes.d.ts +0 -28
  68. package/dist/components/Rules/PointSelector/classes.js +0 -22
  69. package/dist/components/Rules/PointSelector/index.d.ts +0 -20
  70. package/dist/components/Rules/PointSelector/index.js +0 -18
  71. package/dist/components/Rules/PointSelector/liftLayer.d.ts +0 -8
  72. package/dist/components/Rules/PointSelector/liftLayer.js +0 -4
  73. package/dist/components/Rules/PointSelector/sampleValue.d.ts +0 -6
  74. package/dist/components/Rules/PointSelector/sampleValue.js +0 -51
  75. package/dist/components/Rules/PointSelector/sdkBridge.d.ts +0 -508
  76. package/dist/components/Rules/PointSelector/sdkBridge.js +0 -339
  77. package/dist/components/Rules/PointSelector/types.d.ts +0 -304
  78. package/dist/components/Rules/PointSelector/types.js +0 -0
  79. package/dist/components/Rules/PointSelector/usePointSelector.d.ts +0 -161
  80. package/dist/components/Rules/PointSelector/usePointSelector.js +0 -1088
  81. package/dist/components/Rules/RuleBuilder/ActionEditor/ActionEditor.d.ts +0 -28
  82. package/dist/components/Rules/RuleBuilder/ActionEditor/ActionEditor.js +0 -208
  83. package/dist/components/Rules/RuleBuilder/ActionEditor/ActionFields.d.ts +0 -23
  84. package/dist/components/Rules/RuleBuilder/ActionEditor/ActionFields.js +0 -950
  85. package/dist/components/Rules/RuleBuilder/ActionEditor/ActionTargetPicker.d.ts +0 -21
  86. package/dist/components/Rules/RuleBuilder/ActionEditor/ActionTargetPicker.js +0 -110
  87. package/dist/components/Rules/RuleBuilder/ActionEditor/ActionTypeSelect.d.ts +0 -20
  88. package/dist/components/Rules/RuleBuilder/ActionEditor/ActionTypeSelect.js +0 -31
  89. package/dist/components/Rules/RuleBuilder/ActionEditor/AttackTypeField.d.ts +0 -23
  90. package/dist/components/Rules/RuleBuilder/ActionEditor/AttackTypeField.js +0 -131
  91. package/dist/components/Rules/RuleBuilder/ActionEditor/classes.d.ts +0 -17
  92. package/dist/components/Rules/RuleBuilder/ActionEditor/classes.js +0 -14
  93. package/dist/components/Rules/RuleBuilder/ActionEditor/index.d.ts +0 -6
  94. package/dist/components/Rules/RuleBuilder/ActionEditor/index.js +0 -6
  95. package/dist/components/Rules/RuleBuilder/ConditionTree/AddConditionMenu.d.ts +0 -24
  96. package/dist/components/Rules/RuleBuilder/ConditionTree/AddConditionMenu.js +0 -245
  97. package/dist/components/Rules/RuleBuilder/ConditionTree/AttackCondition.d.ts +0 -15
  98. package/dist/components/Rules/RuleBuilder/ConditionTree/AttackCondition.js +0 -691
  99. package/dist/components/Rules/RuleBuilder/ConditionTree/ConditionCard.d.ts +0 -19
  100. package/dist/components/Rules/RuleBuilder/ConditionTree/ConditionCard.js +0 -72
  101. package/dist/components/Rules/RuleBuilder/ConditionTree/ConditionTree.d.ts +0 -27
  102. package/dist/components/Rules/RuleBuilder/ConditionTree/ConditionTree.js +0 -407
  103. package/dist/components/Rules/RuleBuilder/ConditionTree/FieldCondition.d.ts +0 -14
  104. package/dist/components/Rules/RuleBuilder/ConditionTree/FieldCondition.js +0 -269
  105. package/dist/components/Rules/RuleBuilder/ConditionTree/GroupCondition.d.ts +0 -25
  106. package/dist/components/Rules/RuleBuilder/ConditionTree/GroupCondition.js +0 -99
  107. package/dist/components/Rules/RuleBuilder/ConditionTree/SampleCondition.d.ts +0 -14
  108. package/dist/components/Rules/RuleBuilder/ConditionTree/SampleCondition.js +0 -118
  109. package/dist/components/Rules/RuleBuilder/ConditionTree/SignalCondition.d.ts +0 -14
  110. package/dist/components/Rules/RuleBuilder/ConditionTree/SignalCondition.js +0 -446
  111. package/dist/components/Rules/RuleBuilder/ConditionTree/TagCondition.d.ts +0 -14
  112. package/dist/components/Rules/RuleBuilder/ConditionTree/TagCondition.js +0 -266
  113. package/dist/components/Rules/RuleBuilder/ConditionTree/classes.d.ts +0 -35
  114. package/dist/components/Rules/RuleBuilder/ConditionTree/classes.js +0 -57
  115. package/dist/components/Rules/RuleBuilder/ConditionTree/index.d.ts +0 -15
  116. package/dist/components/Rules/RuleBuilder/ConditionTree/index.js +0 -10
  117. package/dist/components/Rules/RuleBuilder/RuleBuilder.d.ts +0 -67
  118. package/dist/components/Rules/RuleBuilder/RuleBuilder.js +0 -366
  119. package/dist/components/Rules/RuleBuilder/Summary/ActionSummary.d.ts +0 -32
  120. package/dist/components/Rules/RuleBuilder/Summary/ActionSummary.js +0 -420
  121. package/dist/components/Rules/RuleBuilder/Summary/ConditionSummary.d.ts +0 -27
  122. package/dist/components/Rules/RuleBuilder/Summary/ConditionSummary.js +0 -446
  123. package/dist/components/Rules/RuleBuilder/Summary/index.d.ts +0 -7
  124. package/dist/components/Rules/RuleBuilder/Summary/index.js +0 -2
  125. package/dist/components/Rules/RuleBuilder/classes.d.ts +0 -19
  126. package/dist/components/Rules/RuleBuilder/classes.js +0 -18
  127. package/dist/components/Rules/RuleBuilder/index.d.ts +0 -55
  128. package/dist/components/Rules/RuleBuilder/index.js +0 -11
  129. package/dist/components/Rules/RuleBuilder/models/actionModel.d.ts +0 -31
  130. package/dist/components/Rules/RuleBuilder/models/actionModel.js +0 -276
  131. package/dist/components/Rules/RuleBuilder/models/conditionModel.d.ts +0 -95
  132. package/dist/components/Rules/RuleBuilder/models/conditionModel.js +0 -418
  133. package/dist/components/Rules/RuleBuilder/models/index.d.ts +0 -3
  134. package/dist/components/Rules/RuleBuilder/models/index.js +0 -3
  135. package/dist/components/Rules/RuleBuilder/models/validation.d.ts +0 -176
  136. package/dist/components/Rules/RuleBuilder/models/validation.js +0 -242
  137. package/dist/components/Rules/RuleBuilder/shared/ChoiceSelect.d.ts +0 -27
  138. package/dist/components/Rules/RuleBuilder/shared/ChoiceSelect.js +0 -92
  139. package/dist/components/Rules/RuleBuilder/shared/index.d.ts +0 -1
  140. package/dist/components/Rules/RuleBuilder/shared/index.js +0 -1
  141. package/dist/components/Rules/RuleBuilder/types.d.ts +0 -384
  142. package/dist/components/Rules/RuleBuilder/types.js +0 -0
  143. package/dist/components/Rules/RuleBuilder/utils/constants.d.ts +0 -65
  144. package/dist/components/Rules/RuleBuilder/utils/constants.js +0 -356
  145. package/dist/components/Rules/RuleBuilder/utils/extractBindings.d.ts +0 -48
  146. package/dist/components/Rules/RuleBuilder/utils/extractBindings.js +0 -42
  147. package/dist/components/Rules/RuleBuilder/utils/helpers.d.ts +0 -92
  148. package/dist/components/Rules/RuleBuilder/utils/helpers.js +0 -54
  149. package/dist/components/Rules/RuleBuilder/utils/index.d.ts +0 -2
  150. package/dist/components/Rules/RuleBuilder/utils/index.js +0 -2
@@ -0,0 +1,52 @@
1
+ import { describe, expect, it } from '@rstest/core';
2
+ import { readdirSync, readFileSync } from 'node:fs';
3
+ import path from 'node:path';
4
+
5
+ // Tailwind v4 emits no CSS for a utility whose `--color-*` token does not exist, so a
6
+ // typo or a removed token renders nothing and fails nowhere. This test is that check.
7
+ const src = path.resolve(__dirname, '..');
8
+ const files = (dir: string, ext: RegExp): string[] =>
9
+ readdirSync(dir, { recursive: true, encoding: 'utf8' })
10
+ .filter(f => ext.test(f))
11
+ .map(f => path.join(dir, f));
12
+
13
+ const tokens = new Set(
14
+ files(__dirname, /\.css$/).flatMap(f =>
15
+ [...readFileSync(f, 'utf8').matchAll(/--color-([a-z0-9-]+)\s*:/g)].map(m => m[1] as string),
16
+ ),
17
+ );
18
+ // Only names in a semantic namespace (`bg-…`, `text-…`, `badge-…`) are checked, so
19
+ // unrelated utilities like `text-sm` or `border-2` never match.
20
+ const semantic = readFileSync(path.join(__dirname, 'semantic.css'), 'utf8');
21
+ const namespaces = new Set([...semantic.matchAll(/--color-([a-z]+)-/g)].map(m => m[1] as string));
22
+
23
+ const UTILITY =
24
+ /(?<![\w-])(?:bg|text|border(?:-[trblxyse])?|fill|stroke|ring(?:-offset)?|outline|divide|from|via|to|decoration|accent|caret|placeholder)-([a-z][a-z0-9-]*[a-z0-9])(?![\w-]|\$\{)/g;
25
+ const VAR = /var\(--color-([a-z0-9-]+)[,)]/g;
26
+
27
+ const unknownTokens = () =>
28
+ files(src, /\.(tsx?|css|mdx)$/).flatMap(file => {
29
+ const rel = path.relative(src, file);
30
+ return readFileSync(file, 'utf8')
31
+ .split('\n')
32
+ .flatMap((line, i) =>
33
+ /^\s*(\/\/|\*)/.test(line)
34
+ ? []
35
+ : [...line.matchAll(UTILITY), ...line.matchAll(VAR)]
36
+ .map(m => m[1] as string)
37
+ // A one-segment name (`text-badge`) is a plain string value, not a token
38
+ .filter(
39
+ name =>
40
+ name.includes('-') &&
41
+ namespaces.has(name.split('-')[0] as string) &&
42
+ !tokens.has(name),
43
+ )
44
+ .map(name => `${rel}:${i + 1} ${name}`),
45
+ );
46
+ });
47
+
48
+ describe('theme tokens', () => {
49
+ it('every semantic color utility and var() resolves to a defined --color-* token', () => {
50
+ expect(unknownTokens()).toEqual([]);
51
+ });
52
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wallarm-org/design-system",
3
- "version": "4.10.0-rc-feat-parser.1",
3
+ "version": "4.10.1",
4
4
  "description": "Core design system library with React components and Storybook documentation",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -101,7 +101,6 @@
101
101
  "code-connect:publish": "node --env-file-if-exists=../../.env.local node_modules/@figma/code-connect/bin/figma connect publish --exit-on-unreadable-files"
102
102
  },
103
103
  "devDependencies": {
104
- "@axe-core/playwright": "4.14.0",
105
104
  "@babel/core": "7.29.7",
106
105
  "@babel/preset-typescript": "7.29.7",
107
106
  "@figma/code-connect": "2.0.2",
@@ -131,10 +130,8 @@
131
130
  "@wallarm-org/publish-scripts": "workspace:*",
132
131
  "@wallarm-org/rsbuild-config": "workspace:*",
133
132
  "@wallarm-org/rstest-config": "workspace:*",
134
- "@wallarm-org/rules-lib": "workspace:*",
135
133
  "@wallarm-org/tailwind-config": "workspace:*",
136
134
  "@wallarm-org/typescript-config": "workspace:*",
137
- "axe-playwright": "2.2.2",
138
135
  "babel-plugin-react-compiler": "1.0.0",
139
136
  "glob": "13.0.6",
140
137
  "jsdom": "catalog:",
@@ -1,14 +0,0 @@
1
- import type { FC } from 'react';
2
- export interface KeyboardShortcutsDialogProps {
3
- /** Whether dialog is open */
4
- open: boolean;
5
- /** Called when dialog should close */
6
- onOpenChange: (open: boolean) => void;
7
- }
8
- /**
9
- * KeyboardShortcutsDialog Component
10
- *
11
- * Modal showing all available keyboard shortcuts.
12
- * Triggered by pressing '?' key.
13
- */
14
- export declare const KeyboardShortcutsDialog: FC<KeyboardShortcutsDialogProps>;
@@ -1,209 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { c } from "react/compiler-runtime";
3
- import { useTestId } from "../../../utils/testId.js";
4
- import { Dialog, DialogBody, DialogClose, DialogContent, DialogHeader, DialogPositioner, DialogTitle } from "../../Dialog/index.js";
5
- import { Kbd } from "../../Kbd/index.js";
6
- import { Text } from "../../Text/index.js";
7
- const SHORTCUTS = [
8
- {
9
- title: "Navigation",
10
- shortcuts: [
11
- {
12
- keys: [
13
- "↑",
14
- "↓"
15
- ],
16
- description: "Navigate menu items (focus stays in input)"
17
- },
18
- {
19
- keys: [
20
- "Tab"
21
- ],
22
- description: "Move to Next button (closes menu)"
23
- },
24
- {
25
- keys: [
26
- "↵"
27
- ],
28
- description: "Select highlighted item"
29
- },
30
- {
31
- keys: [
32
- "Esc"
33
- ],
34
- description: "Close menu (press again to blur input)"
35
- }
36
- ]
37
- },
38
- {
39
- title: "Selection",
40
- shortcuts: [
41
- {
42
- keys: [
43
- "1",
44
- "2",
45
- "…"
46
- ],
47
- description: 'Choose item by number (type 1-2 digits, e.g. "12" for option 12)'
48
- },
49
- {
50
- keys: [
51
- "Space"
52
- ],
53
- description: "Toggle checkbox (multi-select step only)"
54
- },
55
- {
56
- keys: [
57
- "↵"
58
- ],
59
- description: "Apply selected items (multi-select)"
60
- },
61
- {
62
- keys: [
63
- "Ctrl",
64
- "↵"
65
- ],
66
- description: "Jump to condition step"
67
- }
68
- ]
69
- },
70
- {
71
- title: "Editing",
72
- shortcuts: [
73
- {
74
- keys: [
75
- "Backspace"
76
- ],
77
- description: "Remove last step (when input empty)"
78
- },
79
- {
80
- keys: [
81
- "⌥C"
82
- ],
83
- description: "Toggle ignore case (name/value input)"
84
- }
85
- ]
86
- },
87
- {
88
- title: "Advanced",
89
- shortcuts: [
90
- {
91
- keys: [
92
- "?"
93
- ],
94
- description: "Show this keyboard shortcuts dialog"
95
- },
96
- {
97
- keys: [
98
- "Esc"
99
- ],
100
- description: "Close dialog"
101
- }
102
- ]
103
- }
104
- ];
105
- const KeyboardShortcutsDialog = (t0)=>{
106
- const $ = c(8);
107
- const { open, onOpenChange } = t0;
108
- const testId = useTestId("keyboard-shortcuts");
109
- let t1;
110
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
111
- t1 = /*#__PURE__*/ jsxs(DialogHeader, {
112
- children: [
113
- /*#__PURE__*/ jsx(DialogTitle, {
114
- children: "Keyboard Shortcuts"
115
- }),
116
- /*#__PURE__*/ jsx(DialogClose, {})
117
- ]
118
- });
119
- $[0] = t1;
120
- } else t1 = $[0];
121
- let t2;
122
- if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
123
- t2 = /*#__PURE__*/ jsx(DialogBody, {
124
- children: /*#__PURE__*/ jsx("div", {
125
- className: "flex flex-col gap-24",
126
- children: SHORTCUTS.map(_temp2)
127
- })
128
- });
129
- $[1] = t2;
130
- } else t2 = $[1];
131
- let t3;
132
- if ($[2] !== testId) {
133
- t3 = /*#__PURE__*/ jsx(DialogPositioner, {
134
- children: /*#__PURE__*/ jsxs(DialogContent, {
135
- "data-slot": "keyboard-shortcuts-dialog",
136
- "data-testid": testId,
137
- children: [
138
- t1,
139
- t2
140
- ]
141
- })
142
- });
143
- $[2] = testId;
144
- $[3] = t3;
145
- } else t3 = $[3];
146
- let t4;
147
- if ($[4] !== onOpenChange || $[5] !== open || $[6] !== t3) {
148
- t4 = /*#__PURE__*/ jsx(Dialog, {
149
- open: open,
150
- onOpenChange: onOpenChange,
151
- children: t3
152
- });
153
- $[4] = onOpenChange;
154
- $[5] = open;
155
- $[6] = t3;
156
- $[7] = t4;
157
- } else t4 = $[7];
158
- return t4;
159
- };
160
- KeyboardShortcutsDialog.displayName = "KeyboardShortcutsDialog";
161
- function _temp(shortcut) {
162
- return /*#__PURE__*/ jsxs("div", {
163
- className: "flex items-center justify-between gap-16",
164
- children: [
165
- /*#__PURE__*/ jsx("div", {
166
- className: "flex-1",
167
- children: /*#__PURE__*/ jsx(Text, {
168
- size: "sm",
169
- children: shortcut.description
170
- })
171
- }),
172
- /*#__PURE__*/ jsx("div", {
173
- className: "flex items-center gap-4",
174
- children: shortcut.keys.map((key, j)=>/*#__PURE__*/ jsxs("span", {
175
- className: "contents",
176
- children: [
177
- /*#__PURE__*/ jsx(Kbd, {
178
- size: "small",
179
- children: key
180
- }),
181
- j < shortcut.keys.length - 1 && /*#__PURE__*/ jsx(Text, {
182
- size: "xs",
183
- color: "secondary",
184
- children: "+"
185
- })
186
- ]
187
- }, `${shortcut.description}-${key}`))
188
- })
189
- ]
190
- }, shortcut.description);
191
- }
192
- function _temp2(section) {
193
- return /*#__PURE__*/ jsxs("div", {
194
- className: "flex flex-col gap-12",
195
- children: [
196
- /*#__PURE__*/ jsx(Text, {
197
- size: "sm",
198
- weight: "bold",
199
- color: "secondary",
200
- children: section.title
201
- }),
202
- /*#__PURE__*/ jsx("div", {
203
- className: "flex flex-col gap-8",
204
- children: section.shortcuts.map(_temp)
205
- })
206
- ]
207
- }, section.title);
208
- }
209
- export { KeyboardShortcutsDialog };
@@ -1,15 +0,0 @@
1
- import { type FC, type RefObject } from 'react';
2
- import { type ConditionType } from '@wallarm-org/rules-lib/ui';
3
- import type { PointSelectorModel } from './usePointSelector.js';
4
- interface Props {
5
- model: PointSelectorModel;
6
- conditionInputRef: RefObject<HTMLInputElement | null>;
7
- valueInputRef: RefObject<HTMLInputElement | null>;
8
- conditionChipRef: RefObject<HTMLButtonElement | null>;
9
- condition: ConditionType | null;
10
- value: string;
11
- ignoreCase: boolean;
12
- }
13
- /** Step 2: a numbered list of conditions, then the value. */
14
- export declare const MatchStep: FC<Props>;
15
- export {};
@@ -1,186 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useEffect, useId, useRef, useState } from "react";
3
- import { conditionLabel } from "@wallarm-org/rules-lib/ui";
4
- import { useTestId } from "../../../utils/testId.js";
5
- import { Button } from "../../Button/index.js";
6
- import { Checkbox, CheckboxIndicator, CheckboxLabel } from "../../Checkbox/index.js";
7
- import { Input } from "../../Input/index.js";
8
- import { Loader } from "../../Loader/index.js";
9
- import { Text } from "../../Text/index.js";
10
- import { StepMenu } from "./StepMenu.js";
11
- const MatchStep = ({ model, conditionInputRef, valueInputRef, conditionChipRef, condition, value, ignoreCase })=>{
12
- const testId = useTestId('match');
13
- const anchorRef = useRef(null);
14
- const menuId = useId();
15
- const { ui, actions, keys } = model;
16
- const choosing = 'condition' === ui.stage;
17
- const safeActions = {
18
- closeConditionList: actions?.closeConditionList ?? (()=>{}),
19
- setConditionQuery: actions?.setConditionQuery ?? (()=>{}),
20
- highlightCondition: actions?.highlightCondition ?? (()=>{}),
21
- chooseCondition: actions?.chooseCondition ?? (()=>{}),
22
- editCondition: actions?.editCondition ?? (()=>{}),
23
- setValue: actions?.setValue ?? (()=>{}),
24
- setIgnoreCase: actions?.setIgnoreCase ?? (()=>{})
25
- };
26
- const safeKeys = {
27
- handleConditionKey: keys?.handleConditionKey ?? (()=>{}),
28
- handleValueKey: keys?.handleValueKey ?? (()=>{})
29
- };
30
- const [regexError, setRegexError] = useState(null);
31
- const [validatingRegex, setValidatingRegex] = useState(false);
32
- const validationTimeoutRef = useRef(null);
33
- useEffect(()=>{
34
- const isRegexCondition = 'regexp' === condition || 'nregexp' === condition;
35
- if (!isRegexCondition || !value) {
36
- setRegexError(null);
37
- setValidatingRegex(false);
38
- return;
39
- }
40
- if (validationTimeoutRef.current) clearTimeout(validationTimeoutRef.current);
41
- setValidatingRegex(true);
42
- validationTimeoutRef.current = setTimeout(()=>{
43
- try {
44
- new RegExp(value);
45
- setRegexError(null);
46
- } catch (error) {
47
- setRegexError(error instanceof Error ? error.message : 'Invalid regex pattern');
48
- } finally{
49
- setValidatingRegex(false);
50
- }
51
- }, 300);
52
- return ()=>{
53
- if (validationTimeoutRef.current) clearTimeout(validationTimeoutRef.current);
54
- };
55
- }, [
56
- condition,
57
- value
58
- ]);
59
- const handleListClose = ()=>requestAnimationFrame(()=>{
60
- if (conditionInputRef.current !== document.activeElement) safeActions.closeConditionList();
61
- });
62
- return /*#__PURE__*/ jsxs("div", {
63
- "data-slot": "match-step",
64
- "data-testid": testId,
65
- className: "flex flex-col gap-8",
66
- children: [
67
- /*#__PURE__*/ jsxs(Text, {
68
- size: "sm",
69
- weight: "medium",
70
- children: [
71
- "2. ",
72
- model.conditionTitle
73
- ]
74
- }),
75
- choosing ? /*#__PURE__*/ jsxs("div", {
76
- ref: anchorRef,
77
- className: "w-[460px] max-w-full",
78
- children: [
79
- /*#__PURE__*/ jsx(Input, {
80
- ref: conditionInputRef,
81
- role: "combobox",
82
- "aria-haspopup": "menu",
83
- "aria-controls": menuId,
84
- "aria-expanded": true,
85
- "aria-label": "type to filter, or the number of a condition",
86
- placeholder: "type to filter, or a number",
87
- value: ui.conditionQuery,
88
- spellCheck: false,
89
- autoComplete: "off",
90
- onChange: (e)=>safeActions.setConditionQuery(e.target.value),
91
- onKeyDown: safeKeys.handleConditionKey
92
- }),
93
- /*#__PURE__*/ jsx(StepMenu, {
94
- open: true,
95
- contentId: menuId,
96
- anchorRef: anchorRef,
97
- focusRef: conditionInputRef,
98
- title: "Choose a condition",
99
- rows: model.conditionRows,
100
- highlightedId: model.conditionHighlightedId ?? null,
101
- footer: "list",
102
- escLabel: "to go back",
103
- onHighlight: safeActions.highlightCondition,
104
- onChoose: safeActions.chooseCondition,
105
- onClose: handleListClose
106
- })
107
- ]
108
- }) : /*#__PURE__*/ jsxs("div", {
109
- className: "flex flex-col gap-6",
110
- children: [
111
- /*#__PURE__*/ jsxs("div", {
112
- className: "flex items-center gap-8",
113
- children: [
114
- /*#__PURE__*/ jsx(Button, {
115
- ref: conditionChipRef,
116
- variant: "outline",
117
- color: "neutral",
118
- size: "large",
119
- onClick: safeActions.editCondition,
120
- children: condition ? `${conditionLabel(condition)} ✎` : 'Choose a condition'
121
- }),
122
- model.conditionTakesValue && /*#__PURE__*/ jsxs("div", {
123
- className: "relative flex-1",
124
- children: [
125
- /*#__PURE__*/ jsx(Input, {
126
- ref: valueInputRef,
127
- "aria-label": "value",
128
- className: "font-mono",
129
- placeholder: "the value; * stands for any text",
130
- value: value,
131
- spellCheck: false,
132
- autoComplete: "off",
133
- onChange: (e)=>safeActions.setValue(e.target.value),
134
- onKeyDown: safeKeys.handleValueKey,
135
- error: null !== regexError,
136
- "aria-describedby": regexError ? `${testId}--regex-error` : void 0
137
- }),
138
- validatingRegex && /*#__PURE__*/ jsx("div", {
139
- className: "absolute right-12 top-1/2 -translate-y-1/2",
140
- children: /*#__PURE__*/ jsx(Loader, {
141
- size: "sm",
142
- background: false,
143
- "data-testid": `${testId}--regex-loading`
144
- })
145
- })
146
- ]
147
- })
148
- ]
149
- }),
150
- regexError && /*#__PURE__*/ jsxs(Text, {
151
- id: `${testId}--regex-error`,
152
- size: "xs",
153
- color: "danger",
154
- "data-testid": `${testId}--regex-error`,
155
- children: [
156
- "Regex compilation error: ",
157
- regexError
158
- ]
159
- }),
160
- model.conditionTakesValue && /*#__PURE__*/ jsxs("div", {
161
- className: "flex items-center justify-between gap-12",
162
- children: [
163
- /*#__PURE__*/ jsx(Text, {
164
- size: "xs",
165
- color: "secondary",
166
- children: model.readAs
167
- }),
168
- /*#__PURE__*/ jsxs(Checkbox, {
169
- checked: ignoreCase,
170
- onCheckedChange: (d)=>safeActions.setIgnoreCase(true === d.checked),
171
- children: [
172
- /*#__PURE__*/ jsx(CheckboxIndicator, {}),
173
- /*#__PURE__*/ jsx(CheckboxLabel, {
174
- children: "Ignore letter case (⌥C)"
175
- })
176
- ]
177
- })
178
- ]
179
- })
180
- ]
181
- })
182
- ]
183
- });
184
- };
185
- MatchStep.displayName = 'MatchStep';
186
- export { MatchStep };
@@ -1,16 +0,0 @@
1
- import type { FC, HTMLAttributes, Ref } from 'react';
2
- export interface MenuFooterHintsProps extends HTMLAttributes<HTMLDivElement> {
3
- /** Ref forwarding to root element */
4
- ref?: Ref<HTMLDivElement>;
5
- /** Variant determines which shortcuts to show */
6
- variant: 'list' | 'pick' | 'name';
7
- /** Label for Escape key */
8
- escLabel?: string;
9
- }
10
- /**
11
- * MenuFooterHints Component
12
- *
13
- * Keyboard hints in the menu footer, matching FilterInput style.
14
- * Based on rules-frontend MenuFooterHints pattern.
15
- */
16
- export declare const MenuFooterHints: FC<MenuFooterHintsProps>;