@patternfly/pfe-core 3.0.0 → 4.0.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.
Files changed (102) hide show
  1. package/controllers/activedescendant-controller.d.ts +99 -0
  2. package/controllers/activedescendant-controller.js +230 -0
  3. package/controllers/activedescendant-controller.js.map +1 -0
  4. package/controllers/at-focus-controller.d.ts +56 -0
  5. package/controllers/at-focus-controller.js +168 -0
  6. package/controllers/at-focus-controller.js.map +1 -0
  7. package/controllers/cascade-controller.d.ts +7 -2
  8. package/controllers/cascade-controller.js +6 -1
  9. package/controllers/cascade-controller.js.map +1 -1
  10. package/controllers/combobox-controller.d.ts +117 -0
  11. package/controllers/combobox-controller.js +611 -0
  12. package/controllers/combobox-controller.js.map +1 -0
  13. package/controllers/css-variable-controller.js +1 -1
  14. package/controllers/css-variable-controller.js.map +1 -1
  15. package/controllers/floating-dom-controller.d.ts +8 -1
  16. package/controllers/floating-dom-controller.js +12 -5
  17. package/controllers/floating-dom-controller.js.map +1 -1
  18. package/controllers/internals-controller.d.ts +26 -9
  19. package/controllers/internals-controller.js +45 -13
  20. package/controllers/internals-controller.js.map +1 -1
  21. package/controllers/light-dom-controller.js +2 -2
  22. package/controllers/light-dom-controller.js.map +1 -1
  23. package/controllers/listbox-controller.d.ts +118 -33
  24. package/controllers/listbox-controller.js +347 -154
  25. package/controllers/listbox-controller.js.map +1 -1
  26. package/controllers/logger.d.ts +13 -10
  27. package/controllers/logger.js +15 -11
  28. package/controllers/logger.js.map +1 -1
  29. package/controllers/overflow-controller.js +10 -6
  30. package/controllers/overflow-controller.js.map +1 -1
  31. package/controllers/perf-controller.js.map +1 -1
  32. package/controllers/property-observer-controller.d.ts +13 -16
  33. package/controllers/property-observer-controller.js +54 -25
  34. package/controllers/property-observer-controller.js.map +1 -1
  35. package/controllers/roving-tabindex-controller.d.ts +12 -61
  36. package/controllers/roving-tabindex-controller.js +57 -203
  37. package/controllers/roving-tabindex-controller.js.map +1 -1
  38. package/controllers/scroll-spy-controller.d.ts +4 -1
  39. package/controllers/scroll-spy-controller.js +9 -6
  40. package/controllers/scroll-spy-controller.js.map +1 -1
  41. package/controllers/slot-controller.d.ts +12 -16
  42. package/controllers/slot-controller.js +17 -20
  43. package/controllers/slot-controller.js.map +1 -1
  44. package/controllers/style-controller.js +3 -1
  45. package/controllers/style-controller.js.map +1 -1
  46. package/controllers/tabs-aria-controller.d.ts +2 -0
  47. package/controllers/tabs-aria-controller.js +2 -0
  48. package/controllers/tabs-aria-controller.js.map +1 -1
  49. package/controllers/test/combobox-controller.spec.d.ts +1 -0
  50. package/controllers/test/combobox-controller.spec.js +282 -0
  51. package/controllers/test/combobox-controller.spec.js.map +1 -0
  52. package/controllers/timestamp-controller.js +7 -2
  53. package/controllers/timestamp-controller.js.map +1 -1
  54. package/core.d.ts +0 -23
  55. package/core.js +1 -38
  56. package/core.js.map +1 -1
  57. package/custom-elements.json +3862 -1369
  58. package/decorators/bound.d.ts +3 -1
  59. package/decorators/bound.js +3 -1
  60. package/decorators/bound.js.map +1 -1
  61. package/decorators/cascades.d.ts +2 -1
  62. package/decorators/cascades.js +2 -1
  63. package/decorators/cascades.js.map +1 -1
  64. package/decorators/deprecation.d.ts +6 -5
  65. package/decorators/deprecation.js +6 -5
  66. package/decorators/deprecation.js.map +1 -1
  67. package/decorators/initializer.js.map +1 -1
  68. package/decorators/listen.d.ts +8 -0
  69. package/decorators/listen.js +22 -0
  70. package/decorators/listen.js.map +1 -0
  71. package/decorators/observed.d.ts +12 -16
  72. package/decorators/observed.js +39 -44
  73. package/decorators/observed.js.map +1 -1
  74. package/decorators/observes.d.ts +15 -0
  75. package/decorators/observes.js +30 -0
  76. package/decorators/observes.js.map +1 -0
  77. package/decorators/time.d.ts +1 -0
  78. package/decorators/time.js +6 -9
  79. package/decorators/time.js.map +1 -1
  80. package/decorators/trace.d.ts +4 -1
  81. package/decorators/trace.js +4 -1
  82. package/decorators/trace.js.map +1 -1
  83. package/decorators.d.ts +2 -0
  84. package/decorators.js +2 -0
  85. package/decorators.js.map +1 -1
  86. package/functions/arraysAreEquivalent.d.ts +9 -0
  87. package/functions/arraysAreEquivalent.js +28 -0
  88. package/functions/arraysAreEquivalent.js.map +1 -0
  89. package/functions/containsDeep.d.ts +2 -0
  90. package/functions/containsDeep.js +2 -0
  91. package/functions/containsDeep.js.map +1 -1
  92. package/functions/context.d.ts +3 -4
  93. package/functions/context.js +6 -2
  94. package/functions/context.js.map +1 -1
  95. package/functions/debounce.js.map +1 -1
  96. package/functions/isElementInView.d.ts +4 -6
  97. package/functions/isElementInView.js +9 -11
  98. package/functions/isElementInView.js.map +1 -1
  99. package/package.json +12 -4
  100. package/ssr-shims.d.ts +17 -0
  101. package/ssr-shims.js +55 -0
  102. package/ssr-shims.js.map +1 -0
@@ -1,58 +1,143 @@
1
1
  import type { ReactiveController, ReactiveControllerHost } from 'lit';
2
- export interface ListboxAccessibilityController<Item extends HTMLElement> extends ReactiveController {
3
- items: Item[];
4
- activeItem?: Item;
5
- nextItem?: Item;
6
- prevItem?: Item;
7
- firstItem?: Item;
8
- lastItem?: Item;
9
- updateItems(items: Item[]): void;
10
- setActiveItem(item: Item): void;
11
- }
12
2
  /**
13
- * Filtering, multiselect, and orientation options for listbox
3
+ * Options for listbox controller
14
4
  */
15
- export interface ListboxConfigOptions<T extends HTMLElement> {
5
+ export interface ListboxControllerOptions<Item extends HTMLElement> {
6
+ /**
7
+ * Whether the listbox supports multiple selections.
8
+ */
16
9
  multi?: boolean;
17
- a11yController: ListboxAccessibilityController<T>;
18
- getHTMLElement(): HTMLElement | null;
19
- requestSelect(option: T, force?: boolean): boolean;
20
- isSelected(option: T): boolean;
10
+ /**
11
+ * Optional callback to control the selection behavior of items. By default, ListboxController
12
+ * will set the `aria-selected` attribute. When overriding this option, it will call it on your
13
+ * element with the selected state.
14
+ * Callers **must** ensure that the correct ARIA state is set.
15
+ */
16
+ setItemSelected?(item: Item, selected: boolean): void;
17
+ /**
18
+ * Optional predicate to ascertain whether a custom element item is disabled or not
19
+ * By default, if the item matches any of these conditions, it is considered disabled:
20
+ * 1. it's `disabled` DOM property is `true`
21
+ * 1. it has the `aria-disabled="true"` attribute
22
+ * 2. it has the `disabled` attribute present
23
+ * 3. it matches the `:disabled` pseudo selector
24
+ */
25
+ isItemDisabled?(item: Item): boolean;
26
+ /**
27
+ * Predicate which determines if a given element is in fact an item
28
+ * instead of e.g a presentational divider. By default, elements must meet the following criteria
29
+ * 1. element a child of a listbox role,
30
+ * 2. element does not have role="presentation"
31
+ * 2. element is not an `<hr>`
32
+ * **NB**: When overriding, you must avoid outside references. This predicate must
33
+ * only consider the element itself, without reference to the host element's items array.
34
+ * @example ```js
35
+ * isItem: (item) => item instanceof MyCustomItem
36
+ * ```
37
+ */
38
+ isItem?(item: EventTarget | null): item is Item;
39
+ /**
40
+ * Function returning the item which currently has assistive technology focus.
41
+ * In most cases, this should be the `atFocusedItem` of an ATFocusController
42
+ * i.e. RovingTabindexController or ActivedescendantController.
43
+ *
44
+ */
45
+ getATFocusedItem(): Item | null;
46
+ /**
47
+ * Function returning the DOM node which is the direct parent of the item elements
48
+ * Defaults to the controller host.
49
+ * If the controller host is not an HTMLElement, this *must* be set
50
+ */
51
+ getItemsContainer?(): HTMLElement | null;
52
+ /**
53
+ * Optional function returning an additional DOM node which controls the listbox, e.g.
54
+ * a combobox input.
55
+ */
56
+ getControlsElements?(): HTMLElement[];
21
57
  }
58
+ /**
59
+ * @param item possible disabled item
60
+ * @package do not import this outside of `@patternfly/pfe-core`, it is subject to change at any time
61
+ */
62
+ export declare function isItem<Item extends HTMLElement>(item: EventTarget | null): item is Item;
63
+ /**
64
+ * This is a fib. aria-disabled might not be present on an element that uses internals,
65
+ * and the `disabled` attribute may not accurately represent the disabled state.
66
+ * short of patching the `attachInternals` constructor, it may not be possible at
67
+ * runtime to know with certainty that an arbitrary custom element is disabled or not.
68
+ * @param item possibly disabled item
69
+ * @package do not import this outside of `@patternfly/pfe-core`, it is subject to change at any time
70
+ */
71
+ export declare function isItemDisabled<Item extends HTMLElement>(item: Item): boolean;
22
72
  /**
23
73
  * Implements listbox semantics and accesibility. As there are two recognized
24
74
  * patterns for implementing keyboard interactions with listbox patterns,
25
75
  * provide a secondary controller (either RovingTabindexController or
26
76
  * ActiveDescendantController) to complete the implementation.
77
+ *
78
+ * @see https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_focus_vs_selection
79
+ *
80
+ * > Occasionally, it may appear as if two elements on the page have focus at the same time.
81
+ * > For example, in a multi-select list box, when an option is selected it may be greyed.
82
+ * > Yet, the focus indicator can still be moved to other options, which may also be selected.
83
+ * > Similarly, when a user activates a tab in a tablist, the selected state is set on the tab
84
+ * > and its visual appearance changes. However, the user can still navigate, moving the focus
85
+ * > indicator elsewhere on the page while the tab retains its selected appearance and state.
86
+ * >
87
+ * > Focus and selection are quite different. From the keyboard user's perspective,
88
+ * > focus is a pointer, like a mouse pointer; it tracks the path of navigation.
89
+ * > There is only one point of focus at any time and all operations take place at the
90
+ * > point of focus. On the other hand, selection is an operation that can be performed in
91
+ * > some widgets, such as list boxes, trees, and tablists. If a widget supports only single
92
+ * > selection, then only one item can be selected and very often the selected state will simply
93
+ * > follow the focus when focus is moved inside of the widget.
94
+ * > That is, in some widgets, moving focus may also perform the select operation.
95
+ * > However, if the widget supports multiple selection, then more than one item can be in a
96
+ * > selected state, and keys for moving focus do not perform selection. Some multi-select widgets
97
+ * > do support key commands that both move focus and change selection, but those keys are
98
+ * > different from the normal navigation keys. Finally, when focus leaves a widget that includes
99
+ * > a selected element, the selected state persists.
100
+ * >
101
+ * > From the developer's perspective, the difference is simple -- the focused element is the
102
+ * > active element (document.activeElement). Selected elements are elements that have
103
+ * > aria-selected="true".
104
+ * >
105
+ * > With respect to focus and the selected state, the most important considerations for designers
106
+ * > and developers are:
107
+ * >
108
+ * > - The visual focus indicator must always be visible.
109
+ * > - The selected state must be visually distinct from the focus indicator.
27
110
  */
28
111
  export declare class ListboxController<Item extends HTMLElement> implements ReactiveController {
29
112
  #private;
30
113
  host: ReactiveControllerHost;
31
- private _options;
32
114
  private static instances;
33
- static of<Item extends HTMLElement>(host: ReactiveControllerHost, options: ListboxConfigOptions<Item>): ListboxController<Item>;
34
- private constructor();
115
+ static of<Item extends HTMLElement>(host: ReactiveControllerHost, options: ListboxControllerOptions<Item>): ListboxController<Item>;
35
116
  /** Whether listbox is disabled */
36
117
  disabled: boolean;
37
- /** Current active descendant in listbox */
38
- get activeItem(): Item | undefined;
39
- get nextItem(): Item | undefined;
40
- get options(): Item[];
118
+ get container(): HTMLElement;
119
+ get multi(): boolean;
120
+ set multi(v: boolean);
121
+ get items(): Item[];
41
122
  /**
42
- * array of options which are selected
123
+ * register's the host's Item elements as listbox controller items
124
+ * sets aria-setsize and aria-posinset on items
125
+ * @param items items
43
126
  */
44
- get selectedOptions(): Item[];
45
- get value(): Item | Item[];
46
- private get element();
47
- hostConnected(): Promise<void>;
48
- hostUpdated(): void;
49
- hostDisconnected(): void;
127
+ set items(items: Item[]);
50
128
  /**
51
129
  * sets the listbox value based on selected options
130
+ * @param selected item or items
52
131
  */
53
- setValue(value: Item | Item[]): void;
132
+ set selected(selected: Item[]);
54
133
  /**
55
- * register's the host's Item elements as listbox controller items
134
+ * array of options which are selected
56
135
  */
57
- setOptions(options: Item[]): void;
136
+ get selected(): Item[];
137
+ private constructor();
138
+ hostConnected(): Promise<void>;
139
+ hostUpdate(): void;
140
+ hostUpdated(): void;
141
+ hostDisconnected(): void;
142
+ isSelected(item: Item): boolean;
58
143
  }