@ni/ok-components 1.12.4 → 1.13.0

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.
@@ -1518,6 +1518,222 @@
1518
1518
  "declarations": [],
1519
1519
  "exports": []
1520
1520
  },
1521
+ {
1522
+ "kind": "javascript-module",
1523
+ "path": "src/fv/filter-bar/index.ts",
1524
+ "declarations": [
1525
+ {
1526
+ "kind": "class",
1527
+ "description": "Displays an active query and dispatches edit and clear actions.",
1528
+ "name": "FvFilterBar",
1529
+ "members": [
1530
+ {
1531
+ "kind": "field",
1532
+ "name": "label",
1533
+ "type": {
1534
+ "text": "string"
1535
+ },
1536
+ "privacy": "public",
1537
+ "default": "'Filters'",
1538
+ "description": "Text shown before the active query expression."
1539
+ },
1540
+ {
1541
+ "kind": "field",
1542
+ "name": "disabled",
1543
+ "type": {
1544
+ "text": "boolean"
1545
+ },
1546
+ "privacy": "public",
1547
+ "default": "false",
1548
+ "description": "Prevents editing and clearing the displayed query."
1549
+ },
1550
+ {
1551
+ "kind": "field",
1552
+ "name": "showClearButton",
1553
+ "type": {
1554
+ "text": "boolean"
1555
+ },
1556
+ "privacy": "public",
1557
+ "default": "true",
1558
+ "description": "Controls visibility of the clear button when a query is active."
1559
+ },
1560
+ {
1561
+ "kind": "field",
1562
+ "name": "query",
1563
+ "type": {
1564
+ "text": "FvFilterBarQueryDocument"
1565
+ },
1566
+ "privacy": "public",
1567
+ "default": "{ version: 1, root: null }",
1568
+ "description": "Query document shared with FvQueryBuilder."
1569
+ },
1570
+ {
1571
+ "kind": "field",
1572
+ "name": "definition",
1573
+ "type": {
1574
+ "text": "FvFilterBarDefinition | undefined"
1575
+ },
1576
+ "privacy": "public",
1577
+ "description": "Field and operator labels used to display the query."
1578
+ },
1579
+ {
1580
+ "kind": "field",
1581
+ "name": "expression",
1582
+ "type": {
1583
+ "text": "string"
1584
+ },
1585
+ "privacy": "public",
1586
+ "readonly": true
1587
+ },
1588
+ {
1589
+ "kind": "method",
1590
+ "name": "handleEditClick",
1591
+ "privacy": "public",
1592
+ "return": {
1593
+ "type": {
1594
+ "text": "void"
1595
+ }
1596
+ }
1597
+ },
1598
+ {
1599
+ "kind": "method",
1600
+ "name": "handleClearClick",
1601
+ "privacy": "public",
1602
+ "return": {
1603
+ "type": {
1604
+ "text": "void"
1605
+ }
1606
+ }
1607
+ },
1608
+ {
1609
+ "kind": "method",
1610
+ "name": "formatNode",
1611
+ "privacy": "private",
1612
+ "return": {
1613
+ "type": {
1614
+ "text": "FvFilterBarToken[]"
1615
+ }
1616
+ },
1617
+ "parameters": [
1618
+ {
1619
+ "name": "node",
1620
+ "type": {
1621
+ "text": "FvFilterBarQueryNode"
1622
+ }
1623
+ },
1624
+ {
1625
+ "name": "isRoot",
1626
+ "default": "false"
1627
+ }
1628
+ ]
1629
+ },
1630
+ {
1631
+ "kind": "method",
1632
+ "name": "formatValue",
1633
+ "privacy": "private",
1634
+ "return": {
1635
+ "type": {
1636
+ "text": "string"
1637
+ }
1638
+ },
1639
+ "parameters": [
1640
+ {
1641
+ "name": "value",
1642
+ "type": {
1643
+ "text": "unknown"
1644
+ }
1645
+ },
1646
+ {
1647
+ "name": "schema",
1648
+ "type": {
1649
+ "text": "unknown"
1650
+ }
1651
+ }
1652
+ ]
1653
+ }
1654
+ ],
1655
+ "events": [
1656
+ {
1657
+ "name": "edit-filter",
1658
+ "type": {
1659
+ "text": "CustomEvent"
1660
+ }
1661
+ },
1662
+ {
1663
+ "name": "clear-filter",
1664
+ "type": {
1665
+ "text": "CustomEvent"
1666
+ }
1667
+ }
1668
+ ],
1669
+ "attributes": [
1670
+ {
1671
+ "name": "label",
1672
+ "type": {
1673
+ "text": "string"
1674
+ },
1675
+ "default": "'Filters'",
1676
+ "description": "Text shown before the active query expression.",
1677
+ "fieldName": "label"
1678
+ },
1679
+ {
1680
+ "name": "disabled",
1681
+ "type": {
1682
+ "text": "boolean"
1683
+ },
1684
+ "default": "false",
1685
+ "description": "Prevents editing and clearing the displayed query.",
1686
+ "fieldName": "disabled"
1687
+ },
1688
+ {
1689
+ "name": "show-clear-button",
1690
+ "type": {
1691
+ "text": "boolean"
1692
+ },
1693
+ "default": "true",
1694
+ "description": "Controls visibility of the clear button when a query is active.",
1695
+ "fieldName": "showClearButton"
1696
+ }
1697
+ ],
1698
+ "superclass": {
1699
+ "name": "FoundationElement",
1700
+ "package": "@ni/fast-foundation"
1701
+ }
1702
+ },
1703
+ {
1704
+ "kind": "variable",
1705
+ "name": "fvFilterBarTag",
1706
+ "type": {
1707
+ "text": "string"
1708
+ },
1709
+ "default": "'ok-fv-filter-bar'"
1710
+ }
1711
+ ],
1712
+ "exports": [
1713
+ {
1714
+ "kind": "js",
1715
+ "name": "FvFilterBar",
1716
+ "declaration": {
1717
+ "name": "FvFilterBar",
1718
+ "module": "src/fv/filter-bar/index.ts"
1719
+ }
1720
+ },
1721
+ {
1722
+ "kind": "js",
1723
+ "name": "fvFilterBarTag",
1724
+ "declaration": {
1725
+ "name": "fvFilterBarTag",
1726
+ "module": "src/fv/filter-bar/index.ts"
1727
+ }
1728
+ }
1729
+ ]
1730
+ },
1731
+ {
1732
+ "kind": "javascript-module",
1733
+ "path": "src/fv/filter-bar/types.ts",
1734
+ "declarations": [],
1735
+ "exports": []
1736
+ },
1521
1737
  {
1522
1738
  "kind": "javascript-module",
1523
1739
  "path": "src/fv/master-detail-list/index.ts",
@@ -230,6 +230,49 @@
230
230
 
231
231
  <hr/>
232
232
 
233
+ ## class: `FvFilterBar`
234
+
235
+ ### Superclass
236
+
237
+ | Name | Module | Package |
238
+ | ------------------- | ------ | ------------------- |
239
+ | `FoundationElement` | | @ni/fast-foundation |
240
+
241
+ ### Fields
242
+
243
+ | Name | Privacy | Type | Default | Description | Inherited From |
244
+ | ----------------- | ------- | ------------------------------------ | ---------------------------- | --------------------------------------------------------------- | -------------- |
245
+ | `label` | public | `string` | `'Filters'` | Text shown before the active query expression. | |
246
+ | `disabled` | public | `boolean` | `false` | Prevents editing and clearing the displayed query. | |
247
+ | `showClearButton` | public | `boolean` | `true` | Controls visibility of the clear button when a query is active. | |
248
+ | `query` | public | `FvFilterBarQueryDocument` | `{ version: 1, root: null }` | Query document shared with FvQueryBuilder. | |
249
+ | `definition` | public | `FvFilterBarDefinition \| undefined` | | Field and operator labels used to display the query. | |
250
+ | `expression` | public | `string` | | | |
251
+
252
+ ### Methods
253
+
254
+ | Name | Privacy | Description | Parameters | Return | Inherited From |
255
+ | ------------------ | ------- | ----------- | ---------- | ------ | -------------- |
256
+ | `handleEditClick` | public | | | `void` | |
257
+ | `handleClearClick` | public | | | `void` | |
258
+
259
+ ### Events
260
+
261
+ | Name | Type | Description | Inherited From |
262
+ | -------------- | ------------- | ----------- | -------------- |
263
+ | `edit-filter` | `CustomEvent` | | |
264
+ | `clear-filter` | `CustomEvent` | | |
265
+
266
+ ### Attributes
267
+
268
+ | Name | Field | Inherited From |
269
+ | ------------------- | --------------- | -------------- |
270
+ | `label` | label | |
271
+ | `disabled` | disabled | |
272
+ | `show-clear-button` | showClearButton | |
273
+
274
+ <hr/>
275
+
233
276
  ## class: `FvMasterDetailList`
234
277
 
235
278
  ### Superclass
@@ -4,6 +4,7 @@ import './bulk-edit-field';
4
4
  import './chip-selector';
5
5
  import './context-help';
6
6
  import './edit-commit-bar';
7
+ import './filter-bar';
7
8
  import './master-detail-list-item';
8
9
  import './master-detail-list';
9
10
  import './split-button';
@@ -4,6 +4,7 @@ import './bulk-edit-field';
4
4
  import './chip-selector';
5
5
  import './context-help';
6
6
  import './edit-commit-bar';
7
+ import './filter-bar';
7
8
  import './master-detail-list-item';
8
9
  import './master-detail-list';
9
10
  import './split-button';
@@ -1 +1 @@
1
- {"version":3,"file":"all-fv.js","sourceRoot":"","sources":["../../../src/fv/all-fv.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,QAAQ,CAAC;AAChB,OAAO,mBAAmB,CAAC;AAC3B,OAAO,iBAAiB,CAAC;AACzB,OAAO,gBAAgB,CAAC;AACxB,OAAO,mBAAmB,CAAC;AAC3B,OAAO,2BAA2B,CAAC;AACnC,OAAO,sBAAsB,CAAC;AAC9B,OAAO,gBAAgB,CAAC;AACxB,OAAO,uBAAuB,CAAC;AAC/B,OAAO,iBAAiB,CAAC;AACzB,OAAO,iBAAiB,CAAC;AACzB,OAAO,sBAAsB,CAAC;AAC9B,OAAO,gBAAgB,CAAC;AACxB,OAAO,YAAY,CAAC;AACpB,OAAO,gBAAgB,CAAC","sourcesContent":["import './accordion-item';\nimport './card';\nimport './bulk-edit-field';\nimport './chip-selector';\nimport './context-help';\nimport './edit-commit-bar';\nimport './master-detail-list-item';\nimport './master-detail-list';\nimport './split-button';\nimport './split-button-anchor';\nimport './sticky-header';\nimport './summary-panel';\nimport './summary-panel-tile';\nimport './search-input';\nimport './splitter';\nimport './split-layout';\n"]}
1
+ {"version":3,"file":"all-fv.js","sourceRoot":"","sources":["../../../src/fv/all-fv.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,QAAQ,CAAC;AAChB,OAAO,mBAAmB,CAAC;AAC3B,OAAO,iBAAiB,CAAC;AACzB,OAAO,gBAAgB,CAAC;AACxB,OAAO,mBAAmB,CAAC;AAC3B,OAAO,cAAc,CAAC;AACtB,OAAO,2BAA2B,CAAC;AACnC,OAAO,sBAAsB,CAAC;AAC9B,OAAO,gBAAgB,CAAC;AACxB,OAAO,uBAAuB,CAAC;AAC/B,OAAO,iBAAiB,CAAC;AACzB,OAAO,iBAAiB,CAAC;AACzB,OAAO,sBAAsB,CAAC;AAC9B,OAAO,gBAAgB,CAAC;AACxB,OAAO,YAAY,CAAC;AACpB,OAAO,gBAAgB,CAAC","sourcesContent":["import './accordion-item';\nimport './card';\nimport './bulk-edit-field';\nimport './chip-selector';\nimport './context-help';\nimport './edit-commit-bar';\nimport './filter-bar';\nimport './master-detail-list-item';\nimport './master-detail-list';\nimport './split-button';\nimport './split-button-anchor';\nimport './sticky-header';\nimport './summary-panel';\nimport './summary-panel-tile';\nimport './search-input';\nimport './splitter';\nimport './split-layout';\n"]}
@@ -0,0 +1,30 @@
1
+ import { FoundationElement } from '@ni/fast-foundation';
2
+ import type { FvFilterBarDefinition, FvFilterBarQueryDocument, FvFilterBarToken } from './types';
3
+ declare global {
4
+ interface HTMLElementTagNameMap {
5
+ 'ok-fv-filter-bar': FvFilterBar;
6
+ }
7
+ }
8
+ /** Displays an active query and dispatches edit and clear actions. */
9
+ export declare class FvFilterBar extends FoundationElement {
10
+ /** Text shown before the active query expression. */
11
+ label: string;
12
+ /** Prevents editing and clearing the displayed query. */
13
+ disabled: boolean;
14
+ /** Controls visibility of the clear button when a query is active. */
15
+ showClearButton: boolean;
16
+ /** Query document shared with FvQueryBuilder. */
17
+ query: FvFilterBarQueryDocument;
18
+ /** Field and operator labels used to display the query. */
19
+ definition?: FvFilterBarDefinition;
20
+ /** @internal */
21
+ editButton: HTMLButtonElement;
22
+ get expression(): string;
23
+ /** @internal */
24
+ get queryTokens(): readonly FvFilterBarToken[];
25
+ handleEditClick(): void;
26
+ handleClearClick(): void;
27
+ private formatNode;
28
+ private formatValue;
29
+ }
30
+ export declare const fvFilterBarTag = "ok-fv-filter-bar";
@@ -0,0 +1,120 @@
1
+ import { __decorate } from "tslib";
2
+ import { attr, observable, volatile } from '@ni/fast-element';
3
+ import { DesignSystem, FoundationElement } from '@ni/fast-foundation';
4
+ import { styles } from './styles';
5
+ import { template } from './template';
6
+ function isRecord(value) {
7
+ return typeof value === 'object' && value !== null;
8
+ }
9
+ /** Displays an active query and dispatches edit and clear actions. */
10
+ export class FvFilterBar extends FoundationElement {
11
+ constructor() {
12
+ super(...arguments);
13
+ /** Text shown before the active query expression. */
14
+ this.label = 'Filters';
15
+ /** Prevents editing and clearing the displayed query. */
16
+ this.disabled = false;
17
+ /** Controls visibility of the clear button when a query is active. */
18
+ this.showClearButton = true;
19
+ /** Query document shared with FvQueryBuilder. */
20
+ this.query = { version: 1, root: null };
21
+ }
22
+ get expression() {
23
+ return this.queryTokens.map(token => (token.kind === 'predicate'
24
+ ? `${token.field} ${token.operator}${token.value}`
25
+ : token.text)).join('');
26
+ }
27
+ /** @internal */
28
+ get queryTokens() {
29
+ return this.query.root ? this.formatNode(this.query.root, true) : [];
30
+ }
31
+ handleEditClick() {
32
+ this.dispatchEvent(new CustomEvent('edit-filter', {
33
+ bubbles: true,
34
+ composed: true,
35
+ detail: { query: this.query }
36
+ }));
37
+ }
38
+ handleClearClick() {
39
+ this.editButton.focus();
40
+ this.dispatchEvent(new CustomEvent('clear-filter', {
41
+ bubbles: true,
42
+ composed: true,
43
+ detail: { query: this.query }
44
+ }));
45
+ }
46
+ formatNode(node, isRoot = false) {
47
+ if (node.kind === 'predicate') {
48
+ const field = this.definition?.fields.find(candidate => candidate.id === node.fieldId);
49
+ const operator = this.definition?.operators.find(candidate => candidate.id === node.operatorId);
50
+ const valueSchema = operator?.operand?.kind === 'schema' ? operator.operand.schema : field?.valueSchema;
51
+ return [{
52
+ kind: 'predicate',
53
+ field: field?.label ?? node.fieldId,
54
+ operator: operator?.label ?? node.operatorId,
55
+ value: node.value === undefined ? '' : ` ${this.formatValue(node.value, valueSchema)}`
56
+ }];
57
+ }
58
+ const tokens = [];
59
+ for (const child of node.children) {
60
+ const childTokens = this.formatNode(child);
61
+ if (childTokens.length > 0) {
62
+ if (tokens.length > 0) {
63
+ tokens.push({ kind: 'logic', text: ` ${node.combinator.toUpperCase()} ` });
64
+ }
65
+ tokens.push(...childTokens);
66
+ }
67
+ }
68
+ return tokens.length > 0 && !isRoot
69
+ ? [{ kind: 'group', text: '(' }, ...tokens, { kind: 'group', text: ')' }]
70
+ : tokens;
71
+ }
72
+ formatValue(value, schema) {
73
+ if (Array.isArray(value)) {
74
+ return value.map(item => this.formatValue(item, schema)).join(', ');
75
+ }
76
+ if (isRecord(schema) && Array.isArray(schema.oneOf)) {
77
+ for (const option of schema.oneOf) {
78
+ if (isRecord(option) && option.const === value && typeof option.title === 'string') {
79
+ return option.title;
80
+ }
81
+ }
82
+ }
83
+ if (value !== null && typeof value === 'object') {
84
+ return JSON.stringify(value) ?? '';
85
+ }
86
+ if (typeof value === 'string') {
87
+ return value;
88
+ }
89
+ if (typeof value === 'number' || typeof value === 'boolean') {
90
+ return value.toString();
91
+ }
92
+ return 'null';
93
+ }
94
+ }
95
+ __decorate([
96
+ attr
97
+ ], FvFilterBar.prototype, "label", void 0);
98
+ __decorate([
99
+ attr({ mode: 'boolean' })
100
+ ], FvFilterBar.prototype, "disabled", void 0);
101
+ __decorate([
102
+ attr({ attribute: 'show-clear-button', mode: 'boolean' })
103
+ ], FvFilterBar.prototype, "showClearButton", void 0);
104
+ __decorate([
105
+ observable
106
+ ], FvFilterBar.prototype, "query", void 0);
107
+ __decorate([
108
+ observable
109
+ ], FvFilterBar.prototype, "definition", void 0);
110
+ __decorate([
111
+ volatile
112
+ ], FvFilterBar.prototype, "queryTokens", null);
113
+ const okFvFilterBar = FvFilterBar.compose({
114
+ baseName: 'fv-filter-bar',
115
+ template,
116
+ styles
117
+ });
118
+ DesignSystem.getOrCreate().withPrefix('ok').register(okFvFilterBar());
119
+ export const fvFilterBarTag = 'ok-fv-filter-bar';
120
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/fv/filter-bar/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAStC,SAAS,QAAQ,CAAC,KAAc;IAC5B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACvD,CAAC;AAQ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QAAQ,EAAE,CAAC;YAC9C,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;QACvC,CAAC;QACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC5B,OAAO,KAAK,CAAC;QACjB,CAAC;QACD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;YAC1D,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC5B,CAAC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AAtGU;IADN,IAAI;0CACoB;AAIlB;IADN,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;6CACF;AAIjB;IADN,IAAI,CAAC,EAAE,SAAS,EAAE,mBAAmB,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;oDAC5B;AAIvB;IADN,UAAU;0CACyD;AAI7D;IADN,UAAU;+CAC+B;AAa1C;IADC,QAAQ;8CAGR;AAyEL,MAAM,aAAa,GAAG,WAAW,CAAC,OAAO,CAAC;IACtC,QAAQ,EAAE,eAAe;IACzB,QAAQ;IACR,MAAM;CACT,CAAC,CAAC;AAEH,YAAY,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,aAAa,EAAE,CAAC,CAAC;AACtE,MAAM,CAAC,MAAM,cAAc,GAAG,kBAAkB,CAAC","sourcesContent":["import { attr, observable, volatile } from '@ni/fast-element';\nimport { DesignSystem, FoundationElement } from '@ni/fast-foundation';\nimport { styles } from './styles';\nimport { template } from './template';\nimport type {\n FvFilterBarDefinition,\n FvFilterBarEventDetail,\n FvFilterBarQueryDocument,\n FvFilterBarQueryNode,\n FvFilterBarToken\n} from './types';\n\nfunction isRecord(value: unknown): value is { [key: string]: unknown } {\n return typeof value === 'object' && value !== null;\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ok-fv-filter-bar': FvFilterBar;\n }\n}\n\n/** Displays an active query and dispatches edit and clear actions. */\nexport class FvFilterBar extends FoundationElement {\n /** Text shown before the active query expression. */\n @attr\n public label = 'Filters';\n\n /** Prevents editing and clearing the displayed query. */\n @attr({ mode: 'boolean' })\n public disabled = false;\n\n /** Controls visibility of the clear button when a query is active. */\n @attr({ attribute: 'show-clear-button', mode: 'boolean' })\n public showClearButton = true;\n\n /** Query document shared with FvQueryBuilder. */\n @observable\n public query: FvFilterBarQueryDocument = { version: 1, root: null };\n\n /** Field and operator labels used to display the query. */\n @observable\n public definition?: FvFilterBarDefinition;\n\n /** @internal */\n public editButton!: HTMLButtonElement;\n\n public get expression(): string {\n return this.queryTokens.map(token => (token.kind === 'predicate'\n ? `${token.field} ${token.operator}${token.value}`\n : token.text)).join('');\n }\n\n /** @internal */\n @volatile\n public get queryTokens(): readonly FvFilterBarToken[] {\n return this.query.root ? this.formatNode(this.query.root, true) : [];\n }\n\n public handleEditClick(): void {\n this.dispatchEvent(new CustomEvent<FvFilterBarEventDetail>('edit-filter', {\n bubbles: true,\n composed: true,\n detail: { query: this.query }\n }));\n }\n\n public handleClearClick(): void {\n this.editButton.focus();\n this.dispatchEvent(new CustomEvent<FvFilterBarEventDetail>('clear-filter', {\n bubbles: true,\n composed: true,\n detail: { query: this.query }\n }));\n }\n\n private formatNode(node: FvFilterBarQueryNode, isRoot = false): FvFilterBarToken[] {\n if (node.kind === 'predicate') {\n const field = this.definition?.fields.find(candidate => candidate.id === node.fieldId);\n const operator = this.definition?.operators.find(candidate => candidate.id === node.operatorId);\n const valueSchema = operator?.operand?.kind === 'schema' ? operator.operand.schema : field?.valueSchema;\n return [{\n kind: 'predicate',\n field: field?.label ?? node.fieldId,\n operator: operator?.label ?? node.operatorId,\n value: node.value === undefined ? '' : ` ${this.formatValue(node.value, valueSchema)}`\n }];\n }\n\n const tokens: FvFilterBarToken[] = [];\n for (const child of node.children) {\n const childTokens = this.formatNode(child);\n if (childTokens.length > 0) {\n if (tokens.length > 0) {\n tokens.push({ kind: 'logic', text: ` ${node.combinator.toUpperCase()} ` });\n }\n tokens.push(...childTokens);\n }\n }\n return tokens.length > 0 && !isRoot\n ? [{ kind: 'group', text: '(' }, ...tokens, { kind: 'group', text: ')' }]\n : tokens;\n }\n\n private formatValue(value: unknown, schema: unknown): string {\n if (Array.isArray(value)) {\n return value.map(item => this.formatValue(item, schema)).join(', ');\n }\n\n if (isRecord(schema) && Array.isArray(schema.oneOf)) {\n for (const option of schema.oneOf) {\n if (isRecord(option) && option.const === value && typeof option.title === 'string') {\n return option.title;\n }\n }\n }\n\n if (value !== null && typeof value === 'object') {\n return JSON.stringify(value) ?? '';\n }\n if (typeof value === 'string') {\n return value;\n }\n if (typeof value === 'number' || typeof value === 'boolean') {\n return value.toString();\n }\n return 'null';\n }\n}\n\nconst okFvFilterBar = FvFilterBar.compose({\n baseName: 'fv-filter-bar',\n template,\n styles\n});\n\nDesignSystem.getOrCreate().withPrefix('ok').register(okFvFilterBar());\nexport const fvFilterBarTag = 'ok-fv-filter-bar';\n"]}
@@ -0,0 +1 @@
1
+ export declare const styles: import("@ni/fast-element").ElementStyles;
@@ -0,0 +1,119 @@
1
+ import { css } from '@ni/fast-element';
2
+ import { bodyDisabledFontColor, bodyFont, bodyFontColor, borderHoverColor, borderWidth, controlHeight, fillHoverColor, iconColor, iconSize, linkProminentFontColor, sectionBackgroundColor, smallPadding, standardPadding } from '@ni/nimble-components/dist/esm/theme-provider/design-tokens';
3
+ import { display } from '../../utilities/style/display';
4
+ export const styles = css `
5
+ @layer base, hover, focusVisible, disabled, top;
6
+
7
+ @layer base {
8
+ ${display('flex')}
9
+
10
+ :host {
11
+ min-width: 0;
12
+ font: ${bodyFont};
13
+ color: ${bodyFontColor};
14
+ }
15
+
16
+ .filter-bar {
17
+ display: flex;
18
+ align-items: center;
19
+ min-width: 0;
20
+ max-width: 100%;
21
+ height: 30px;
22
+ padding: 0 ${standardPadding};
23
+ }
24
+
25
+ .filter-bar-edit,
26
+ .filter-bar-clear {
27
+ -webkit-appearance: none;
28
+ appearance: none;
29
+ display: inline-flex;
30
+ align-items: center;
31
+ min-width: 0;
32
+ padding: 0;
33
+ border: none;
34
+ border-radius: 2px;
35
+ background: transparent;
36
+ color: inherit;
37
+ font: inherit;
38
+ cursor: pointer;
39
+ }
40
+
41
+ .filter-bar-edit {
42
+ flex: 0 1 auto;
43
+ height: 30px;
44
+ gap: calc(2 * ${smallPadding});
45
+ text-align: start;
46
+ }
47
+
48
+ .filter-bar-content {
49
+ min-width: 0;
50
+ overflow: hidden;
51
+ text-overflow: ellipsis;
52
+ white-space: nowrap;
53
+ }
54
+
55
+ .filter-bar-label {
56
+ margin-inline-end: 10px;
57
+ }
58
+
59
+ .query-expression {
60
+ padding: 0 ${smallPadding};
61
+ background-color: ${sectionBackgroundColor};
62
+ border-radius: 50px;
63
+ }
64
+
65
+ .logical-operator {
66
+ font-weight: 600;
67
+ color: ${linkProminentFontColor};
68
+ }
69
+
70
+ .compound-expression-container {
71
+ font-size: medium;
72
+ }
73
+
74
+ .filter-bar-icon {
75
+ flex: 0 0 auto;
76
+ width: ${iconSize};
77
+ height: ${iconSize};
78
+ ${iconColor.cssCustomProperty}: currentColor;
79
+ }
80
+
81
+ .filter-bar-clear {
82
+ ${controlHeight.cssCustomProperty}: 24px;
83
+ flex: 0 0 auto;
84
+ justify-content: center;
85
+ width: ${controlHeight};
86
+ height: ${controlHeight};
87
+ margin-inline-start: calc(2 * ${smallPadding});
88
+ }
89
+ }
90
+
91
+ @layer hover {
92
+ .filter-bar-clear:hover {
93
+ background: ${fillHoverColor};
94
+ }
95
+ }
96
+
97
+ @layer focusVisible {
98
+ .filter-bar-edit:focus-visible,
99
+ .filter-bar-clear:focus-visible {
100
+ outline: ${borderWidth} solid ${borderHoverColor};
101
+ outline-offset: -1px;
102
+ }
103
+ }
104
+
105
+ @layer disabled {
106
+ .filter-bar-edit:disabled,
107
+ .filter-bar-clear:disabled {
108
+ color: ${bodyDisabledFontColor};
109
+ cursor: not-allowed;
110
+ }
111
+
112
+ :host([disabled]) .logical-operator {
113
+ color: inherit;
114
+ }
115
+ }
116
+
117
+ @layer top {}
118
+ `;
119
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../../src/fv/filter-bar/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EACH,qBAAqB,EACrB,QAAQ,EACR,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,cAAc,EACd,SAAS,EACT,QAAQ,EACR,sBAAsB,EACtB,sBAAsB,EACtB,YAAY,EACZ,eAAe,EAClB,MAAM,6DAA6D,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAExD,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;UAIf,OAAO,CAAC,MAAM,CAAC;;;;oBAIL,QAAQ;qBACP,aAAa;;;;;;;;;yBAST,eAAe;;;;;;;;;;;;;;;;;;;;;;4BAsBZ,YAAY;;;;;;;;;;;;;;;;yBAgBf,YAAY;gCACL,sBAAsB;;;;;;qBAMjC,sBAAsB;;;;;;;;;qBAStB,QAAQ;sBACP,QAAQ;cAChB,SAAS,CAAC,iBAAiB;;;;cAI3B,aAAa,CAAC,iBAAiB;;;qBAGxB,aAAa;sBACZ,aAAa;4CACS,YAAY;;;;;;0BAM9B,cAAc;;;;;;;uBAOjB,WAAW,UAAU,gBAAgB;;;;;;;;qBAQvC,qBAAqB;;;;;;;;;;CAUzC,CAAC","sourcesContent":["import { css } from '@ni/fast-element';\nimport {\n bodyDisabledFontColor,\n bodyFont,\n bodyFontColor,\n borderHoverColor,\n borderWidth,\n controlHeight,\n fillHoverColor,\n iconColor,\n iconSize,\n linkProminentFontColor,\n sectionBackgroundColor,\n smallPadding,\n standardPadding\n} from '@ni/nimble-components/dist/esm/theme-provider/design-tokens';\nimport { display } from '../../utilities/style/display';\n\nexport const styles = css`\n @layer base, hover, focusVisible, disabled, top;\n\n @layer base {\n ${display('flex')}\n\n :host {\n min-width: 0;\n font: ${bodyFont};\n color: ${bodyFontColor};\n }\n\n .filter-bar {\n display: flex;\n align-items: center;\n min-width: 0;\n max-width: 100%;\n height: 30px;\n padding: 0 ${standardPadding};\n }\n\n .filter-bar-edit,\n .filter-bar-clear {\n -webkit-appearance: none;\n appearance: none;\n display: inline-flex;\n align-items: center;\n min-width: 0;\n padding: 0;\n border: none;\n border-radius: 2px;\n background: transparent;\n color: inherit;\n font: inherit;\n cursor: pointer;\n }\n\n .filter-bar-edit {\n flex: 0 1 auto;\n height: 30px;\n gap: calc(2 * ${smallPadding});\n text-align: start;\n }\n\n .filter-bar-content {\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .filter-bar-label {\n margin-inline-end: 10px;\n }\n\n .query-expression {\n padding: 0 ${smallPadding};\n background-color: ${sectionBackgroundColor};\n border-radius: 50px;\n }\n\n .logical-operator {\n font-weight: 600;\n color: ${linkProminentFontColor};\n }\n\n .compound-expression-container {\n font-size: medium;\n }\n\n .filter-bar-icon {\n flex: 0 0 auto;\n width: ${iconSize};\n height: ${iconSize};\n ${iconColor.cssCustomProperty}: currentColor;\n }\n\n .filter-bar-clear {\n ${controlHeight.cssCustomProperty}: 24px;\n flex: 0 0 auto;\n justify-content: center;\n width: ${controlHeight};\n height: ${controlHeight};\n margin-inline-start: calc(2 * ${smallPadding});\n }\n }\n\n @layer hover {\n .filter-bar-clear:hover {\n background: ${fillHoverColor};\n }\n }\n\n @layer focusVisible {\n .filter-bar-edit:focus-visible,\n .filter-bar-clear:focus-visible {\n outline: ${borderWidth} solid ${borderHoverColor};\n outline-offset: -1px;\n }\n }\n\n @layer disabled {\n .filter-bar-edit:disabled,\n .filter-bar-clear:disabled {\n color: ${bodyDisabledFontColor};\n cursor: not-allowed;\n }\n\n :host([disabled]) .logical-operator {\n color: inherit;\n }\n }\n\n @layer top {}\n`;\n"]}
@@ -0,0 +1,2 @@
1
+ import type { FvFilterBar } from '.';
2
+ export declare const template: import("@ni/fast-element").ViewTemplate<FvFilterBar, any>;
@@ -0,0 +1,34 @@
1
+ import { html, ref, repeat, when } from '@ni/fast-element';
2
+ import { iconFilterTag } from '@ni/nimble-components/dist/esm/icons/filter';
3
+ import { iconXmarkTag } from '@ni/nimble-components/dist/esm/icons/xmark';
4
+ const queryTokenTemplate = html `${when(x => x.kind === 'predicate', html `<span class="query-expression"><b>${x => (x.kind === 'predicate' ? x.field : '')}</b> ${x => (x.kind === 'predicate' ? x.operator : '')}<b>${x => (x.kind === 'predicate' ? x.value : '')}</b></span>`)}${when(x => x.kind === 'logic', html `<span class="logical-operator">${x => (x.kind === 'logic' ? x.text : '')}</span>`)}${when(x => x.kind === 'group', html `<span class="compound-expression-container">${x => (x.kind === 'group' ? x.text : '')}</span>`)}`;
5
+ export const template = html `
6
+ <div class="filter-bar" role="group" aria-label="${x => x.label}">
7
+ <button
8
+ ${ref('editButton')}
9
+ class="filter-bar-edit"
10
+ type="button"
11
+ aria-label="${x => `Edit filters: ${x.label}`}"
12
+ title="${x => x.expression}"
13
+ ?disabled="${x => x.disabled}"
14
+ @click="${x => x.handleEditClick()}"
15
+ >
16
+ <${iconFilterTag} class="filter-bar-icon" aria-hidden="true"></${iconFilterTag}>
17
+ <span class="filter-bar-content">
18
+ <span class="filter-bar-label">${x => x.label}</span>${when(x => x.expression.length > 0, html `<span class="filter-bar-expression">${repeat(x => x.queryTokens, queryTokenTemplate)}</span>`)}
19
+ </span>
20
+ </button>
21
+ ${when(x => x.showClearButton && x.expression.length > 0, html `
22
+ <button
23
+ class="filter-bar-clear"
24
+ type="button"
25
+ aria-label="Clear filters"
26
+ ?disabled="${x => x.disabled}"
27
+ @click="${x => x.handleClearClick()}"
28
+ >
29
+ <${iconXmarkTag} class="filter-bar-icon" aria-hidden="true"></${iconXmarkTag}>
30
+ </button>
31
+ `)}
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AAC,CAAC,CAAC,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,CACxH,EAAE,CAAC;AAER,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,CAAa;uDACc,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK;;cAErD,GAAG,CAAC,YAAY,CAAC;;;0BAGL,CAAC,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC,KAAK,EAAE;qBACpC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU;yBACb,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ;sBAClB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,eAAe,EAAE;;eAE/B,aAAa,iDAAiD,aAAa;;iDAEzC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,UAAU,IAAI,CACvD,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,EAC5B,IAAI,CAAa,uCAAuC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,kBAAkB,CAAC,SAAS,CAClH;;;UAGP,IAAI,CACF,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,eAAe,IAAI,CAAC,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,EACjD,IAAI,CAAa;;;;;iCAKI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ;8BAClB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,gBAAgB,EAAE;;uBAEhC,YAAY,iDAAiD,YAAY;;aAEnF,CACJ;;CAER,CAAC","sourcesContent":["import { html, ref, repeat, when } from '@ni/fast-element';\nimport { iconFilterTag } from '@ni/nimble-components/dist/esm/icons/filter';\nimport { iconXmarkTag } from '@ni/nimble-components/dist/esm/icons/xmark';\nimport type { FvFilterBar } from '.';\nimport type { FvFilterBarToken } from './types';\n\nconst queryTokenTemplate = html<FvFilterBarToken>`${when(\n x => x.kind === 'predicate',\n html<FvFilterBarToken>`<span class=\"query-expression\"><b>${x => (x.kind === 'predicate' ? x.field : '')}</b> ${x => (x.kind === 'predicate' ? x.operator : '')}<b>${x => (x.kind === 'predicate' ? x.value : '')}</b></span>`\n )}${when(\n x => x.kind === 'logic',\n html<FvFilterBarToken>`<span class=\"logical-operator\">${x => (x.kind === 'logic' ? x.text : '')}</span>`\n )}${when(\n x => x.kind === 'group',\n html<FvFilterBarToken>`<span class=\"compound-expression-container\">${x => (x.kind === 'group' ? x.text : '')}</span>`\n )}`;\n\nexport const template = html<FvFilterBar>`\n <div class=\"filter-bar\" role=\"group\" aria-label=\"${x => x.label}\">\n <button\n ${ref('editButton')}\n class=\"filter-bar-edit\"\n type=\"button\"\n aria-label=\"${x => `Edit filters: ${x.label}`}\"\n title=\"${x => x.expression}\"\n ?disabled=\"${x => x.disabled}\"\n @click=\"${x => x.handleEditClick()}\"\n >\n <${iconFilterTag} class=\"filter-bar-icon\" aria-hidden=\"true\"></${iconFilterTag}>\n <span class=\"filter-bar-content\">\n <span class=\"filter-bar-label\">${x => x.label}</span>${when(\n x => x.expression.length > 0,\n html<FvFilterBar>`<span class=\"filter-bar-expression\">${repeat(x => x.queryTokens, queryTokenTemplate)}</span>`\n )}\n </span>\n </button>\n ${when(\n x => x.showClearButton && x.expression.length > 0,\n html<FvFilterBar>`\n <button\n class=\"filter-bar-clear\"\n type=\"button\"\n aria-label=\"Clear filters\"\n ?disabled=\"${x => x.disabled}\"\n @click=\"${x => x.handleClearClick()}\"\n >\n <${iconXmarkTag} class=\"filter-bar-icon\" aria-hidden=\"true\"></${iconXmarkTag}>\n </button>\n `\n )}\n </div>\n`;\n"]}