baseline-foundry 0.1.3

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 (145) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +588 -0
  3. package/config/experiments/ibm-plex-engine-smoke.json +115 -0
  4. package/config/experiments/ubuntu-engine-smoke.json +115 -0
  5. package/config/foundation-theme.json +117 -0
  6. package/config/tiers/app.json +120 -0
  7. package/config/tiers/documentation.json +120 -0
  8. package/config/tiers/editorial.json +120 -0
  9. package/config/tiers/os.json +120 -0
  10. package/dist/accordion.d.ts +5 -0
  11. package/dist/accordion.js +32 -0
  12. package/dist/application-layout.d.ts +4 -0
  13. package/dist/application-layout.js +181 -0
  14. package/dist/baseline-grid-overlay.d.ts +5 -0
  15. package/dist/baseline-grid-overlay.js +50 -0
  16. package/dist/baseline-grid-theme.d.ts +3 -0
  17. package/dist/baseline-grid-theme.js +3 -0
  18. package/dist/baseline-grid.d.ts +7 -0
  19. package/dist/baseline-grid.js +35 -0
  20. package/dist/build.d.ts +21 -0
  21. package/dist/build.js +440 -0
  22. package/dist/code-snippet.d.ts +6 -0
  23. package/dist/code-snippet.js +95 -0
  24. package/dist/contextual-menu.d.ts +4 -0
  25. package/dist/contextual-menu.js +156 -0
  26. package/dist/css-app-tier.d.ts +1 -0
  27. package/dist/css-app-tier.js +77 -0
  28. package/dist/css-components/article-pagination.d.ts +13 -0
  29. package/dist/css-components/article-pagination.js +151 -0
  30. package/dist/css-components/button-actions.d.ts +7 -0
  31. package/dist/css-components/button-actions.js +165 -0
  32. package/dist/css-components/cards-options.d.ts +6 -0
  33. package/dist/css-components/cards-options.js +180 -0
  34. package/dist/css-components/chip-badge-status.d.ts +10 -0
  35. package/dist/css-components/chip-badge-status.js +162 -0
  36. package/dist/css-components/content-card.d.ts +25 -0
  37. package/dist/css-components/content-card.js +517 -0
  38. package/dist/css-components/control-row.d.ts +2 -0
  39. package/dist/css-components/control-row.js +18 -0
  40. package/dist/css-components/cta-figure-aspect.d.ts +1 -0
  41. package/dist/css-components/cta-figure-aspect.js +123 -0
  42. package/dist/css-components/document-navigation.d.ts +13 -0
  43. package/dist/css-components/document-navigation.js +400 -0
  44. package/dist/css-components/editorial-content.d.ts +6 -0
  45. package/dist/css-components/editorial-content.js +52 -0
  46. package/dist/css-components/icon.d.ts +1 -0
  47. package/dist/css-components/icon.js +75 -0
  48. package/dist/css-components/interactive-feedback.d.ts +2 -0
  49. package/dist/css-components/interactive-feedback.js +230 -0
  50. package/dist/css-components/interactive-tables.d.ts +7 -0
  51. package/dist/css-components/interactive-tables.js +164 -0
  52. package/dist/css-components/linked-logo-site-layout.d.ts +21 -0
  53. package/dist/css-components/linked-logo-site-layout.js +214 -0
  54. package/dist/css-components/list-tree.d.ts +5 -0
  55. package/dist/css-components/list-tree.js +98 -0
  56. package/dist/css-components/list.d.ts +3 -0
  57. package/dist/css-components/list.js +119 -0
  58. package/dist/css-components/logo-media.d.ts +16 -0
  59. package/dist/css-components/logo-media.js +219 -0
  60. package/dist/css-components/navigation-layout.d.ts +5 -0
  61. package/dist/css-components/navigation-layout.js +151 -0
  62. package/dist/css-components/panel.d.ts +6 -0
  63. package/dist/css-components/panel.js +148 -0
  64. package/dist/css-components/search-box-and-filter.d.ts +9 -0
  65. package/dist/css-components/search-box-and-filter.js +267 -0
  66. package/dist/css-components/sites-editorial-ports.d.ts +19 -0
  67. package/dist/css-components/sites-editorial-ports.js +264 -0
  68. package/dist/css-components/sites-foundation.d.ts +17 -0
  69. package/dist/css-components/sites-foundation.js +173 -0
  70. package/dist/css-components/sites-rich-lists.d.ts +18 -0
  71. package/dist/css-components/sites-rich-lists.js +364 -0
  72. package/dist/css-components/static-content-ports.d.ts +14 -0
  73. package/dist/css-components/static-content-ports.js +206 -0
  74. package/dist/css-components/tab-section.d.ts +19 -0
  75. package/dist/css-components/tab-section.js +103 -0
  76. package/dist/css-components/table.d.ts +7 -0
  77. package/dist/css-components/table.js +79 -0
  78. package/dist/css-components/tabs-choice-breadcrumbs.d.ts +9 -0
  79. package/dist/css-components/tabs-choice-breadcrumbs.js +307 -0
  80. package/dist/css-components/tiered-list-equal-height-row.d.ts +1 -0
  81. package/dist/css-components/tiered-list-equal-height-row.js +286 -0
  82. package/dist/css-components.d.ts +2 -0
  83. package/dist/css-components.js +2701 -0
  84. package/dist/css-grid.d.ts +1 -0
  85. package/dist/css-grid.js +179 -0
  86. package/dist/css.d.ts +6 -0
  87. package/dist/css.js +431 -0
  88. package/dist/experiments/ibm-plex-engine-smoke/styles.css +8969 -0
  89. package/dist/experiments/ibm-plex-engine-smoke/surfaces.json +604 -0
  90. package/dist/experiments/ibm-plex-engine-smoke/tokens.json +217 -0
  91. package/dist/in-page-navigation.d.ts +7 -0
  92. package/dist/in-page-navigation.js +136 -0
  93. package/dist/index.d.ts +37 -0
  94. package/dist/index.js +18 -0
  95. package/dist/interactive-feedback.d.ts +14 -0
  96. package/dist/interactive-feedback.js +96 -0
  97. package/dist/interactive-tables.d.ts +28 -0
  98. package/dist/interactive-tables.js +184 -0
  99. package/dist/list-tree.d.ts +4 -0
  100. package/dist/list-tree.js +44 -0
  101. package/dist/panel-drawer.d.ts +4 -0
  102. package/dist/panel-drawer.js +171 -0
  103. package/dist/presets/app-tier/styles.css +9459 -0
  104. package/dist/presets/app-tier/surfaces.json +1225 -0
  105. package/dist/presets/app-tier/tokens.json +221 -0
  106. package/dist/presets/prose/styles.css +9442 -0
  107. package/dist/presets/prose/surfaces.json +1225 -0
  108. package/dist/presets/prose/tokens.json +221 -0
  109. package/dist/presets.d.ts +6 -0
  110. package/dist/presets.js +27 -0
  111. package/dist/range-controls.d.ts +9 -0
  112. package/dist/range-controls.js +73 -0
  113. package/dist/resizable-aside.d.ts +4 -0
  114. package/dist/resizable-aside.js +328 -0
  115. package/dist/side-navigation.d.ts +4 -0
  116. package/dist/side-navigation.js +219 -0
  117. package/dist/styles.css +9442 -0
  118. package/dist/surfaces.json +1225 -0
  119. package/dist/tabs.d.ts +4 -0
  120. package/dist/tabs.js +88 -0
  121. package/dist/tier-registry.d.ts +10 -0
  122. package/dist/tier-registry.js +25 -0
  123. package/dist/tiers/app/styles.css +9459 -0
  124. package/dist/tiers/app/surfaces.json +1225 -0
  125. package/dist/tiers/app/tokens.json +221 -0
  126. package/dist/tiers/documentation/styles.css +9442 -0
  127. package/dist/tiers/documentation/surfaces.json +1225 -0
  128. package/dist/tiers/documentation/tokens.json +221 -0
  129. package/dist/tiers/editorial/styles.css +9442 -0
  130. package/dist/tiers/editorial/surfaces.json +1225 -0
  131. package/dist/tiers/editorial/tokens.json +221 -0
  132. package/dist/tiers/os/styles.css +9442 -0
  133. package/dist/tiers/os/surfaces.json +1225 -0
  134. package/dist/tiers/os/tokens.json +221 -0
  135. package/dist/tokens.json +221 -0
  136. package/dist/tooltip.d.ts +4 -0
  137. package/dist/tooltip.js +70 -0
  138. package/dist/top-navigation.d.ts +4 -0
  139. package/dist/top-navigation.js +354 -0
  140. package/dist/types.d.ts +155 -0
  141. package/dist/types.js +1 -0
  142. package/dist/vanilla-theme-colors.d.ts +5 -0
  143. package/dist/vanilla-theme-colors.js +208 -0
  144. package/docs/publishing.md +66 -0
  145. package/package.json +108 -0
@@ -0,0 +1,217 @@
1
+ {
2
+ "baselineUnit": "0.5rem",
3
+ "fontFiles": [
4
+ {
5
+ "family": "ibm-plex-sans",
6
+ "path": "../../../assets/fonts/IBMPlexSansVar-Roman.woff2",
7
+ "cssFamily": "IBM Plex Sans",
8
+ "fontStyle": "normal",
9
+ "fontWeight": "100 700",
10
+ "fontDisplay": "swap"
11
+ }
12
+ ],
13
+ "fontStacks": {
14
+ "ibm-plex-sans": "\"IBM Plex Sans\", \"Segoe UI\", system-ui, sans-serif"
15
+ },
16
+ "roles": {
17
+ "body": {
18
+ "fontSize": "1rem",
19
+ "lineHeight": "1.5rem",
20
+ "fontFamily": "ibm-plex-sans",
21
+ "fontWeight": 400,
22
+ "fontStyle": "normal",
23
+ "spaceAfter": "1rem",
24
+ "nudgeTop": "0.375rem",
25
+ "identifier": "body",
26
+ "fontStack": "\"IBM Plex Sans\", \"Segoe UI\", system-ui, sans-serif",
27
+ "marginBottom": "0.125rem"
28
+ },
29
+ "h1": {
30
+ "fontSize": "8rem",
31
+ "lineHeight": "9rem",
32
+ "fontFamily": "ibm-plex-sans",
33
+ "fontWeight": 400,
34
+ "fontStyle": "normal",
35
+ "spaceAfter": "1rem",
36
+ "nudgeTop": "0rem",
37
+ "identifier": "h1",
38
+ "fontStack": "\"IBM Plex Sans\", \"Segoe UI\", system-ui, sans-serif",
39
+ "marginBottom": "0.5rem"
40
+ },
41
+ "h2": {
42
+ "fontSize": "4rem",
43
+ "lineHeight": "5rem",
44
+ "fontFamily": "ibm-plex-sans",
45
+ "fontWeight": 300,
46
+ "fontStyle": "normal",
47
+ "spaceAfter": "1rem",
48
+ "nudgeTop": "0rem",
49
+ "identifier": "h2",
50
+ "fontStack": "\"IBM Plex Sans\", \"Segoe UI\", system-ui, sans-serif",
51
+ "marginBottom": "0.5rem"
52
+ },
53
+ "h3": {
54
+ "fontSize": "2.5rem",
55
+ "lineHeight": "3rem",
56
+ "fontFamily": "ibm-plex-sans",
57
+ "fontWeight": 500,
58
+ "fontStyle": "normal",
59
+ "spaceAfter": "1rem",
60
+ "nudgeTop": "0.025rem",
61
+ "identifier": "h3",
62
+ "fontStack": "\"IBM Plex Sans\", \"Segoe UI\", system-ui, sans-serif",
63
+ "marginBottom": "0.475rem"
64
+ },
65
+ "h4": {
66
+ "fontSize": "1.5rem",
67
+ "lineHeight": "2rem",
68
+ "fontFamily": "ibm-plex-sans",
69
+ "fontWeight": 400,
70
+ "fontStyle": "normal",
71
+ "spaceAfter": "1rem",
72
+ "nudgeTop": "0.41667rem",
73
+ "identifier": "h4",
74
+ "fontStack": "\"IBM Plex Sans\", \"Segoe UI\", system-ui, sans-serif",
75
+ "marginBottom": "0.08333rem"
76
+ },
77
+ "h5": {
78
+ "fontSize": "1rem",
79
+ "lineHeight": "1.5rem",
80
+ "fontFamily": "ibm-plex-sans",
81
+ "fontWeight": 600,
82
+ "fontStyle": "normal",
83
+ "spaceAfter": "1rem",
84
+ "nudgeTop": "0.375rem",
85
+ "identifier": "h5",
86
+ "fontStack": "\"IBM Plex Sans\", \"Segoe UI\", system-ui, sans-serif",
87
+ "marginBottom": "0.125rem",
88
+ "fontVariantCaps": "all-small-caps"
89
+ },
90
+ "h6": {
91
+ "fontSize": "1rem",
92
+ "lineHeight": "1.5rem",
93
+ "fontFamily": "ibm-plex-sans",
94
+ "fontWeight": 400,
95
+ "fontStyle": "normal",
96
+ "spaceAfter": "1rem",
97
+ "nudgeTop": "0.375rem",
98
+ "identifier": "h6",
99
+ "fontStack": "\"IBM Plex Sans\", \"Segoe UI\", system-ui, sans-serif",
100
+ "marginBottom": "0.125rem"
101
+ }
102
+ },
103
+ "elements": {
104
+ "body": {
105
+ "fontSize": "1rem",
106
+ "lineHeight": "1.5rem",
107
+ "fontFamily": "ibm-plex-sans",
108
+ "fontWeight": 400,
109
+ "fontStyle": "normal",
110
+ "spaceAfter": "1rem",
111
+ "nudgeTop": "0.375rem",
112
+ "identifier": "body",
113
+ "fontStack": "\"IBM Plex Sans\", \"Segoe UI\", system-ui, sans-serif",
114
+ "marginBottom": "0.125rem"
115
+ },
116
+ "h6": {
117
+ "fontSize": "1rem",
118
+ "lineHeight": "1.5rem",
119
+ "fontFamily": "ibm-plex-sans",
120
+ "fontWeight": 400,
121
+ "fontStyle": "normal",
122
+ "spaceAfter": "1rem",
123
+ "nudgeTop": "0.375rem",
124
+ "identifier": "h6",
125
+ "fontStack": "\"IBM Plex Sans\", \"Segoe UI\", system-ui, sans-serif",
126
+ "marginBottom": "0.125rem"
127
+ },
128
+ "h5": {
129
+ "fontSize": "1rem",
130
+ "lineHeight": "1.5rem",
131
+ "fontFamily": "ibm-plex-sans",
132
+ "fontWeight": 600,
133
+ "fontStyle": "normal",
134
+ "spaceAfter": "1rem",
135
+ "nudgeTop": "0.375rem",
136
+ "identifier": "h5",
137
+ "fontStack": "\"IBM Plex Sans\", \"Segoe UI\", system-ui, sans-serif",
138
+ "marginBottom": "0.125rem",
139
+ "fontVariantCaps": "all-small-caps"
140
+ },
141
+ "h4": {
142
+ "fontSize": "1.5rem",
143
+ "lineHeight": "2rem",
144
+ "fontFamily": "ibm-plex-sans",
145
+ "fontWeight": 400,
146
+ "fontStyle": "normal",
147
+ "spaceAfter": "1rem",
148
+ "nudgeTop": "0.41667rem",
149
+ "identifier": "h4",
150
+ "fontStack": "\"IBM Plex Sans\", \"Segoe UI\", system-ui, sans-serif",
151
+ "marginBottom": "0.08333rem"
152
+ },
153
+ "h3": {
154
+ "fontSize": "2.5rem",
155
+ "lineHeight": "3rem",
156
+ "fontFamily": "ibm-plex-sans",
157
+ "fontWeight": 500,
158
+ "fontStyle": "normal",
159
+ "spaceAfter": "1rem",
160
+ "nudgeTop": "0.025rem",
161
+ "identifier": "h3",
162
+ "fontStack": "\"IBM Plex Sans\", \"Segoe UI\", system-ui, sans-serif",
163
+ "marginBottom": "0.475rem"
164
+ },
165
+ "h2": {
166
+ "fontSize": "4rem",
167
+ "lineHeight": "5rem",
168
+ "fontFamily": "ibm-plex-sans",
169
+ "fontWeight": 300,
170
+ "fontStyle": "normal",
171
+ "spaceAfter": "1rem",
172
+ "nudgeTop": "0rem",
173
+ "identifier": "h2",
174
+ "fontStack": "\"IBM Plex Sans\", \"Segoe UI\", system-ui, sans-serif",
175
+ "marginBottom": "0.5rem"
176
+ },
177
+ "h1": {
178
+ "fontSize": "8rem",
179
+ "lineHeight": "9rem",
180
+ "fontFamily": "ibm-plex-sans",
181
+ "fontWeight": 400,
182
+ "fontStyle": "normal",
183
+ "spaceAfter": "1rem",
184
+ "nudgeTop": "0rem",
185
+ "identifier": "h1",
186
+ "fontStack": "\"IBM Plex Sans\", \"Segoe UI\", system-ui, sans-serif",
187
+ "marginBottom": "0.5rem"
188
+ }
189
+ },
190
+ "layout": {
191
+ "contentMaxWidth": "120rem",
192
+ "contentPaddingInline": "1.5rem",
193
+ "measure": "40rem",
194
+ "sectionSpace": "4rem",
195
+ "sectionSpaceShallow": "1.5rem",
196
+ "sectionSpaceDeep": "8rem",
197
+ "stripSpace": "4rem",
198
+ "gridGapInline": "1.5rem",
199
+ "gridGapBlock": "1.5rem",
200
+ "pageMargin": "1.5rem"
201
+ },
202
+ "components": {
203
+ "borderWidth": "1px",
204
+ "barThickness": "0.1875rem",
205
+ "radius": "0rem",
206
+ "controlBlockPadding": "0.5rem",
207
+ "controlCompactBlockPadding": "0.25rem",
208
+ "controlInlinePadding": "1rem",
209
+ "controlInlinePaddingAction": "1rem",
210
+ "controlInlinePaddingField": "0.5rem",
211
+ "controlVisualSize": "1rem",
212
+ "fieldGap": "0.5rem",
213
+ "panelPaddingInline": "1rem",
214
+ "panelPaddingBlock": "1rem",
215
+ "accordionIndent": "1.5rem"
216
+ }
217
+ }
@@ -0,0 +1,7 @@
1
+ export interface InPageNavigationInitOptions {
2
+ root?: ParentNode;
3
+ observeCurrent?: boolean;
4
+ expandLabel?: string;
5
+ collapseLabel?: string;
6
+ }
7
+ export declare function initInPageNavigations(options?: InPageNavigationInitOptions): () => void;
@@ -0,0 +1,136 @@
1
+ const ROOT_SELECTOR = ".bf-in-page-navigation";
2
+ const TOGGLE_SELECTOR = ".bf-in-page-navigation-toggle[aria-controls]";
3
+ const LIST_SELECTOR = ".bf-in-page-navigation-list";
4
+ const LINK_SELECTOR = ".bf-in-page-navigation-link[href^='#']";
5
+ function closestElement(target, selector) {
6
+ return target instanceof Element ? target.closest(selector) : null;
7
+ }
8
+ function controlledList(toggle) {
9
+ const controlledId = toggle.getAttribute("aria-controls");
10
+ const list = controlledId ? toggle.ownerDocument.getElementById(controlledId) : null;
11
+ const navigation = toggle.closest(ROOT_SELECTOR);
12
+ return list?.matches(LIST_SELECTOR) && navigation?.contains(list) ? list : null;
13
+ }
14
+ function stateLabel(toggle, expanded, options) {
15
+ const attribute = expanded ? "data-bf-collapse-label" : "data-bf-expand-label";
16
+ return toggle.getAttribute(attribute)?.trim()
17
+ || (expanded ? options.collapseLabel ?? "Collapse in-page navigation" : options.expandLabel ?? "Expand in-page navigation");
18
+ }
19
+ function syncToggle(toggle, expanded, options) {
20
+ const navigation = toggle.closest(ROOT_SELECTOR);
21
+ const list = controlledList(toggle);
22
+ if (!navigation || !list)
23
+ return;
24
+ navigation.classList.toggle("is-expanded", expanded);
25
+ toggle.setAttribute("aria-expanded", String(expanded));
26
+ toggle.setAttribute("aria-label", stateLabel(toggle, expanded, options));
27
+ list.setAttribute("aria-expanded", String(expanded));
28
+ const icon = toggle.querySelector(".bf-icon");
29
+ icon?.classList.toggle("is-chevron-down", !expanded);
30
+ icon?.classList.toggle("is-chevron-up", expanded);
31
+ if (!expanded) {
32
+ navigation.querySelector(`${LINK_SELECTOR}[aria-current]`)?.scrollIntoView({
33
+ block: "nearest",
34
+ inline: "nearest"
35
+ });
36
+ }
37
+ }
38
+ function setCurrentLink(navigation, activeLink) {
39
+ for (const link of Array.from(navigation.querySelectorAll(LINK_SELECTOR))) {
40
+ if (link === activeLink) {
41
+ link.setAttribute("aria-current", "location");
42
+ link.classList.add("is-active");
43
+ }
44
+ else {
45
+ link.removeAttribute("aria-current");
46
+ link.classList.remove("is-active");
47
+ }
48
+ }
49
+ }
50
+ function currentObservers(root) {
51
+ if (typeof IntersectionObserver === "undefined")
52
+ return [];
53
+ const observers = [];
54
+ for (const navigation of Array.from(root.querySelectorAll(ROOT_SELECTOR))) {
55
+ const linksByTarget = new Map();
56
+ for (const link of Array.from(navigation.querySelectorAll(LINK_SELECTOR))) {
57
+ let targetId = link.hash.slice(1);
58
+ try {
59
+ targetId = decodeURIComponent(targetId);
60
+ }
61
+ catch {
62
+ continue;
63
+ }
64
+ const target = targetId ? link.ownerDocument.getElementById(targetId) : null;
65
+ if (target)
66
+ linksByTarget.set(target, link);
67
+ }
68
+ if (linksByTarget.size === 0)
69
+ continue;
70
+ const visible = new Map();
71
+ const observer = new IntersectionObserver(entries => {
72
+ for (const entry of entries) {
73
+ if (entry.isIntersecting)
74
+ visible.set(entry.target, entry.boundingClientRect.top);
75
+ else
76
+ visible.delete(entry.target);
77
+ }
78
+ const nearest = Array.from(visible.entries()).sort((a, b) => Math.abs(a[1]) - Math.abs(b[1]))[0];
79
+ const activeLink = nearest ? linksByTarget.get(nearest[0]) : null;
80
+ if (activeLink)
81
+ setCurrentLink(navigation, activeLink);
82
+ }, {
83
+ rootMargin: "-10% 0px -60% 0px",
84
+ threshold: [0, 0.5]
85
+ });
86
+ for (const target of linksByTarget.keys())
87
+ observer.observe(target);
88
+ observers.push(observer);
89
+ }
90
+ return observers;
91
+ }
92
+ export function initInPageNavigations(options = {}) {
93
+ const root = options.root ?? document;
94
+ for (const toggle of Array.from(root.querySelectorAll(TOGGLE_SELECTOR))) {
95
+ if (controlledList(toggle)) {
96
+ syncToggle(toggle, toggle.getAttribute("aria-expanded") === "true", options);
97
+ }
98
+ }
99
+ const observers = options.observeCurrent === false ? [] : currentObservers(root);
100
+ const onClick = (event) => {
101
+ const toggle = closestElement(event.target, TOGGLE_SELECTOR);
102
+ if (toggle && root.contains(toggle) && controlledList(toggle)) {
103
+ event.preventDefault();
104
+ syncToggle(toggle, toggle.getAttribute("aria-expanded") !== "true", options);
105
+ return;
106
+ }
107
+ const link = closestElement(event.target, LINK_SELECTOR);
108
+ const navigation = link?.closest(ROOT_SELECTOR);
109
+ if (link && navigation && root.contains(navigation)) {
110
+ setCurrentLink(navigation, link);
111
+ const navigationToggle = navigation.querySelector(TOGGLE_SELECTOR);
112
+ if (navigationToggle?.getAttribute("aria-expanded") === "true") {
113
+ syncToggle(navigationToggle, false, options);
114
+ }
115
+ }
116
+ };
117
+ const onKeyDown = (event) => {
118
+ if (!(event instanceof KeyboardEvent) || event.key !== "Escape")
119
+ return;
120
+ const navigation = closestElement(event.target, ROOT_SELECTOR);
121
+ const toggle = navigation?.querySelector(TOGGLE_SELECTOR);
122
+ if (!toggle || toggle.getAttribute("aria-expanded") !== "true")
123
+ return;
124
+ event.preventDefault();
125
+ syncToggle(toggle, false, options);
126
+ toggle.focus();
127
+ };
128
+ root.addEventListener("click", onClick);
129
+ root.addEventListener("keydown", onKeyDown);
130
+ return () => {
131
+ root.removeEventListener("click", onClick);
132
+ root.removeEventListener("keydown", onKeyDown);
133
+ for (const observer of observers)
134
+ observer.disconnect();
135
+ };
136
+ }
@@ -0,0 +1,37 @@
1
+ export { initAccordions, toggleAccordionButton } from "./accordion.js";
2
+ export { initApplicationLayouts } from "./application-layout.js";
3
+ export { initBaselineGridToggles, setupBaselineGridToggle } from "./baseline-grid.js";
4
+ export { generateBaselineGridOverlayCss, generateBaselineGridThemeOverrideCss } from "./baseline-grid-overlay.js";
5
+ export { initCodeSnippets } from "./code-snippet.js";
6
+ export { initContextualMenus } from "./contextual-menu.js";
7
+ export { initInPageNavigations } from "./in-page-navigation.js";
8
+ export { initInteractiveFeedback, initNotificationDismissals, initPasswordReveals } from "./interactive-feedback.js";
9
+ export { initExpandingTables, initInteractiveTables, initMobileCardTables, initSortableTables } from "./interactive-tables.js";
10
+ export { initListTree } from "./list-tree.js";
11
+ export { initPanelDrawers } from "./panel-drawer.js";
12
+ export { initRangeControls, setupRangeControl, updateRangeFill } from "./range-controls.js";
13
+ export { initResizableAsides } from "./resizable-aside.js";
14
+ export { initSideNavigations } from "./side-navigation.js";
15
+ export { initTopNavigations } from "./top-navigation.js";
16
+ export { initTabs } from "./tabs.js";
17
+ export { initTooltips } from "./tooltip.js";
18
+ export { isTierName, tierDescriptions, tierNames } from "./tier-registry.js";
19
+ export type { AccordionInitOptions } from "./accordion.js";
20
+ export type { ApplicationLayoutInitOptions } from "./application-layout.js";
21
+ export type { BaselineGridInitOptions } from "./baseline-grid.js";
22
+ export type { BaselineGridOverlayOptions } from "./baseline-grid-overlay.js";
23
+ export type { CodeSnippetInitOptions } from "./code-snippet.js";
24
+ export type { ContextualMenuInitOptions } from "./contextual-menu.js";
25
+ export type { InPageNavigationInitOptions } from "./in-page-navigation.js";
26
+ export type { InteractiveFeedbackInitOptions, NotificationDismissInitOptions, PasswordRevealInitOptions } from "./interactive-feedback.js";
27
+ export type { ExpandingTableInitOptions, InteractiveTablesInitOptions, MobileCardTableInitOptions, SortableTableInitOptions, TableSortCompare, TableSortContext, TableSortDirection } from "./interactive-tables.js";
28
+ export type { ListTreeInitOptions } from "./list-tree.js";
29
+ export type { PanelDrawerInitOptions } from "./panel-drawer.js";
30
+ export type { RangeControlsInitOptions } from "./range-controls.js";
31
+ export type { ResizableAsideInitOptions } from "./resizable-aside.js";
32
+ export type { SideNavigationInitOptions } from "./side-navigation.js";
33
+ export type { TopNavigationInitOptions } from "./top-navigation.js";
34
+ export type { BaselineGeneratorTokens, BuildThemeResult, ComponentTokens, DeriveBaselineTokensResult, LayoutTokens, ThemeComponentsConfig, ThemeConfig, ThemeElementConfig, ThemeFontFile, ThemeLayoutConfig, ThemeSurface, ThemeSurfaceManifest, ThemeSurfaceManifestEntry, ThemeTokens, TypographyToken } from "./types.js";
35
+ export type { BuiltInThemeName, PresetName, TierName } from "./tier-registry.js";
36
+ export type { TabsInitOptions } from "./tabs.js";
37
+ export type { TooltipInitOptions } from "./tooltip.js";
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ export { initAccordions, toggleAccordionButton } from "./accordion.js";
2
+ export { initApplicationLayouts } from "./application-layout.js";
3
+ export { initBaselineGridToggles, setupBaselineGridToggle } from "./baseline-grid.js";
4
+ export { generateBaselineGridOverlayCss, generateBaselineGridThemeOverrideCss } from "./baseline-grid-overlay.js";
5
+ export { initCodeSnippets } from "./code-snippet.js";
6
+ export { initContextualMenus } from "./contextual-menu.js";
7
+ export { initInPageNavigations } from "./in-page-navigation.js";
8
+ export { initInteractiveFeedback, initNotificationDismissals, initPasswordReveals } from "./interactive-feedback.js";
9
+ export { initExpandingTables, initInteractiveTables, initMobileCardTables, initSortableTables } from "./interactive-tables.js";
10
+ export { initListTree } from "./list-tree.js";
11
+ export { initPanelDrawers } from "./panel-drawer.js";
12
+ export { initRangeControls, setupRangeControl, updateRangeFill } from "./range-controls.js";
13
+ export { initResizableAsides } from "./resizable-aside.js";
14
+ export { initSideNavigations } from "./side-navigation.js";
15
+ export { initTopNavigations } from "./top-navigation.js";
16
+ export { initTabs } from "./tabs.js";
17
+ export { initTooltips } from "./tooltip.js";
18
+ export { isTierName, tierDescriptions, tierNames } from "./tier-registry.js";
@@ -0,0 +1,14 @@
1
+ export interface PasswordRevealInitOptions {
2
+ root?: ParentNode;
3
+ showLabel?: string;
4
+ hideLabel?: string;
5
+ }
6
+ export interface NotificationDismissInitOptions {
7
+ root?: ParentNode;
8
+ }
9
+ export interface InteractiveFeedbackInitOptions extends PasswordRevealInitOptions {
10
+ root?: ParentNode;
11
+ }
12
+ export declare function initPasswordReveals(options?: PasswordRevealInitOptions): () => void;
13
+ export declare function initNotificationDismissals(options?: NotificationDismissInitOptions): () => void;
14
+ export declare function initInteractiveFeedback(options?: InteractiveFeedbackInitOptions): () => void;
@@ -0,0 +1,96 @@
1
+ const PASSWORD_REVEAL_SELECTOR = ".bf-password-reveal[aria-controls]";
2
+ const PASSWORD_REVEAL_LABEL_SELECTOR = ".bf-password-reveal-label";
3
+ const NOTIFICATION_CLOSE_SELECTOR = ".bf-notification-close[aria-controls]";
4
+ function closestButton(target, selector) {
5
+ if (!(target instanceof Element)) {
6
+ return null;
7
+ }
8
+ return target.closest(selector);
9
+ }
10
+ function controlledElement(control, expectedSelector) {
11
+ const controlledId = control.getAttribute("aria-controls");
12
+ if (!controlledId) {
13
+ return null;
14
+ }
15
+ const ownerDocument = control.ownerDocument;
16
+ const element = ownerDocument.getElementById(controlledId);
17
+ return element?.matches(expectedSelector) ? element : null;
18
+ }
19
+ function passwordLabel(toggle, fallback, state) {
20
+ const attribute = state === "show" ? "data-bf-show-label" : "data-bf-hide-label";
21
+ return toggle.getAttribute(attribute)?.trim() || fallback;
22
+ }
23
+ function syncPasswordReveal(toggle, input, showLabel, hideLabel) {
24
+ const isRevealed = input.type === "text";
25
+ const label = passwordLabel(toggle, isRevealed ? hideLabel : showLabel, isRevealed ? "hide" : "show");
26
+ toggle.setAttribute("aria-pressed", String(isRevealed));
27
+ const visibleLabel = toggle.querySelector(PASSWORD_REVEAL_LABEL_SELECTOR);
28
+ if (visibleLabel) {
29
+ visibleLabel.textContent = label;
30
+ }
31
+ }
32
+ export function initPasswordReveals(options = {}) {
33
+ const root = options.root ?? document;
34
+ const showLabel = options.showLabel ?? "Show password";
35
+ const hideLabel = options.hideLabel ?? "Hide password";
36
+ for (const toggle of Array.from(root.querySelectorAll(PASSWORD_REVEAL_SELECTOR))) {
37
+ const input = controlledElement(toggle, "input[type='password'], input[type='text']");
38
+ if (input) {
39
+ syncPasswordReveal(toggle, input, showLabel, hideLabel);
40
+ }
41
+ }
42
+ const onClick = (event) => {
43
+ const toggle = closestButton(event.target, PASSWORD_REVEAL_SELECTOR);
44
+ if (!toggle || !root.contains(toggle)) {
45
+ return;
46
+ }
47
+ const input = controlledElement(toggle, "input[type='password'], input[type='text']");
48
+ if (!input) {
49
+ return;
50
+ }
51
+ event.preventDefault();
52
+ input.type = input.type === "password" ? "text" : "password";
53
+ syncPasswordReveal(toggle, input, showLabel, hideLabel);
54
+ };
55
+ root.addEventListener("click", onClick);
56
+ return () => root.removeEventListener("click", onClick);
57
+ }
58
+ export function initNotificationDismissals(options = {}) {
59
+ const root = options.root ?? document;
60
+ const onClick = (event) => {
61
+ const closeButton = closestButton(event.target, NOTIFICATION_CLOSE_SELECTOR);
62
+ if (!closeButton || !root.contains(closeButton)) {
63
+ return;
64
+ }
65
+ const notification = controlledElement(closeButton, ".bf-notification");
66
+ if (!notification) {
67
+ return;
68
+ }
69
+ event.preventDefault();
70
+ if (closeButton.ownerDocument.activeElement === closeButton) {
71
+ const visibleNotifications = Array.from(root.querySelectorAll(".bf-notification:not([hidden])"));
72
+ const notificationIndex = visibleNotifications.indexOf(notification);
73
+ const focusTarget = visibleNotifications[notificationIndex + 1] ??
74
+ visibleNotifications[notificationIndex - 1] ??
75
+ notification.parentElement;
76
+ if (focusTarget && focusTarget !== notification) {
77
+ if (!focusTarget.hasAttribute("tabindex")) {
78
+ focusTarget.tabIndex = -1;
79
+ focusTarget.addEventListener("blur", () => focusTarget.removeAttribute("tabindex"), { once: true });
80
+ }
81
+ focusTarget.focus({ preventScroll: true });
82
+ }
83
+ }
84
+ notification.hidden = true;
85
+ };
86
+ root.addEventListener("click", onClick);
87
+ return () => root.removeEventListener("click", onClick);
88
+ }
89
+ export function initInteractiveFeedback(options = {}) {
90
+ const disposePasswordReveals = initPasswordReveals(options);
91
+ const disposeNotificationDismissals = initNotificationDismissals(options);
92
+ return () => {
93
+ disposeNotificationDismissals();
94
+ disposePasswordReveals();
95
+ };
96
+ }
@@ -0,0 +1,28 @@
1
+ export type TableSortDirection = "none" | "ascending" | "descending";
2
+ export interface TableSortContext {
3
+ columnIndex: number;
4
+ direction: Exclude<TableSortDirection, "none">;
5
+ table: HTMLTableElement;
6
+ }
7
+ export type TableSortCompare = (valueA: string, valueB: string, context: TableSortContext) => number;
8
+ export interface SortableTableInitOptions {
9
+ root?: ParentNode;
10
+ compare?: TableSortCompare;
11
+ locale?: string | string[];
12
+ }
13
+ export interface ExpandingTableInitOptions {
14
+ root?: ParentNode;
15
+ expandedLabel?: string;
16
+ collapsedLabel?: string;
17
+ }
18
+ export interface MobileCardTableInitOptions {
19
+ root?: ParentNode;
20
+ }
21
+ export interface InteractiveTablesInitOptions extends SortableTableInitOptions {
22
+ expandedLabel?: string;
23
+ collapsedLabel?: string;
24
+ }
25
+ export declare function initSortableTables(options?: SortableTableInitOptions): () => void;
26
+ export declare function initExpandingTables(options?: ExpandingTableInitOptions): () => void;
27
+ export declare function initMobileCardTables(options?: MobileCardTableInitOptions): () => void;
28
+ export declare function initInteractiveTables(options?: InteractiveTablesInitOptions): () => void;