@ds-mo/ui 1.0.2 → 1.1.0

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 (177) hide show
  1. package/dist/components/ds-bar-nav-action.js +1 -1
  2. package/dist/components/ds-bar-nav.js +1 -1
  3. package/dist/components/ds-bar-nav.js.map +1 -1
  4. package/dist/components/ds-breadcrumb.js +1 -1
  5. package/dist/components/ds-button-group.js +1 -1
  6. package/dist/components/ds-button.js +1 -1
  7. package/dist/components/ds-card.js +1 -1
  8. package/dist/components/ds-card.js.map +1 -1
  9. package/dist/components/ds-checkbox.js +1 -1
  10. package/dist/components/ds-divider.js +1 -1
  11. package/dist/components/ds-empty-state.js +1 -1
  12. package/dist/components/ds-empty-state.js.map +1 -1
  13. package/dist/components/ds-fade.js +1 -1
  14. package/dist/components/ds-field.js +1 -1
  15. package/dist/components/ds-header.js +1 -1
  16. package/dist/components/ds-header.js.map +1 -1
  17. package/dist/components/ds-icon.js +1 -1
  18. package/dist/components/ds-input.js +1 -1
  19. package/dist/components/ds-label-wrap.js +1 -1
  20. package/dist/components/ds-menu.js +1 -1
  21. package/dist/components/ds-modal.js +1 -1
  22. package/dist/components/ds-panel-nav.js +1 -1
  23. package/dist/components/ds-radio-group.js +1 -1
  24. package/dist/components/ds-radio-group.js.map +1 -1
  25. package/dist/components/ds-scrollbar.js +1 -1
  26. package/dist/components/ds-select.js +1 -1
  27. package/dist/components/ds-slider.js +1 -1
  28. package/dist/components/ds-slider.js.map +1 -1
  29. package/dist/components/ds-surface.js +1 -1
  30. package/dist/components/ds-tab-group-nav.d.ts +11 -0
  31. package/dist/components/ds-tab-group-nav.js +2 -0
  32. package/dist/components/ds-tab-group-nav.js.map +1 -0
  33. package/dist/components/ds-tab-group.js +1 -1
  34. package/dist/components/ds-tab-group.js.map +1 -1
  35. package/dist/components/ds-table.js +1 -1
  36. package/dist/components/ds-table.js.map +1 -1
  37. package/dist/components/ds-tag.js +1 -1
  38. package/dist/components/ds-text.js +1 -1
  39. package/dist/components/ds-toast-provider.js +1 -1
  40. package/dist/components/ds-toggle-button-group.js +1 -1
  41. package/dist/components/ds-toggle-button.js +1 -1
  42. package/dist/components/ds-toggle.js +1 -1
  43. package/dist/components/ds-tooltip.js +1 -1
  44. package/dist/components/p-BQq26pt9.js +2 -0
  45. package/dist/components/p-BQq26pt9.js.map +1 -0
  46. package/dist/components/p-CMyQsk0K.js +2 -0
  47. package/dist/components/p-CMyQsk0K.js.map +1 -0
  48. package/dist/components/{p-D3CwGoIu.js → p-COsKOwZR.js} +2 -2
  49. package/dist/components/p-CpbnmEu1.js +2 -0
  50. package/dist/components/p-CpbnmEu1.js.map +1 -0
  51. package/dist/components/{p-DouEVPmi.js → p-Dd0GrKaF.js} +2 -2
  52. package/dist/components/{p-BvxKLqNx.js → p-H89PzqGU.js} +2 -2
  53. package/dist/components/{p-BYe8Rfdg.js → p-Vwlmhl4E.js} +2 -2
  54. package/dist/components/{p-C4p1fG67.js → p-woooYulR.js} +2 -2
  55. package/dist/types/.stencil/BarNav/BarNav.d.ts +7 -2
  56. package/dist/types/.stencil/BarNav/bar-nav-dom-utils.d.ts +1 -2
  57. package/dist/types/.stencil/TabGroupNav/TabGroupNav.d.ts +27 -0
  58. package/dist/types/components.d.ts +68 -0
  59. package/package.json +37 -7
  60. package/src/angular/index.ts +1 -0
  61. package/src/angular/proxies.ts +28 -0
  62. package/src/react/components.ts +46 -0
  63. package/src/react/ds-accordion.ts +27 -0
  64. package/src/react/ds-badge.ts +26 -0
  65. package/src/react/ds-banner.ts +27 -0
  66. package/src/react/ds-bar-nav-action.ts +27 -0
  67. package/src/react/ds-bar-nav.ts +33 -0
  68. package/src/react/ds-breadcrumb.ts +27 -0
  69. package/src/react/ds-button-group.ts +27 -0
  70. package/src/react/ds-button.ts +35 -0
  71. package/src/react/ds-card.ts +26 -0
  72. package/src/react/ds-checkbox.ts +27 -0
  73. package/src/react/ds-divider.ts +26 -0
  74. package/src/react/ds-empty-state.ts +26 -0
  75. package/src/react/ds-fade.ts +26 -0
  76. package/src/react/ds-field.ts +26 -0
  77. package/src/react/ds-header.ts +26 -0
  78. package/src/react/ds-icon.ts +26 -0
  79. package/src/react/ds-input.ts +33 -0
  80. package/src/react/ds-label-wrap.ts +26 -0
  81. package/src/react/ds-loader.ts +26 -0
  82. package/src/react/ds-menu.ts +33 -0
  83. package/src/react/ds-modal.ts +27 -0
  84. package/src/react/ds-pagination.ts +27 -0
  85. package/src/react/ds-panel-nav.ts +37 -0
  86. package/src/react/ds-radio-group.ts +27 -0
  87. package/src/react/ds-scrollbar.ts +26 -0
  88. package/src/react/ds-select.ts +27 -0
  89. package/src/react/ds-sidebar.ts +33 -0
  90. package/src/react/ds-skeleton.ts +26 -0
  91. package/src/react/ds-slider.ts +27 -0
  92. package/src/react/ds-surface.ts +26 -0
  93. package/src/react/ds-tab-group-nav.ts +27 -0
  94. package/src/react/ds-tab-group.ts +27 -0
  95. package/src/react/ds-table.ts +35 -0
  96. package/src/react/ds-tag.ts +35 -0
  97. package/src/react/ds-text.ts +26 -0
  98. package/src/react/ds-toast-provider.ts +26 -0
  99. package/src/react/ds-toggle-button-group.ts +27 -0
  100. package/src/react/ds-toggle-button.ts +27 -0
  101. package/src/react/ds-toggle.ts +27 -0
  102. package/src/react/ds-tooltip.ts +26 -0
  103. package/src/wc/components/Accordion/Accordion.tsx +144 -0
  104. package/src/wc/components/Badge/Badge.tsx +34 -0
  105. package/src/wc/components/Badge/index.ts +1 -0
  106. package/src/wc/components/Banner/Banner.tsx +148 -0
  107. package/src/wc/components/BarNav/BarNav.tsx +605 -0
  108. package/src/wc/components/BarNav/bar-nav-dom-utils.ts +23 -0
  109. package/src/wc/components/BarNav/bar-nav-tabs-menu-utils.ts +59 -0
  110. package/src/wc/components/BarNav/bar-nav-utils.ts +76 -0
  111. package/src/wc/components/BarNav/index.ts +1 -0
  112. package/src/wc/components/BarNavAction/BarNavAction.tsx +67 -0
  113. package/src/wc/components/BarNavAction/index.ts +1 -0
  114. package/src/wc/components/Breadcrumb/Breadcrumb.tsx +61 -0
  115. package/src/wc/components/Button/Button.tsx +158 -0
  116. package/src/wc/components/Button/index.ts +1 -0
  117. package/src/wc/components/ButtonGroup/ButtonGroup.tsx +110 -0
  118. package/src/wc/components/Card/Card.tsx +26 -0
  119. package/src/wc/components/Checkbox/Checkbox.tsx +60 -0
  120. package/src/wc/components/Checkbox/index.ts +1 -0
  121. package/src/wc/components/Divider/Divider.tsx +23 -0
  122. package/src/wc/components/Divider/index.ts +2 -0
  123. package/src/wc/components/EmptyState/EmptyState.tsx +32 -0
  124. package/src/wc/components/Fade/Fade.tsx +32 -0
  125. package/src/wc/components/Fade/index.ts +1 -0
  126. package/src/wc/components/Field/Field.tsx +28 -0
  127. package/src/wc/components/Header/Header.tsx +33 -0
  128. package/src/wc/components/Icon/Icon.tsx +112 -0
  129. package/src/wc/components/Icon/flag-icon-catalog.ts +68 -0
  130. package/src/wc/components/Icon/index.ts +1 -0
  131. package/src/wc/components/Icon/system-icon-catalog.ts +798 -0
  132. package/src/wc/components/Input/Input.tsx +100 -0
  133. package/src/wc/components/Input/index.ts +1 -0
  134. package/src/wc/components/LabelWrap/LabelWrap.tsx +38 -0
  135. package/src/wc/components/Loader/Loader.tsx +47 -0
  136. package/src/wc/components/Loader/index.ts +1 -0
  137. package/src/wc/components/Menu/Menu.tsx +340 -0
  138. package/src/wc/components/Modal/Modal.tsx +197 -0
  139. package/src/wc/components/Pagination/Pagination.tsx +97 -0
  140. package/src/wc/components/PanelNav/PanelNav.tsx +666 -0
  141. package/src/wc/components/PanelNav/index.ts +7 -0
  142. package/src/wc/components/PanelNav/panel-nav-utils.ts +124 -0
  143. package/src/wc/components/RadioGroup/RadioGroup.tsx +128 -0
  144. package/src/wc/components/RadioGroup/index.ts +1 -0
  145. package/src/wc/components/Scrollbar/Scrollbar.tsx +189 -0
  146. package/src/wc/components/Select/Select.tsx +195 -0
  147. package/src/wc/components/Sidebar/Sidebar.tsx +245 -0
  148. package/src/wc/components/Skeleton/Skeleton.tsx +64 -0
  149. package/src/wc/components/Skeleton/index.ts +1 -0
  150. package/src/wc/components/Slider/Slider.tsx +68 -0
  151. package/src/wc/components/Slider/index.ts +1 -0
  152. package/src/wc/components/Surface/Surface.tsx +81 -0
  153. package/src/wc/components/TabGroup/TabGroup.tsx +188 -0
  154. package/src/wc/components/TabGroup/tab-item-utils.ts +24 -0
  155. package/src/wc/components/TabGroupNav/TabGroupNav.tsx +188 -0
  156. package/src/wc/components/Table/Table.tsx +268 -0
  157. package/src/wc/components/Tag/Tag.tsx +135 -0
  158. package/src/wc/components/Tag/index.ts +1 -0
  159. package/src/wc/components/Text/Text.tsx +100 -0
  160. package/src/wc/components/Text/index.ts +1 -0
  161. package/src/wc/components/Toast/Toast.tsx +174 -0
  162. package/src/wc/components/Toast/toast-service.ts +60 -0
  163. package/src/wc/components/Toggle/Toggle.tsx +43 -0
  164. package/src/wc/components/Toggle/index.ts +1 -0
  165. package/src/wc/components/ToggleButton/ToggleButton.tsx +120 -0
  166. package/src/wc/components/ToggleButtonGroup/ToggleButtonGroup.tsx +118 -0
  167. package/src/wc/components/Tooltip/Tooltip.tsx +196 -0
  168. package/src/wc/components.d.ts +3028 -0
  169. package/dist/components/p-DV8pmt1m.js +0 -2
  170. package/dist/components/p-DV8pmt1m.js.map +0 -1
  171. package/dist/components/p-STnE_bmQ.js +0 -2
  172. package/dist/components/p-STnE_bmQ.js.map +0 -1
  173. /package/dist/components/{p-D3CwGoIu.js.map → p-COsKOwZR.js.map} +0 -0
  174. /package/dist/components/{p-DouEVPmi.js.map → p-Dd0GrKaF.js.map} +0 -0
  175. /package/dist/components/{p-BvxKLqNx.js.map → p-H89PzqGU.js.map} +0 -0
  176. /package/dist/components/{p-BYe8Rfdg.js.map → p-Vwlmhl4E.js.map} +0 -0
  177. /package/dist/components/{p-C4p1fG67.js.map → p-woooYulR.js.map} +0 -0
@@ -0,0 +1,197 @@
1
+ import { Component, Prop, State, Event, EventEmitter, Element, Watch, h, Host } from '@stencil/core';
2
+
3
+ export type ModalWidth = 'sm' | 'md' | 'lg';
4
+
5
+ const WIDTH_MAP: Record<ModalWidth, string> = {
6
+ sm: 'var(--dimension-modal-width-sm, 400px)',
7
+ md: 'var(--dimension-modal-width-md, 560px)',
8
+ lg: 'var(--dimension-modal-width-lg, 720px)',
9
+ };
10
+
11
+ const CLOSE_ANIMATION_MS = 220;
12
+
13
+ const FOCUSABLE_SEL = [
14
+ 'a[href]',
15
+ 'area[href]',
16
+ 'button:not([disabled])',
17
+ 'input:not([disabled]):not([type="hidden"])',
18
+ 'select:not([disabled])',
19
+ 'textarea:not([disabled])',
20
+ 'iframe',
21
+ '[contenteditable="true"]',
22
+ '[tabindex]:not([tabindex="-1"])',
23
+ ].join(',');
24
+
25
+ let modalIdCounter = 0;
26
+
27
+ @Component({
28
+ tag: 'ds-modal',
29
+ styleUrl: 'Modal.css',
30
+ scoped: true,
31
+ })
32
+ export class Modal {
33
+ @Element() el!: HTMLElement;
34
+
35
+ @Prop({ mutable: true }) open: boolean = false;
36
+ @Prop() heading!: string;
37
+ @Prop() subtitle: string | undefined;
38
+ @Prop() modalWidth: ModalWidth | string = 'md';
39
+
40
+ @State() private shouldRender: boolean = false;
41
+ @State() private closing: boolean = false;
42
+
43
+ @Event() dsClose!: EventEmitter<void>;
44
+
45
+ private instanceId = ++modalIdCounter;
46
+ private titleId = `ds-modal-title-${modalIdCounter}`;
47
+ private subtitleId = `ds-modal-subtitle-${modalIdCounter}`;
48
+ private previousFocus: HTMLElement | null = null;
49
+ private escapeHandler: ((e: KeyboardEvent) => void) | null = null;
50
+ private tabHandler: ((e: KeyboardEvent) => void) | null = null;
51
+ private closeTimer: ReturnType<typeof setTimeout> | null = null;
52
+
53
+ componentDidLoad() {
54
+ if (this.open) this.onOpenChange(true);
55
+ }
56
+
57
+ disconnectedCallback() {
58
+ this.teardownListeners();
59
+ }
60
+
61
+ @Watch('open')
62
+ onOpenChange(isOpen: boolean) {
63
+ if (isOpen) {
64
+ this.shouldRender = true;
65
+ this.closing = false;
66
+ this.previousFocus = document.activeElement as HTMLElement | null;
67
+ requestAnimationFrame(() => {
68
+ this.focusFirst();
69
+ this.setupListeners();
70
+ });
71
+ } else if (this.shouldRender) {
72
+ this.closing = true;
73
+ this.teardownListeners();
74
+ this.closeTimer = setTimeout(() => {
75
+ this.shouldRender = false;
76
+ this.closing = false;
77
+ this.closeTimer = null;
78
+ this.previousFocus?.focus?.();
79
+ this.previousFocus = null;
80
+ }, CLOSE_ANIMATION_MS);
81
+ }
82
+ }
83
+
84
+ private focusFirst() {
85
+ const dialog = this.el.querySelector('.modal-dialog') as HTMLElement | null;
86
+ if (!dialog) return;
87
+ const focusables = this.getFocusables(dialog);
88
+ (focusables[0] ?? dialog).focus();
89
+ }
90
+
91
+ private getFocusables(root: HTMLElement): HTMLElement[] {
92
+ return Array.from(root.querySelectorAll<HTMLElement>(FOCUSABLE_SEL)).filter(
93
+ el => !el.hasAttribute('disabled') && el.getAttribute('aria-hidden') !== 'true'
94
+ );
95
+ }
96
+
97
+ private setupListeners() {
98
+ this.escapeHandler = (e: KeyboardEvent) => {
99
+ if (e.key === 'Escape') { e.preventDefault(); this.close(); }
100
+ };
101
+
102
+ this.tabHandler = (e: KeyboardEvent) => {
103
+ if (e.key !== 'Tab') return;
104
+ const dialog = this.el.querySelector('.modal-dialog') as HTMLElement | null;
105
+ if (!dialog) return;
106
+ const focusables = this.getFocusables(dialog);
107
+ if (!focusables.length) { e.preventDefault(); dialog.focus(); return; }
108
+ const first = focusables[0];
109
+ const last = focusables[focusables.length - 1];
110
+ const active = document.activeElement;
111
+ if (e.shiftKey) {
112
+ if (active === first || active === dialog || !dialog.contains(active)) {
113
+ e.preventDefault(); last.focus();
114
+ }
115
+ } else {
116
+ if (active === last || !dialog.contains(active)) {
117
+ e.preventDefault(); first.focus();
118
+ }
119
+ }
120
+ };
121
+
122
+ document.addEventListener('keydown', this.escapeHandler);
123
+ document.addEventListener('keydown', this.tabHandler);
124
+ }
125
+
126
+ private teardownListeners() {
127
+ if (this.escapeHandler) {
128
+ document.removeEventListener('keydown', this.escapeHandler);
129
+ this.escapeHandler = null;
130
+ }
131
+ if (this.tabHandler) {
132
+ document.removeEventListener('keydown', this.tabHandler);
133
+ this.tabHandler = null;
134
+ }
135
+ if (this.closeTimer) {
136
+ clearTimeout(this.closeTimer);
137
+ this.closeTimer = null;
138
+ }
139
+ }
140
+
141
+ private close() {
142
+ this.dsClose.emit();
143
+ this.open = false;
144
+ }
145
+
146
+ private handleBackdropMouseDown(e: MouseEvent) {
147
+ if (e.target === e.currentTarget) this.close();
148
+ }
149
+
150
+ private get resolvedWidth(): string {
151
+ if (this.modalWidth === 'sm' || this.modalWidth === 'md' || this.modalWidth === 'lg') {
152
+ return WIDTH_MAP[this.modalWidth];
153
+ }
154
+ return this.modalWidth as string;
155
+ }
156
+
157
+ render() {
158
+ // Always render slots so scoped-mode slot distribution doesn't leak content.
159
+ // The backdrop is hidden via CSS when not active.
160
+ const hidden = !this.shouldRender && !this.closing;
161
+
162
+ return (
163
+ <Host style={{ display: 'contents' }}>
164
+ <div
165
+ class={{ 'modal-backdrop': true, 'modal-backdrop--closing': this.closing, 'modal-backdrop--hidden': hidden }}
166
+ onMouseDown={(e: MouseEvent) => this.handleBackdropMouseDown(e)}
167
+ style={{ position: 'fixed', inset: '0', zIndex: '9999', display: hidden ? 'none' : 'flex', alignItems: 'center', justifyContent: 'center', padding: 'var(--dimension-space-200)' }}
168
+ >
169
+ <div
170
+ class={{ 'modal-dialog': true, 'modal-dialog--closing': this.closing }}
171
+ role="dialog"
172
+ aria-modal="true"
173
+ aria-labelledby={this.titleId}
174
+ aria-describedby={this.subtitle ? this.subtitleId : undefined}
175
+ tabIndex={-1}
176
+ style={{ width: `min(${this.resolvedWidth}, calc(100vw - 32px))` }}
177
+ >
178
+ <div class="modal-header">
179
+ <h2 id={this.titleId} class="text-title-small modal-title">{this.heading}</h2>
180
+ {this.subtitle && (
181
+ <div id={this.subtitleId} class="modal-subtitle text-body-medium">
182
+ {this.subtitle}
183
+ </div>
184
+ )}
185
+ </div>
186
+ <div class="modal-body">
187
+ <slot />
188
+ </div>
189
+ <div class="modal-footer">
190
+ <slot name="footer" />
191
+ </div>
192
+ </div>
193
+ </div>
194
+ </Host>
195
+ );
196
+ }
197
+ }
@@ -0,0 +1,97 @@
1
+ import { Component, Prop, Event, EventEmitter, h, Host } from '@stencil/core';
2
+
3
+ function buildRange(start: number, end: number): (number | 'ellipsis')[] {
4
+ const items: (number | 'ellipsis')[] = [];
5
+ for (let i = start; i <= end; i++) items.push(i);
6
+ return items;
7
+ }
8
+
9
+ function buildPages(page: number, totalPages: number, siblings: number): (number | 'ellipsis')[] {
10
+ const totalSlots = siblings * 2 + 5;
11
+ if (totalPages <= totalSlots) return buildRange(1, totalPages);
12
+
13
+ const leftSibling = Math.max(page - siblings, 2);
14
+ const rightSibling = Math.min(page + siblings, totalPages - 1);
15
+ const showLeft = leftSibling > 2;
16
+ const showRight = rightSibling < totalPages - 1;
17
+
18
+ if (!showLeft && showRight) return [...buildRange(1, siblings * 2 + 3), 'ellipsis', totalPages];
19
+ if (showLeft && !showRight) return [1, 'ellipsis', ...buildRange(totalPages - (siblings * 2 + 2), totalPages)];
20
+ return [1, 'ellipsis', ...buildRange(leftSibling, rightSibling), 'ellipsis', totalPages];
21
+ }
22
+
23
+ @Component({
24
+ tag: 'ds-pagination',
25
+ styleUrl: 'Pagination.css',
26
+ scoped: true,
27
+ })
28
+ export class Pagination {
29
+ @Prop({ mutable: true }) page: number = 1;
30
+ @Prop() totalPages: number = 1;
31
+ @Prop() siblingCount: number = 1;
32
+ @Prop() inactive: boolean = false;
33
+
34
+ @Event() dsPageChange!: EventEmitter<number>;
35
+
36
+ private go(p: number) {
37
+ if (this.inactive) return;
38
+ this.page = p;
39
+ this.dsPageChange.emit(p);
40
+ }
41
+
42
+ render() {
43
+ if (this.totalPages <= 1) return <Host style={{ display: 'none' }} />;
44
+
45
+ const pages = buildPages(this.page, this.totalPages, this.siblingCount);
46
+
47
+ return (
48
+ <Host>
49
+ <nav
50
+ class={{ pagination: true, 'pagination--inactive': this.inactive }}
51
+ aria-label="Pagination"
52
+ >
53
+ <button
54
+ type="button"
55
+ class="button button--nav"
56
+ disabled={this.page <= 1 || this.inactive}
57
+ onClick={() => this.go(this.page - 1)}
58
+ aria-label="Previous page"
59
+ >
60
+ &#x2039;
61
+ </button>
62
+
63
+ {pages.map((item, i) =>
64
+ item === 'ellipsis' ? (
65
+ <span key={`e${i}`} class="ellipsis">
66
+ <span class="text-body-small" style={{ color: 'var(--color-foreground-tertiary)' }}>…</span>
67
+ </span>
68
+ ) : (
69
+ <button
70
+ key={item}
71
+ type="button"
72
+ class={{ button: true, 'button--active': item === this.page }}
73
+ onClick={() => this.go(item)}
74
+ aria-current={item === this.page ? 'page' : undefined}
75
+ disabled={this.inactive}
76
+ >
77
+ <span class={item === this.page ? 'text-body-small-emphasis' : 'text-body-small'}>
78
+ {item}
79
+ </span>
80
+ </button>
81
+ )
82
+ )}
83
+
84
+ <button
85
+ type="button"
86
+ class="button button--nav"
87
+ disabled={this.page >= this.totalPages || this.inactive}
88
+ onClick={() => this.go(this.page + 1)}
89
+ aria-label="Next page"
90
+ >
91
+ &#x203A;
92
+ </button>
93
+ </nav>
94
+ </Host>
95
+ );
96
+ }
97
+ }