@refinitiv-ui/elements 7.9.1 → 7.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import { JSXInterface } from '../jsx';
2
- import { CSSResultGroup, ControlElement, MultiValue, PropertyValues, TemplateResult } from '@refinitiv-ui/core';
2
+ import { CSSResultGroup, FormFieldElement, MultiValue, PropertyValues, TemplateResult } from '@refinitiv-ui/core';
3
3
  import '../icon/index.js';
4
4
  import '../item/index.js';
5
5
  import '../overlay/index.js';
@@ -12,16 +12,24 @@ export type { SelectData, SelectDataItem };
12
12
  * @attr {boolean} disabled - Set disabled state
13
13
  * @prop {boolean} [disabled=false] - Set disabled state
14
14
  *
15
+ * @attr {string} placeholder - Set placeholder text
16
+ * @prop {string} [placeholder=""] - Set placeholder text
17
+ *
18
+ * @attr {boolean} error - Set error state
19
+ * @prop {boolean} [error=false] - Set error state
20
+ *
21
+ * @attr {boolean} warning - Set warning state
22
+ * @prop {boolean} [warning=false] - Set warning state
23
+ *
15
24
  * @fires value-changed - Fired when the user commits a value change. The event is not triggered if `value` property is changed programmatically.
16
25
  * @fires opened-changed - Fired when the user opens or closes control's popup. The event is not triggered if `opened` property is changed programmatically.
17
26
  */
18
- export declare class Select extends ControlElement implements MultiValue {
27
+ export declare class Select extends FormFieldElement implements MultiValue {
19
28
  /**
20
29
  * Element version number
21
30
  * @returns version number
22
31
  */
23
32
  static get version(): string;
24
- protected readonly defaultRole: string | null;
25
33
  /**
26
34
  * A `CSSResultGroup` that will be used
27
35
  * to style the host, slotted children
@@ -51,22 +59,10 @@ export declare class Select extends ControlElement implements MultiValue {
51
59
  * @readonly
52
60
  */
53
61
  get labels(): string[];
54
- /**
55
- * Placeholder to display when no value is set
56
- */
57
- placeholder: string;
58
62
  /**
59
63
  * Toggles the opened state of the list
60
64
  */
61
65
  opened: boolean;
62
- /**
63
- * Set error state
64
- */
65
- error: boolean;
66
- /**
67
- * Set warning state
68
- */
69
- warning: boolean;
70
66
  /**
71
67
  * Switch to multiple select input
72
68
  * @ignore
@@ -111,11 +107,6 @@ export declare class Select extends ControlElement implements MultiValue {
111
107
  * Reference to the label element
112
108
  */
113
109
  private labelRef;
114
- /**
115
- * Called when connected to DOM
116
- * @returns {void}
117
- */
118
- connectedCallback(): void;
119
110
  /**
120
111
  * Updates the element
121
112
  * @param changedProperties Properties that has changed
@@ -369,10 +360,6 @@ export declare class Select extends ControlElement implements MultiValue {
369
360
  * Template for label
370
361
  */
371
362
  private get labelTemplate();
372
- /**
373
- * Edit template when select is not readonly or disabled
374
- */
375
- private get editTemplate();
376
363
  /**
377
364
  * Get default slot template
378
365
  */
@@ -382,9 +369,17 @@ export declare class Select extends ControlElement implements MultiValue {
382
369
  */
383
370
  private get dataContent();
384
371
  /**
385
- * Edit template when select is not readonly or disabled
372
+ * `ef-items` template generated from slot or `data`
373
+ */
374
+ private get itemsTemplate();
375
+ /**
376
+ * Template of a listbox containing ef-item(s)
377
+ */
378
+ private get listboxTemplate();
379
+ /**
380
+ * Area that allows select to be clickable and toggle between open and close
386
381
  */
387
- private get popupTemplate();
382
+ private get triggerTemplate();
388
383
  /**
389
384
  * A `TemplateResult` that will be used
390
385
  * to render the updated internal template.
@@ -405,7 +400,7 @@ declare global {
405
400
 
406
401
  namespace JSX {
407
402
  interface IntrinsicElements {
408
- 'ef-select': Partial<Select> | JSXInterface.ControlHTMLAttributes<Select>;
403
+ 'ef-select': Partial<Select> | JSXInterface.HTMLAttributes<Select>;
409
404
  }
410
405
  }
411
406
  }
@@ -1,5 +1,5 @@
1
1
  import { __decorate } from "tslib";
2
- import { ControlElement, FocusedPropertyKey, css, html } from '@refinitiv-ui/core';
2
+ import { FocusedPropertyKey, FormFieldElement, css, html, nothing } from '@refinitiv-ui/core';
3
3
  import { customElement } from '@refinitiv-ui/core/decorators/custom-element.js';
4
4
  import { property } from '@refinitiv-ui/core/decorators/property.js';
5
5
  import { createRef, ref } from '@refinitiv-ui/core/directives/ref.js';
@@ -44,13 +44,21 @@ var Navigation;
44
44
  * @attr {boolean} disabled - Set disabled state
45
45
  * @prop {boolean} [disabled=false] - Set disabled state
46
46
  *
47
+ * @attr {string} placeholder - Set placeholder text
48
+ * @prop {string} [placeholder=""] - Set placeholder text
49
+ *
50
+ * @attr {boolean} error - Set error state
51
+ * @prop {boolean} [error=false] - Set error state
52
+ *
53
+ * @attr {boolean} warning - Set warning state
54
+ * @prop {boolean} [warning=false] - Set warning state
55
+ *
47
56
  * @fires value-changed - Fired when the user commits a value change. The event is not triggered if `value` property is changed programmatically.
48
57
  * @fires opened-changed - Fired when the user opens or closes control's popup. The event is not triggered if `opened` property is changed programmatically.
49
58
  */
50
- let Select = class Select extends ControlElement {
59
+ let Select = class Select extends FormFieldElement {
51
60
  constructor() {
52
61
  super(...arguments);
53
- this.defaultRole = 'combobox';
54
62
  this.composer = new CollectionComposer([]);
55
63
  this._data = null;
56
64
  this.popupDynamicStyles = {}; /* set popup min-width based on select width or CSS vars */
@@ -60,22 +68,10 @@ let Select = class Select extends ControlElement {
60
68
  this.keySearchTerm = ''; /* used for quick search */
61
69
  this.keySearchThrottler = new TimeoutTaskRunner(KEY_SEARCH_DEBOUNCER);
62
70
  this.resizeThrottler = new AnimationTaskRunner();
63
- /**
64
- * Placeholder to display when no value is set
65
- */
66
- this.placeholder = '';
67
71
  /**
68
72
  * Toggles the opened state of the list
69
73
  */
70
74
  this.opened = false;
71
- /**
72
- * Set error state
73
- */
74
- this.error = false;
75
- /**
76
- * Set warning state
77
- */
78
- this.warning = false;
79
75
  /**
80
76
  * This variable is here to ensure that the value and data are in sync when data is set after the value.
81
77
  * This is developer error to use both, selected and value to control the selections.
@@ -151,6 +147,9 @@ let Select = class Select extends ControlElement {
151
147
  display: none;
152
148
  }
153
149
  #box {
150
+ outline: none;
151
+ width: 100%;
152
+ height: 100%;
154
153
  align-items: center;
155
154
  display: inline-flex;
156
155
  flex-flow: row nowrap;
@@ -173,19 +172,6 @@ let Select = class Select extends ControlElement {
173
172
  left: 0;
174
173
  cursor: pointer;
175
174
  }
176
- #select {
177
- position: absolute;
178
- top: 0;
179
- left: 0;
180
- right: 0;
181
- bottom: 0;
182
- width: 100%;
183
- height: 100%;
184
- opacity: 0;
185
- border: none;
186
- padding: 0;
187
- margin: 0;
188
- }
189
175
  `;
190
176
  }
191
177
  /**
@@ -279,15 +265,6 @@ let Select = class Select extends ControlElement {
279
265
  }
280
266
  return this.selectedSlotItems.map((item) => this.getItemValue(item));
281
267
  }
282
- /**
283
- * Called when connected to DOM
284
- * @returns {void}
285
- */
286
- connectedCallback() {
287
- super.connectedCallback();
288
- // Indicating that this select has a popup of type listbox
289
- this.setAttribute('aria-haspopup', 'listbox');
290
- }
291
268
  /**
292
269
  * Updates the element
293
270
  * @param changedProperties Properties that has changed
@@ -312,10 +289,6 @@ let Select = class Select extends ControlElement {
312
289
  else {
313
290
  this.closing();
314
291
  }
315
- this.setAttribute('aria-expanded', this.opened ? 'true' : 'false');
316
- }
317
- if (changedProperties.has('error')) {
318
- this.setAttribute('aria-invalid', this.error ? 'true' : 'false');
319
292
  }
320
293
  super.update(changedProperties);
321
294
  }
@@ -871,17 +844,6 @@ let Select = class Select extends ControlElement {
871
844
  get labelTemplate() {
872
845
  return html `<div part="label" ${ref(this.labelRef)}>${this.labelText}</div>`;
873
846
  }
874
- /**
875
- * Edit template when select is not readonly or disabled
876
- */
877
- get editTemplate() {
878
- if (!this.readonly && !this.disabled) {
879
- return html `
880
- <div id="trigger" @tapstart="${this.toggleOpened}"></div>
881
- ${this.popupTemplate}
882
- `;
883
- }
884
- }
885
847
  /**
886
848
  * Get default slot template
887
849
  */
@@ -895,37 +857,44 @@ let Select = class Select extends ControlElement {
895
857
  return html `${this.composer.queryItems(() => true).map((item) => this.toItem(item))}`;
896
858
  }
897
859
  /**
898
- * Edit template when select is not readonly or disabled
899
- */
900
- get popupTemplate() {
901
- if (this.lazyRendered) {
902
- return html `<ef-overlay
903
- ${ref(this.menuRef)}
904
- tabindex="-1"
905
- id="menu"
906
- part="list"
907
- role="listbox"
908
- style=${styleMap(this.popupDynamicStyles)}
909
- with-shadow
910
- lock-position-target
911
- .positionTarget=${this}
912
- .position=${POPUP_POSITION}
913
- ?opened=${this.opened}
914
- @tap=${this.onPopupTap}
915
- @mousemove=${this.onPopupMouseMove}
916
- @keydown=${this.onPopupKeyDown}
917
- @opened-changed="${this.onPopupOpenedChanged}"
918
- @opened="${this.onPopupOpened}"
919
- @refit=${this.onPopupRefit}
920
- @closed="${this.onPopupClosed}"
921
- >${this.hasDataItems() ? this.dataContent : this.slottedContent}</ef-overlay
922
- >`;
923
- }
924
- else {
925
- // This code is required because IE11 polyfill need items to be within a slot
926
- // to make MutationObserver to observe items correctly
927
- return html `<div style="display: none !important;"><slot></slot></div>`;
928
- }
860
+ * `ef-items` template generated from slot or `data`
861
+ */
862
+ get itemsTemplate() {
863
+ return this.hasDataItems() ? this.dataContent : this.slottedContent;
864
+ }
865
+ /**
866
+ * Template of a listbox containing ef-item(s)
867
+ */
868
+ get listboxTemplate() {
869
+ return this.lazyRendered
870
+ ? html `<ef-overlay
871
+ ${ref(this.menuRef)}
872
+ tabindex="-1"
873
+ id="menu"
874
+ part="list"
875
+ role="listbox"
876
+ style=${styleMap(this.popupDynamicStyles)}
877
+ with-shadow
878
+ lock-position-target
879
+ .positionTarget=${this}
880
+ .position=${POPUP_POSITION}
881
+ ?opened=${this.opened}
882
+ @tap=${this.onPopupTap}
883
+ @mousemove=${this.onPopupMouseMove}
884
+ @keydown=${this.onPopupKeyDown}
885
+ @opened-changed="${this.onPopupOpenedChanged}"
886
+ @opened="${this.onPopupOpened}"
887
+ @refit=${this.onPopupRefit}
888
+ @closed="${this.onPopupClosed}"
889
+ >${this.itemsTemplate}</ef-overlay
890
+ >`
891
+ : nothing;
892
+ }
893
+ /**
894
+ * Area that allows select to be clickable and toggle between open and close
895
+ */
896
+ get triggerTemplate() {
897
+ return html ` <div id="trigger" @tapstart="${this.toggleOpened}"></div>`;
929
898
  }
930
899
  /**
931
900
  * A `TemplateResult` that will be used
@@ -933,11 +902,25 @@ let Select = class Select extends ControlElement {
933
902
  * @return Render template
934
903
  */
935
904
  render() {
936
- return html ` <div id="box">
905
+ return html `<div
906
+ id="box"
907
+ tabindex="0"
908
+ role="combobox"
909
+ placeholder=${this.placeholder || nothing}
910
+ aria-haspopup="listbox"
911
+ aria-controls="menu"
912
+ aria-invalid=${this.error ? 'true' : 'false'}
913
+ aria-expanded=${this.opened ? 'true' : 'false'}
914
+ aria-required=${this.inputAriaRequired}
915
+ aria-label=${this.inputAriaLabel ?? nothing}
916
+ aria-description=${this.inputAriaDescription ?? nothing}
917
+ >
937
918
  <div id="text">${this.placeholderHidden() ? this.labelTemplate : this.placeholderTemplate}</div>
938
- <ef-icon icon="down" part="icon"></ef-icon>
919
+ <ef-icon aria-hidden="true" icon="down" part="icon"></ef-icon>
939
920
  </div>
940
- ${this.editTemplate}`;
921
+ ${!this.readonly && !this.disabled
922
+ ? html ` ${this.triggerTemplate} ${this.listboxTemplate} `
923
+ : nothing}`;
941
924
  }
942
925
  };
943
926
  __decorate([
@@ -946,18 +929,9 @@ __decorate([
946
929
  __decorate([
947
930
  property({ type: Array, attribute: false })
948
931
  ], Select.prototype, "labels", null);
949
- __decorate([
950
- property({ type: String })
951
- ], Select.prototype, "placeholder", void 0);
952
932
  __decorate([
953
933
  property({ type: Boolean, reflect: true })
954
934
  ], Select.prototype, "opened", void 0);
955
- __decorate([
956
- property({ type: Boolean, reflect: true })
957
- ], Select.prototype, "error", void 0);
958
- __decorate([
959
- property({ type: Boolean, reflect: true })
960
- ], Select.prototype, "warning", void 0);
961
935
  __decorate([
962
936
  property({ type: Boolean })
963
937
  ], Select.prototype, "multiple", null);
@@ -0,0 +1,49 @@
1
+ import { JSXInterface } from '../../jsx';
2
+ import { BasicElement, CSSResultGroup, PropertyValues, TemplateResult } from '@refinitiv-ui/core';
3
+ export declare class SliderMarker extends BasicElement {
4
+ /**
5
+ * Element version number
6
+ * @returns version number
7
+ */
8
+ static get version(): string;
9
+ static get styles(): CSSResultGroup;
10
+ /**
11
+ * Used to determine the position of the marker on the scale.
12
+ */
13
+ value: string;
14
+ /**
15
+ * Specify label alignment
16
+ */
17
+ labelAlign: 'left' | 'right' | 'center' | null;
18
+ /**
19
+ * On first updated lifecycle
20
+ * @param changedProperties changed properties
21
+ * @returns {void}
22
+ */
23
+ protected firstUpdated(changedProperties: PropertyValues): void;
24
+ /**
25
+ * A `TemplateResult` that will be used
26
+ * to render the updated internal template.
27
+ * @returns Render template
28
+ */
29
+ protected render(): TemplateResult;
30
+ }
31
+ declare global {
32
+ interface HTMLElementTagNameMap {
33
+ 'ef-slider-marker': SliderMarker;
34
+ }
35
+ }
36
+
37
+ declare global {
38
+ interface HTMLElementTagNameMap {
39
+ 'ef-slider-marker': SliderMarker;
40
+ }
41
+
42
+ namespace JSX {
43
+ interface IntrinsicElements {
44
+ 'ef-slider-marker': Partial<SliderMarker> | JSXInterface.HTMLAttributes<SliderMarker>;
45
+ }
46
+ }
47
+ }
48
+
49
+ export {};
@@ -0,0 +1,72 @@
1
+ import { __decorate } from "tslib";
2
+ import { BasicElement, css, html } from '@refinitiv-ui/core';
3
+ import { customElement } from '@refinitiv-ui/core/decorators/custom-element.js';
4
+ import { property } from '@refinitiv-ui/core/decorators/property.js';
5
+ import { VERSION } from '../../version.js';
6
+ let SliderMarker = class SliderMarker extends BasicElement {
7
+ constructor() {
8
+ super(...arguments);
9
+ /**
10
+ * Used to determine the position of the marker on the scale.
11
+ */
12
+ this.value = '';
13
+ /**
14
+ * Specify label alignment
15
+ */
16
+ this.labelAlign = null;
17
+ }
18
+ /**
19
+ * Element version number
20
+ * @returns version number
21
+ */
22
+ static get version() {
23
+ return VERSION;
24
+ }
25
+ static get styles() {
26
+ return css `
27
+ :host {
28
+ position: absolute;
29
+ }
30
+ [part='marker'] {
31
+ width: 100%;
32
+ height: 100%;
33
+ }
34
+ [part='label'] {
35
+ white-space: nowrap;
36
+ position: absolute;
37
+ }
38
+ `;
39
+ }
40
+ /**
41
+ * On first updated lifecycle
42
+ * @param changedProperties changed properties
43
+ * @returns {void}
44
+ */
45
+ firstUpdated(changedProperties) {
46
+ super.firstUpdated(changedProperties);
47
+ this.setAttribute('aria-hidden', 'true');
48
+ }
49
+ /**
50
+ * A `TemplateResult` that will be used
51
+ * to render the updated internal template.
52
+ * @returns Render template
53
+ */
54
+ render() {
55
+ return html `
56
+ <div part="marker"></div>
57
+ <div part="label">
58
+ <slot></slot>
59
+ </div>
60
+ `;
61
+ }
62
+ };
63
+ __decorate([
64
+ property({ type: String })
65
+ ], SliderMarker.prototype, "value", void 0);
66
+ __decorate([
67
+ property({ type: String, reflect: true, attribute: 'label-align' })
68
+ ], SliderMarker.prototype, "labelAlign", void 0);
69
+ SliderMarker = __decorate([
70
+ customElement('ef-slider-marker')
71
+ ], SliderMarker);
72
+ export { SliderMarker };