@ionic/core 9.0.11-nightly.20261111 → 9.0.11

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 (113) hide show
  1. package/components/ion-back-button.js +1 -1
  2. package/components/ion-breadcrumb.js +1 -1
  3. package/components/ion-button.js +1 -1
  4. package/components/ion-card.js +1 -1
  5. package/components/ion-datetime.js +1 -1
  6. package/components/ion-fab-button.js +1 -1
  7. package/components/ion-input-password-toggle.js +1 -1
  8. package/components/ion-item-option.js +1 -1
  9. package/components/ion-item.js +1 -1
  10. package/components/ion-menu-button.js +1 -1
  11. package/components/ion-router-link.js +1 -1
  12. package/components/ion-segment-button.js +1 -1
  13. package/components/ion-select-modal.js +1 -1
  14. package/components/ion-select-popover.js +1 -1
  15. package/components/ion-select.js +1 -1
  16. package/components/ion-tab-button.js +1 -1
  17. package/components/p-BLmEEVy_.js +4 -0
  18. package/components/p-C-Jb89-w.js +4 -0
  19. package/components/{p-Dy7x-KDF.js → p-DBlNaRT2.js} +1 -1
  20. package/components/p-DBtEgJe4.js +4 -0
  21. package/components/{p-C-SO5kIs.js → p-nZiC4mrP.js} +1 -1
  22. package/dist/cjs/attribute-controller-BRwSyjfI.js +219 -0
  23. package/dist/cjs/ion-back-button.cjs.entry.js +11 -2
  24. package/dist/cjs/ion-breadcrumb_2.cjs.entry.js +26 -4
  25. package/dist/cjs/ion-button_2.cjs.entry.js +10 -4
  26. package/dist/cjs/ion-card_5.cjs.entry.js +23 -3
  27. package/dist/cjs/ion-fab_3.cjs.entry.js +9 -2
  28. package/dist/cjs/ion-item-option_3.cjs.entry.js +13 -2
  29. package/dist/cjs/ion-item_8.cjs.entry.js +19 -3
  30. package/dist/cjs/ion-menu_3.cjs.entry.js +11 -2
  31. package/dist/cjs/ion-route_4.cjs.entry.js +14 -2
  32. package/dist/cjs/ion-segment_2.cjs.entry.js +7 -2
  33. package/dist/cjs/ion-select_3.cjs.entry.js +8 -3
  34. package/dist/cjs/ion-tab-bar_2.cjs.entry.js +11 -2
  35. package/dist/cjs/ionic.cjs.js +1 -1
  36. package/dist/cjs/loader.cjs.js +1 -1
  37. package/dist/collection/components/back-button/back-button.js +12 -3
  38. package/dist/collection/components/breadcrumb/breadcrumb.js +28 -5
  39. package/dist/collection/components/button/button.js +10 -4
  40. package/dist/collection/components/card/card.js +24 -3
  41. package/dist/collection/components/fab-button/fab-button.js +10 -3
  42. package/dist/collection/components/item/item.js +19 -3
  43. package/dist/collection/components/item-option/item-option.js +14 -3
  44. package/dist/collection/components/menu-button/menu-button.js +12 -3
  45. package/dist/collection/components/router-link/router-link.js +15 -3
  46. package/dist/collection/components/segment-button/segment-button.js +7 -2
  47. package/dist/collection/components/select/select.js +8 -3
  48. package/dist/collection/components/tab-button/tab-button.js +12 -3
  49. package/dist/collection/utils/attribute-controller.js +107 -20
  50. package/dist/docs.json +1 -1
  51. package/dist/esm/attribute-controller-BMdZtDiw.js +215 -0
  52. package/dist/esm/ion-back-button.entry.js +12 -3
  53. package/dist/esm/ion-breadcrumb_2.entry.js +27 -5
  54. package/dist/esm/ion-button_2.entry.js +10 -4
  55. package/dist/esm/ion-card_5.entry.js +23 -3
  56. package/dist/esm/ion-fab_3.entry.js +10 -3
  57. package/dist/esm/ion-item-option_3.entry.js +14 -3
  58. package/dist/esm/ion-item_8.entry.js +19 -3
  59. package/dist/esm/ion-menu_3.entry.js +12 -3
  60. package/dist/esm/ion-route_4.entry.js +15 -3
  61. package/dist/esm/ion-segment_2.entry.js +7 -2
  62. package/dist/esm/ion-select_3.entry.js +8 -3
  63. package/dist/esm/ion-tab-bar_2.entry.js +12 -3
  64. package/dist/esm/ionic.js +1 -1
  65. package/dist/esm/loader.js +1 -1
  66. package/dist/ionic/ionic.esm.js +1 -1
  67. package/dist/ionic/p-13cebf9c.entry.js +4 -0
  68. package/dist/ionic/p-2JXUmy2G.js +4 -0
  69. package/dist/ionic/p-41e7f290.entry.js +4 -0
  70. package/dist/ionic/p-498151f8.entry.js +4 -0
  71. package/dist/ionic/p-499eba5c.entry.js +4 -0
  72. package/dist/ionic/p-4dd92223.entry.js +4 -0
  73. package/dist/ionic/p-542337a7.entry.js +4 -0
  74. package/dist/ionic/p-872ad61b.entry.js +4 -0
  75. package/dist/ionic/p-a4c1dd02.entry.js +4 -0
  76. package/dist/ionic/p-a6666b03.entry.js +4 -0
  77. package/dist/ionic/p-df9b3bc5.entry.js +4 -0
  78. package/dist/ionic/p-dfc8cf89.entry.js +4 -0
  79. package/dist/ionic/p-e702cb5c.entry.js +4 -0
  80. package/dist/types/components/back-button/back-button.d.ts +3 -0
  81. package/dist/types/components/breadcrumb/breadcrumb.d.ts +8 -0
  82. package/dist/types/components/button/button.d.ts +1 -0
  83. package/dist/types/components/card/card.d.ts +6 -0
  84. package/dist/types/components/fab-button/fab-button.d.ts +2 -0
  85. package/dist/types/components/item/item.d.ts +6 -0
  86. package/dist/types/components/item-option/item-option.d.ts +4 -0
  87. package/dist/types/components/menu-button/menu-button.d.ts +3 -0
  88. package/dist/types/components/router-link/router-link.d.ts +5 -0
  89. package/dist/types/components/segment-button/segment-button.d.ts +1 -0
  90. package/dist/types/components/select/select.d.ts +1 -0
  91. package/dist/types/components/tab-button/tab-button.d.ts +3 -0
  92. package/dist/types/utils/attribute-controller.d.ts +28 -6
  93. package/hydrate/index.js +359 -150
  94. package/hydrate/index.mjs +359 -150
  95. package/package.json +1 -1
  96. package/components/p-C0TdbIVo.js +0 -4
  97. package/components/p-CCFj0kgH.js +0 -4
  98. package/components/p-kKGBuIkf.js +0 -4
  99. package/dist/cjs/attribute-controller-0-lwbVEj.js +0 -131
  100. package/dist/esm/attribute-controller-ItNOXNp9.js +0 -128
  101. package/dist/ionic/p-013b9aba.entry.js +0 -4
  102. package/dist/ionic/p-1252621e.entry.js +0 -4
  103. package/dist/ionic/p-27960f65.entry.js +0 -4
  104. package/dist/ionic/p-43729675.entry.js +0 -4
  105. package/dist/ionic/p-84470714.entry.js +0 -4
  106. package/dist/ionic/p-8dQB1sG_.js +0 -4
  107. package/dist/ionic/p-9515f840.entry.js +0 -4
  108. package/dist/ionic/p-96d040b0.entry.js +0 -4
  109. package/dist/ionic/p-9d7e5a0b.entry.js +0 -4
  110. package/dist/ionic/p-a45caa30.entry.js +0 -4
  111. package/dist/ionic/p-b0faaae2.entry.js +0 -4
  112. package/dist/ionic/p-c56c23b6.entry.js +0 -4
  113. package/dist/ionic/p-c7ea2647.entry.js +0 -4
@@ -12,11 +12,11 @@ import { ariaAttributes, inheritAttributes } from "./helpers";
12
12
  * Create the controller in `componentWillLoad`. It takes the initial copy and starts
13
13
  * watching right away, so `init()` is only needed to resume after a move.
14
14
  *
15
- * Two things to know before adopting it. Only the initial copy removes the attributes
16
- * from the host, so a value written after load sits on the host as well as on the
17
- * element it is applied to, which matters if the host has a role of its own. And an
18
- * attribute from the initial markup can never be removed, only overwritten, since the
19
- * copy already took it off the host and a `removeAttribute` there fires no mutation.
15
+ * Two things to know before adopting it. Unless `moveFromHost` says otherwise, only the
16
+ * initial copy removes the attributes from the host, so a value written after load sits
17
+ * on the host as well as on the element it is applied to, which matters if the host has
18
+ * a role of its own. And an attribute moved off the host can never be removed, only
19
+ * overwritten, since removing it from the host doesn't fire a mutation.
20
20
  * An empty string works for `aria-label` and friends, but a token-valued attribute
21
21
  * has to be set to its default instead, so `aria-pressed="false"` rather than empty.
22
22
  *
@@ -28,10 +28,15 @@ import { ariaAttributes, inheritAttributes } from "./helpers";
28
28
  * attributes the component renders on its own `<Host>`, since a later change to one of
29
29
  * those is the component's own write, and for attributes that would put a second node in
30
30
  * the accessibility tree if the host kept a copy alongside the one we apply.
31
+ * @param moveFromHost Called on load, after every write and on `refresh()` to decide whether
32
+ * a value moves off the host. A rejected value stays on the host and is left out of
33
+ * `attributes`. It can read component state, as long as the component calls `refresh()`
34
+ * when that state changes.
31
35
  */
32
- export const createAttributeController = (el, attributes, onChange, hostOwnedAttributes = []) => {
36
+ export const createAttributeController = (el, attributes, onChange, hostOwnedAttributes = [], moveFromHost) => {
33
37
  let inherited = inheritAttributes(el, attributes);
34
38
  let observer;
39
+ const staysOnHost = (name, value) => moveFromHost !== undefined && value != null && !moveFromHost(name, value);
35
40
  const watchedAttributes = attributes.filter((attr) => !hostOwnedAttributes.includes(attr));
36
41
  /**
37
42
  * The names still on the host, which is everything written after load. The initial
@@ -47,6 +52,25 @@ export const createAttributeController = (el, attributes, onChange, hostOwnedAtt
47
52
  hostWritten.add(name);
48
53
  }
49
54
  };
55
+ const moveOffHost = (changed) => {
56
+ if (moveFromHost === undefined) {
57
+ return;
58
+ }
59
+ for (const [name, value] of Object.entries(changed)) {
60
+ if (value != null && !staysOnHost(name, value)) {
61
+ el.removeAttribute(name);
62
+ // Without this, the missing attribute would read as a developer removal later.
63
+ hostWritten.delete(name);
64
+ }
65
+ }
66
+ };
67
+ // The initial copy took everything off the host, so put back what has to stay there.
68
+ for (const [name, value] of Object.entries(inherited)) {
69
+ if (staysOnHost(name, value)) {
70
+ el.setAttribute(name, value);
71
+ hostWritten.add(name);
72
+ }
73
+ }
50
74
  /**
51
75
  * Nothing is watching while the host is out of the tree, since `disconnectedCallback`
52
76
  * calls `destroy()`, and `forceUpdate` is a no-op on a disconnected host anyway. So
@@ -67,36 +91,74 @@ export const createAttributeController = (el, attributes, onChange, hostOwnedAtt
67
91
  }
68
92
  changed[name] = value;
69
93
  }
94
+ moveOffHost(changed);
70
95
  if (Object.keys(changed).length > 0) {
71
96
  inherited = { ...inherited, ...changed };
72
97
  onChange();
73
98
  }
74
99
  };
100
+ const handleRecords = (mutations) => {
101
+ const changed = {};
102
+ for (const mutation of mutations) {
103
+ const name = mutation.attributeName;
104
+ // A removed attribute reads back as null, which clears it from the element the
105
+ // values are spread onto.
106
+ const value = el.getAttribute(name);
107
+ setPresence(name, value);
108
+ changed[name] = value;
109
+ }
110
+ moveOffHost(changed);
111
+ // Drop the removals `moveOffHost` just queued, or they'd read back as the developer
112
+ // clearing the attribute.
113
+ observer?.takeRecords();
114
+ inherited = { ...inherited, ...changed };
115
+ onChange();
116
+ };
75
117
  const init = () => {
76
118
  // There is no MutationObserver in SSR or the hydrate build.
77
119
  if (observer !== undefined || watchedAttributes.length === 0 || win === undefined || !('MutationObserver' in win)) {
78
120
  return;
79
121
  }
80
122
  readMissedChanges();
81
- observer = new MutationObserver((mutations) => {
82
- const changed = {};
83
- for (const mutation of mutations) {
84
- const name = mutation.attributeName;
85
- // A removed attribute reads back as null, which clears it from the element the
86
- // values are spread onto.
87
- const value = el.getAttribute(name);
88
- setPresence(name, value);
89
- changed[name] = value;
90
- }
91
- inherited = { ...inherited, ...changed };
92
- onChange();
93
- });
123
+ observer = new MutationObserver(handleRecords);
94
124
  observer.observe(el, { attributeFilter: watchedAttributes });
95
125
  };
96
126
  const destroy = () => {
97
127
  observer?.disconnect();
98
128
  observer = undefined;
99
129
  };
130
+ const refresh = () => {
131
+ if (moveFromHost === undefined) {
132
+ return;
133
+ }
134
+ // A write made earlier in the same tick hasn't reached `inherited` yet, so take it in
135
+ // first, or the loop below would act on the old value and drop the new one.
136
+ if (observer !== undefined) {
137
+ const pending = observer.takeRecords();
138
+ if (pending.length > 0) {
139
+ handleRecords(pending);
140
+ }
141
+ }
142
+ else {
143
+ readMissedChanges();
144
+ }
145
+ for (const [name, value] of Object.entries(inherited)) {
146
+ if (value == null) {
147
+ continue;
148
+ }
149
+ const onHost = el.hasAttribute(name);
150
+ if (staysOnHost(name, value) && !onHost) {
151
+ el.setAttribute(name, value);
152
+ hostWritten.add(name);
153
+ }
154
+ else if (!staysOnHost(name, value) && onHost) {
155
+ el.removeAttribute(name);
156
+ hostWritten.delete(name);
157
+ }
158
+ }
159
+ // Drop our own writes, or they'd read back as the developer's.
160
+ observer?.takeRecords();
161
+ };
100
162
  /**
101
163
  * Has to run after the initial copy, because that copy removes the attributes from the
102
164
  * host and an observer armed any earlier would read the removal as a developer clearing
@@ -105,10 +167,20 @@ export const createAttributeController = (el, attributes, onChange, hostOwnedAtt
105
167
  init();
106
168
  return {
107
169
  get attributes() {
108
- return inherited;
170
+ if (moveFromHost === undefined) {
171
+ return inherited;
172
+ }
173
+ const moved = {};
174
+ for (const [name, value] of Object.entries(inherited)) {
175
+ if (!staysOnHost(name, value)) {
176
+ moved[name] = value;
177
+ }
178
+ }
179
+ return moved;
109
180
  },
110
181
  init,
111
182
  destroy,
183
+ refresh,
112
184
  };
113
185
  };
114
186
  /**
@@ -124,3 +196,18 @@ export const createAttributeController = (el, attributes, onChange, hostOwnedAtt
124
196
  export const createAriaAttributeController = (el, onChange, hostOwnedAttributes = []) => {
125
197
  return createAttributeController(el, ariaAttributes, onChange, hostOwnedAttributes);
126
198
  };
199
+ /**
200
+ * Moves `tabindex` from the host to the native element in the shadow root, including later
201
+ * writes, since a host with a `tabindex` is an extra tab stop with no name. A negative
202
+ * `tabindex` stays on the host, where it already skips the shadow root and the focus
203
+ * utilities expect to find it.
204
+ *
205
+ * @internal
206
+ * @param el The host element to copy from and watch.
207
+ * @param onChange Called after `tabindex` changes, so the component can re-render.
208
+ * @param hasNativeElement Whether the component renders a native element to move `tabindex`
209
+ * to. Call `refresh()` when the answer changes.
210
+ */
211
+ export const createTabindexController = (el, onChange, hasNativeElement = () => true) => {
212
+ return createAttributeController(el, ['tabindex'], onChange, [], (_, value) => hasNativeElement() && parseInt(value, 10) >= 0);
213
+ };
package/dist/docs.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "timestamp": "2026-11-11T06:12:11",
2
+ "timestamp": "2026-11-11T18:07:02",
3
3
  "compiler": {
4
4
  "name": "@stencil/core",
5
5
  "version": "4.45.2",
@@ -0,0 +1,215 @@
1
+ /*!
2
+ * (C) Ionic http://ionicframework.com - MIT License
3
+ */
4
+ import { b as inheritAttributes, w as win, q as ariaAttributes } from './helpers-p94IkmEA.js';
5
+
6
+ /**
7
+ * Copies a set of attributes off the host element so they can be applied to an element
8
+ * inside the shadow root, then keeps that copy in sync as the host attributes change.
9
+ * Using `inheritAttributes` alone copies once at load, so anything written to the host
10
+ * afterwards never reaches the element the assistive technology reads.
11
+ *
12
+ * Create the controller in `componentWillLoad`. It takes the initial copy and starts
13
+ * watching right away, so `init()` is only needed to resume after a move.
14
+ *
15
+ * Two things to know before adopting it. Unless `moveFromHost` says otherwise, only the
16
+ * initial copy removes the attributes from the host, so a value written after load sits
17
+ * on the host as well as on the element it is applied to, which matters if the host has
18
+ * a role of its own. And an attribute moved off the host can never be removed, only
19
+ * overwritten, since removing it from the host doesn't fire a mutation.
20
+ * An empty string works for `aria-label` and friends, but a token-valued attribute
21
+ * has to be set to its default instead, so `aria-pressed="false"` rather than empty.
22
+ *
23
+ * @internal
24
+ * @param el The host element to copy from and watch.
25
+ * @param attributes The attributes to copy and watch.
26
+ * @param onChange Called after `attributes` changes, so the component can re-render.
27
+ * @param hostOwnedAttributes Attributes copied at load but not watched. Use it for
28
+ * attributes the component renders on its own `<Host>`, since a later change to one of
29
+ * those is the component's own write, and for attributes that would put a second node in
30
+ * the accessibility tree if the host kept a copy alongside the one we apply.
31
+ * @param moveFromHost Called on load, after every write and on `refresh()` to decide whether
32
+ * a value moves off the host. A rejected value stays on the host and is left out of
33
+ * `attributes`. It can read component state, as long as the component calls `refresh()`
34
+ * when that state changes.
35
+ */
36
+ const createAttributeController = (el, attributes, onChange, hostOwnedAttributes = [], moveFromHost) => {
37
+ let inherited = inheritAttributes(el, attributes);
38
+ let observer;
39
+ const staysOnHost = (name, value) => moveFromHost !== undefined && value != null && !moveFromHost(name, value);
40
+ const watchedAttributes = attributes.filter((attr) => !hostOwnedAttributes.includes(attr));
41
+ /**
42
+ * The names still on the host, which is everything written after load. The initial
43
+ * copy removes what it captures, so a missing attribute only counts as a removal
44
+ * when its name is in here.
45
+ */
46
+ const hostWritten = new Set();
47
+ const setPresence = (name, value) => {
48
+ if (value === null) {
49
+ hostWritten.delete(name);
50
+ }
51
+ else {
52
+ hostWritten.add(name);
53
+ }
54
+ };
55
+ const moveOffHost = (changed) => {
56
+ if (moveFromHost === undefined) {
57
+ return;
58
+ }
59
+ for (const [name, value] of Object.entries(changed)) {
60
+ if (value != null && !staysOnHost(name, value)) {
61
+ el.removeAttribute(name);
62
+ // Without this, the missing attribute would read as a developer removal later.
63
+ hostWritten.delete(name);
64
+ }
65
+ }
66
+ };
67
+ // The initial copy took everything off the host, so put back what has to stay there.
68
+ for (const [name, value] of Object.entries(inherited)) {
69
+ if (staysOnHost(name, value)) {
70
+ el.setAttribute(name, value);
71
+ hostWritten.add(name);
72
+ }
73
+ }
74
+ /**
75
+ * Nothing is watching while the host is out of the tree, since `disconnectedCallback`
76
+ * calls `destroy()`, and `forceUpdate` is a no-op on a disconnected host anyway. So
77
+ * the host has to be re-read on the way back in.
78
+ */
79
+ const readMissedChanges = () => {
80
+ const changed = {};
81
+ for (const name of watchedAttributes) {
82
+ const value = el.getAttribute(name);
83
+ const wasOnHost = hostWritten.has(name);
84
+ setPresence(name, value);
85
+ /**
86
+ * An attribute that was never written to the host is missing because the initial
87
+ * copy took it, not because the developer cleared it.
88
+ */
89
+ if ((value === null && !wasOnHost) || value === inherited[name]) {
90
+ continue;
91
+ }
92
+ changed[name] = value;
93
+ }
94
+ moveOffHost(changed);
95
+ if (Object.keys(changed).length > 0) {
96
+ inherited = { ...inherited, ...changed };
97
+ onChange();
98
+ }
99
+ };
100
+ const handleRecords = (mutations) => {
101
+ const changed = {};
102
+ for (const mutation of mutations) {
103
+ const name = mutation.attributeName;
104
+ // A removed attribute reads back as null, which clears it from the element the
105
+ // values are spread onto.
106
+ const value = el.getAttribute(name);
107
+ setPresence(name, value);
108
+ changed[name] = value;
109
+ }
110
+ moveOffHost(changed);
111
+ // Drop the removals `moveOffHost` just queued, or they'd read back as the developer
112
+ // clearing the attribute.
113
+ observer?.takeRecords();
114
+ inherited = { ...inherited, ...changed };
115
+ onChange();
116
+ };
117
+ const init = () => {
118
+ // There is no MutationObserver in SSR or the hydrate build.
119
+ if (observer !== undefined || watchedAttributes.length === 0 || win === undefined || !('MutationObserver' in win)) {
120
+ return;
121
+ }
122
+ readMissedChanges();
123
+ observer = new MutationObserver(handleRecords);
124
+ observer.observe(el, { attributeFilter: watchedAttributes });
125
+ };
126
+ const destroy = () => {
127
+ observer?.disconnect();
128
+ observer = undefined;
129
+ };
130
+ const refresh = () => {
131
+ if (moveFromHost === undefined) {
132
+ return;
133
+ }
134
+ // A write made earlier in the same tick hasn't reached `inherited` yet, so take it in
135
+ // first, or the loop below would act on the old value and drop the new one.
136
+ if (observer !== undefined) {
137
+ const pending = observer.takeRecords();
138
+ if (pending.length > 0) {
139
+ handleRecords(pending);
140
+ }
141
+ }
142
+ else {
143
+ readMissedChanges();
144
+ }
145
+ for (const [name, value] of Object.entries(inherited)) {
146
+ if (value == null) {
147
+ continue;
148
+ }
149
+ const onHost = el.hasAttribute(name);
150
+ if (staysOnHost(name, value) && !onHost) {
151
+ el.setAttribute(name, value);
152
+ hostWritten.add(name);
153
+ }
154
+ else if (!staysOnHost(name, value) && onHost) {
155
+ el.removeAttribute(name);
156
+ hostWritten.delete(name);
157
+ }
158
+ }
159
+ // Drop our own writes, or they'd read back as the developer's.
160
+ observer?.takeRecords();
161
+ };
162
+ /**
163
+ * Has to run after the initial copy, because that copy removes the attributes from the
164
+ * host and an observer armed any earlier would read the removal as a developer clearing
165
+ * them.
166
+ */
167
+ init();
168
+ return {
169
+ get attributes() {
170
+ if (moveFromHost === undefined) {
171
+ return inherited;
172
+ }
173
+ const moved = {};
174
+ for (const [name, value] of Object.entries(inherited)) {
175
+ if (!staysOnHost(name, value)) {
176
+ moved[name] = value;
177
+ }
178
+ }
179
+ return moved;
180
+ },
181
+ init,
182
+ destroy,
183
+ refresh,
184
+ };
185
+ };
186
+ /**
187
+ * The `createAttributeController` equivalent of `inheritAriaAttributes`, which copies and
188
+ * watches every ARIA attribute plus `role`.
189
+ *
190
+ * @internal
191
+ * @param el The host element to copy from and watch.
192
+ * @param onChange Called after the attributes change, so the component can re-render.
193
+ * @param hostOwnedAttributes Attributes copied at load but not watched. See
194
+ * `createAttributeController`.
195
+ */
196
+ const createAriaAttributeController = (el, onChange, hostOwnedAttributes = []) => {
197
+ return createAttributeController(el, ariaAttributes, onChange, hostOwnedAttributes);
198
+ };
199
+ /**
200
+ * Moves `tabindex` from the host to the native element in the shadow root, including later
201
+ * writes, since a host with a `tabindex` is an extra tab stop with no name. A negative
202
+ * `tabindex` stays on the host, where it already skips the shadow root and the focus
203
+ * utilities expect to find it.
204
+ *
205
+ * @internal
206
+ * @param el The host element to copy from and watch.
207
+ * @param onChange Called after `tabindex` changes, so the component can re-render.
208
+ * @param hasNativeElement Whether the component renders a native element to move `tabindex`
209
+ * to. Call `refresh()` when the answer changes.
210
+ */
211
+ const createTabindexController = (el, onChange, hasNativeElement = () => true) => {
212
+ return createAttributeController(el, ['tabindex'], onChange, [], (_, value) => hasNativeElement() && parseInt(value, 10) >= 0);
213
+ };
214
+
215
+ export { createAriaAttributeController as a, createAttributeController as b, createTabindexController as c };
@@ -1,7 +1,8 @@
1
1
  /*!
2
2
  * (C) Ionic http://ionicframework.com - MIT License
3
3
  */
4
- import { r as registerInstance, i as config, h, f as Host, g as getElement } from './index-BpRUsN_W.js';
4
+ import { r as registerInstance, i as config, h, f as Host, g as getElement, j as forceUpdate } from './index-BpRUsN_W.js';
5
+ import { c as createTabindexController } from './attribute-controller-BMdZtDiw.js';
5
6
  import { i as inheritAriaAttributes } from './helpers-p94IkmEA.js';
6
7
  import { o as openURL, c as createColorClasses, h as hostContext } from './theme-byZM6qHV.js';
7
8
  import { c as chevronBack, a as arrowBackSharp } from './index-BvabGprD.js';
@@ -35,10 +36,17 @@ const BackButton = class {
35
36
  }
36
37
  componentWillLoad() {
37
38
  this.inheritedAttributes = inheritAriaAttributes(this.el);
39
+ this.tabindexController = createTabindexController(this.el, () => forceUpdate(this));
38
40
  if (this.defaultHref === undefined) {
39
41
  this.defaultHref = config.get('backButtonDefaultHref');
40
42
  }
41
43
  }
44
+ connectedCallback() {
45
+ this.tabindexController?.init();
46
+ }
47
+ disconnectedCallback() {
48
+ this.tabindexController?.destroy();
49
+ }
42
50
  get backButtonIcon() {
43
51
  const icon = this.icon;
44
52
  if (icon != null) {
@@ -72,7 +80,8 @@ const BackButton = class {
72
80
  const showBackButton = defaultHref !== undefined;
73
81
  const mode = getIonMode(this);
74
82
  const ariaLabel = inheritedAttributes['aria-label'] || backButtonText || 'back';
75
- return (h(Host, { key: '5466624a10f1ab56f5469e6dc07080303880f2fe', onClick: this.onClick, class: createColorClasses(color, {
83
+ const tabindexAttributes = this.tabindexController?.attributes ?? {};
84
+ return (h(Host, { key: '0b7d30b4421e69c01041819a242bb4d57ee08cdd', onClick: this.onClick, class: createColorClasses(color, {
76
85
  [mode]: true,
77
86
  button: true, // ion-buttons target .button
78
87
  'back-button-disabled': disabled,
@@ -82,7 +91,7 @@ const BackButton = class {
82
91
  'ion-activatable': true,
83
92
  'ion-focusable': true,
84
93
  'show-back-button': showBackButton,
85
- }) }, h("button", { key: '63bc75ef0ad7cc9fb79e58217a3314b20acd73e3', type: type, disabled: disabled, class: "button-native", part: "native", "aria-label": ariaLabel }, h("span", { key: '5d3eacbd11af2245c6e1151cab446a0d96559ad8', class: "button-inner" }, backButtonIcon && (h("ion-icon", { key: '6439af0ae463764174e7d3207f02267811df666d', part: "icon", icon: backButtonIcon, "aria-hidden": "true", lazy: false, "flip-rtl": icon === undefined })), backButtonText && (h("span", { key: '8ee89fb18dfdb5b75948a8b197ff4cdbc008742f', part: "text", "aria-hidden": "true", class: "button-text" }, backButtonText))), mode === 'md' && h("ion-ripple-effect", { key: '63803a884998bc73bea5afe0b2a0a14e3fa4d6bf', type: this.rippleType }))));
94
+ }) }, h("button", { key: '20bf90c1b19af213eb7db6fb105423b1d5552cc7', type: type, disabled: disabled, class: "button-native", part: "native", "aria-label": ariaLabel, ...tabindexAttributes }, h("span", { key: '1472b6bac0ae85a040f8de0a505cc6479e96b672', class: "button-inner" }, backButtonIcon && (h("ion-icon", { key: '223376e1501ca203b9f6d004707dd1d18b5fc076', part: "icon", icon: backButtonIcon, "aria-hidden": "true", lazy: false, "flip-rtl": icon === undefined })), backButtonText && (h("span", { key: '0e94d0b6c930193ed3762946731cf9f4ae626b72', part: "text", "aria-hidden": "true", class: "button-text" }, backButtonText))), mode === 'md' && h("ion-ripple-effect", { key: '7ef5b94fbbca517f333d1ae55198b373d843fec4', type: this.rippleType }))));
86
95
  }
87
96
  get el() { return getElement(this); }
88
97
  };
@@ -1,7 +1,8 @@
1
1
  /*!
2
2
  * (C) Ionic http://ionicframework.com - MIT License
3
3
  */
4
- import { r as registerInstance, d as createEvent, h, f as Host, g as getElement } from './index-BpRUsN_W.js';
4
+ import { r as registerInstance, d as createEvent, h, f as Host, g as getElement, j as forceUpdate } from './index-BpRUsN_W.js';
5
+ import { c as createTabindexController } from './attribute-controller-BMdZtDiw.js';
5
6
  import { i as inheritAriaAttributes } from './helpers-p94IkmEA.js';
6
7
  import { c as createColorClasses, o as openURL, h as hostContext } from './theme-byZM6qHV.js';
7
8
  import { p as chevronForwardOutline, q as ellipsisHorizontal } from './index-BvabGprD.js';
@@ -48,6 +49,21 @@ const Breadcrumb = class {
48
49
  }
49
50
  componentWillLoad() {
50
51
  this.inheritedAttributes = inheritAriaAttributes(this.el);
52
+ // A breadcrumb without an `href` has no native link, so `tabindex` stays on the host.
53
+ this.tabindexController = createTabindexController(this.el, () => forceUpdate(this), () => this.isClickable());
54
+ }
55
+ /**
56
+ * Adding or removing `href` adds or removes the native link, so `tabindex` has to move
57
+ * with it.
58
+ */
59
+ hrefChanged() {
60
+ this.tabindexController?.refresh();
61
+ }
62
+ connectedCallback() {
63
+ this.tabindexController?.init();
64
+ }
65
+ disconnectedCallback() {
66
+ this.tabindexController?.destroy();
51
67
  }
52
68
  isClickable() {
53
69
  return this.href !== undefined;
@@ -55,6 +71,7 @@ const Breadcrumb = class {
55
71
  render() {
56
72
  const { color, active, collapsed, disabled, download, el, inheritedAttributes, last, routerAnimation, routerDirection, separator, showCollapsedIndicator, target, } = this;
57
73
  const clickable = this.isClickable();
74
+ const tabindexAttributes = this.tabindexController?.attributes ?? {};
58
75
  const TagType = this.href === undefined ? 'span' : 'a';
59
76
  // Links can still be tabbed to when set to disabled if they have an href
60
77
  // in order to truly disable them we can keep it as an anchor but remove the href
@@ -71,7 +88,7 @@ const Breadcrumb = class {
71
88
  // to show the separator as long as it isn't also the last breadcrumb
72
89
  // otherwise if not collapsed use the value in separator
73
90
  const showSeparator = last ? false : collapsed ? (showCollapsedIndicator && !last ? true : false) : separator;
74
- return (h(Host, { key: '32ca61c83721dff52b5e97171ed449dce3584a55', onClick: (ev) => openURL(href, ev, routerDirection, routerAnimation), "aria-disabled": disabled ? 'true' : null, class: createColorClasses(color, {
91
+ return (h(Host, { key: '6f50e8b42045b81771ffd123a3cb708c603c1541', onClick: (ev) => openURL(href, ev, routerDirection, routerAnimation), "aria-disabled": disabled ? 'true' : null, class: createColorClasses(color, {
75
92
  [mode]: true,
76
93
  'breadcrumb-active': active,
77
94
  'breadcrumb-collapsed': collapsed,
@@ -81,17 +98,22 @@ const Breadcrumb = class {
81
98
  'in-toolbar-color': hostContext('ion-toolbar[color]', this.el),
82
99
  'ion-activatable': clickable,
83
100
  'ion-focusable': clickable,
84
- }) }, h(TagType, { key: '479feb845f4a6d8009d5422b33eb423730b9722b', ...attrs, class: "breadcrumb-native", part: "native", disabled: disabled, onFocus: this.onFocus, onBlur: this.onBlur, ...inheritedAttributes }, h("slot", { key: '3c5dcaeb0d258235d1b7707868026ff1d1404099', name: "start" }), h("slot", { key: 'f1cfb934443cd97dc220882c5e3596ea879d66cf' }), h("slot", { key: '539710121b5b1f3ee8d4c24a9651b67c2ae08add', name: "end" })), showCollapsedIndicator && (h("button", { key: 'ed53a95ccd89022c8b7bee0658a221ec62a5c73b', part: "collapsed-indicator", "aria-label": "Show more breadcrumbs", onClick: () => this.collapsedIndicatorClick(), ref: (collapsedEl) => (this.collapsedRef = collapsedEl), class: {
101
+ }) }, h(TagType, { key: '4ac14d323e1d35e987862aa9b875d30be2310a71', ...attrs, class: "breadcrumb-native", part: "native", disabled: disabled, onFocus: this.onFocus, onBlur: this.onBlur, ...inheritedAttributes, ...tabindexAttributes }, h("slot", { key: 'a3598ed5bc506acc4f5bef525cd2404b00228620', name: "start" }), h("slot", { key: '0696a0ffd1513c1d93deb269fdf600e9ef434f17' }), h("slot", { key: 'bf315bd49788604c27b8ba354796250b56f2fcb0', name: "end" })), showCollapsedIndicator && (h("button", { key: 'b130482d7ed16e3c452fa779b0696d1f8687e379', part: "collapsed-indicator", "aria-label": "Show more breadcrumbs", onClick: () => this.collapsedIndicatorClick(), ref: (collapsedEl) => (this.collapsedRef = collapsedEl), class: {
85
102
  'breadcrumbs-collapsed-indicator': true,
86
- } }, h("ion-icon", { key: 'a849e1142a86f06f207cf11662fa2a560ab7fc6a', "aria-hidden": "true", icon: ellipsisHorizontal, lazy: false }))), showSeparator && (
103
+ } }, h("ion-icon", { key: 'd5094d69a6477b390afaa230f76011bef97f386f', "aria-hidden": "true", icon: ellipsisHorizontal, lazy: false }))), showSeparator && (
87
104
  /**
88
105
  * Separators should not be announced by narrators.
89
106
  * We add aria-hidden on the span so that this applies
90
107
  * to any custom separators too.
91
108
  */
92
- h("span", { key: 'fc3c741cb01fafef8b26046c7ee5b190efc69a7c', class: "breadcrumb-separator", part: "separator", "aria-hidden": "true" }, h("slot", { key: '4871932ae1dae520767e0713e7cee2d11b0bba6d', name: "separator" }, mode === 'ios' ? (h("ion-icon", { icon: chevronForwardOutline, lazy: false, "flip-rtl": true })) : (h("span", null, "/")))))));
109
+ h("span", { key: '98421acb32aa73507ea1ab078555c20f4bdef6cd', class: "breadcrumb-separator", part: "separator", "aria-hidden": "true" }, h("slot", { key: '8b37779f2003554631a923a8d7ce2436238d1b05', name: "separator" }, mode === 'ios' ? (h("ion-icon", { icon: chevronForwardOutline, lazy: false, "flip-rtl": true })) : (h("span", null, "/")))))));
93
110
  }
94
111
  get el() { return getElement(this); }
112
+ static get watchers() { return {
113
+ "href": [{
114
+ "hrefChanged": 0
115
+ }]
116
+ }; }
95
117
  };
96
118
  Breadcrumb.style = {
97
119
  ios: breadcrumbIosCss(),
@@ -2,7 +2,7 @@
2
2
  * (C) Ionic http://ionicframework.com - MIT License
3
3
  */
4
4
  import { r as registerInstance, d as createEvent, a as printIonWarning, h, f as Host, g as getElement, j as forceUpdate, k as getAssetPath } from './index-BpRUsN_W.js';
5
- import { c as createAriaAttributeController } from './attribute-controller-ItNOXNp9.js';
5
+ import { a as createAriaAttributeController, c as createTabindexController } from './attribute-controller-BMdZtDiw.js';
6
6
  import { k as hasShadowDom } from './helpers-p94IkmEA.js';
7
7
  import { o as openURL, c as createColorClasses$1, h as hostContext } from './theme-byZM6qHV.js';
8
8
  import { b as getIonMode$1 } from './ionic-global-Cep6oYzK.js';
@@ -126,12 +126,15 @@ const Button = class {
126
126
  * two elements in the accessibility tree.
127
127
  */
128
128
  this.ariaController = createAriaAttributeController(this.el, () => forceUpdate(this), ['aria-disabled', 'role']);
129
+ this.tabindexController = createTabindexController(this.el, () => forceUpdate(this));
129
130
  }
130
131
  connectedCallback() {
131
132
  this.ariaController?.init();
133
+ this.tabindexController?.init();
132
134
  }
133
135
  disconnectedCallback() {
134
136
  this.ariaController?.destroy();
137
+ this.tabindexController?.destroy();
135
138
  }
136
139
  get hasIconOnly() {
137
140
  return !!this.el.querySelector('[slot="icon-only"]');
@@ -207,7 +210,10 @@ const Button = class {
207
210
  render() {
208
211
  const mode = getIonMode$1(this);
209
212
  const { buttonType, type, disabled, rel, target, size, href, color, expand, hasIconOnly, shape, strong } = this;
210
- const inheritedAttributes = this.ariaController?.attributes ?? {};
213
+ const inheritedAttributes = {
214
+ ...this.ariaController?.attributes,
215
+ ...this.tabindexController?.attributes,
216
+ };
211
217
  const finalSize = size === undefined && this.inItem ? 'small' : size;
212
218
  const TagType = href === undefined ? 'button' : 'a';
213
219
  const attrs = TagType === 'button'
@@ -232,7 +238,7 @@ const Button = class {
232
238
  {
233
239
  type !== 'button' && this.renderHiddenButton();
234
240
  }
235
- return (h(Host, { key: 'fd42d1a5836c148cddd6c474c130ce4bb36286ea', onClick: this.handleClick, "aria-disabled": disabled ? 'true' : null, class: createColorClasses$1(color, {
241
+ return (h(Host, { key: '9676cd8eb88ff0ff0582eeaa8b87ed4525a4dbee', onClick: this.handleClick, "aria-disabled": disabled ? 'true' : null, class: createColorClasses$1(color, {
236
242
  [mode]: true,
237
243
  [buttonType]: true,
238
244
  [`${buttonType}-${expand}`]: expand !== undefined,
@@ -247,7 +253,7 @@ const Button = class {
247
253
  'button-disabled': disabled,
248
254
  'ion-activatable': true,
249
255
  'ion-focusable': true,
250
- }) }, h(TagType, { key: '97dbf689ea912aed38182dbe0097a2bf5b768816', ...attrs, class: "button-native", part: "native", disabled: disabled, onFocus: this.onFocus, onBlur: this.onBlur, ...inheritedAttributes }, h("span", { key: '0f1ff4c667e95a8e3dc787fee43fe529b95477b7', class: "button-inner" }, h("slot", { key: 'fc1e8b8080d02828c392e9edd6a70e0255435f82', name: "icon-only", onSlotchange: this.slotChanged }), h("slot", { key: 'c1ece4c0d935f4d023d38fee4cf529dd4123d487', name: "start" }), h("slot", { key: '970db0ee1e3633bc9cbff52eca446e4891ff6851' }), h("slot", { key: 'ef8d7d894f01dbe881f381b985620c2a482e55fe', name: "end" })), mode === 'md' && h("ion-ripple-effect", { key: 'fea5e49a54b0efd07b1bd35d9fd5d2d862a2bac1', type: this.rippleType }))));
256
+ }) }, h(TagType, { key: '42609eab7e854c1e1ddf678c7dc83c7ec81e560e', ...attrs, class: "button-native", part: "native", disabled: disabled, onFocus: this.onFocus, onBlur: this.onBlur, ...inheritedAttributes }, h("span", { key: 'a212acc720c9312b3ac35345333df7a7175ace92', class: "button-inner" }, h("slot", { key: '05986b525272c768a37c274748f15aeb2fce313e', name: "icon-only", onSlotchange: this.slotChanged }), h("slot", { key: '4b6951f7b201c19714e97e2075f517f88642a169', name: "start" }), h("slot", { key: 'fa2d5ca4551a14ebfafe5399683e239566571398' }), h("slot", { key: 'ca8edc225165824f535177b99bb39adc1fea5fd2', name: "end" })), mode === 'md' && h("ion-ripple-effect", { key: '01c38cc6c230bb35861bbcc1472f4a2f18522e93', type: this.rippleType }))));
251
257
  }
252
258
  get el() { return getElement(this); }
253
259
  static get watchers() { return {
@@ -2,7 +2,7 @@
2
2
  * (C) Ionic http://ionicframework.com - MIT License
3
3
  */
4
4
  import { r as registerInstance, h, f as Host, g as getElement, j as forceUpdate } from './index-BpRUsN_W.js';
5
- import { a as createAttributeController } from './attribute-controller-ItNOXNp9.js';
5
+ import { b as createAttributeController, c as createTabindexController } from './attribute-controller-BMdZtDiw.js';
6
6
  import { o as openURL, c as createColorClasses } from './theme-byZM6qHV.js';
7
7
  import { b as getIonMode } from './ionic-global-Cep6oYzK.js';
8
8
  import './helpers-p94IkmEA.js';
@@ -40,12 +40,23 @@ const Card = class {
40
40
  * the card host renders no role of its own, so nothing reads the leftover copy.
41
41
  */
42
42
  this.ariaController = createAttributeController(this.el, ['aria-label'], () => forceUpdate(this));
43
+ // A card that isn't clickable has no native button or link, so `tabindex` stays on the host.
44
+ this.tabindexController = createTabindexController(this.el, () => forceUpdate(this), () => this.isClickable());
45
+ }
46
+ /**
47
+ * Changing `href` or `button` adds or removes the native element, so `tabindex` has to
48
+ * move with it.
49
+ */
50
+ clickableChanged() {
51
+ this.tabindexController?.refresh();
43
52
  }
44
53
  connectedCallback() {
45
54
  this.ariaController?.init();
55
+ this.tabindexController?.init();
46
56
  }
47
57
  disconnectedCallback() {
48
58
  this.ariaController?.destroy();
59
+ this.tabindexController?.destroy();
49
60
  }
50
61
  isClickable() {
51
62
  return this.href !== undefined || this.button;
@@ -57,6 +68,7 @@ const Card = class {
57
68
  }
58
69
  const { href, routerAnimation, routerDirection } = this;
59
70
  const inheritedAriaAttributes = this.ariaController?.attributes ?? {};
71
+ const tabindexAttributes = this.tabindexController?.attributes ?? {};
60
72
  const TagType = clickable ? (href === undefined ? 'button' : 'a') : 'div';
61
73
  const attrs = TagType === 'button'
62
74
  ? { type: this.type }
@@ -66,17 +78,25 @@ const Card = class {
66
78
  rel: this.rel,
67
79
  target: this.target,
68
80
  };
69
- return (h(TagType, { ...attrs, ...inheritedAriaAttributes, class: "card-native", part: "native", disabled: this.disabled, onClick: (ev) => openURL(href, ev, routerDirection, routerAnimation) }, h("slot", null), clickable && mode === 'md' && h("ion-ripple-effect", null)));
81
+ return (h(TagType, { ...attrs, ...inheritedAriaAttributes, ...tabindexAttributes, class: "card-native", part: "native", disabled: this.disabled, onClick: (ev) => openURL(href, ev, routerDirection, routerAnimation) }, h("slot", null), clickable && mode === 'md' && h("ion-ripple-effect", null)));
70
82
  }
71
83
  render() {
72
84
  const mode = getIonMode(this);
73
- return (h(Host, { key: '104412c26f53cce36432c3bb4d9e38bbe00c5816', class: createColorClasses(this.color, {
85
+ return (h(Host, { key: 'a50cd4e11f563acefeadc4c8f67536276593384a', class: createColorClasses(this.color, {
74
86
  [mode]: true,
75
87
  'card-disabled': this.disabled,
76
88
  'ion-activatable': this.isClickable(),
77
89
  }) }, this.renderCard(mode)));
78
90
  }
79
91
  get el() { return getElement(this); }
92
+ static get watchers() { return {
93
+ "href": [{
94
+ "clickableChanged": 0
95
+ }],
96
+ "button": [{
97
+ "clickableChanged": 0
98
+ }]
99
+ }; }
80
100
  };
81
101
  Card.style = {
82
102
  ios: cardIosCss(),