-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathPowerSearch.doc.mjs
More file actions
366 lines (361 loc) · 14.5 KB
/
Copy pathPowerSearch.doc.mjs
File metadata and controls
366 lines (361 loc) · 14.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
// Copyright (c) Meta Platforms, Inc. and affiliates.
/** @type {import('@astryxdesign/cli/authoring').ComponentDoc} */
export const docs = {
name: 'PowerSearch',
displayName: 'Power Search',
category: 'Data Input',
keywords: ["powersearch","search","searchbar","filter","filterbar","faceted","querybuilder","structured","omnibar"],
props: [
{
name: 'config',
type: 'PowerSearchConfig',
description:
'Configuration defining available fields, operators, and their value types.',
required: true,
},
{
name: 'filters',
type: 'ReadonlyArray<PowerSearchFilter>',
description: 'Currently active filters.',
required: true,
},
{
name: 'onChange',
type: "(filters: ReadonlyArray<PowerSearchFilter>, changeType: 'add' | 'edit' | 'remove', index: number) => void",
description:
"Called when filters change. changeType is 'add', 'edit', or 'remove'. index is the affected filter's position.",
required: true,
},
{
name: 'label',
type: 'string',
description: 'Accessible label for the search input.',
default: "'Search'",
},
{
name: 'isLabelHidden',
type: 'boolean',
description: 'Visually hides the label while keeping it accessible.',
default: 'true',
},
{
name: 'placeholder',
type: 'string',
description:
'Placeholder text shown when no filters are selected.',
default: "'Search...'",
},
{
name: 'hasAutoFocus',
type: 'boolean',
description: 'Auto-focus the input on mount.',
default: 'false',
},
{
name: 'hasClear',
type: 'boolean',
description: 'Show a clear-all button for removing all filters.',
default: 'true',
},
{
name: 'isReadOnly',
type: 'boolean',
description: 'Prevent adding, editing, or removing filters.',
default: 'false',
},
{
name: 'isDisabled',
type: 'boolean',
description: 'Disables the entire component.',
default: 'false',
},
{
name: 'disabledMessage',
type: 'string',
description:
'Explains why the search is disabled. With isDisabled, shows a tooltip on hover/keyboard focus and keeps the input focusable via aria-disabled (input stays blocked). Use this instead of wrapping a disabled PowerSearch in Tooltip. Disabled controls swallow the hover events an external Tooltip needs.',
},
{
name: 'status',
type: "{type: 'warning' | 'error' | 'success', message?: string}",
description:
'Validation status object with type and optional message.',
},
{
name: 'startIcon',
type: 'ReactNode | IconType',
description:
'Icon to display at the start of the input, before any filter tokens. Forwarded to the internal Tokenizer. Accepts a semantic icon name, an SVG icon component, or a ReactNode directly.',
slotElements: [{__element: 'Icon', props: {icon: 'search', size: 'sm'}}],
},
{
name: 'statusVariant',
type: "'attached' | 'detached'",
description:
'How the status message is placed relative to the input. attached overlaps directly below the input (bordered treatment); detached floats below as a separate element with spacing.',
default: "'attached'",
},
{
name: 'maxTokenLength',
type: 'number',
description: 'Max character length for filter value display in tokens.',
default: '40',
},
{
name: 'popoverSaveButtonLabel',
type: 'string',
description: 'Label for the save button in the edit popover.',
default: "'Apply'",
},
{
name: 'timezoneID',
type: 'string',
description: 'Timezone ID for date formatting (e.g. "America/New_York").',
},
{
name: 'handleRef',
type: 'Ref<PowerSearchHandle>',
description:
'Imperative handle with focusTypeahead() and blurTypeahead() methods.',
},
{
name: 'endContent',
type: 'ReactNode',
description:
'Content to display at the end of the input row. Useful for action buttons or other controls.',
slotElements: [
{__element: 'Icon', props: {icon: 'chevronDown', size: 'sm'}},
{__element: 'Badge', props: {label: '3'}},
],
},
{
name: 'resultCount',
type: 'number | string',
description:
'Number of results matching the current filters. When a number, formatted as "N results". When a string, displayed as-is. Changes are announced to screen readers via a polite live region.',
},
{
name: 'size',
type: "'sm' | 'md' | 'lg'",
description: 'Size of the search input and tokens.',
default: "'md'",
},
{
name: 'xstyle',
type: 'StyleXStyles',
description:
'StyleX styles for layout customization. Must be a stylex.create() value.',
},
],
usage: {
description:
'PowerSearch is a structured filter bar where each token represents a field, operator, and value. Use it for complex multi-dimensional filtering when users need to combine multiple search criteria. For simple single-field search, use a text input instead.',
bestPractices: [
{ guidance: true, description: 'Define clear, descriptive field names and aliases so users can quickly find the filter they need.' },
{ guidance: true, description: 'Provide a result count to give users feedback on how their filters affect the data set.' },
{ guidance: false, description: 'Use PowerSearch for simple keyword searches; a standard text input is more appropriate for single-field lookups.' },
{ guidance: false, description: 'Wrap a disabled PowerSearch in Tooltip to explain why it is disabled; disabled controls swallow the hover events the wrapper needs. Use the disabledMessage prop instead.' },
],
},
theming: {
targets: [
{className: 'astryx-power-search'},
// Same directory, same documented CSS surface: the touch variant's tap
// target is the class a theme reaches for on phone layouts.
{
className: 'astryx-power-search-mobile',
visualProps: ['size', 'status'],
states: ['disabled'],
},
],
},
};
// -------------------------------------------------------
// Auto-generated translations below. Do not edit manually.
// Regenerate with the dense compression protocol.
// See .context/decisions/dense-compression-protocol.md
// -------------------------------------------------------
/** @type {import('@astryxdesign/cli/authoring').ComponentDoc} */
export const docsZh = {
name: 'PowerSearch',
displayName: 'Power Search',
props: [
{
name: 'config',
type: 'PowerSearchConfig',
description: '定义可用字段、运算符及其值类型的配置。',
required: true,
},
{
name: 'filters',
type: 'ReadonlyArray<PowerSearchFilter>',
description: '当前活跃的过滤器。',
required: true,
},
{
name: 'onChange',
type: "(filters: ReadonlyArray<PowerSearchFilter>, changeType: 'add' | 'edit' | 'remove', index: number) => void",
description:
"当过滤器变更时调用。changeType 为 'add'、'edit' 或 'remove'。index 为受影响的过滤器位置。",
required: true,
},
{
name: 'label',
type: 'string',
description: '搜索输入框的无障碍标签。',
default: "'Search'",
},
{
name: 'isLabelHidden',
type: 'boolean',
description: '视觉上隐藏标签,同时保持无障碍性。',
default: 'true',
},
{
name: 'placeholder',
type: 'string',
description: '未选择过滤器时显示的占位文本。',
default: "'Search...'",
},
{
name: 'hasAutoFocus',
type: 'boolean',
description: '挂载时自动聚焦输入框。',
default: 'false',
},
{
name: 'hasClear',
type: 'boolean',
description: '显示清除全部按钮以移除所有过滤器。',
default: 'true',
},
{
name: 'isReadOnly',
type: 'boolean',
description: '阻止添加、编辑或移除过滤器。',
default: 'false',
},
{
name: 'isDisabled',
type: 'boolean',
description: '禁用整个组件。',
default: 'false',
},
{
name: 'disabledMessage',
type: 'string',
description:
'Explains why the search is disabled. With isDisabled, shows a tooltip on hover/keyboard focus and keeps the input focusable via aria-disabled (input stays blocked). Use this instead of wrapping a disabled PowerSearch in Tooltip. Disabled controls swallow the hover events an external Tooltip needs.',
},
{
name: 'status',
type: "{type: 'warning' | 'error' | 'success', message?: string}",
description: '带有类型和可选消息的验证状态对象。',
},
{
name: 'startIcon',
type: 'ReactNode | IconType',
description:
'在输入框开头(筛选 token 之前)显示的图标,转发给内部的 Tokenizer。接受语义图标名称、SVG 图标组件或直接传入 ReactNode。',
},
{
name: 'statusVariant',
type: "'attached' | 'detached'",
description:
'状态消息相对于输入框的放置方式。attached 直接叠加在输入框下方(带边框处理);detached 作为独立元素浮于下方并留有间距。',
default: "'attached'",
},
{
name: 'maxTokenLength',
type: 'number',
description: '令牌中过滤器值显示的最大字符长度。',
default: '40',
},
{
name: 'popoverSaveButtonLabel',
type: 'string',
description: '编辑弹出窗口中保存按钮的标签。',
default: "'Apply'",
},
{
name: 'timezoneID',
type: 'string',
description: '用于日期格式化的时区 ID(例如 "America/New_York")。',
},
{
name: 'handleRef',
type: 'Ref<PowerSearchHandle>',
description: '提供 focusTypeahead() 和 blurTypeahead() 方法的命令式句柄。',
},
{
name: 'endContent',
type: 'ReactNode',
description: '显示在输入行末尾的内容。适用于操作按钮或其他控件。',
},
{
name: 'resultCount',
type: 'number | string',
description:
'匹配当前过滤器的结果数量。数字类型时格式化为"N results"。字符串类型时按原样显示。数量变化会通过 polite 实时区域向屏幕阅读器播报。',
},
{
name: 'size',
type: "'sm' | 'md' | 'lg'",
description: '搜索输入框和标记的尺寸。',
default: "'md'",
},
{
name: 'xstyle',
type: 'StyleXStyles',
description: '用于布局自定义的 StyleX 样式。必须是 stylex.create() 值。',
},
],
usage: {
description:
'PowerSearch is a structured filter bar where each token represents a field, operator, and value. Use it for complex multi-dimensional filtering when users need to combine multiple search criteria. For simple single-field search, use a text input instead.',
bestPractices: [
{ guidance: true, description: 'Define clear, descriptive field names and aliases so users can quickly find the filter they need.' },
{ guidance: true, description: 'Provide a result count to give users feedback on how their filters affect the data set.' },
{ guidance: false, description: 'Use PowerSearch for simple keyword searches; a standard text input is more appropriate for single-field lookups.' },
{ guidance: false, description: 'Wrap a disabled PowerSearch in Tooltip to explain why it is disabled; disabled controls swallow the hover events the wrapper needs. Use the disabledMessage prop instead.' },
],
},
};
/** @type {import('@astryxdesign/cli/authoring').ComponentTranslationDoc} */
export const docsDense = {
description:
'Structured filter bar where each token represents filter (field+operator+value). Users select fields from typeahead dropdown, configure operators+values in edit popover, manage filters as removable tokens.',
usage: {
description:
'PowerSearch is a structured filter bar where each token represents a field, operator, and value. Use it for complex multi-dimensional filtering when users need to combine multiple search criteria. For simple single-field search, use a text input instead.',
bestPractices: [
{ guidance: true, description: 'Define clear, descriptive field names and aliases so users can quickly find the filter they need.' },
{ guidance: true, description: 'Provide a result count to give users feedback on how their filters affect the data set.' },
{ guidance: false, description: 'Use PowerSearch for simple keyword searches; a standard text input is more appropriate for single-field lookups.' },
{ guidance: false, description: 'Wrap a disabled PowerSearch in Tooltip to explain why it is disabled; disabled controls swallow the hover events the wrapper needs. Use the disabledMessage prop instead.' },
],
},
propDescriptions: {
config: 'Configuration defining available fields, operators, value types.',
filters: 'Currently active filters.',
onChange: "Called on filter change. changeType is 'add', 'edit', or 'remove'. index is affected filter position.",
label: 'Accessible label for search input.',
isLabelHidden: 'Visually hides label while keeping accessible.',
placeholder: 'Text shown when no filters selected.',
hasAutoFocus: 'Auto-focus input on mount.',
hasClear: 'Show clear-all button for removing all filters.',
isReadOnly: 'Prevent adding, editing, or removing filters.',
isDisabled: 'Disables entire component.',
status: 'Validation status object w/ type + optional message.',
startIcon: 'Icon at input start, before filter tokens. Forwarded to internal Tokenizer.',
statusVariant: 'How status message is placed: attached overlaps below input; detached floats below w/ spacing.',
maxTokenLength: 'Max char length for filter value display in tokens.',
popoverSaveButtonLabel: 'Label for save button in edit popover.',
timezoneID: 'Timezone ID for date formatting (e.g. "America/New_York").',
handleRef: 'Imperative handle w/ focusTypeahead() + blurTypeahead() methods.',
endContent: 'Content at end of input row. Useful for action buttons or controls.',
resultCount: 'Result count matching current filters. Number formatted as "N results"; string displayed as-is.',
size: 'Search input+token size.',
xstyle: 'StyleX styles for layout customization. Must be stylex.create() value.',
},
};