@ni/nimble-components 35.11.0 → 35.12.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.
- package/dist/all-components-bundle.js +5215 -2968
- package/dist/all-components-bundle.js.map +1 -1
- package/dist/all-components-bundle.min.js +3857 -3538
- package/dist/all-components-bundle.min.js.map +1 -1
- package/dist/custom-elements.json +83 -83
- package/dist/custom-elements.md +24 -24
- package/dist/esm/combobox/styles.js +7 -0
- package/dist/esm/combobox/styles.js.map +1 -1
- package/dist/esm/number-field/styles.js +8 -0
- package/dist/esm/number-field/styles.js.map +1 -1
- package/dist/esm/rich-text/editor/models/create-tiptap-editor.js +16 -2
- package/dist/esm/rich-text/editor/models/create-tiptap-editor.js.map +1 -1
- package/dist/esm/text-area/styles.js +4 -1
- package/dist/esm/text-area/styles.js.map +1 -1
- package/dist/esm/text-field/styles.js +3 -0
- package/dist/esm/text-field/styles.js.map +1 -1
- package/package.json +13 -13
|
@@ -392,6 +392,89 @@
|
|
|
392
392
|
}
|
|
393
393
|
]
|
|
394
394
|
},
|
|
395
|
+
{
|
|
396
|
+
"kind": "javascript-module",
|
|
397
|
+
"path": "src/anchor-tab/index.ts",
|
|
398
|
+
"declarations": [
|
|
399
|
+
{
|
|
400
|
+
"kind": "class",
|
|
401
|
+
"description": "A nimble-styled link tab",
|
|
402
|
+
"name": "AnchorTab",
|
|
403
|
+
"members": [
|
|
404
|
+
{
|
|
405
|
+
"kind": "field",
|
|
406
|
+
"name": "disabled",
|
|
407
|
+
"type": {
|
|
408
|
+
"text": "boolean"
|
|
409
|
+
},
|
|
410
|
+
"privacy": "public",
|
|
411
|
+
"default": "false",
|
|
412
|
+
"description": "When true, the control will be immutable by user interaction. See https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled | disabled HTML attribute for more information."
|
|
413
|
+
},
|
|
414
|
+
{
|
|
415
|
+
"kind": "field",
|
|
416
|
+
"name": "ariaSelected",
|
|
417
|
+
"type": {
|
|
418
|
+
"text": "string"
|
|
419
|
+
},
|
|
420
|
+
"privacy": "public",
|
|
421
|
+
"default": "'false'",
|
|
422
|
+
"description": "Indicates the current \"selected\" state of various widgets.\nhttps://www.w3.org/TR/wai-aria-1.1/#aria-selected"
|
|
423
|
+
}
|
|
424
|
+
],
|
|
425
|
+
"attributes": [
|
|
426
|
+
{
|
|
427
|
+
"name": "disabled",
|
|
428
|
+
"type": {
|
|
429
|
+
"text": "boolean"
|
|
430
|
+
},
|
|
431
|
+
"default": "false",
|
|
432
|
+
"description": "When true, the control will be immutable by user interaction. See https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled | disabled HTML attribute for more information.",
|
|
433
|
+
"fieldName": "disabled"
|
|
434
|
+
},
|
|
435
|
+
{
|
|
436
|
+
"name": "aria-selected",
|
|
437
|
+
"type": {
|
|
438
|
+
"text": "string"
|
|
439
|
+
},
|
|
440
|
+
"default": "'false'",
|
|
441
|
+
"description": "Indicates the current \"selected\" state of various widgets.\nhttps://www.w3.org/TR/wai-aria-1.1/#aria-selected",
|
|
442
|
+
"fieldName": "ariaSelected"
|
|
443
|
+
}
|
|
444
|
+
],
|
|
445
|
+
"superclass": {
|
|
446
|
+
"name": "AnchorBase",
|
|
447
|
+
"module": "/src/anchor-base"
|
|
448
|
+
}
|
|
449
|
+
},
|
|
450
|
+
{
|
|
451
|
+
"kind": "variable",
|
|
452
|
+
"name": "anchorTabTag",
|
|
453
|
+
"type": {
|
|
454
|
+
"text": "string"
|
|
455
|
+
},
|
|
456
|
+
"default": "'nimble-anchor-tab'"
|
|
457
|
+
}
|
|
458
|
+
],
|
|
459
|
+
"exports": [
|
|
460
|
+
{
|
|
461
|
+
"kind": "js",
|
|
462
|
+
"name": "AnchorTab",
|
|
463
|
+
"declaration": {
|
|
464
|
+
"name": "AnchorTab",
|
|
465
|
+
"module": "src/anchor-tab/index.ts"
|
|
466
|
+
}
|
|
467
|
+
},
|
|
468
|
+
{
|
|
469
|
+
"kind": "js",
|
|
470
|
+
"name": "anchorTabTag",
|
|
471
|
+
"declaration": {
|
|
472
|
+
"name": "anchorTabTag",
|
|
473
|
+
"module": "src/anchor-tab/index.ts"
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
]
|
|
477
|
+
},
|
|
395
478
|
{
|
|
396
479
|
"kind": "javascript-module",
|
|
397
480
|
"path": "src/anchor-step/index.ts",
|
|
@@ -576,89 +659,6 @@
|
|
|
576
659
|
}
|
|
577
660
|
]
|
|
578
661
|
},
|
|
579
|
-
{
|
|
580
|
-
"kind": "javascript-module",
|
|
581
|
-
"path": "src/anchor-tab/index.ts",
|
|
582
|
-
"declarations": [
|
|
583
|
-
{
|
|
584
|
-
"kind": "class",
|
|
585
|
-
"description": "A nimble-styled link tab",
|
|
586
|
-
"name": "AnchorTab",
|
|
587
|
-
"members": [
|
|
588
|
-
{
|
|
589
|
-
"kind": "field",
|
|
590
|
-
"name": "disabled",
|
|
591
|
-
"type": {
|
|
592
|
-
"text": "boolean"
|
|
593
|
-
},
|
|
594
|
-
"privacy": "public",
|
|
595
|
-
"default": "false",
|
|
596
|
-
"description": "When true, the control will be immutable by user interaction. See https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled | disabled HTML attribute for more information."
|
|
597
|
-
},
|
|
598
|
-
{
|
|
599
|
-
"kind": "field",
|
|
600
|
-
"name": "ariaSelected",
|
|
601
|
-
"type": {
|
|
602
|
-
"text": "string"
|
|
603
|
-
},
|
|
604
|
-
"privacy": "public",
|
|
605
|
-
"default": "'false'",
|
|
606
|
-
"description": "Indicates the current \"selected\" state of various widgets.\nhttps://www.w3.org/TR/wai-aria-1.1/#aria-selected"
|
|
607
|
-
}
|
|
608
|
-
],
|
|
609
|
-
"attributes": [
|
|
610
|
-
{
|
|
611
|
-
"name": "disabled",
|
|
612
|
-
"type": {
|
|
613
|
-
"text": "boolean"
|
|
614
|
-
},
|
|
615
|
-
"default": "false",
|
|
616
|
-
"description": "When true, the control will be immutable by user interaction. See https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled | disabled HTML attribute for more information.",
|
|
617
|
-
"fieldName": "disabled"
|
|
618
|
-
},
|
|
619
|
-
{
|
|
620
|
-
"name": "aria-selected",
|
|
621
|
-
"type": {
|
|
622
|
-
"text": "string"
|
|
623
|
-
},
|
|
624
|
-
"default": "'false'",
|
|
625
|
-
"description": "Indicates the current \"selected\" state of various widgets.\nhttps://www.w3.org/TR/wai-aria-1.1/#aria-selected",
|
|
626
|
-
"fieldName": "ariaSelected"
|
|
627
|
-
}
|
|
628
|
-
],
|
|
629
|
-
"superclass": {
|
|
630
|
-
"name": "AnchorBase",
|
|
631
|
-
"module": "/src/anchor-base"
|
|
632
|
-
}
|
|
633
|
-
},
|
|
634
|
-
{
|
|
635
|
-
"kind": "variable",
|
|
636
|
-
"name": "anchorTabTag",
|
|
637
|
-
"type": {
|
|
638
|
-
"text": "string"
|
|
639
|
-
},
|
|
640
|
-
"default": "'nimble-anchor-tab'"
|
|
641
|
-
}
|
|
642
|
-
],
|
|
643
|
-
"exports": [
|
|
644
|
-
{
|
|
645
|
-
"kind": "js",
|
|
646
|
-
"name": "AnchorTab",
|
|
647
|
-
"declaration": {
|
|
648
|
-
"name": "AnchorTab",
|
|
649
|
-
"module": "src/anchor-tab/index.ts"
|
|
650
|
-
}
|
|
651
|
-
},
|
|
652
|
-
{
|
|
653
|
-
"kind": "js",
|
|
654
|
-
"name": "anchorTabTag",
|
|
655
|
-
"declaration": {
|
|
656
|
-
"name": "anchorTabTag",
|
|
657
|
-
"module": "src/anchor-tab/index.ts"
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
]
|
|
661
|
-
},
|
|
662
662
|
{
|
|
663
663
|
"kind": "javascript-module",
|
|
664
664
|
"path": "src/anchor-tabs/index.ts",
|
package/dist/custom-elements.md
CHANGED
|
@@ -93,6 +93,30 @@
|
|
|
93
93
|
|
|
94
94
|
<hr/>
|
|
95
95
|
|
|
96
|
+
## class: `AnchorTab`
|
|
97
|
+
|
|
98
|
+
### Superclass
|
|
99
|
+
|
|
100
|
+
| Name | Module | Package |
|
|
101
|
+
| ------------ | ---------------- | ------- |
|
|
102
|
+
| `AnchorBase` | /src/anchor-base | |
|
|
103
|
+
|
|
104
|
+
### Fields
|
|
105
|
+
|
|
106
|
+
| Name | Privacy | Type | Default | Description | Inherited From |
|
|
107
|
+
| -------------- | ------- | --------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------- |
|
|
108
|
+
| `disabled` | public | `boolean` | `false` | When true, the control will be immutable by user interaction. See https\://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled \| disabled HTML attribute for more information. | |
|
|
109
|
+
| `ariaSelected` | public | `string` | `'false'` | Indicates the current "selected" state of various widgets.
https\://www\.w3.org/TR/wai-aria-1.1/#aria-selected | |
|
|
110
|
+
|
|
111
|
+
### Attributes
|
|
112
|
+
|
|
113
|
+
| Name | Field | Inherited From |
|
|
114
|
+
| --------------- | ------------ | -------------- |
|
|
115
|
+
| `disabled` | disabled | |
|
|
116
|
+
| `aria-selected` | ariaSelected | |
|
|
117
|
+
|
|
118
|
+
<hr/>
|
|
119
|
+
|
|
96
120
|
## class: `AnchorStep`
|
|
97
121
|
|
|
98
122
|
### Superclass
|
|
@@ -125,30 +149,6 @@
|
|
|
125
149
|
|
|
126
150
|
<hr/>
|
|
127
151
|
|
|
128
|
-
## class: `AnchorTab`
|
|
129
|
-
|
|
130
|
-
### Superclass
|
|
131
|
-
|
|
132
|
-
| Name | Module | Package |
|
|
133
|
-
| ------------ | ---------------- | ------- |
|
|
134
|
-
| `AnchorBase` | /src/anchor-base | |
|
|
135
|
-
|
|
136
|
-
### Fields
|
|
137
|
-
|
|
138
|
-
| Name | Privacy | Type | Default | Description | Inherited From |
|
|
139
|
-
| -------------- | ------- | --------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------- |
|
|
140
|
-
| `disabled` | public | `boolean` | `false` | When true, the control will be immutable by user interaction. See https\://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled \| disabled HTML attribute for more information. | |
|
|
141
|
-
| `ariaSelected` | public | `string` | `'false'` | Indicates the current "selected" state of various widgets.
https\://www\.w3.org/TR/wai-aria-1.1/#aria-selected | |
|
|
142
|
-
|
|
143
|
-
### Attributes
|
|
144
|
-
|
|
145
|
-
| Name | Field | Inherited From |
|
|
146
|
-
| --------------- | ------------ | -------------- |
|
|
147
|
-
| `disabled` | disabled | |
|
|
148
|
-
| `aria-selected` | ariaSelected | |
|
|
149
|
-
|
|
150
|
-
<hr/>
|
|
151
|
-
|
|
152
152
|
## class: `AnchorTabs`
|
|
153
153
|
|
|
154
154
|
### Superclass
|
|
@@ -12,6 +12,7 @@ export const styles = css `
|
|
|
12
12
|
${requiredVisibleStyles}
|
|
13
13
|
|
|
14
14
|
:host {
|
|
15
|
+
field-sizing: fixed;
|
|
15
16
|
--ni-private-hover-bottom-border-width: 2px;
|
|
16
17
|
--ni-private-bottom-border-width: 1px;
|
|
17
18
|
--ni-private-height-within-border: calc(
|
|
@@ -20,6 +21,7 @@ export const styles = css `
|
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
.control {
|
|
24
|
+
field-sizing: inherit;
|
|
23
25
|
bottom-border-width: var(--ni-private-bottom-border-width);
|
|
24
26
|
}
|
|
25
27
|
|
|
@@ -27,7 +29,12 @@ export const styles = css `
|
|
|
27
29
|
border-bottom-color: ${borderHoverColor};
|
|
28
30
|
}
|
|
29
31
|
|
|
32
|
+
slot[name='control'] {
|
|
33
|
+
field-sizing: inherit;
|
|
34
|
+
}
|
|
35
|
+
|
|
30
36
|
.selected-value {
|
|
37
|
+
field-sizing: inherit;
|
|
31
38
|
-webkit-appearance: none;
|
|
32
39
|
background: transparent;
|
|
33
40
|
border: none;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/combobox/styles.ts"],"names":[],"mappings":"AAAA,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M,MAAM,GAAG,GAAG,CAAA;MACnB,cAAc;MACd,WAAW;MACX,qBAAqB;;;;;;;cAOb,aAAa,UAAU,WAAW;;;;;;;;;;+BAUjB,gBAAgB;;;;;;;;;;;;;;;;;;;;;;qBAsB1B,YAAY;;;;;iBAKhB,oBAAoB;;;;iBAIpB,qBAAqB;;;;iBAIrB,oBAAoB;;;;;;;;;;yBAUZ,YAAY;;;;;;;;;;uCAUE,qBAAqB;uBACrC,aAAa;;;;;;UAM1B,aAAa,CAAC,iBAAiB;uBAClB,YAAY;;;;gBAInB,qBAAqB;;CAEpC,CAAC,aAAa,CACX,kBAAkB,CACd,kBAAkB,CAAC,KAAK,EACxB,GAAG,CAAA;;uCAE4B,WAAW;;;SAGzC,CACJ,CACJ,CAAC","sourcesContent":["import { css } from '@ni/fast-element';\nimport {\n controlHeight,\n bodyDisabledFontColor,\n borderRgbPartialColor,\n smallPadding,\n borderHoverColor,\n borderWidth,\n placeholderFontColor\n} from '../theme-provider/design-tokens';\n\nimport { styles as dropdownStyles } from '../patterns/dropdown/styles';\nimport { styles as errorStyles } from '../patterns/error/styles';\nimport { styles as requiredVisibleStyles } from '../patterns/required-visible/styles';\nimport { focusVisible } from '../utilities/style/focus';\nimport { appearanceBehavior } from '../utilities/style/appearance';\nimport { DropdownAppearance } from '../select/types';\n\nexport const styles = css`\n ${dropdownStyles}\n ${errorStyles}\n ${requiredVisibleStyles}\n\n :host {\n field-sizing: fixed;\n --ni-private-hover-bottom-border-width: 2px;\n --ni-private-bottom-border-width: 1px;\n --ni-private-height-within-border: calc(\n ${controlHeight} - 2 * ${borderWidth}\n );\n }\n\n .control {\n field-sizing: inherit;\n bottom-border-width: var(--ni-private-bottom-border-width);\n }\n\n .control:focus-within {\n border-bottom-color: ${borderHoverColor};\n }\n\n slot[name='control'] {\n field-sizing: inherit;\n }\n\n .selected-value {\n field-sizing: inherit;\n -webkit-appearance: none;\n background: transparent;\n border: none;\n color: inherit;\n margin: auto 0;\n width: 100%;\n font: inherit;\n height: var(--ni-private-height-within-border);\n }\n\n .selected-value:hover,\n .selected-value:disabled,\n .selected-value:active,\n .selected-value${focusVisible} {\n outline: none;\n }\n\n .selected-value::placeholder {\n color: ${placeholderFontColor};\n }\n\n :host([disabled]) .selected-value::placeholder {\n color: ${bodyDisabledFontColor};\n }\n\n :host([disabled][appearance-readonly]) .selected-value::placeholder {\n color: ${placeholderFontColor};\n }\n\n [part='indicator'] {\n display: none;\n }\n\n .end-slot-container {\n display: flex;\n align-items: baseline;\n padding-right: ${smallPadding};\n }\n\n :host([disabled][appearance-readonly]) .end-slot-container {\n display: none;\n }\n\n .separator {\n display: inline;\n width: 2px;\n border-right: 2px solid rgba(${borderRgbPartialColor}, 0.15);\n height: calc(${controlHeight} - 12px);\n align-self: center;\n margin-left: 4px;\n }\n\n .dropdown-button {\n ${controlHeight.cssCustomProperty}: 24px;\n margin-left: ${smallPadding};\n }\n\n :host([disabled]) .dropdown-icon {\n fill: ${bodyDisabledFontColor};\n }\n`.withBehaviors(\n appearanceBehavior(\n DropdownAppearance.block,\n css`\n :host([error-visible]) .control {\n border-bottom-width: ${borderWidth};\n padding-bottom: 0;\n }\n `\n )\n);\n"]}
|
|
@@ -16,6 +16,7 @@ export const styles = css `
|
|
|
16
16
|
outline: none;
|
|
17
17
|
${userSelectNone}
|
|
18
18
|
color: ${bodyFontColor};
|
|
19
|
+
field-sizing: fixed;
|
|
19
20
|
--ni-private-hover-indicator-width: calc(${borderWidth} + 1px);
|
|
20
21
|
--ni-private-height-within-border: calc(
|
|
21
22
|
${controlHeight} - 2 * ${borderWidth}
|
|
@@ -48,6 +49,7 @@ export const styles = css `
|
|
|
48
49
|
position: relative;
|
|
49
50
|
display: flex;
|
|
50
51
|
flex-direction: row;
|
|
52
|
+
field-sizing: inherit;
|
|
51
53
|
justify-content: center;
|
|
52
54
|
align-items: center;
|
|
53
55
|
border-radius: 0px;
|
|
@@ -115,12 +117,17 @@ export const styles = css `
|
|
|
115
117
|
font: inherit;
|
|
116
118
|
background: transparent;
|
|
117
119
|
color: inherit;
|
|
120
|
+
field-sizing: inherit;
|
|
118
121
|
height: var(--ni-private-height-within-border);
|
|
119
122
|
width: 100%;
|
|
120
123
|
border: none;
|
|
121
124
|
padding: 0px;
|
|
122
125
|
padding-left: ${mediumPadding};
|
|
123
126
|
}
|
|
127
|
+
|
|
128
|
+
:host([hide-step]) .control {
|
|
129
|
+
padding-right: ${smallPadding};
|
|
130
|
+
}
|
|
124
131
|
|
|
125
132
|
.control:hover,
|
|
126
133
|
.control:focus,
|
|
@@ -218,6 +225,7 @@ export const styles = css `
|
|
|
218
225
|
|
|
219
226
|
:host([full-bleed]) .control {
|
|
220
227
|
padding-left: 0px;
|
|
228
|
+
padding-right: 0px;
|
|
221
229
|
}
|
|
222
230
|
`));
|
|
223
231
|
//# sourceMappingURL=styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/number-field/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EACH,qBAAqB,EACrB,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,qBAAqB,EACrB,aAAa,EACb,gBAAgB,EAChB,qBAAqB,EACrB,UAAU,EACV,QAAQ,EACR,SAAS,EACT,aAAa,EACb,YAAY,EACZ,6BAA6B,EAChC,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,MAAM,IAAI,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAEhE,MA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CAA0C,EAAE;;;;UAI5C,cAAc;;;;;;4BAMI,WAAW;;;yBAGd,gBAAgB;;4BAEb,UAAU;;;;;;;;;;+BAUP,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;wBA0BhB,aAAa;;;;yBAIZ,YAAY;;;;;;;;;;;;;;;iBAepB,qBAAqB;;;;iBAIrB,qBAAqB;;;;iBAIrB,qBAAqB;;;;;;;MAOhC;AACE;sFACsF,CAAC,EAC3F;;;yBAGqB,YAAY;;;;;;;;UAQ3B,aAAa,CAAC,iBAAiB;;;;;;;;;wBASjB,YAAY;;CAEnC,CAAC,aAAa,CACX,kBAAkB,CACd,qBAAqB,CAAC,SAAS,EAC/B,GAAG,CAAA;;uCAE4B,WAAW;;;SAGzC,CACJ,EACD,kBAAkB,CACd,qBAAqB,CAAC,KAAK,EAC3B,GAAG,CAAA;;yCAE8B,qBAAqB;;;;;uCAKvB,WAAW;;;;;uCAKX,WAAW;;;;;;yCAMT,qBAAqB;;;;;;;uCAOvB,SAAS;;SAEvC,CACJ,EACD,kBAAkB,CACd,qBAAqB,CAAC,OAAO,EAC7B,GAAG,CAAA;;gCAEqB,WAAW;;;SAGlC,CACJ,EACD,kBAAkB,CACd,qBAAqB,CAAC,SAAS,EAC/B,GAAG,CAAA;;gCAEqB,WAAW;iCACV,WAAW;;;;;;;SAOnC,CACJ,CACJ,CAAC","sourcesContent":["import { css } from '@ni/fast-element';\nimport { display } from '../utilities/style/display';\nimport {\n borderRgbPartialColor,\n borderHoverColor,\n borderWidth,\n bodyFontColor,\n bodyDisabledFontColor,\n controlHeight,\n controlLabelFont,\n controlLabelFontColor,\n smallDelay,\n bodyFont,\n failColor,\n mediumPadding,\n smallPadding,\n controlLabelDisabledFontColor\n} from '../theme-provider/design-tokens';\nimport { appearanceBehavior } from '../utilities/style/appearance';\nimport { NumberFieldAppearance } from './types';\nimport { styles as errorStyles } from '../patterns/error/styles';\nimport { styles as requiredVisibleStyles } from '../patterns/required-visible/styles';\nimport { userSelectNone } from '../utilities/style/user-select';\n\nexport const styles = css`\n ${display('inline-block')}\n ${errorStyles}\n ${requiredVisibleStyles}\n\n :host {\n font: ${bodyFont};\n outline: none;\n ${userSelectNone}\n color: ${bodyFontColor};\n field-sizing: fixed;\n --ni-private-hover-indicator-width: calc(${borderWidth} + 1px);\n --ni-private-height-within-border: calc(\n ${controlHeight} - 2 * ${borderWidth}\n );\n }\n\n :host([disabled]) {\n color: ${bodyDisabledFontColor};\n }\n\n :host([disabled][appearance-readonly]) {\n color: ${bodyFontColor};\n }\n\n .label {\n display: flex;\n color: ${controlLabelFontColor};\n font: ${controlLabelFont};\n }\n\n :host([disabled]) .label {\n color: ${controlLabelDisabledFontColor};\n }\n\n :host([disabled][appearance-readonly]) .label {\n color: ${controlLabelFontColor};\n }\n\n .root {\n position: relative;\n display: flex;\n flex-direction: row;\n field-sizing: inherit;\n justify-content: center;\n align-items: center;\n border-radius: 0px;\n border: 0px solid rgba(${borderRgbPartialColor}, 0.3);\n padding: ${borderWidth};\n }\n\n .root:focus-within {\n border-bottom-color: ${borderHoverColor};\n }\n\n :host([readonly]) .root,\n :host([disabled]) .root {\n border-color: rgba(${borderRgbPartialColor}, 0.1);\n }\n\n :host([error-visible]) .root {\n border-bottom-color: ${failColor};\n }\n\n .root::before {\n ${/* Empty string causes alignment issue */ ''}\n content: ' ';\n color: transparent;\n width: 0px;\n ${userSelectNone}\n }\n\n .root::after {\n content: '';\n position: absolute;\n bottom: calc(-1 * ${borderWidth});\n width: 0px;\n height: 0px;\n border-bottom: ${borderHoverColor}\n var(--ni-private-hover-indicator-width) solid;\n transition: width ${smallDelay} ease-in;\n }\n\n @media (prefers-reduced-motion) {\n .root::after {\n transition-duration: 0s;\n }\n }\n\n :host([error-visible]) .root::after {\n border-bottom-color: ${failColor};\n }\n\n :host(:hover) .root::after {\n width: 100%;\n }\n\n :host([readonly]:hover) .root::after,\n :host([disabled]:hover) .root::after {\n width: 0px;\n }\n\n [part='start'] {\n display: none;\n }\n\n .control {\n -webkit-appearance: none;\n font: inherit;\n background: transparent;\n color: inherit;\n field-sizing: inherit;\n height: var(--ni-private-height-within-border);\n width: 100%;\n border: none;\n padding: 0px;\n padding-left: ${mediumPadding};\n }\n \n :host([hide-step]) .control {\n padding-right: ${smallPadding};\n }\n\n .control:hover,\n .control:focus,\n .control:disabled,\n .control:active {\n outline: none;\n }\n\n :host([disabled][appearance-readonly]) .control {\n cursor: text;\n }\n\n .control::placeholder {\n color: ${controlLabelFontColor};\n }\n\n :host([disabled]) .control::placeholder {\n color: ${bodyDisabledFontColor};\n }\n\n :host([disabled][appearance-readonly]) .control::placeholder {\n color: ${controlLabelFontColor};\n }\n\n .controls {\n display: contents;\n }\n\n ${\n /* We are using flex `order` to define the visual ordering of the inc/dec buttons\n and the invalid icon because they are not \"interactive\" i.e. part of the tab order */ ''\n }\n .step-up {\n order: 3;\n padding-right: ${smallPadding};\n }\n\n .step-down {\n order: 2;\n }\n\n .step-up-down-button {\n ${controlHeight.cssCustomProperty}: 24px;\n }\n\n [part='end'] {\n display: contents;\n }\n\n .error-icon {\n order: 1;\n margin-right: ${smallPadding};\n }\n`.withBehaviors(\n appearanceBehavior(\n NumberFieldAppearance.underline,\n css`\n .root {\n border-bottom-width: ${borderWidth};\n padding-bottom: 0;\n }\n `\n ),\n appearanceBehavior(\n NumberFieldAppearance.block,\n css`\n .root {\n background-color: rgba(${borderRgbPartialColor}, 0.1);\n }\n\n .root:focus-within,\n :host([error-visible]) .root {\n border-bottom-width: ${borderWidth};\n padding-bottom: 0;\n }\n\n :host(:hover) .root {\n border-bottom-width: ${borderWidth};\n padding-bottom: 0;\n }\n\n :host([readonly]) .root,\n :host([disabled]) .root {\n background-color: rgba(${borderRgbPartialColor}, 0.07);\n border-color: transparent;\n }\n\n :host([error-visible][readonly]) .root,\n :host([error-visible][disabled]) .root {\n padding-bottom: 0;\n border-bottom-color: ${failColor};\n }\n `\n ),\n appearanceBehavior(\n NumberFieldAppearance.outline,\n css`\n .root {\n border-width: ${borderWidth};\n padding: 0;\n }\n `\n ),\n appearanceBehavior(\n NumberFieldAppearance.frameless,\n css`\n .root {\n padding-left: ${borderWidth};\n padding-right: ${borderWidth};\n }\n\n :host([full-bleed]) .control {\n padding-left: 0px;\n padding-right: 0px;\n }\n `\n )\n);\n"]}
|
|
@@ -188,6 +188,18 @@ function createCustomMentionExtension(config, activeMentionCharacterEmitter, act
|
|
|
188
188
|
allowSpaces: true,
|
|
189
189
|
render: () => {
|
|
190
190
|
let inSuggestionMode = false;
|
|
191
|
+
// Tracks the query for which a `mention-update` event was last emitted.
|
|
192
|
+
// The tiptap suggestion plugin invokes `onStart`/`onUpdate` multiple times
|
|
193
|
+
// for a single query change (e.g. an initial render plus loading and resolved
|
|
194
|
+
// states of its async item fetch). We only want to emit `mention-update` once
|
|
195
|
+
// per distinct query, so we deduplicate against the last emitted query.
|
|
196
|
+
let lastEmittedQuery;
|
|
197
|
+
const emitMentionUpdateIfQueryChanged = (query) => {
|
|
198
|
+
if (query !== lastEmittedQuery) {
|
|
199
|
+
lastEmittedQuery = query;
|
|
200
|
+
config.mentionUpdateEmitter(query);
|
|
201
|
+
}
|
|
202
|
+
};
|
|
191
203
|
return {
|
|
192
204
|
onStart: (props) => {
|
|
193
205
|
/**
|
|
@@ -200,7 +212,7 @@ function createCustomMentionExtension(config, activeMentionCharacterEmitter, act
|
|
|
200
212
|
return;
|
|
201
213
|
}
|
|
202
214
|
inSuggestionMode = true;
|
|
203
|
-
|
|
215
|
+
emitMentionUpdateIfQueryChanged(props.query);
|
|
204
216
|
activeMentionCharacterEmitter(props.text.slice(0, 1));
|
|
205
217
|
activeMentionCommandEmitter(props.command);
|
|
206
218
|
mentionListbox?.show({
|
|
@@ -212,7 +224,7 @@ function createCustomMentionExtension(config, activeMentionCharacterEmitter, act
|
|
|
212
224
|
if (!inSuggestionMode) {
|
|
213
225
|
return;
|
|
214
226
|
}
|
|
215
|
-
|
|
227
|
+
emitMentionUpdateIfQueryChanged(props.query);
|
|
216
228
|
activeMentionCommandEmitter(props.command);
|
|
217
229
|
mentionListbox?.show({
|
|
218
230
|
filter: props.query,
|
|
@@ -229,6 +241,8 @@ function createCustomMentionExtension(config, activeMentionCharacterEmitter, act
|
|
|
229
241
|
return (mentionListbox?.keydownHandler(props.event) ?? false);
|
|
230
242
|
},
|
|
231
243
|
onExit: () => {
|
|
244
|
+
inSuggestionMode = false;
|
|
245
|
+
lastEmittedQuery = undefined;
|
|
232
246
|
activeMentionCharacterEmitter('');
|
|
233
247
|
activeMentionCommandEmitter(undefined);
|
|
234
248
|
mentionListbox?.close();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-tiptap-editor.js","sourceRoot":"","sources":["../../../../../src/rich-text/editor/models/create-tiptap-editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,IAAI,MAAM,wBAAwB,CAAC;AAC1C,OAAO,QAAQ,MAAM,4BAA4B,CAAC;AAClD,OAAO,SAAS,MAAM,8BAA8B,CAAC;AACrD,OAAO,MAAM,MAAM,0BAA0B,CAAC;AAC9C,OAAO,IAAI,MAAM,wBAAwB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,OAAO,MAAM,2BAA2B,CAAC;AAChD,OAAO,SAAS,MAAM,6BAA6B,CAAC;AACpD,OAAO,IAAI,MAAM,wBAAwB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,O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ACb,YAAY,CAAC,MAAM,CAAC,IAAI,CACpB,IAAI,CAAC,WAAW,EAChB,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CACrC,CACJ,CAAC;gBACN,CAAC;YACL,CAAC;iBAAM,CAAC;gBACJ,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC5B,CAAC;QACL,CAAC;aAAM,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,EAAE,CAAC;YACxD,YAAY,CAAC,IAAI,CACb,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAe,CAAC,CACvD,CAAC;QACN,CAAC;aAAM,CAAC;YACJ,MAAM,cAAc,GAAG,yBAAyB,CAC5C,YAAY,EACZ,IAAI,CAAC,OAAO,CACf,CAAC;YACF,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC;QACjD,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["import { Editor, Mark, Node, mergeAttributes } from '@tiptap/core';\nimport Bold from '@tiptap/extension-bold';\nimport Document from '@tiptap/extension-document';\nimport HardBreak from '@tiptap/extension-hard-break';\nimport Italic from '@tiptap/extension-italic';\nimport Link from '@tiptap/extension-link';\nimport { BulletList, ListItem, OrderedList } from '@tiptap/extension-list';\nimport Mention from '@tiptap/extension-mention';\nimport Paragraph from '@tiptap/extension-paragraph';\nimport Text from '@tiptap/extension-text';\nimport { Placeholder, UndoRedo } from '@tiptap/extensions';\nimport { Slice, Fragment, Node as FragmentNode } from 'prosemirror-model';\nimport { PluginKey } from 'prosemirror-state';\n\nimport { keyEscape } from '@ni/fast-web-utilities';\nimport {\n type ActiveMentionCommandEmitter,\n type ActiveMentionCharacterEmitter,\n mentionPluginPrefix\n} from '../types';\n\nimport { anchorTag } from '../../../anchor';\nimport type { MentionExtensionConfiguration } from '../../models/mention-extension-configuration';\nimport type { RichTextMentionListbox } from '../../mention-listbox';\n\nconst validAbsoluteLinkRegex = /^https?:\\/\\//i;\n\nexport function createTiptapEditor(\n activeMentionCharacterEmitter: ActiveMentionCharacterEmitter,\n activeMentionCommandEmitter: ActiveMentionCommandEmitter,\n editor: HTMLDivElement,\n mentionExtensionConfig: MentionExtensionConfiguration[],\n mentionListbox?: RichTextMentionListbox,\n placeholder?: string\n): Editor {\n const customLink = createCustomLinkExtension();\n const mentionExtensions = mentionExtensionConfig.map(config => createCustomMentionExtension(\n config,\n activeMentionCharacterEmitter,\n activeMentionCommandEmitter,\n mentionListbox\n ));\n\n /**\n * For more information on the extensions for the supported formatting options, refer to the links below.\n * Tiptap marks: https://tiptap.dev/api/marks\n * Tiptap nodes: https://tiptap.dev/api/nodes\n */\n const tipTapEditor = new Editor({\n element: editor,\n // The editor will detect markdown syntax for an input only for these items\n // https://tiptap.dev/api/editor#enable-input-rules\n enableInputRules: [BulletList, OrderedList],\n // The editor will not detect markdown syntax when pasting content in any supported items\n // Lists do not have any default paste rules, they have only input rules, so disabled paste rules\n // https://tiptap.dev/api/editor#enable-paste-rules\n enablePasteRules: false,\n editorProps: {\n // Validating whether the links in the pasted content belongs to the supported scheme (HTTPS/HTTP),\n // and rendering it as a link in the editor. If not, rendering it as a plain text.\n // Also, updating the link text content with its href as we support only the absolute link.\n\n // `transformPasted` can be updated/removed when hyperlink support added\n // See: https://github.com/ni/nimble/issues/1527\n transformPasted\n },\n extensions: [\n Document,\n Paragraph,\n Text,\n BulletList,\n OrderedList,\n ListItem,\n Bold,\n Italic,\n UndoRedo,\n Placeholder.configure({\n placeholder,\n showOnlyWhenEditable: false\n }),\n HardBreak,\n customLink,\n ...mentionExtensions\n ]\n });\n\n /**\n * @param slice contains the Fragment of the copied content. If the content is a link, the slice contains Text node with Link mark.\n * ProseMirror reference for `transformPasted`: https://prosemirror.net/docs/ref/#view.EditorProps.transformPasted\n */\n function transformPasted(slice: Slice): Slice {\n const modifiedFragment = updateLinkAndMentionNodes(\n tipTapEditor,\n slice.content\n );\n return new Slice(modifiedFragment, slice.openStart, slice.openEnd);\n }\n\n return tipTapEditor;\n}\n\n/**\n * Extending the default link mark schema defined in the TipTap.\n *\n * \"excludes\": https://prosemirror.net/docs/ref/#model.MarkSpec.excludes\n * \"inclusive\": https://prosemirror.net/docs/ref/#model.MarkSpec.inclusive\n * \"parseHTML\": https://tiptap.dev/guide/custom-extensions#parse-html\n * \"renderHTML\": https://tiptap.dev/guide/custom-extensions/#render-html\n */\nfunction createCustomLinkExtension(): Mark {\n return Link.extend({\n // Excludes can be removed/enabled when hyperlink support added\n // See: https://github.com/ni/nimble/issues/1527\n excludes: '_',\n // Inclusive can be updated when hyperlink support added\n // See: https://github.com/ni/nimble/issues/1527\n inclusive: false,\n parseHTML() {\n return [\n // To load the `nimble-anchor` from the HTML parsed content by markdown-parser as links in the Tiptap editor, the `parseHTML`\n // of Link extension should return nimble `anchorTag`.\n // This is because the link mark schema in `markdown-parser.ts` file uses `<nimble-anchor>` as anchor tag and not `<a>`.\n {\n tag: anchorTag\n },\n // `<a>` tag is added here to support when pasting a link from external source.\n {\n tag: 'a'\n }\n ];\n },\n // HTMLAttribute cannot be in camelCase as we want to match it with the name in Tiptap\n renderHTML({\n // eslint-disable-next-line @typescript-eslint/naming-convention\n HTMLAttributes\n }: {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n HTMLAttributes: { [key: string]: string }\n }) {\n // The below 'a' tag should be replaced with 'nimble-anchor' once the below issue is fixed.\n // https://github.com/ni/nimble/issues/1516\n return ['a', HTMLAttributes];\n }\n }).configure({\n // HTMLAttribute cannot be in camelCase as we want to match it with the name in Tiptap\n // eslint-disable-next-line @typescript-eslint/naming-convention\n HTMLAttributes: {\n rel: 'noopener noreferrer',\n target: null,\n // Adding `class` here is a workaround to render two mentions without a whitespace as display names\n // For more details on this behavior, refer to the issue below:\n // https://github.com/ni/nimble/issues/1707\n class: ''\n },\n autolink: true,\n openOnClick: false,\n // linkOnPaste can be enabled when hyperlink support added\n // See: https://github.com/ni/nimble/issues/1527\n linkOnPaste: false,\n shouldAutoLink: href => validAbsoluteLinkRegex.test(href)\n });\n}\n\nfunction createCustomMentionExtension(\n config: MentionExtensionConfiguration,\n activeMentionCharacterEmitter: ActiveMentionCharacterEmitter,\n activeMentionCommandEmitter: ActiveMentionCommandEmitter,\n mentionListbox?: RichTextMentionListbox\n): Node {\n return Mention.extend({\n name: config.name,\n parseHTML() {\n return [\n {\n tag: config.viewElement\n }\n ];\n },\n addAttributes() {\n return {\n href: {\n default: null,\n parseHTML: (element: HTMLElement) => element.getAttribute('mention-href'),\n renderHTML: (attributes: { [key: string]: string }) => {\n return {\n 'mention-href': attributes.href\n };\n }\n },\n label: {\n default: null,\n parseHTML: (element: HTMLElement) => element.getAttribute('mention-label'),\n renderHTML: (attributes: { [key: string]: string }) => {\n return {\n 'mention-label': attributes.label\n };\n }\n },\n disabled: {\n default: null,\n parseHTML: (element: HTMLElement) => element.getAttribute('disabled'),\n renderHTML: (attributes: { [key: string]: string }) => {\n return {\n disabled: attributes.disabled\n };\n }\n }\n };\n },\n renderHTML({\n node,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n HTMLAttributes\n }: {\n node: FragmentNode,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n HTMLAttributes: { [key: string]: string }\n }) {\n return [\n config.viewElement,\n mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),\n this.options.renderText({\n options: this.options,\n node,\n suggestion: null\n })\n ];\n }\n }).configure({\n suggestion: {\n char: config.character,\n decorationClass: 'nimble-mention-view-edit',\n pluginKey: new PluginKey(config.key),\n allowSpaces: true,\n render: () => {\n let inSuggestionMode = false;\n return {\n onStart: (props): void => {\n /**\n * If the cursor position moves to outside of the mention and configuration element changes,\n * the setMarkdown() will trigger this `onStart` without a decoration node because the cursor\n * position is temporarily moved out of the suggestion decoration. Ignore `onStart` in that case\n * and don't show the mention list box since it doesn't have anything to anchor to.\n */\n if (props.decorationNode === null) {\n return;\n }\n inSuggestionMode = true;\n config.mentionUpdateEmitter(props.query);\n activeMentionCharacterEmitter(props.text.slice(0, 1));\n activeMentionCommandEmitter(props.command);\n mentionListbox?.show({\n filter: props.query,\n anchorNode: props.decorationNode as HTMLElement\n });\n },\n onUpdate: (props): void => {\n if (!inSuggestionMode) {\n return;\n }\n config.mentionUpdateEmitter(props.query);\n activeMentionCommandEmitter(props.command);\n mentionListbox?.show({\n filter: props.query,\n anchorNode: props.decorationNode as HTMLElement\n });\n },\n onKeyDown: (props): boolean => {\n if (!inSuggestionMode) {\n return false;\n }\n if (props.event.key === keyEscape) {\n inSuggestionMode = false;\n }\n return (\n mentionListbox?.keydownHandler(props.event) ?? false\n );\n },\n onExit: (): void => {\n activeMentionCharacterEmitter('');\n activeMentionCommandEmitter(undefined);\n mentionListbox?.close();\n }\n };\n }\n }\n });\n}\n\n/**\n * This method finds the Link mark in the pasted content and update its Text node.\n * If there is no text node, pass the node's fragment recursively and updates only node containing Link mark.\n * If the Text node does not contains Link mark, push the same node to `updatedNodes`.\n *\n * @param fragment Fragment containing the pasted content. [Fragment](https://prosemirror.net/docs/ref/#model.Fragment)\n * @returns modified fragment from the `updatedNode` after updating the valid link text with its href value.\n */\nfunction updateLinkAndMentionNodes(\n tiptapEditor: Editor,\n fragment: Fragment\n): Fragment {\n const updatedNodes: FragmentNode[] = [];\n\n fragment.forEach(node => {\n if (node.isText && node.marks.length > 0) {\n const linkMark = node.marks.find(\n mark => mark.type.name === 'link'\n );\n if (linkMark) {\n // Checks if the link is valid link or not\n // Needing to separately validate the link on paste is a workaround for a tiptap issue\n // See: https://github.com/ni/nimble/issues/1527\n if (\n validAbsoluteLinkRegex.test(linkMark.attrs.href as string)\n ) {\n // The below lines of code is responsible for updating the text content with its href value and creates a new updated text node.\n // This code needs an update when the hyperlink support is added.\n // See: https://github.com/ni/nimble/issues/1527\n updatedNodes.push(\n tiptapEditor.schema.text(\n linkMark.attrs.href as string,\n node.marks\n )\n );\n } else {\n // If it is a invalid link, creates a new Text node with the same text content and without a Link mark.\n updatedNodes.push(\n tiptapEditor.schema.text(\n node.textContent,\n linkMark.removeFromSet(node.marks)\n )\n );\n }\n } else {\n updatedNodes.push(node);\n }\n } else if (node.type.name.startsWith(mentionPluginPrefix)) {\n updatedNodes.push(\n tiptapEditor.schema.text(node.attrs.label as string)\n );\n } else {\n const updatedContent = updateLinkAndMentionNodes(\n tiptapEditor,\n node.content\n );\n updatedNodes.push(node.copy(updatedContent));\n }\n });\n\n return Fragment.fromArray(updatedNodes);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"create-tiptap-editor.js","sourceRoot":"","sources":["../../../../../src/rich-text/editor/models/create-tiptap-editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,IAAI,MAAM,wBAAwB,CAAC;AAC1C,OAAO,QAAQ,MAAM,4BAA4B,CAAC;AAClD,OAAO,SAAS,MAAM,8BAA8B,CAAC;AACrD,OAAO,MAAM,MAAM,0BAA0B,CAAC;AAC9C,OAAO,IAAI,MAAM,wBAAwB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,OAAO,MAAM,2BAA2B,CAAC;AAChD,OAAO,SAAS,MAAM,6BAA6B,CAAC;AACpD,OAAO,IAAI,MAAM,wBAAwB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EAAE,SAAS,EAAE,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EAAE,CAAC;gBACX,0CAA0C;gBAC1C,sFAAsF;gBACtF,gDAAgD;gBAChD,IACI,sBAAsB,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAc,CAAC,EAC5D,CAAC;oBACC,gIAAgI;oBAChI,iEAAiE;oBACjE,gDAAgD;oBAChD,YAAY,CAAC,IAAI,CACb,YAAY,CAAC,MAAM,CAAC,IAAI,CACpB,QAAQ,CAAC,KAAK,CAAC,IAAc,EAC7B,IAAI,CAAC,KAAK,CACb,CACJ,CAAC;gBACN,CAAC;qBAAM,CAAC;oBACJ,uGAAuG;oBACvG,YAAY,CAAC,IAAI,CACb,YAAY,CAAC,MAAM,CAAC,IAAI,CACpB,IAAI,CAAC,WAAW,EAChB,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CACrC,CACJ,CAAC;gBACN,CAAC;YACL,CAAC;iBAAM,CAAC;gBACJ,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC5B,CAAC;QACL,CAAC;aAAM,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,EAAE,CAAC;YACxD,YAAY,CAAC,IAAI,CACb,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAe,CAAC,CACvD,CAAC;QACN,CAAC;aAAM,CAAC;YACJ,MAAM,cAAc,GAAG,yBAAyB,CAC5C,YAAY,EACZ,IAAI,CAAC,OAAO,CACf,CAAC;YACF,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC;QACjD,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["import { Editor, Mark, Node, mergeAttributes } from '@tiptap/core';\nimport Bold from '@tiptap/extension-bold';\nimport Document from '@tiptap/extension-document';\nimport HardBreak from '@tiptap/extension-hard-break';\nimport Italic from '@tiptap/extension-italic';\nimport Link from '@tiptap/extension-link';\nimport { BulletList, ListItem, OrderedList } from '@tiptap/extension-list';\nimport Mention from '@tiptap/extension-mention';\nimport Paragraph from '@tiptap/extension-paragraph';\nimport Text from '@tiptap/extension-text';\nimport { Placeholder, UndoRedo } from '@tiptap/extensions';\nimport { Slice, Fragment, Node as FragmentNode } from 'prosemirror-model';\nimport { PluginKey } from 'prosemirror-state';\n\nimport { keyEscape } from '@ni/fast-web-utilities';\nimport {\n type ActiveMentionCommandEmitter,\n type ActiveMentionCharacterEmitter,\n mentionPluginPrefix\n} from '../types';\n\nimport { anchorTag } from '../../../anchor';\nimport type { MentionExtensionConfiguration } from '../../models/mention-extension-configuration';\nimport type { RichTextMentionListbox } from '../../mention-listbox';\n\nconst validAbsoluteLinkRegex = /^https?:\\/\\//i;\n\nexport function createTiptapEditor(\n activeMentionCharacterEmitter: ActiveMentionCharacterEmitter,\n activeMentionCommandEmitter: ActiveMentionCommandEmitter,\n editor: HTMLDivElement,\n mentionExtensionConfig: MentionExtensionConfiguration[],\n mentionListbox?: RichTextMentionListbox,\n placeholder?: string\n): Editor {\n const customLink = createCustomLinkExtension();\n const mentionExtensions = mentionExtensionConfig.map(config => createCustomMentionExtension(\n config,\n activeMentionCharacterEmitter,\n activeMentionCommandEmitter,\n mentionListbox\n ));\n\n /**\n * For more information on the extensions for the supported formatting options, refer to the links below.\n * Tiptap marks: https://tiptap.dev/api/marks\n * Tiptap nodes: https://tiptap.dev/api/nodes\n */\n const tipTapEditor = new Editor({\n element: editor,\n // The editor will detect markdown syntax for an input only for these items\n // https://tiptap.dev/api/editor#enable-input-rules\n enableInputRules: [BulletList, OrderedList],\n // The editor will not detect markdown syntax when pasting content in any supported items\n // Lists do not have any default paste rules, they have only input rules, so disabled paste rules\n // https://tiptap.dev/api/editor#enable-paste-rules\n enablePasteRules: false,\n editorProps: {\n // Validating whether the links in the pasted content belongs to the supported scheme (HTTPS/HTTP),\n // and rendering it as a link in the editor. If not, rendering it as a plain text.\n // Also, updating the link text content with its href as we support only the absolute link.\n\n // `transformPasted` can be updated/removed when hyperlink support added\n // See: https://github.com/ni/nimble/issues/1527\n transformPasted\n },\n extensions: [\n Document,\n Paragraph,\n Text,\n BulletList,\n OrderedList,\n ListItem,\n Bold,\n Italic,\n UndoRedo,\n Placeholder.configure({\n placeholder,\n showOnlyWhenEditable: false\n }),\n HardBreak,\n customLink,\n ...mentionExtensions\n ]\n });\n\n /**\n * @param slice contains the Fragment of the copied content. If the content is a link, the slice contains Text node with Link mark.\n * ProseMirror reference for `transformPasted`: https://prosemirror.net/docs/ref/#view.EditorProps.transformPasted\n */\n function transformPasted(slice: Slice): Slice {\n const modifiedFragment = updateLinkAndMentionNodes(\n tipTapEditor,\n slice.content\n );\n return new Slice(modifiedFragment, slice.openStart, slice.openEnd);\n }\n\n return tipTapEditor;\n}\n\n/**\n * Extending the default link mark schema defined in the TipTap.\n *\n * \"excludes\": https://prosemirror.net/docs/ref/#model.MarkSpec.excludes\n * \"inclusive\": https://prosemirror.net/docs/ref/#model.MarkSpec.inclusive\n * \"parseHTML\": https://tiptap.dev/guide/custom-extensions#parse-html\n * \"renderHTML\": https://tiptap.dev/guide/custom-extensions/#render-html\n */\nfunction createCustomLinkExtension(): Mark {\n return Link.extend({\n // Excludes can be removed/enabled when hyperlink support added\n // See: https://github.com/ni/nimble/issues/1527\n excludes: '_',\n // Inclusive can be updated when hyperlink support added\n // See: https://github.com/ni/nimble/issues/1527\n inclusive: false,\n parseHTML() {\n return [\n // To load the `nimble-anchor` from the HTML parsed content by markdown-parser as links in the Tiptap editor, the `parseHTML`\n // of Link extension should return nimble `anchorTag`.\n // This is because the link mark schema in `markdown-parser.ts` file uses `<nimble-anchor>` as anchor tag and not `<a>`.\n {\n tag: anchorTag\n },\n // `<a>` tag is added here to support when pasting a link from external source.\n {\n tag: 'a'\n }\n ];\n },\n // HTMLAttribute cannot be in camelCase as we want to match it with the name in Tiptap\n renderHTML({\n // eslint-disable-next-line @typescript-eslint/naming-convention\n HTMLAttributes\n }: {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n HTMLAttributes: { [key: string]: string }\n }) {\n // The below 'a' tag should be replaced with 'nimble-anchor' once the below issue is fixed.\n // https://github.com/ni/nimble/issues/1516\n return ['a', HTMLAttributes];\n }\n }).configure({\n // HTMLAttribute cannot be in camelCase as we want to match it with the name in Tiptap\n // eslint-disable-next-line @typescript-eslint/naming-convention\n HTMLAttributes: {\n rel: 'noopener noreferrer',\n target: null,\n // Adding `class` here is a workaround to render two mentions without a whitespace as display names\n // For more details on this behavior, refer to the issue below:\n // https://github.com/ni/nimble/issues/1707\n class: ''\n },\n autolink: true,\n openOnClick: false,\n // linkOnPaste can be enabled when hyperlink support added\n // See: https://github.com/ni/nimble/issues/1527\n linkOnPaste: false,\n shouldAutoLink: href => validAbsoluteLinkRegex.test(href)\n });\n}\n\nfunction createCustomMentionExtension(\n config: MentionExtensionConfiguration,\n activeMentionCharacterEmitter: ActiveMentionCharacterEmitter,\n activeMentionCommandEmitter: ActiveMentionCommandEmitter,\n mentionListbox?: RichTextMentionListbox\n): Node {\n return Mention.extend({\n name: config.name,\n parseHTML() {\n return [\n {\n tag: config.viewElement\n }\n ];\n },\n addAttributes() {\n return {\n href: {\n default: null,\n parseHTML: (element: HTMLElement) => element.getAttribute('mention-href'),\n renderHTML: (attributes: { [key: string]: string }) => {\n return {\n 'mention-href': attributes.href\n };\n }\n },\n label: {\n default: null,\n parseHTML: (element: HTMLElement) => element.getAttribute('mention-label'),\n renderHTML: (attributes: { [key: string]: string }) => {\n return {\n 'mention-label': attributes.label\n };\n }\n },\n disabled: {\n default: null,\n parseHTML: (element: HTMLElement) => element.getAttribute('disabled'),\n renderHTML: (attributes: { [key: string]: string }) => {\n return {\n disabled: attributes.disabled\n };\n }\n }\n };\n },\n renderHTML({\n node,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n HTMLAttributes\n }: {\n node: FragmentNode,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n HTMLAttributes: { [key: string]: string }\n }) {\n return [\n config.viewElement,\n mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),\n this.options.renderText({\n options: this.options,\n node,\n suggestion: null\n })\n ];\n }\n }).configure({\n suggestion: {\n char: config.character,\n decorationClass: 'nimble-mention-view-edit',\n pluginKey: new PluginKey(config.key),\n allowSpaces: true,\n render: () => {\n let inSuggestionMode = false;\n // Tracks the query for which a `mention-update` event was last emitted.\n // The tiptap suggestion plugin invokes `onStart`/`onUpdate` multiple times\n // for a single query change (e.g. an initial render plus loading and resolved\n // states of its async item fetch). We only want to emit `mention-update` once\n // per distinct query, so we deduplicate against the last emitted query.\n let lastEmittedQuery: string | undefined;\n const emitMentionUpdateIfQueryChanged = (query: string): void => {\n if (query !== lastEmittedQuery) {\n lastEmittedQuery = query;\n config.mentionUpdateEmitter(query);\n }\n };\n return {\n onStart: (props): void => {\n /**\n * If the cursor position moves to outside of the mention and configuration element changes,\n * the setMarkdown() will trigger this `onStart` without a decoration node because the cursor\n * position is temporarily moved out of the suggestion decoration. Ignore `onStart` in that case\n * and don't show the mention list box since it doesn't have anything to anchor to.\n */\n if (props.decorationNode === null) {\n return;\n }\n inSuggestionMode = true;\n emitMentionUpdateIfQueryChanged(props.query);\n activeMentionCharacterEmitter(props.text.slice(0, 1));\n activeMentionCommandEmitter(props.command);\n mentionListbox?.show({\n filter: props.query,\n anchorNode: props.decorationNode as HTMLElement\n });\n },\n onUpdate: (props): void => {\n if (!inSuggestionMode) {\n return;\n }\n emitMentionUpdateIfQueryChanged(props.query);\n activeMentionCommandEmitter(props.command);\n mentionListbox?.show({\n filter: props.query,\n anchorNode: props.decorationNode as HTMLElement\n });\n },\n onKeyDown: (props): boolean => {\n if (!inSuggestionMode) {\n return false;\n }\n if (props.event.key === keyEscape) {\n inSuggestionMode = false;\n }\n return (\n mentionListbox?.keydownHandler(props.event) ?? false\n );\n },\n onExit: (): void => {\n inSuggestionMode = false;\n lastEmittedQuery = undefined;\n activeMentionCharacterEmitter('');\n activeMentionCommandEmitter(undefined);\n mentionListbox?.close();\n }\n };\n }\n }\n });\n}\n\n/**\n * This method finds the Link mark in the pasted content and update its Text node.\n * If there is no text node, pass the node's fragment recursively and updates only node containing Link mark.\n * If the Text node does not contains Link mark, push the same node to `updatedNodes`.\n *\n * @param fragment Fragment containing the pasted content. [Fragment](https://prosemirror.net/docs/ref/#model.Fragment)\n * @returns modified fragment from the `updatedNode` after updating the valid link text with its href value.\n */\nfunction updateLinkAndMentionNodes(\n tiptapEditor: Editor,\n fragment: Fragment\n): Fragment {\n const updatedNodes: FragmentNode[] = [];\n\n fragment.forEach(node => {\n if (node.isText && node.marks.length > 0) {\n const linkMark = node.marks.find(\n mark => mark.type.name === 'link'\n );\n if (linkMark) {\n // Checks if the link is valid link or not\n // Needing to separately validate the link on paste is a workaround for a tiptap issue\n // See: https://github.com/ni/nimble/issues/1527\n if (\n validAbsoluteLinkRegex.test(linkMark.attrs.href as string)\n ) {\n // The below lines of code is responsible for updating the text content with its href value and creates a new updated text node.\n // This code needs an update when the hyperlink support is added.\n // See: https://github.com/ni/nimble/issues/1527\n updatedNodes.push(\n tiptapEditor.schema.text(\n linkMark.attrs.href as string,\n node.marks\n )\n );\n } else {\n // If it is a invalid link, creates a new Text node with the same text content and without a Link mark.\n updatedNodes.push(\n tiptapEditor.schema.text(\n node.textContent,\n linkMark.removeFromSet(node.marks)\n )\n );\n }\n } else {\n updatedNodes.push(node);\n }\n } else if (node.type.name.startsWith(mentionPluginPrefix)) {\n updatedNodes.push(\n tiptapEditor.schema.text(node.attrs.label as string)\n );\n } else {\n const updatedContent = updateLinkAndMentionNodes(\n tiptapEditor,\n node.content\n );\n updatedNodes.push(node.copy(updatedContent));\n }\n });\n\n return Fragment.fromArray(updatedNodes);\n}\n"]}
|
|
@@ -16,6 +16,8 @@ export const styles = css `
|
|
|
16
16
|
outline: none;
|
|
17
17
|
${userSelectNone}
|
|
18
18
|
color: ${bodyFontColor};
|
|
19
|
+
field-sizing: fixed;
|
|
20
|
+
min-width: 100px;
|
|
19
21
|
flex-direction: column;
|
|
20
22
|
vertical-align: top;
|
|
21
23
|
--ni-private-hover-indicator-width: calc(${borderWidth} + 1px);
|
|
@@ -47,6 +49,7 @@ export const styles = css `
|
|
|
47
49
|
display: flex;
|
|
48
50
|
justify-content: center;
|
|
49
51
|
position: relative;
|
|
52
|
+
field-sizing: inherit;
|
|
50
53
|
height: 100%;
|
|
51
54
|
width: 100%;
|
|
52
55
|
}
|
|
@@ -91,7 +94,7 @@ export const styles = css `
|
|
|
91
94
|
border-radius: 0px;
|
|
92
95
|
align-items: flex-end;
|
|
93
96
|
border: ${borderWidth} solid transparent;
|
|
94
|
-
|
|
97
|
+
field-sizing: inherit;
|
|
95
98
|
min-height: calc(${iconSize} + ${standardPadding});
|
|
96
99
|
padding: 8px;
|
|
97
100
|
${
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/text-area/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EACH,qBAAqB,EACrB,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,aAAa,EACb,qBAAqB,EACrB,gBAAgB,EAChB,qBAAqB,EACrB,QAAQ,EACR,6BAA6B,EAC7B,QAAQ,EACR,SAAS,EACT,eAAe,EACf,aAAa,EAChB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,MAAM,IAAI,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AACtF,OAAO,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;;;;;;;;;;;;;;;;;;kBAqBtB,WAAW;;2BAEF,QAAQ,MAAM,eAAe;;UAE9C;AACE,wFAAwF,CAAC,EAC7F;8BACsB,QAAQ;;;;;;;;;;;;+BAYP,gBAAgB;;;;;;;;6BAQlB,qBAAqB;;;;;;;;+BAQnB,SAAS;;;;+BAIT,SAAS;;;;iBAIvB,qBAAqB;;;;iBAIrB,6BAA6B;;;;iBAI7B,qBAAqB;;;;;;;;;;;;;;;;;;;;eAoBvB,aAAa;;;CAG3B,CAAC,aAAa,CACX,kBAAkB,CACd,kBAAkB,CAAC,OAAO,EAC1B,GAAG,CAAA;;qCAE0B,qBAAqB;;;SAGjD,CACJ,EACD,kBAAkB,CACd,kBAAkB,CAAC,KAAK,EACxB,GAAG,CAAA;;yCAE8B,qBAAqB;;;;;;;;;yCASrB,qBAAqB;;;;qCAIzB,qBAAqB;;;;;uCAKnB,SAAS;;SAEvC,CACJ,CACJ,CAAC","sourcesContent":["import { css } from '@ni/fast-element';\nimport { display } from '../utilities/style/display';\nimport {\n borderRgbPartialColor,\n borderHoverColor,\n borderWidth,\n smallDelay,\n bodyFontColor,\n bodyDisabledFontColor,\n controlLabelFont,\n controlLabelFontColor,\n bodyFont,\n controlLabelDisabledFontColor,\n iconSize,\n failColor,\n standardPadding,\n mediumPadding\n} from '../theme-provider/design-tokens';\nimport { appearanceBehavior } from '../utilities/style/appearance';\nimport { TextAreaAppearance } from './types';\nimport { styles as errorStyles } from '../patterns/error/styles';\nimport { styles as requiredVisibleStyles } from '../patterns/required-visible/styles';\nimport { userSelectNone } from '../utilities/style/user-select';\n\nexport const styles = css`\n ${display('inline-flex')}\n ${errorStyles}\n ${requiredVisibleStyles}\n\n :host {\n font: ${bodyFont};\n outline: none;\n ${userSelectNone}\n color: ${bodyFontColor};\n field-sizing: fixed;\n min-width: 100px;\n flex-direction: column;\n vertical-align: top;\n --ni-private-hover-indicator-width: calc(${borderWidth} + 1px);\n }\n\n :host([disabled]) {\n color: ${bodyDisabledFontColor};\n }\n\n :host([disabled][appearance-readonly]) {\n color: ${bodyFontColor};\n }\n\n .label {\n display: block;\n color: ${controlLabelFontColor};\n font: ${controlLabelFont};\n }\n\n :host([disabled]) .label {\n color: ${controlLabelDisabledFontColor};\n }\n\n :host([disabled][appearance-readonly]) .label {\n color: ${controlLabelFontColor};\n }\n\n .container {\n display: flex;\n justify-content: center;\n position: relative;\n field-sizing: inherit;\n height: 100%;\n width: 100%;\n }\n\n .container::after {\n content: ' ';\n position: absolute;\n bottom: calc(-1 * ${borderWidth});\n width: 0px;\n height: 0px;\n border-bottom: ${borderHoverColor}\n var(--ni-private-hover-indicator-width) solid;\n transition: width ${smallDelay} ease-in;\n }\n\n @media (prefers-reduced-motion) {\n .container::after {\n transition-duration: 0s;\n }\n }\n\n :host([error-visible]) .container::after {\n border-bottom-color: ${failColor};\n }\n\n :host(:hover) .container::after {\n width: 100%;\n }\n\n :host([disabled]:hover) .container::after,\n :host([readonly]:hover) .container::after {\n width: 0px;\n }\n\n .control {\n -webkit-appearance: none;\n font: inherit;\n flex-grow: 1;\n outline: none;\n position: relative;\n color: inherit;\n border-radius: 0px;\n align-items: flex-end;\n border: ${borderWidth} solid transparent;\n field-sizing: inherit;\n min-height: calc(${iconSize} + ${standardPadding});\n padding: 8px;\n ${\n /* This padding ensures that showing/hiding the error icon doesn't affect text layout */ ''\n }\n padding-right: calc(${iconSize});\n margin: 0px;\n resize: none;\n }\n\n @media (prefers-reduced-motion) {\n .control {\n transition-duration: 0s;\n }\n }\n\n .control:focus-within {\n border-bottom-color: ${borderHoverColor};\n }\n\n .control[readonly],\n .control[readonly]:hover,\n .control[readonly]:hover:focus-within,\n .control[disabled],\n .control[disabled]:hover {\n border-color: rgba(${borderRgbPartialColor}, 0.1);\n }\n\n :host([disabled][appearance-readonly]) .control {\n cursor: text;\n }\n\n :host([error-visible]) .control {\n border-bottom-color: ${failColor};\n }\n\n :host([error-visible]) .control[readonly]:hover:focus-within {\n border-bottom-color: ${failColor};\n }\n\n .control::placeholder {\n color: ${controlLabelFontColor};\n }\n\n :host([disabled]) .control::placeholder {\n color: ${controlLabelDisabledFontColor};\n }\n\n :host([disabled][appearance-readonly]) .control::placeholder {\n color: ${controlLabelFontColor};\n }\n\n :host([resize='both']) .control {\n resize: both;\n }\n :host([resize='horizontal']) .control {\n resize: horizontal;\n }\n :host([resize='vertical']) .control {\n resize: vertical;\n }\n\n :host([error-visible]) .error-icon {\n display: none;\n }\n\n :host([error-visible]) .error-icon.scrollbar-width-calculated {\n display: inline-flex;\n position: absolute;\n top: ${mediumPadding};\n right: var(--ni-private-scrollbar-width);\n }\n`.withBehaviors(\n appearanceBehavior(\n TextAreaAppearance.outline,\n css`\n .control {\n border-color: rgba(${borderRgbPartialColor}, 0.3);\n background-color: transparent;\n }\n `\n ),\n appearanceBehavior(\n TextAreaAppearance.block,\n css`\n .control {\n background-color: rgba(${borderRgbPartialColor}, 0.1);\n }\n\n :host([readonly]) .control {\n background-color: transparent;\n }\n\n :host([disabled]) .control {\n border-color: transparent;\n background-color: rgba(${borderRgbPartialColor}, 0.1);\n }\n\n :host([disabled][appearance-readonly]) .control {\n border-color: rgba(${borderRgbPartialColor}, 0.1);\n background-color: transparent;\n }\n\n :host([error-visible][disabled]) .control {\n border-bottom-color: ${failColor};\n }\n `\n )\n);\n"]}
|
|
@@ -18,6 +18,7 @@ export const styles = css `
|
|
|
18
18
|
outline: none;
|
|
19
19
|
${userSelectNone}
|
|
20
20
|
color: ${bodyFontColor};
|
|
21
|
+
field-sizing: fixed;
|
|
21
22
|
--ni-private-hover-indicator-width: calc(${borderWidth} + 1px);
|
|
22
23
|
--ni-private-height-within-border: calc(
|
|
23
24
|
${controlHeight} - 2 * ${borderWidth}
|
|
@@ -52,6 +53,7 @@ export const styles = css `
|
|
|
52
53
|
display: flex;
|
|
53
54
|
flex-direction: row;
|
|
54
55
|
border-radius: 0px;
|
|
56
|
+
field-sizing: inherit;
|
|
55
57
|
font: inherit;
|
|
56
58
|
align-items: center;
|
|
57
59
|
justify-content: center;
|
|
@@ -130,6 +132,7 @@ export const styles = css `
|
|
|
130
132
|
background: transparent;
|
|
131
133
|
color: inherit;
|
|
132
134
|
padding: 0px;
|
|
135
|
+
field-sizing: inherit;
|
|
133
136
|
height: var(--ni-private-height-within-border);
|
|
134
137
|
width: 100%;
|
|
135
138
|
margin-top: auto;
|