@ni/ok-components 1.8.2 → 1.9.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.
- package/dist/all-components-bundle.js +10325 -10187
- package/dist/all-components-bundle.js.map +1 -1
- package/dist/all-components-bundle.min.js +6433 -6253
- package/dist/all-components-bundle.min.js.map +1 -1
- package/dist/custom-elements.json +580 -215
- package/dist/custom-elements.md +75 -34
- package/dist/esm/fv/all-fv.d.ts +1 -0
- package/dist/esm/fv/all-fv.js +1 -0
- package/dist/esm/fv/all-fv.js.map +1 -1
- package/dist/esm/fv/splitter/index.d.ts +69 -0
- package/dist/esm/fv/splitter/index.js +266 -0
- package/dist/esm/fv/splitter/index.js.map +1 -0
- package/dist/esm/fv/splitter/styles.d.ts +1 -0
- package/dist/esm/fv/splitter/styles.js +62 -0
- package/dist/esm/fv/splitter/styles.js.map +1 -0
- package/dist/esm/fv/splitter/template.d.ts +2 -0
- package/dist/esm/fv/splitter/template.js +12 -0
- package/dist/esm/fv/splitter/template.js.map +1 -0
- package/package.json +5 -5
package/dist/custom-elements.md
CHANGED
|
@@ -34,40 +34,6 @@
|
|
|
34
34
|
|
|
35
35
|
<hr/>
|
|
36
36
|
|
|
37
|
-
## class: `FvCard`
|
|
38
|
-
|
|
39
|
-
### Superclass
|
|
40
|
-
|
|
41
|
-
| Name | Module | Package |
|
|
42
|
-
| ------------------- | ------ | ------------------- |
|
|
43
|
-
| `FoundationElement` | | @ni/fast-foundation |
|
|
44
|
-
|
|
45
|
-
### Fields
|
|
46
|
-
|
|
47
|
-
| Name | Privacy | Type | Default | Description | Inherited From |
|
|
48
|
-
| ----------------- | ------- | --------------------------- | ------- | ----------- | -------------- |
|
|
49
|
-
| `title` | public | `string` | `''` | | |
|
|
50
|
-
| `subtitle` | public | `string` | `''` | | |
|
|
51
|
-
| `description` | public | `string` | `''` | | |
|
|
52
|
-
| `appearance` | public | `FvCardAppearanceType` | | | |
|
|
53
|
-
| `interactionMode` | public | `FvCardInteractionModeType` | | | |
|
|
54
|
-
| `disabled` | public | `boolean` | `false` | | |
|
|
55
|
-
| `initials` | public | `string` | `''` | | |
|
|
56
|
-
|
|
57
|
-
### Attributes
|
|
58
|
-
|
|
59
|
-
| Name | Field | Inherited From |
|
|
60
|
-
| ------------------ | --------------- | -------------- |
|
|
61
|
-
| `card-title` | title | |
|
|
62
|
-
| `subtitle` | subtitle | |
|
|
63
|
-
| `description` | description | |
|
|
64
|
-
| `appearance` | appearance | |
|
|
65
|
-
| `interaction-mode` | interactionMode | |
|
|
66
|
-
| `disabled` | disabled | |
|
|
67
|
-
| `initials` | initials | |
|
|
68
|
-
|
|
69
|
-
<hr/>
|
|
70
|
-
|
|
71
37
|
## class: `FvChipSelector`
|
|
72
38
|
|
|
73
39
|
### Superclass
|
|
@@ -108,6 +74,40 @@
|
|
|
108
74
|
|
|
109
75
|
<hr/>
|
|
110
76
|
|
|
77
|
+
## class: `FvCard`
|
|
78
|
+
|
|
79
|
+
### Superclass
|
|
80
|
+
|
|
81
|
+
| Name | Module | Package |
|
|
82
|
+
| ------------------- | ------ | ------------------- |
|
|
83
|
+
| `FoundationElement` | | @ni/fast-foundation |
|
|
84
|
+
|
|
85
|
+
### Fields
|
|
86
|
+
|
|
87
|
+
| Name | Privacy | Type | Default | Description | Inherited From |
|
|
88
|
+
| ----------------- | ------- | --------------------------- | ------- | ----------- | -------------- |
|
|
89
|
+
| `title` | public | `string` | `''` | | |
|
|
90
|
+
| `subtitle` | public | `string` | `''` | | |
|
|
91
|
+
| `description` | public | `string` | `''` | | |
|
|
92
|
+
| `appearance` | public | `FvCardAppearanceType` | | | |
|
|
93
|
+
| `interactionMode` | public | `FvCardInteractionModeType` | | | |
|
|
94
|
+
| `disabled` | public | `boolean` | `false` | | |
|
|
95
|
+
| `initials` | public | `string` | `''` | | |
|
|
96
|
+
|
|
97
|
+
### Attributes
|
|
98
|
+
|
|
99
|
+
| Name | Field | Inherited From |
|
|
100
|
+
| ------------------ | --------------- | -------------- |
|
|
101
|
+
| `card-title` | title | |
|
|
102
|
+
| `subtitle` | subtitle | |
|
|
103
|
+
| `description` | description | |
|
|
104
|
+
| `appearance` | appearance | |
|
|
105
|
+
| `interaction-mode` | interactionMode | |
|
|
106
|
+
| `disabled` | disabled | |
|
|
107
|
+
| `initials` | initials | |
|
|
108
|
+
|
|
109
|
+
<hr/>
|
|
110
|
+
|
|
111
111
|
## class: `FvContextHelp`
|
|
112
112
|
|
|
113
113
|
### Superclass
|
|
@@ -308,6 +308,47 @@
|
|
|
308
308
|
|
|
309
309
|
<hr/>
|
|
310
310
|
|
|
311
|
+
## class: `FvSplitter`
|
|
312
|
+
|
|
313
|
+
### Superclass
|
|
314
|
+
|
|
315
|
+
| Name | Module | Package |
|
|
316
|
+
| ------------------- | ------ | ------------------- |
|
|
317
|
+
| `FoundationElement` | | @ni/fast-foundation |
|
|
318
|
+
|
|
319
|
+
### Fields
|
|
320
|
+
|
|
321
|
+
| Name | Privacy | Type | Default | Description | Inherited From |
|
|
322
|
+
| ---------------- | ------- | --------------------- | ---------------- | ----------------------------------------------------------------------- | -------------- |
|
|
323
|
+
| `ariaLabel` | public | `string` | `'Resize panes'` | The accessible name for the separator. | |
|
|
324
|
+
| `ariaLabelledby` | public | `string \| undefined` | | Identifies the element that labels the separator. | |
|
|
325
|
+
| `ariaControls` | public | `string \| undefined` | | Identifies the primary pane controlled by the separator. | |
|
|
326
|
+
| `position` | public | `number` | `60` | The splitter position as a percentage of the containing layout's width. | |
|
|
327
|
+
| `min` | public | `number` | `0` | The minimum allowed position. | |
|
|
328
|
+
| `max` | public | `number` | `100` | The maximum allowed position. | |
|
|
329
|
+
| `step` | public | `number` | `1` | The percentage-point increment used for keyboard resizing. | |
|
|
330
|
+
|
|
331
|
+
### Events
|
|
332
|
+
|
|
333
|
+
| Name | Type | Description | Inherited From |
|
|
334
|
+
| -------- | ------- | ----------- | -------------- |
|
|
335
|
+
| `change` | `Event` | | |
|
|
336
|
+
| `input` | `Event` | | |
|
|
337
|
+
|
|
338
|
+
### Attributes
|
|
339
|
+
|
|
340
|
+
| Name | Field | Inherited From |
|
|
341
|
+
| ----------------- | -------------- | -------------- |
|
|
342
|
+
| `aria-label` | ariaLabel | |
|
|
343
|
+
| `aria-labelledby` | ariaLabelledby | |
|
|
344
|
+
| `aria-controls` | ariaControls | |
|
|
345
|
+
| `position` | position | |
|
|
346
|
+
| `min` | min | |
|
|
347
|
+
| `max` | max | |
|
|
348
|
+
| `step` | step | |
|
|
349
|
+
|
|
350
|
+
<hr/>
|
|
351
|
+
|
|
311
352
|
## class: `FvStickyHeader`
|
|
312
353
|
|
|
313
354
|
### Superclass
|
package/dist/esm/fv/all-fv.d.ts
CHANGED
package/dist/esm/fv/all-fv.js
CHANGED
|
@@ -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,iBAAiB,CAAC;AACzB,OAAO,gBAAgB,CAAC;AACxB,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","sourcesContent":["import './accordion-item';\nimport './card';\nimport './chip-selector';\nimport './context-help';\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';\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,iBAAiB,CAAC;AACzB,OAAO,gBAAgB,CAAC;AACxB,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","sourcesContent":["import './accordion-item';\nimport './card';\nimport './chip-selector';\nimport './context-help';\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';\n"]}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { FoundationElement } from '@ni/fast-foundation';
|
|
2
|
+
declare global {
|
|
3
|
+
interface HTMLElementTagNameMap {
|
|
4
|
+
'ok-fv-splitter': FvSplitter;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* A vertical separator that enables pointer and keyboard resizing between two panes.
|
|
9
|
+
*/
|
|
10
|
+
export declare class FvSplitter extends FoundationElement {
|
|
11
|
+
/** The accessible name for the separator. */
|
|
12
|
+
ariaLabel: string;
|
|
13
|
+
/** Identifies the element that labels the separator. */
|
|
14
|
+
ariaLabelledby: string | undefined;
|
|
15
|
+
/** Identifies the primary pane controlled by the separator. */
|
|
16
|
+
ariaControls: string | undefined;
|
|
17
|
+
/** The splitter position as a percentage of the containing layout's width. */
|
|
18
|
+
position: number;
|
|
19
|
+
/** The minimum allowed position. */
|
|
20
|
+
min: number;
|
|
21
|
+
/** The maximum allowed position. */
|
|
22
|
+
max: number;
|
|
23
|
+
/** The percentage-point increment used for keyboard resizing. */
|
|
24
|
+
step: number;
|
|
25
|
+
/** @internal */
|
|
26
|
+
resizing: boolean;
|
|
27
|
+
private pointerId;
|
|
28
|
+
private pointerStartPosition;
|
|
29
|
+
private requestedPosition;
|
|
30
|
+
private applyingConstrainedPosition;
|
|
31
|
+
private requestedPositionResetScheduled;
|
|
32
|
+
private positionChangeCallbackVersion;
|
|
33
|
+
constructor();
|
|
34
|
+
/** @internal */
|
|
35
|
+
connectedCallback(): void;
|
|
36
|
+
/** @internal */
|
|
37
|
+
disconnectedCallback(): void;
|
|
38
|
+
/** @internal */
|
|
39
|
+
positionChanged(): void;
|
|
40
|
+
/** @internal */
|
|
41
|
+
minChanged(): void;
|
|
42
|
+
/** @internal */
|
|
43
|
+
maxChanged(): void;
|
|
44
|
+
/** @internal */
|
|
45
|
+
resizingChanged(): void;
|
|
46
|
+
/** @internal */
|
|
47
|
+
handlePointerDown(event: PointerEvent): boolean;
|
|
48
|
+
/** @internal */
|
|
49
|
+
handlePointerMove(event: PointerEvent): boolean;
|
|
50
|
+
/** @internal */
|
|
51
|
+
handlePointerUp(event: PointerEvent): boolean;
|
|
52
|
+
/** @internal */
|
|
53
|
+
handlePointerCancel(event: PointerEvent): boolean;
|
|
54
|
+
/** @internal */
|
|
55
|
+
handleKeyDown(event: KeyboardEvent): boolean;
|
|
56
|
+
private get validMin();
|
|
57
|
+
private get validMax();
|
|
58
|
+
private get validStep();
|
|
59
|
+
private get isRtl();
|
|
60
|
+
private readonly keydownHandler;
|
|
61
|
+
private constrain;
|
|
62
|
+
private updatePosition;
|
|
63
|
+
private applyConstrainedPosition;
|
|
64
|
+
private resetRequestedPositionAfterSynchronousUpdates;
|
|
65
|
+
private finishResize;
|
|
66
|
+
private syncAriaValueAttributesIfConnected;
|
|
67
|
+
private syncAriaValueAttributes;
|
|
68
|
+
}
|
|
69
|
+
export declare const fvSplitterTag = "ok-fv-splitter";
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { attr, nullableNumberConverter, observable } from '@ni/fast-element';
|
|
3
|
+
import { DesignSystem, FoundationElement } from '@ni/fast-foundation';
|
|
4
|
+
import { styles } from './styles';
|
|
5
|
+
import { template } from './template';
|
|
6
|
+
/**
|
|
7
|
+
* A vertical separator that enables pointer and keyboard resizing between two panes.
|
|
8
|
+
*/
|
|
9
|
+
export class FvSplitter extends FoundationElement {
|
|
10
|
+
constructor() {
|
|
11
|
+
super();
|
|
12
|
+
/** The accessible name for the separator. */
|
|
13
|
+
this.ariaLabel = 'Resize panes';
|
|
14
|
+
/** The splitter position as a percentage of the containing layout's width. */
|
|
15
|
+
this.position = 60;
|
|
16
|
+
/** The minimum allowed position. */
|
|
17
|
+
this.min = 0;
|
|
18
|
+
/** The maximum allowed position. */
|
|
19
|
+
this.max = 100;
|
|
20
|
+
/** The percentage-point increment used for keyboard resizing. */
|
|
21
|
+
this.step = 1;
|
|
22
|
+
/** @internal */
|
|
23
|
+
this.resizing = false;
|
|
24
|
+
this.pointerStartPosition = 0;
|
|
25
|
+
this.requestedPosition = this.position;
|
|
26
|
+
this.applyingConstrainedPosition = false;
|
|
27
|
+
this.requestedPositionResetScheduled = false;
|
|
28
|
+
this.positionChangeCallbackVersion = 0;
|
|
29
|
+
this.keydownHandler = (event) => {
|
|
30
|
+
this.handleKeyDown(event);
|
|
31
|
+
};
|
|
32
|
+
const positionDescriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(this), 'position');
|
|
33
|
+
if (!positionDescriptor?.get || !positionDescriptor.set) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const getPosition = positionDescriptor.get.bind(this);
|
|
37
|
+
const setPosition = positionDescriptor.set.bind(this);
|
|
38
|
+
Object.defineProperty(this, 'position', {
|
|
39
|
+
configurable: true,
|
|
40
|
+
enumerable: positionDescriptor.enumerable,
|
|
41
|
+
get: getPosition,
|
|
42
|
+
set: (value) => {
|
|
43
|
+
const previousPosition = getPosition();
|
|
44
|
+
const callbackVersion = this.positionChangeCallbackVersion;
|
|
45
|
+
setPosition(value);
|
|
46
|
+
if (!this.applyingConstrainedPosition
|
|
47
|
+
&& callbackVersion === this.positionChangeCallbackVersion
|
|
48
|
+
&& previousPosition === getPosition()) {
|
|
49
|
+
this.requestedPosition = getPosition();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/** @internal */
|
|
55
|
+
connectedCallback() {
|
|
56
|
+
super.connectedCallback();
|
|
57
|
+
this.setAttribute('role', 'separator');
|
|
58
|
+
this.setAttribute('aria-orientation', 'vertical');
|
|
59
|
+
this.setAttribute('aria-label', this.ariaLabel);
|
|
60
|
+
this.tabIndex = 0;
|
|
61
|
+
this.addEventListener('keydown', this.keydownHandler);
|
|
62
|
+
this.syncAriaValueAttributes();
|
|
63
|
+
}
|
|
64
|
+
/** @internal */
|
|
65
|
+
disconnectedCallback() {
|
|
66
|
+
this.removeEventListener('keydown', this.keydownHandler);
|
|
67
|
+
super.disconnectedCallback();
|
|
68
|
+
}
|
|
69
|
+
/** @internal */
|
|
70
|
+
positionChanged() {
|
|
71
|
+
this.positionChangeCallbackVersion += 1;
|
|
72
|
+
if (!this.applyingConstrainedPosition) {
|
|
73
|
+
this.requestedPosition = this.position;
|
|
74
|
+
this.resetRequestedPositionAfterSynchronousUpdates();
|
|
75
|
+
}
|
|
76
|
+
this.applyConstrainedPosition();
|
|
77
|
+
}
|
|
78
|
+
/** @internal */
|
|
79
|
+
minChanged() {
|
|
80
|
+
this.applyConstrainedPosition();
|
|
81
|
+
}
|
|
82
|
+
/** @internal */
|
|
83
|
+
maxChanged() {
|
|
84
|
+
this.applyConstrainedPosition();
|
|
85
|
+
}
|
|
86
|
+
/** @internal */
|
|
87
|
+
resizingChanged() {
|
|
88
|
+
this.toggleAttribute('resizing', this.resizing);
|
|
89
|
+
}
|
|
90
|
+
/** @internal */
|
|
91
|
+
handlePointerDown(event) {
|
|
92
|
+
if (event.button !== 0 || !event.isPrimary || this.pointerId !== undefined) {
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
event.preventDefault();
|
|
96
|
+
const pointerTarget = event.currentTarget;
|
|
97
|
+
this.focus();
|
|
98
|
+
this.pointerId = event.pointerId;
|
|
99
|
+
this.pointerStartPosition = this.position;
|
|
100
|
+
this.resizing = true;
|
|
101
|
+
if (event.pointerId !== -1) {
|
|
102
|
+
pointerTarget.setPointerCapture(event.pointerId);
|
|
103
|
+
}
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
/** @internal */
|
|
107
|
+
handlePointerMove(event) {
|
|
108
|
+
if (event.pointerId !== this.pointerId) {
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
const container = this.parentElement;
|
|
112
|
+
if (!container) {
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
const bounds = container.getBoundingClientRect();
|
|
116
|
+
if (bounds.width > 0) {
|
|
117
|
+
const distanceFromInlineStart = this.isRtl
|
|
118
|
+
? bounds.right - event.clientX
|
|
119
|
+
: event.clientX - bounds.left;
|
|
120
|
+
this.updatePosition((distanceFromInlineStart / bounds.width) * 100);
|
|
121
|
+
}
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
/** @internal */
|
|
125
|
+
handlePointerUp(event) {
|
|
126
|
+
if (event.pointerId === this.pointerId) {
|
|
127
|
+
this.finishResize();
|
|
128
|
+
}
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
/** @internal */
|
|
132
|
+
handlePointerCancel(event) {
|
|
133
|
+
if (event.pointerId === this.pointerId) {
|
|
134
|
+
this.updatePosition(this.pointerStartPosition);
|
|
135
|
+
this.resizing = false;
|
|
136
|
+
this.pointerId = undefined;
|
|
137
|
+
}
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
/** @internal */
|
|
141
|
+
handleKeyDown(event) {
|
|
142
|
+
let nextPosition;
|
|
143
|
+
const direction = this.isRtl ? -1 : 1;
|
|
144
|
+
switch (event.key) {
|
|
145
|
+
case 'ArrowLeft':
|
|
146
|
+
nextPosition = this.position - direction * this.validStep;
|
|
147
|
+
break;
|
|
148
|
+
case 'ArrowRight':
|
|
149
|
+
nextPosition = this.position + direction * this.validStep;
|
|
150
|
+
break;
|
|
151
|
+
case 'Home':
|
|
152
|
+
nextPosition = this.validMin;
|
|
153
|
+
break;
|
|
154
|
+
case 'End':
|
|
155
|
+
nextPosition = this.validMax;
|
|
156
|
+
break;
|
|
157
|
+
default:
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
event.preventDefault();
|
|
161
|
+
const previousPosition = this.position;
|
|
162
|
+
this.updatePosition(nextPosition);
|
|
163
|
+
if (this.position !== previousPosition) {
|
|
164
|
+
this.dispatchEvent(new Event('change', { bubbles: true, composed: true }));
|
|
165
|
+
}
|
|
166
|
+
return true;
|
|
167
|
+
}
|
|
168
|
+
get validMin() {
|
|
169
|
+
return Number.isFinite(this.min) ? Math.min(100, Math.max(0, this.min)) : 0;
|
|
170
|
+
}
|
|
171
|
+
get validMax() {
|
|
172
|
+
const max = Number.isFinite(this.max) ? this.max : 100;
|
|
173
|
+
return Math.max(this.validMin, Math.min(100, Math.max(0, max)));
|
|
174
|
+
}
|
|
175
|
+
get validStep() {
|
|
176
|
+
return Number.isFinite(this.step) && this.step > 0 ? this.step : 1;
|
|
177
|
+
}
|
|
178
|
+
get isRtl() {
|
|
179
|
+
return getComputedStyle(this).direction === 'rtl';
|
|
180
|
+
}
|
|
181
|
+
constrain(position) {
|
|
182
|
+
const finitePosition = Number.isFinite(position) ? position : 60;
|
|
183
|
+
return Math.min(this.validMax, Math.max(this.validMin, finitePosition));
|
|
184
|
+
}
|
|
185
|
+
updatePosition(position) {
|
|
186
|
+
const nextPosition = this.constrain(position);
|
|
187
|
+
this.requestedPosition = nextPosition;
|
|
188
|
+
if (nextPosition !== this.position) {
|
|
189
|
+
this.position = nextPosition;
|
|
190
|
+
this.dispatchEvent(new Event('input', { bubbles: true, composed: true }));
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
applyConstrainedPosition() {
|
|
194
|
+
const constrainedPosition = this.constrain(this.requestedPosition);
|
|
195
|
+
if (constrainedPosition !== this.position) {
|
|
196
|
+
this.applyingConstrainedPosition = true;
|
|
197
|
+
this.position = constrainedPosition;
|
|
198
|
+
this.applyingConstrainedPosition = false;
|
|
199
|
+
}
|
|
200
|
+
this.syncAriaValueAttributesIfConnected();
|
|
201
|
+
}
|
|
202
|
+
resetRequestedPositionAfterSynchronousUpdates() {
|
|
203
|
+
if (this.requestedPositionResetScheduled) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
this.requestedPositionResetScheduled = true;
|
|
207
|
+
queueMicrotask(() => {
|
|
208
|
+
this.requestedPositionResetScheduled = false;
|
|
209
|
+
this.requestedPosition = this.position;
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
finishResize() {
|
|
213
|
+
const changed = this.position !== this.pointerStartPosition;
|
|
214
|
+
this.resizing = false;
|
|
215
|
+
this.pointerId = undefined;
|
|
216
|
+
if (changed) {
|
|
217
|
+
this.dispatchEvent(new Event('change', { bubbles: true, composed: true }));
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
syncAriaValueAttributesIfConnected() {
|
|
221
|
+
if (this.$fastController.isConnected) {
|
|
222
|
+
this.syncAriaValueAttributes();
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
syncAriaValueAttributes() {
|
|
226
|
+
this.setAttribute('aria-valuemin', String(this.validMin));
|
|
227
|
+
this.setAttribute('aria-valuemax', String(this.validMax));
|
|
228
|
+
this.setAttribute('aria-valuenow', String(this.position));
|
|
229
|
+
this.setAttribute('aria-valuetext', `${this.position} percent`);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
__decorate([
|
|
233
|
+
attr({ attribute: 'aria-label' })
|
|
234
|
+
], FvSplitter.prototype, "ariaLabel", void 0);
|
|
235
|
+
__decorate([
|
|
236
|
+
attr({ attribute: 'aria-labelledby' })
|
|
237
|
+
], FvSplitter.prototype, "ariaLabelledby", void 0);
|
|
238
|
+
__decorate([
|
|
239
|
+
attr({ attribute: 'aria-controls' })
|
|
240
|
+
], FvSplitter.prototype, "ariaControls", void 0);
|
|
241
|
+
__decorate([
|
|
242
|
+
attr({ converter: nullableNumberConverter })
|
|
243
|
+
], FvSplitter.prototype, "position", void 0);
|
|
244
|
+
__decorate([
|
|
245
|
+
attr({ converter: nullableNumberConverter })
|
|
246
|
+
], FvSplitter.prototype, "min", void 0);
|
|
247
|
+
__decorate([
|
|
248
|
+
attr({ converter: nullableNumberConverter })
|
|
249
|
+
], FvSplitter.prototype, "max", void 0);
|
|
250
|
+
__decorate([
|
|
251
|
+
attr({ converter: nullableNumberConverter })
|
|
252
|
+
], FvSplitter.prototype, "step", void 0);
|
|
253
|
+
__decorate([
|
|
254
|
+
observable
|
|
255
|
+
], FvSplitter.prototype, "resizing", void 0);
|
|
256
|
+
const okFvSplitter = FvSplitter.compose({
|
|
257
|
+
baseName: 'fv-splitter',
|
|
258
|
+
template,
|
|
259
|
+
styles,
|
|
260
|
+
shadowOptions: {
|
|
261
|
+
delegatesFocus: false
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
DesignSystem.getOrCreate().withPrefix('ok').register(okFvSplitter());
|
|
265
|
+
export const fvSplitterTag = 'ok-fv-splitter';
|
|
266
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/fv/splitter/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,uBAAuB,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC7E,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;AAQtC;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,iBAAiB;IAwC7C;QACI,KAAK,EAAE,CAAC;QAxCZ,6CAA6C;QAE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E,iBAAiB,EAAE,CAAC;kDACG;AAInC;IADN,IAAI,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;gDACG;AAIjC;IADN,IAAI,CAAC,EAAE,SAAS,EAAE,uBAAuB,EAAE,CAAC;4CACxB;AAId;IADN,IAAI,CAAC,EAAE,SAAS,EAAE,uBAAuB,EAAE,CAAC;uCAC9B;AAIR;IADN,IAAI,CAAC,EAAE,SAAS,EAAE,uBAAuB,EAAE,CAAC;uCAC5B;AAIV;IADN,IAAI,CAAC,EAAE,SAAS,EAAE,uBAAuB,EAAE,CAAC;wCAC7B;AAIT;IADN,UAAU;4CACa;AAsP5B,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,CAAC;IACpC,QAAQ,EAAE,aAAa;IACvB,QAAQ;IACR,MAAM;IACN,aAAa,EAAE;QACX,cAAc,EAAE,KAAK;KACxB;CACJ,CAAC,CAAC;AAEH,YAAY,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC,CAAC;AACrE,MAAM,CAAC,MAAM,aAAa,GAAG,gBAAgB,CAAC","sourcesContent":["import { attr, nullableNumberConverter, observable } from '@ni/fast-element';\nimport { DesignSystem, FoundationElement } from '@ni/fast-foundation';\nimport { styles } from './styles';\nimport { template } from './template';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ok-fv-splitter': FvSplitter;\n }\n}\n\n/**\n * A vertical separator that enables pointer and keyboard resizing between two panes.\n */\nexport class FvSplitter extends FoundationElement {\n /** The accessible name for the separator. */\n @attr({ attribute: 'aria-label' })\n public override ariaLabel = 'Resize panes';\n\n /** Identifies the element that labels the separator. */\n @attr({ attribute: 'aria-labelledby' })\n public ariaLabelledby: string | undefined;\n\n /** Identifies the primary pane controlled by the separator. */\n @attr({ attribute: 'aria-controls' })\n public ariaControls: string | undefined;\n\n /** The splitter position as a percentage of the containing layout's width. */\n @attr({ converter: nullableNumberConverter })\n public position = 60;\n\n /** The minimum allowed position. */\n @attr({ converter: nullableNumberConverter })\n public min = 0;\n\n /** The maximum allowed position. */\n @attr({ converter: nullableNumberConverter })\n public max = 100;\n\n /** The percentage-point increment used for keyboard resizing. */\n @attr({ converter: nullableNumberConverter })\n public step = 1;\n\n /** @internal */\n @observable\n public resizing = false;\n\n private pointerId: number | undefined;\n private pointerStartPosition = 0;\n private requestedPosition = this.position;\n private applyingConstrainedPosition = false;\n private requestedPositionResetScheduled = false;\n private positionChangeCallbackVersion = 0;\n\n public constructor() {\n super();\n\n const positionDescriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(this), 'position');\n if (!positionDescriptor?.get || !positionDescriptor.set) {\n return;\n }\n\n const getPosition = positionDescriptor.get.bind(this) as () => number;\n const setPosition = positionDescriptor.set.bind(this) as (value: number) => void;\n Object.defineProperty(this, 'position', {\n configurable: true,\n enumerable: positionDescriptor.enumerable,\n get: getPosition,\n set: (value: number) => {\n const previousPosition = getPosition();\n const callbackVersion = this.positionChangeCallbackVersion;\n setPosition(value);\n if (!this.applyingConstrainedPosition\n && callbackVersion === this.positionChangeCallbackVersion\n && previousPosition === getPosition()) {\n this.requestedPosition = getPosition();\n }\n }\n });\n }\n\n /** @internal */\n public override connectedCallback(): void {\n super.connectedCallback();\n\n this.setAttribute('role', 'separator');\n this.setAttribute('aria-orientation', 'vertical');\n this.setAttribute('aria-label', this.ariaLabel);\n this.tabIndex = 0;\n this.addEventListener('keydown', this.keydownHandler);\n this.syncAriaValueAttributes();\n }\n\n /** @internal */\n public override disconnectedCallback(): void {\n this.removeEventListener('keydown', this.keydownHandler);\n super.disconnectedCallback();\n }\n\n /** @internal */\n public positionChanged(): void {\n this.positionChangeCallbackVersion += 1;\n if (!this.applyingConstrainedPosition) {\n this.requestedPosition = this.position;\n this.resetRequestedPositionAfterSynchronousUpdates();\n }\n this.applyConstrainedPosition();\n }\n\n /** @internal */\n public minChanged(): void {\n this.applyConstrainedPosition();\n }\n\n /** @internal */\n public maxChanged(): void {\n this.applyConstrainedPosition();\n }\n\n /** @internal */\n public resizingChanged(): void {\n this.toggleAttribute('resizing', this.resizing);\n }\n\n /** @internal */\n public handlePointerDown(event: PointerEvent): boolean {\n if (event.button !== 0 || !event.isPrimary || this.pointerId !== undefined) {\n return true;\n }\n\n event.preventDefault();\n const pointerTarget = event.currentTarget as HTMLElement;\n this.focus();\n this.pointerId = event.pointerId;\n this.pointerStartPosition = this.position;\n this.resizing = true;\n if (event.pointerId !== -1) {\n pointerTarget.setPointerCapture(event.pointerId);\n }\n return true;\n }\n\n /** @internal */\n public handlePointerMove(event: PointerEvent): boolean {\n if (event.pointerId !== this.pointerId) {\n return true;\n }\n\n const container = this.parentElement;\n if (!container) {\n return true;\n }\n\n const bounds = container.getBoundingClientRect();\n if (bounds.width > 0) {\n const distanceFromInlineStart = this.isRtl\n ? bounds.right - event.clientX\n : event.clientX - bounds.left;\n this.updatePosition((distanceFromInlineStart / bounds.width) * 100);\n }\n return true;\n }\n\n /** @internal */\n public handlePointerUp(event: PointerEvent): boolean {\n if (event.pointerId === this.pointerId) {\n this.finishResize();\n }\n return true;\n }\n\n /** @internal */\n public handlePointerCancel(event: PointerEvent): boolean {\n if (event.pointerId === this.pointerId) {\n this.updatePosition(this.pointerStartPosition);\n this.resizing = false;\n this.pointerId = undefined;\n }\n return true;\n }\n\n /** @internal */\n public handleKeyDown(event: KeyboardEvent): boolean {\n let nextPosition: number | undefined;\n const direction = this.isRtl ? -1 : 1;\n switch (event.key) {\n case 'ArrowLeft':\n nextPosition = this.position - direction * this.validStep;\n break;\n case 'ArrowRight':\n nextPosition = this.position + direction * this.validStep;\n break;\n case 'Home':\n nextPosition = this.validMin;\n break;\n case 'End':\n nextPosition = this.validMax;\n break;\n default:\n return true;\n }\n\n event.preventDefault();\n const previousPosition = this.position;\n this.updatePosition(nextPosition);\n if (this.position !== previousPosition) {\n this.dispatchEvent(new Event('change', { bubbles: true, composed: true }));\n }\n return true;\n }\n\n private get validMin(): number {\n return Number.isFinite(this.min) ? Math.min(100, Math.max(0, this.min)) : 0;\n }\n\n private get validMax(): number {\n const max = Number.isFinite(this.max) ? this.max : 100;\n return Math.max(this.validMin, Math.min(100, Math.max(0, max)));\n }\n\n private get validStep(): number {\n return Number.isFinite(this.step) && this.step > 0 ? this.step : 1;\n }\n\n private get isRtl(): boolean {\n return getComputedStyle(this).direction === 'rtl';\n }\n\n private readonly keydownHandler = (event: KeyboardEvent): void => {\n this.handleKeyDown(event);\n };\n\n private constrain(position: number): number {\n const finitePosition = Number.isFinite(position) ? position : 60;\n return Math.min(this.validMax, Math.max(this.validMin, finitePosition));\n }\n\n private updatePosition(position: number): void {\n const nextPosition = this.constrain(position);\n this.requestedPosition = nextPosition;\n if (nextPosition !== this.position) {\n this.position = nextPosition;\n this.dispatchEvent(new Event('input', { bubbles: true, composed: true }));\n }\n }\n\n private applyConstrainedPosition(): void {\n const constrainedPosition = this.constrain(this.requestedPosition);\n if (constrainedPosition !== this.position) {\n this.applyingConstrainedPosition = true;\n this.position = constrainedPosition;\n this.applyingConstrainedPosition = false;\n }\n this.syncAriaValueAttributesIfConnected();\n }\n\n private resetRequestedPositionAfterSynchronousUpdates(): void {\n if (this.requestedPositionResetScheduled) {\n return;\n }\n\n this.requestedPositionResetScheduled = true;\n queueMicrotask(() => {\n this.requestedPositionResetScheduled = false;\n this.requestedPosition = this.position;\n });\n }\n\n private finishResize(): void {\n const changed = this.position !== this.pointerStartPosition;\n this.resizing = false;\n this.pointerId = undefined;\n if (changed) {\n this.dispatchEvent(new Event('change', { bubbles: true, composed: true }));\n }\n }\n\n private syncAriaValueAttributesIfConnected(): void {\n if (this.$fastController.isConnected) {\n this.syncAriaValueAttributes();\n }\n }\n\n private syncAriaValueAttributes(): void {\n this.setAttribute('aria-valuemin', String(this.validMin));\n this.setAttribute('aria-valuemax', String(this.validMax));\n this.setAttribute('aria-valuenow', String(this.position));\n this.setAttribute('aria-valuetext', `${this.position} percent`);\n }\n}\n\nconst okFvSplitter = FvSplitter.compose({\n baseName: 'fv-splitter',\n template,\n styles,\n shadowOptions: {\n delegatesFocus: false\n }\n});\n\nDesignSystem.getOrCreate().withPrefix('ok').register(okFvSplitter());\nexport const fvSplitterTag = 'ok-fv-splitter';"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const styles: import("@ni/fast-element").ElementStyles;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { css } from '@ni/fast-element';
|
|
2
|
+
import { borderHoverColor, dividerBackgroundDynamicColor } 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, active;
|
|
6
|
+
|
|
7
|
+
@layer base {
|
|
8
|
+
${display('block')}
|
|
9
|
+
|
|
10
|
+
:host {
|
|
11
|
+
position: relative;
|
|
12
|
+
flex: 0 0 2px;
|
|
13
|
+
width: 2px;
|
|
14
|
+
height: 100%;
|
|
15
|
+
min-height: 0;
|
|
16
|
+
background: ${dividerBackgroundDynamicColor};
|
|
17
|
+
outline: none;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.splitter {
|
|
21
|
+
position: absolute;
|
|
22
|
+
inset: 0 -8px 0 -2px;
|
|
23
|
+
cursor: col-resize;
|
|
24
|
+
touch-action: none;
|
|
25
|
+
user-select: none;
|
|
26
|
+
-webkit-user-select: none;
|
|
27
|
+
outline: none;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@layer hover {
|
|
32
|
+
:host(:hover) {
|
|
33
|
+
background: ${borderHoverColor};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@layer focusVisible {
|
|
38
|
+
:host(:focus),
|
|
39
|
+
:host(:focus-visible) {
|
|
40
|
+
outline: none;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
:host(:focus-visible)::before {
|
|
44
|
+
content: '';
|
|
45
|
+
position: absolute;
|
|
46
|
+
z-index: 1;
|
|
47
|
+
inset-block: 0;
|
|
48
|
+
left: 1px;
|
|
49
|
+
width: 3px;
|
|
50
|
+
transform: translateX(-50%);
|
|
51
|
+
background: ${borderHoverColor};
|
|
52
|
+
pointer-events: none;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@layer active {
|
|
57
|
+
:host([resizing]) {
|
|
58
|
+
background: ${borderHoverColor};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
`;
|
|
62
|
+
//# sourceMappingURL=styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../../src/fv/splitter/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EACH,gBAAgB,EAChB,6BAA6B,EAChC,MAAM,6DAA6D,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAExD,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;UAIf,OAAO,CAAC,OAAO,CAAC;;;;;;;;0BAQA,6BAA6B;;;;;;;;;;;;;;;;;0BAiB7B,gBAAgB;;;;;;;;;;;;;;;;;;0BAkBhB,gBAAgB;;;;;;;0BAOhB,gBAAgB;;;CAGzC,CAAC","sourcesContent":["import { css } from '@ni/fast-element';\nimport {\n borderHoverColor,\n dividerBackgroundDynamicColor\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, active;\n\n @layer base {\n ${display('block')}\n\n :host {\n position: relative;\n flex: 0 0 2px;\n width: 2px;\n height: 100%;\n min-height: 0;\n background: ${dividerBackgroundDynamicColor};\n outline: none;\n }\n\n .splitter {\n position: absolute;\n inset: 0 -8px 0 -2px;\n cursor: col-resize;\n touch-action: none;\n user-select: none;\n -webkit-user-select: none;\n outline: none;\n }\n }\n\n @layer hover {\n :host(:hover) {\n background: ${borderHoverColor};\n }\n }\n\n @layer focusVisible {\n :host(:focus),\n :host(:focus-visible) {\n outline: none;\n }\n\n :host(:focus-visible)::before {\n content: '';\n position: absolute;\n z-index: 1;\n inset-block: 0;\n left: 1px;\n width: 3px;\n transform: translateX(-50%);\n background: ${borderHoverColor};\n pointer-events: none;\n }\n }\n\n @layer active {\n :host([resizing]) {\n background: ${borderHoverColor};\n }\n }\n`;"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { html } from '@ni/fast-element';
|
|
2
|
+
export const template = html `
|
|
3
|
+
<div
|
|
4
|
+
class="splitter"
|
|
5
|
+
@pointerdown="${(x, c) => x.handlePointerDown(c.event)}"
|
|
6
|
+
@pointermove="${(x, c) => x.handlePointerMove(c.event)}"
|
|
7
|
+
@pointerup="${(x, c) => x.handlePointerUp(c.event)}"
|
|
8
|
+
@pointercancel="${(x, c) => x.handlePointerCancel(c.event)}"
|
|
9
|
+
@lostpointercapture="${(x, c) => x.handlePointerCancel(c.event)}"
|
|
10
|
+
></div>
|
|
11
|
+
`;
|
|
12
|
+
//# sourceMappingURL=template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../../../src/fv/splitter/template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAGxC,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,CAAY;;;wBAGhB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,KAAqB,CAAC;wBACtD,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,KAAqB,CAAC;sBACxD,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,KAAqB,CAAC;0BAChD,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,KAAqB,CAAC;+BACnD,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,KAAqB,CAAC;;CAEtF,CAAC","sourcesContent":["import { html } from '@ni/fast-element';\nimport type { FvSplitter } from '.';\n\nexport const template = html<FvSplitter>`\n <div\n class=\"splitter\"\n @pointerdown=\"${(x, c) => x.handlePointerDown(c.event as PointerEvent)}\"\n @pointermove=\"${(x, c) => x.handlePointerMove(c.event as PointerEvent)}\"\n @pointerup=\"${(x, c) => x.handlePointerUp(c.event as PointerEvent)}\"\n @pointercancel=\"${(x, c) => x.handlePointerCancel(c.event as PointerEvent)}\"\n @lostpointercapture=\"${(x, c) => x.handlePointerCancel(c.event as PointerEvent)}\"\n ></div>\n`;"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ni/ok-components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "NI Ok Components",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "npm run build:components && npm run build:cem",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"@ni/fast-element": "^10.1.2",
|
|
44
44
|
"@ni/fast-foundation": "^10.2.5",
|
|
45
45
|
"@ni/fast-web-utilities": "^10.0.0",
|
|
46
|
-
"@ni/nimble-components": "^35.13.
|
|
47
|
-
"@ni/spright-components": "^6.22.
|
|
46
|
+
"@ni/nimble-components": "^35.13.1",
|
|
47
|
+
"@ni/spright-components": "^6.22.1",
|
|
48
48
|
"tslib": "^2.2.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@custom-elements-manifest/to-markdown": "^0.1.0",
|
|
53
53
|
"@ni-private/eslint-config-nimble": "*",
|
|
54
54
|
"@ni-private/jasmine-extensions": "^0.0.1",
|
|
55
|
-
"@ni/jasmine-parameterized": "^1.0.
|
|
55
|
+
"@ni/jasmine-parameterized": "^1.0.11",
|
|
56
56
|
"@rollup/plugin-commonjs": "^29.0.0",
|
|
57
57
|
"@rollup/plugin-node-resolve": "^16.0.0",
|
|
58
58
|
"@rollup/plugin-replace": "^6.0.0",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"karma-spec-reporter": "^0.0.36",
|
|
69
69
|
"karma-vite": "^1.0.5",
|
|
70
70
|
"karma-webkit-launcher": "^2.6.0",
|
|
71
|
-
"playwright": "1.
|
|
71
|
+
"playwright": "1.62.0",
|
|
72
72
|
"rollup": "^4.60.2",
|
|
73
73
|
"rollup-plugin-sourcemaps2": "^0.5.0",
|
|
74
74
|
"typescript": "~5.8.3"
|