@db-ux/react-core-components 4.9.0 → 4.10.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 (166) hide show
  1. package/CHANGELOG.md +17 -1
  2. package/README.md +97 -35
  3. package/dist/components/accordion/accordion.js +102 -86
  4. package/dist/components/accordion/model.d.ts +2 -2
  5. package/dist/components/accordion/model.js +4 -2
  6. package/dist/components/accordion-item/accordion-item.d.ts +2 -1
  7. package/dist/components/accordion-item/accordion-item.js +89 -56
  8. package/dist/components/accordion-item/model.d.ts +5 -1
  9. package/dist/components/badge/badge.js +72 -32
  10. package/dist/components/badge/model.d.ts +1 -1
  11. package/dist/components/badge/model.js +12 -1
  12. package/dist/components/brand/brand.js +60 -13
  13. package/dist/components/brand/model.d.ts +1 -1
  14. package/dist/components/button/button.js +75 -21
  15. package/dist/components/button/model.d.ts +1 -1
  16. package/dist/components/button/model.js +13 -2
  17. package/dist/components/card/card.js +65 -15
  18. package/dist/components/card/model.d.ts +1 -1
  19. package/dist/components/card/model.js +8 -2
  20. package/dist/components/checkbox/checkbox.js +163 -157
  21. package/dist/components/checkbox/model.d.ts +1 -1
  22. package/dist/components/custom-button/custom-button.js +65 -10
  23. package/dist/components/custom-button/model.d.ts +2 -2
  24. package/dist/components/custom-select/custom-select.js +509 -727
  25. package/dist/components/custom-select/model.d.ts +4 -4
  26. package/dist/components/custom-select/model.js +8 -1
  27. package/dist/components/custom-select-dropdown/custom-select-dropdown.js +62 -11
  28. package/dist/components/custom-select-dropdown/model.d.ts +1 -1
  29. package/dist/components/custom-select-dropdown/model.js +8 -1
  30. package/dist/components/custom-select-form-field/custom-select-form-field.js +57 -10
  31. package/dist/components/custom-select-form-field/model.d.ts +1 -1
  32. package/dist/components/custom-select-list/custom-select-list.js +60 -11
  33. package/dist/components/custom-select-list/model.d.ts +1 -1
  34. package/dist/components/custom-select-list-item/custom-select-list-item.js +89 -32
  35. package/dist/components/custom-select-list-item/model.d.ts +1 -1
  36. package/dist/components/custom-select-list-item/model.js +4 -1
  37. package/dist/components/divider/divider.js +60 -10
  38. package/dist/components/divider/model.d.ts +1 -1
  39. package/dist/components/divider/model.js +4 -2
  40. package/dist/components/drawer/drawer.js +118 -97
  41. package/dist/components/drawer/model.d.ts +1 -1
  42. package/dist/components/drawer/model.js +14 -4
  43. package/dist/components/header/header.js +143 -65
  44. package/dist/components/header/model.d.ts +1 -1
  45. package/dist/components/icon/icon.js +61 -12
  46. package/dist/components/icon/model.d.ts +1 -1
  47. package/dist/components/icon/model.js +11 -1
  48. package/dist/components/infotext/infotext.js +62 -12
  49. package/dist/components/infotext/model.d.ts +1 -1
  50. package/dist/components/input/input.js +198 -167
  51. package/dist/components/input/model.d.ts +1 -1
  52. package/dist/components/input/model.js +21 -5
  53. package/dist/components/link/link.js +70 -12
  54. package/dist/components/link/model.d.ts +1 -1
  55. package/dist/components/link/model.js +8 -3
  56. package/dist/components/navigation/model.d.ts +1 -1
  57. package/dist/components/navigation/navigation.js +57 -11
  58. package/dist/components/navigation-item/model.d.ts +6 -2
  59. package/dist/components/navigation-item/navigation-item.js +117 -81
  60. package/dist/components/notification/model.d.ts +1 -1
  61. package/dist/components/notification/model.js +12 -3
  62. package/dist/components/notification/notification.js +100 -32
  63. package/dist/components/page/model.d.ts +1 -1
  64. package/dist/components/page/model.js +4 -2
  65. package/dist/components/page/page.js +74 -46
  66. package/dist/components/popover/model.d.ts +1 -1
  67. package/dist/components/popover/popover.js +126 -125
  68. package/dist/components/radio/model.d.ts +1 -1
  69. package/dist/components/radio/radio.js +124 -85
  70. package/dist/components/section/model.d.ts +1 -1
  71. package/dist/components/section/section.js +59 -10
  72. package/dist/components/select/model.d.ts +1 -1
  73. package/dist/components/select/select.js +188 -191
  74. package/dist/components/stack/model.d.ts +1 -1
  75. package/dist/components/stack/model.js +14 -4
  76. package/dist/components/stack/stack.js +63 -10
  77. package/dist/components/switch/model.d.ts +1 -1
  78. package/dist/components/switch/switch.js +182 -150
  79. package/dist/components/tab-item/model.d.ts +1 -1
  80. package/dist/components/tab-item/tab-item.js +105 -76
  81. package/dist/components/tab-list/model.d.ts +1 -1
  82. package/dist/components/tab-list/tab-list.js +60 -11
  83. package/dist/components/tab-panel/model.d.ts +1 -1
  84. package/dist/components/tab-panel/tab-panel.js +59 -13
  85. package/dist/components/tabs/model.d.ts +3 -3
  86. package/dist/components/tabs/model.js +4 -2
  87. package/dist/components/tabs/tabs.js +191 -178
  88. package/dist/components/tag/model.d.ts +1 -1
  89. package/dist/components/tag/model.js +4 -1
  90. package/dist/components/tag/tag.js +91 -32
  91. package/dist/components/textarea/model.d.ts +1 -1
  92. package/dist/components/textarea/model.js +13 -2
  93. package/dist/components/textarea/textarea.js +165 -150
  94. package/dist/components/tooltip/model.d.ts +1 -1
  95. package/dist/components/tooltip/model.js +4 -1
  96. package/dist/components/tooltip/tooltip.js +119 -115
  97. package/dist/index.js +64 -81
  98. package/dist/shared/constants.js +32 -94
  99. package/dist/shared/figma.d.ts +12 -6
  100. package/dist/shared/model.js +73 -22
  101. package/dist/utils/document-click-listener.js +26 -29
  102. package/dist/utils/document-scroll-listener.js +30 -38
  103. package/dist/utils/floating-components.js +107 -358
  104. package/dist/utils/form-components.js +34 -60
  105. package/dist/utils/index.js +49 -167
  106. package/dist/utils/navigation.js +68 -135
  107. package/dist/utils/react.js +10 -15
  108. package/package.json +11 -8
  109. package/dist/components/accordion/index.js +0 -1
  110. package/dist/components/accordion-item/index.js +0 -1
  111. package/dist/components/accordion-item/model.js +0 -1
  112. package/dist/components/badge/index.js +0 -1
  113. package/dist/components/brand/index.js +0 -1
  114. package/dist/components/brand/model.js +0 -1
  115. package/dist/components/button/index.js +0 -1
  116. package/dist/components/card/index.js +0 -1
  117. package/dist/components/checkbox/index.js +0 -1
  118. package/dist/components/checkbox/model.js +0 -1
  119. package/dist/components/custom-button/index.js +0 -1
  120. package/dist/components/custom-button/model.js +0 -1
  121. package/dist/components/custom-select/index.js +0 -1
  122. package/dist/components/custom-select-dropdown/index.js +0 -1
  123. package/dist/components/custom-select-form-field/index.js +0 -1
  124. package/dist/components/custom-select-form-field/model.js +0 -1
  125. package/dist/components/custom-select-list/index.js +0 -1
  126. package/dist/components/custom-select-list/model.js +0 -1
  127. package/dist/components/custom-select-list-item/index.js +0 -1
  128. package/dist/components/divider/index.js +0 -1
  129. package/dist/components/drawer/index.js +0 -1
  130. package/dist/components/header/index.js +0 -1
  131. package/dist/components/header/model.js +0 -1
  132. package/dist/components/icon/index.js +0 -1
  133. package/dist/components/infotext/index.js +0 -1
  134. package/dist/components/infotext/model.js +0 -1
  135. package/dist/components/input/index.js +0 -1
  136. package/dist/components/link/index.js +0 -1
  137. package/dist/components/navigation/index.js +0 -1
  138. package/dist/components/navigation/model.js +0 -1
  139. package/dist/components/navigation-item/index.js +0 -1
  140. package/dist/components/navigation-item/model.js +0 -1
  141. package/dist/components/notification/index.js +0 -1
  142. package/dist/components/page/index.js +0 -1
  143. package/dist/components/popover/index.js +0 -1
  144. package/dist/components/popover/model.js +0 -1
  145. package/dist/components/radio/index.js +0 -1
  146. package/dist/components/radio/model.js +0 -1
  147. package/dist/components/section/index.js +0 -1
  148. package/dist/components/section/model.js +0 -1
  149. package/dist/components/select/index.js +0 -1
  150. package/dist/components/select/model.js +0 -1
  151. package/dist/components/stack/index.js +0 -1
  152. package/dist/components/switch/index.js +0 -1
  153. package/dist/components/switch/model.js +0 -1
  154. package/dist/components/tab-item/index.js +0 -1
  155. package/dist/components/tab-item/model.js +0 -1
  156. package/dist/components/tab-list/index.js +0 -1
  157. package/dist/components/tab-list/model.js +0 -1
  158. package/dist/components/tab-panel/index.js +0 -1
  159. package/dist/components/tab-panel/model.js +0 -1
  160. package/dist/components/tabs/index.js +0 -1
  161. package/dist/components/tag/index.js +0 -1
  162. package/dist/components/textarea/index.js +0 -1
  163. package/dist/components/tooltip/index.js +0 -1
  164. package/dist/shared/examples/index.js +0 -4
  165. package/dist/shared/figma.js +0 -1
  166. package/dist/shared/showcase/show-code-link.js +0 -51
@@ -1,152 +1,184 @@
1
1
  "use client";
2
- import * as React from "react";
3
- import { filterPassingProps, getRootProps } from "../../utils/react";
4
- import { useState, useRef, useEffect, forwardRef } from "react";
5
- import { DEFAULT_INVALID_MESSAGE, DEFAULT_INVALID_MESSAGE_ID_SUFFIX, DEFAULT_MESSAGE_ID_SUFFIX, DEFAULT_VALID_MESSAGE, DEFAULT_VALID_MESSAGE_ID_SUFFIX, } from "../../shared/constants";
6
- import { cls, delay, getBoolean, getBooleanAsString, getHideProp, hasVoiceOver, stringPropVisible, } from "../../utils";
7
- import { addCheckedResetEventListener, } from "../../utils/form-components";
8
- import DBInfotext from "../infotext/infotext";
9
- import { useId } from "react";
10
- function DBSwitchFn(props, component) {
11
- var _a, _b, _c;
12
- const uuid = useId();
13
- const _ref = component || useRef(component);
14
- const [_id, set_id] = useState(() => undefined);
15
- const [_messageId, set_messageId] = useState(() => undefined);
16
- const [_validMessageId, set_validMessageId] = useState(() => undefined);
17
- const [_invalidMessageId, set_invalidMessageId] = useState(() => undefined);
18
- const [_invalidMessage, set_invalidMessage] = useState(() => undefined);
19
- const [_descByIds, set_descByIds] = useState(() => undefined);
20
- const [_voiceOverFallback, set_voiceOverFallback] = useState(() => "");
21
- const [abortController, setAbortController] = useState(() => undefined);
22
- function hasValidState() {
23
- var _a;
24
- return !!((_a = props.validMessage) !== null && _a !== void 0 ? _a : props.validation === "valid");
25
- }
26
- function handleValidation() {
27
- var _a, _b, _c, _d, _e, _f;
28
- if (!((_b = (_a = _ref.current) === null || _a === void 0 ? void 0 : _a.validity) === null || _b === void 0 ? void 0 : _b.valid) || props.validation === "invalid") {
29
- set_descByIds(_invalidMessageId);
30
- set_invalidMessage(props.invalidMessage ||
31
- ((_c = _ref.current) === null || _c === void 0 ? void 0 : _c.validationMessage) ||
32
- DEFAULT_INVALID_MESSAGE);
33
- if (hasVoiceOver()) {
34
- set_voiceOverFallback(_invalidMessage || DEFAULT_INVALID_MESSAGE);
35
- delay(() => {
36
- set_voiceOverFallback("");
37
- }, 1000);
38
- }
39
- return;
40
- }
41
- if (hasValidState() && ((_e = (_d = _ref.current) === null || _d === void 0 ? void 0 : _d.validity) === null || _e === void 0 ? void 0 : _e.valid) && props.required) {
42
- set_descByIds(_validMessageId);
43
- if (hasVoiceOver()) {
44
- set_voiceOverFallback((_f = props.validMessage) !== null && _f !== void 0 ? _f : DEFAULT_VALID_MESSAGE);
45
- delay(() => {
46
- set_voiceOverFallback("");
47
- }, 1000);
48
- }
49
- return;
50
- }
51
- if (stringPropVisible(props.message, props.showMessage)) {
52
- set_descByIds(_messageId);
53
- return;
54
- }
55
- set_descByIds(undefined);
56
- }
57
- function handleChange(event, reset) {
58
- if (props.onChange) {
59
- props.onChange(event);
60
- }
61
- handleValidation();
62
- }
63
- function handleBlur(event) {
64
- if (props.onBlur) {
65
- props.onBlur(event);
66
- }
67
- }
68
- function handleFocus(event) {
69
- if (props.onFocus) {
70
- props.onFocus(event);
71
- }
72
- }
73
- function handleKeyDown(event) {
74
- var _a;
75
- // Support ENTER key for toggling the switch (a11y requirement)
76
- if (event.key === "Enter") {
77
- event.preventDefault();
78
- // Toggle the switch by clicking it programmatically
79
- if (!props.disabled) {
80
- (_a = _ref.current) === null || _a === void 0 ? void 0 : _a.click();
81
- }
82
- }
83
- }
84
- function resetIds() {
85
- var _a, _b, _c;
86
- const mId = (_c = (_a = props.id) !== null && _a !== void 0 ? _a : (_b = props.propOverrides) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : `switch-${uuid}`;
87
- set_id(mId);
88
- set_messageId(`${mId}${DEFAULT_MESSAGE_ID_SUFFIX}`);
89
- set_validMessageId(`${mId}${DEFAULT_VALID_MESSAGE_ID_SUFFIX}`);
90
- set_invalidMessageId(`${mId}${DEFAULT_INVALID_MESSAGE_ID_SUFFIX}`);
91
- }
92
- useEffect(() => {
93
- resetIds();
94
- handleValidation();
95
- set_invalidMessage(props.invalidMessage || DEFAULT_INVALID_MESSAGE);
96
- }, []);
97
- useEffect(() => {
98
- var _a, _b;
99
- if ((_a = props.id) !== null && _a !== void 0 ? _a : (_b = props.propOverrides) === null || _b === void 0 ? void 0 : _b.id) {
100
- resetIds();
101
- }
102
- }, [props.id, (_a = props.propOverrides) === null || _a === void 0 ? void 0 : _a.id]);
103
- useEffect(() => {
104
- handleValidation();
105
- }, [
106
- props.validation,
107
- props.required,
108
- props.message,
109
- props.showMessage,
110
- props.validMessage,
111
- props.invalidMessage,
112
- props.checked,
113
- ]);
114
- useEffect(() => {
115
- var _a;
116
- set_invalidMessage(props.invalidMessage ||
117
- ((_a = _ref.current) === null || _a === void 0 ? void 0 : _a.validationMessage) ||
118
- DEFAULT_INVALID_MESSAGE);
119
- }, [_ref.current, props.invalidMessage]);
120
- useEffect(() => {
121
- if (_ref.current) {
122
- const defaultChecked = props.defaultChecked;
123
- let controller = abortController;
124
- if (!controller) {
125
- controller = new AbortController();
126
- setAbortController(controller);
127
- }
128
- addCheckedResetEventListener(_ref.current, {
129
- checked: props.checked,
130
- defaultChecked,
131
- }, (event) => {
132
- handleChange(event, true);
133
- }, controller.signal);
134
- }
135
- }, [_ref.current]);
136
- useEffect(() => {
137
- return () => {
138
- abortController === null || abortController === void 0 ? void 0 : abortController.abort();
139
- };
140
- }, []);
141
- return (React.createElement("div", Object.assign({ "data-visual-aid": getBooleanAsString(props.visualAid), "data-size": props.size, "data-hide-label": getHideProp(props.showLabel), "data-variant": props.variant, "data-hide-asterisk": getHideProp(props.showRequiredAsterisk), "data-custom-validity": props.validation }, getRootProps(props, ["data-icon-variant", "data-icon-variant-before", "data-icon-variant-after", "data-icon-weight", "data-icon-weight-before", "data-icon-weight-after", "data-interactive", "data-force-mobile", "data-color", "data-container-color", "data-bg-color", "data-on-bg-color", "data-color-scheme", "data-font-size", "data-headline-size", "data-divider", "data-focus", "data-font", "data-density"]), { className: cls("db-switch", props.className) }),
142
- React.createElement("label", { htmlFor: _id },
143
- React.createElement("input", Object.assign({ type: "checkbox", role: "switch", id: _id, ref: _ref }, filterPassingProps(props, ["data-icon-variant", "data-icon-variant-before", "data-icon-variant-after", "data-icon-weight", "data-icon-weight-before", "data-icon-weight-after", "data-interactive", "data-force-mobile", "data-color", "data-container-color", "data-bg-color", "data-on-bg-color", "data-color-scheme", "data-font-size", "data-headline-size", "data-divider", "data-focus", "data-font", "data-density"]), { checked: getBoolean(props.checked, "checked"), value: props.value, disabled: getBoolean(props.disabled, "disabled"), "aria-invalid": props.validation === "invalid" ? "true" : undefined, "aria-describedby": _descByIds, name: props.name, required: getBoolean(props.required, "required"), "data-aid-icon": (_b = props.iconLeading) !== null && _b !== void 0 ? _b : props.icon, "data-aid-icon-trailing": props.iconTrailing, onChange: (event) => handleChange(event), onBlur: (event) => handleBlur(event), onFocus: (event) => handleFocus(event), onKeyDown: (event) => handleKeyDown(event) })),
144
- props.label ? React.createElement(React.Fragment, null, props.label) : null,
145
- props.children),
146
- stringPropVisible(props.message, props.showMessage) ? (React.createElement(DBInfotext, { size: "small", semantic: "adaptive", id: _messageId, icon: props.messageIcon }, props.message)) : null,
147
- hasValidState() ? (React.createElement(DBInfotext, { size: "small", semantic: "successful", id: _validMessageId }, (_c = props.validMessage) !== null && _c !== void 0 ? _c : DEFAULT_VALID_MESSAGE)) : null,
148
- React.createElement(DBInfotext, { size: "small", semantic: "critical", id: _invalidMessageId }, _invalidMessage),
149
- React.createElement("span", { "data-visually-hidden": "true", role: "status" }, _voiceOverFallback)));
2
+ import { filterPassingProps as e, getRootProps as t } from "../../utils/react.js";
3
+ import { cls as n, delay as r, getBoolean as i, getBooleanAsString as a, getHideProp as o, hasVoiceOver as s, stringPropVisible as c } from "../../utils/index.js";
4
+ import { DEFAULT_INVALID_MESSAGE_ID_SUFFIX as l, DEFAULT_MESSAGE_ID_SUFFIX as u, DEFAULT_VALID_MESSAGE_ID_SUFFIX as d } from "../../shared/constants.js";
5
+ import { addCheckedResetEventListener as f } from "../../utils/form-components.js";
6
+ import p from "../infotext/infotext.js";
7
+ import { forwardRef as m, useEffect as h, useId as g, useRef as _, useState as v } from "react";
8
+ import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
9
+ //#region src/components/switch/switch.tsx
10
+ function S(m, S) {
11
+ let C = g(), w = S || _(S), [T, E] = v(() => void 0), [D, O] = v(() => void 0), [k, A] = v(() => void 0), [j, M] = v(() => void 0), [N, P] = v(() => void 0), [F, I] = v(() => void 0), [L, R] = v(() => ""), [z, B] = v(() => void 0);
12
+ function V() {
13
+ return !!(m.validMessage ?? m.validation === "valid");
14
+ }
15
+ function H() {
16
+ if (!w.current?.validity?.valid || m.validation === "invalid") {
17
+ I(j), P(m.invalidMessage || w.current?.validationMessage || "TODO: Add an invalidMessage"), s() && (R(N || "TODO: Add an invalidMessage"), r(() => {
18
+ R("");
19
+ }, 1e3));
20
+ return;
21
+ }
22
+ if (V() && w.current?.validity?.valid && m.required) {
23
+ I(k), s() && (R(m.validMessage ?? "TODO: Add a validMessage"), r(() => {
24
+ R("");
25
+ }, 1e3));
26
+ return;
27
+ }
28
+ if (c(m.message, m.showMessage)) {
29
+ I(D);
30
+ return;
31
+ }
32
+ I(void 0);
33
+ }
34
+ function U(e, t) {
35
+ m.onChange && m.onChange(e), H();
36
+ }
37
+ function W(e) {
38
+ m.onBlur && m.onBlur(e);
39
+ }
40
+ function G(e) {
41
+ m.onFocus && m.onFocus(e);
42
+ }
43
+ function K(e) {
44
+ e.key === "Enter" && (e.preventDefault(), m.disabled || w.current?.click());
45
+ }
46
+ function q() {
47
+ let e = m.id ?? m.propOverrides?.id ?? `switch-${C}`;
48
+ E(e), O(`${e}${u}`), A(`${e}${d}`), M(`${e}${l}`);
49
+ }
50
+ return h(() => {
51
+ q(), H(), P(m.invalidMessage || "TODO: Add an invalidMessage");
52
+ }, []), h(() => {
53
+ (m.id ?? m.propOverrides?.id) && q();
54
+ }, [m.id, m.propOverrides?.id]), h(() => {
55
+ H();
56
+ }, [
57
+ m.validation,
58
+ m.required,
59
+ m.message,
60
+ m.showMessage,
61
+ m.validMessage,
62
+ m.invalidMessage,
63
+ m.checked
64
+ ]), h(() => {
65
+ P(m.invalidMessage || w.current?.validationMessage || "TODO: Add an invalidMessage");
66
+ }, [w.current, m.invalidMessage]), h(() => {
67
+ if (w.current) {
68
+ let e = m.defaultChecked, t = z;
69
+ t || (t = new AbortController(), B(t)), f(w.current, {
70
+ checked: m.checked,
71
+ defaultChecked: e
72
+ }, (e) => {
73
+ U(e, !0);
74
+ }, t.signal);
75
+ }
76
+ }, [w.current]), h(() => () => {
77
+ z?.abort();
78
+ }, []), /* @__PURE__ */ x("div", {
79
+ "data-visual-aid": a(m.visualAid),
80
+ "data-size": m.size,
81
+ "data-hide-label": o(m.showLabel),
82
+ "data-variant": m.variant,
83
+ "data-hide-asterisk": o(m.showRequiredAsterisk),
84
+ "data-custom-validity": m.validation,
85
+ ...t(m, [
86
+ "data-icon-variant",
87
+ "data-icon-variant-before",
88
+ "data-icon-variant-after",
89
+ "data-icon-weight",
90
+ "data-icon-weight-before",
91
+ "data-icon-weight-after",
92
+ "data-interactive",
93
+ "data-force-mobile",
94
+ "data-color",
95
+ "data-container-color",
96
+ "data-bg-color",
97
+ "data-on-bg-color",
98
+ "data-color-scheme",
99
+ "data-font-size",
100
+ "data-headline-size",
101
+ "data-divider",
102
+ "data-focus",
103
+ "data-font",
104
+ "data-density"
105
+ ]),
106
+ className: n("db-switch", m.className),
107
+ children: [
108
+ /* @__PURE__ */ x("label", {
109
+ htmlFor: T,
110
+ children: [
111
+ /* @__PURE__ */ b("input", {
112
+ type: "checkbox",
113
+ role: "switch",
114
+ id: T,
115
+ ref: w,
116
+ ...e(m, [
117
+ "data-icon-variant",
118
+ "data-icon-variant-before",
119
+ "data-icon-variant-after",
120
+ "data-icon-weight",
121
+ "data-icon-weight-before",
122
+ "data-icon-weight-after",
123
+ "data-interactive",
124
+ "data-force-mobile",
125
+ "data-color",
126
+ "data-container-color",
127
+ "data-bg-color",
128
+ "data-on-bg-color",
129
+ "data-color-scheme",
130
+ "data-font-size",
131
+ "data-headline-size",
132
+ "data-divider",
133
+ "data-focus",
134
+ "data-font",
135
+ "data-density"
136
+ ]),
137
+ checked: i(m.checked, "checked"),
138
+ value: m.value,
139
+ disabled: i(m.disabled, "disabled"),
140
+ "aria-invalid": m.validation === "invalid" ? "true" : void 0,
141
+ "aria-describedby": F,
142
+ name: m.name,
143
+ required: i(m.required, "required"),
144
+ "data-aid-icon": m.iconLeading ?? m.icon,
145
+ "data-aid-icon-trailing": m.iconTrailing,
146
+ onChange: (e) => U(e),
147
+ onBlur: (e) => W(e),
148
+ onFocus: (e) => G(e),
149
+ onKeyDown: (e) => K(e)
150
+ }),
151
+ m.label ? /* @__PURE__ */ b(y, { children: m.label }) : null,
152
+ m.children
153
+ ]
154
+ }),
155
+ c(m.message, m.showMessage) ? /* @__PURE__ */ b(p, {
156
+ size: "small",
157
+ semantic: "adaptive",
158
+ id: D,
159
+ icon: m.messageIcon,
160
+ children: m.message
161
+ }) : null,
162
+ V() ? /* @__PURE__ */ b(p, {
163
+ size: "small",
164
+ semantic: "successful",
165
+ id: k,
166
+ children: m.validMessage ?? "TODO: Add a validMessage"
167
+ }) : null,
168
+ /* @__PURE__ */ b(p, {
169
+ size: "small",
170
+ semantic: "critical",
171
+ id: j,
172
+ children: N
173
+ }),
174
+ /* @__PURE__ */ b("span", {
175
+ "data-visually-hidden": "true",
176
+ role: "status",
177
+ children: L
178
+ })
179
+ ]
180
+ });
150
181
  }
151
- const DBSwitch = forwardRef(DBSwitchFn);
152
- export default DBSwitch;
182
+ var C = m(S);
183
+ //#endregion
184
+ export { C as default };
@@ -1,4 +1,4 @@
1
- import { ActiveProps, ChangeEventProps, ChangeEventState, GlobalProps, GlobalState, IconLeadingProps, IconProps, IconTrailingProps, InitializedState, NameProps, NameState, ShowIconLeadingProps, ShowIconProps, ShowIconTrailingProps } from '../../shared/model';
1
+ import type { ActiveProps, ChangeEventProps, ChangeEventState, GlobalProps, GlobalState, IconLeadingProps, IconProps, IconTrailingProps, InitializedState, NameProps, NameState, ShowIconLeadingProps, ShowIconProps, ShowIconTrailingProps } from '../../shared/model';
2
2
  export type DBTabItemDefaultProps = {
3
3
  /**
4
4
  * To control the component
@@ -1,78 +1,107 @@
1
1
  "use client";
2
- import * as React from "react";
3
- import { filterPassingProps, getRootProps } from "../../utils/react";
4
- import { useState, useRef, useEffect, forwardRef } from "react";
5
- import { cls, getBoolean, getBooleanAsString } from "../../utils";
6
- function DBTabItemFn(props, component) {
7
- var _a, _b, _c, _d, _e, _f;
8
- const _ref = component || useRef(component);
9
- const [_selected, set_selected] = useState(() => false);
10
- const [_name, set_name] = useState(() => undefined);
11
- const [initialized, setInitialized] = useState(() => false);
12
- const [_listenerAdded, set_listenerAdded] = useState(() => false);
13
- const [boundSetSelectedOnChange, setBoundSetSelectedOnChange] = useState(() => undefined);
14
- function setSelectedOnChange(event) {
15
- event.stopPropagation();
16
- set_selected(event.target === _ref.current);
17
- }
18
- function handleNameAttribute() {
19
- if (_ref.current) {
20
- const setAttribute = _ref.current.setAttribute;
21
- _ref.current.setAttribute = (attribute, value) => {
22
- setAttribute.call(_ref.current, attribute, value);
23
- if (attribute === "name") {
24
- set_name(value);
25
- }
26
- };
27
- }
28
- }
29
- function handleChange(event) {
30
- if (props.onChange) {
31
- props.onChange(event);
32
- }
33
- }
34
- useEffect(() => {
35
- setBoundSetSelectedOnChange(() => setSelectedOnChange);
36
- setInitialized(true);
37
- }, []);
38
- useEffect(() => {
39
- var _a;
40
- if (_ref.current && initialized && boundSetSelectedOnChange) {
41
- handleNameAttribute();
42
- setInitialized(false);
43
- // deselect this tab when another tab in tablist is selected
44
- if (!_listenerAdded) {
45
- (_a = _ref.current
46
- .closest("[role=tablist]")) === null || _a === void 0 ? void 0 : _a.addEventListener("change", boundSetSelectedOnChange);
47
- set_listenerAdded(true);
48
- }
49
- // Initialize selected state from either active prop (set by parent) or checked attribute
50
- if (props.active || _ref.current.checked) {
51
- set_selected(true);
52
- _ref.current.click();
53
- }
54
- }
55
- }, [_ref.current, initialized, boundSetSelectedOnChange]);
56
- useEffect(() => {
57
- if (props.name) {
58
- set_name(props.name);
59
- }
60
- }, [props.name]);
61
- useEffect(() => {
62
- return () => {
63
- var _a;
64
- if (_listenerAdded && _ref.current && boundSetSelectedOnChange) {
65
- (_a = _ref.current
66
- .closest("[role=tablist]")) === null || _a === void 0 ? void 0 : _a.removeEventListener("change", boundSetSelectedOnChange);
67
- set_listenerAdded(false);
68
- }
69
- };
70
- }, []);
71
- return (React.createElement("li", Object.assign({ role: "none" }, getRootProps(props, ["data-icon-variant", "data-icon-variant-before", "data-icon-variant-after", "data-icon-weight", "data-icon-weight-before", "data-icon-weight-after", "data-interactive", "data-force-mobile", "data-color", "data-container-color", "data-bg-color", "data-on-bg-color", "data-color-scheme", "data-font-size", "data-headline-size", "data-divider", "data-focus", "data-font", "data-density"]), { className: cls("db-tab-item", props.className) }),
72
- React.createElement("label", { htmlFor: (_a = props.id) !== null && _a !== void 0 ? _a : (_b = props.propOverrides) === null || _b === void 0 ? void 0 : _b.id, "data-icon": (_c = props.iconLeading) !== null && _c !== void 0 ? _c : props.icon, "data-icon-trailing": props.iconTrailing, "data-show-icon": getBooleanAsString((_d = props.showIconLeading) !== null && _d !== void 0 ? _d : props.showIcon), "data-show-icon-trailing": getBooleanAsString(props.showIconTrailing), "data-no-text": getBooleanAsString(props.noText) },
73
- React.createElement("input", Object.assign({ type: "radio", role: "tab", disabled: getBoolean(props.disabled, "disabled"), "aria-selected": _selected, checked: getBoolean(props.checked, "checked"), ref: _ref }, filterPassingProps(props, ["data-icon-variant", "data-icon-variant-before", "data-icon-variant-after", "data-icon-weight", "data-icon-weight-before", "data-icon-weight-after", "data-interactive", "data-force-mobile", "data-color", "data-container-color", "data-bg-color", "data-on-bg-color", "data-color-scheme", "data-font-size", "data-headline-size", "data-divider", "data-focus", "data-font", "data-density"]), { name: _name, id: (_e = props.id) !== null && _e !== void 0 ? _e : (_f = props.propOverrides) === null || _f === void 0 ? void 0 : _f.id, onInput: (event) => handleChange(event) })),
74
- props.label ? React.createElement(React.Fragment, null, props.label) : null,
75
- props.children)));
2
+ import { filterPassingProps as e, getRootProps as t } from "../../utils/react.js";
3
+ import { cls as n, getBoolean as r, getBooleanAsString as i } from "../../utils/index.js";
4
+ import { forwardRef as a, useEffect as o, useRef as s, useState as c } from "react";
5
+ import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
6
+ //#region src/components/tab-item/tab-item.tsx
7
+ function f(a, f) {
8
+ let p = f || s(f), [m, h] = c(() => !1), [g, _] = c(() => void 0), [v, y] = c(() => !1), [b, x] = c(() => !1), [S, C] = c(() => void 0);
9
+ function w(e) {
10
+ e.stopPropagation(), h(e.target === p.current);
11
+ }
12
+ function T() {
13
+ if (p.current) {
14
+ let e = p.current.setAttribute;
15
+ p.current.setAttribute = (t, n) => {
16
+ e.call(p.current, t, n), t === "name" && _(n);
17
+ };
18
+ }
19
+ }
20
+ function E(e) {
21
+ a.onChange && a.onChange(e);
22
+ }
23
+ return o(() => {
24
+ C(() => w), y(!0);
25
+ }, []), o(() => {
26
+ p.current && v && S && (T(), y(!1), b || (p.current.closest("[role=tablist]")?.addEventListener("change", S), x(!0)), (a.active || p.current.checked) && (h(!0), p.current.click()));
27
+ }, [
28
+ p.current,
29
+ v,
30
+ S
31
+ ]), o(() => {
32
+ a.name && _(a.name);
33
+ }, [a.name]), o(() => () => {
34
+ b && p.current && S && (p.current.closest("[role=tablist]")?.removeEventListener("change", S), x(!1));
35
+ }, []), /* @__PURE__ */ u("li", {
36
+ role: "none",
37
+ ...t(a, [
38
+ "data-icon-variant",
39
+ "data-icon-variant-before",
40
+ "data-icon-variant-after",
41
+ "data-icon-weight",
42
+ "data-icon-weight-before",
43
+ "data-icon-weight-after",
44
+ "data-interactive",
45
+ "data-force-mobile",
46
+ "data-color",
47
+ "data-container-color",
48
+ "data-bg-color",
49
+ "data-on-bg-color",
50
+ "data-color-scheme",
51
+ "data-font-size",
52
+ "data-headline-size",
53
+ "data-divider",
54
+ "data-focus",
55
+ "data-font",
56
+ "data-density"
57
+ ]),
58
+ className: n("db-tab-item", a.className),
59
+ children: /* @__PURE__ */ d("label", {
60
+ htmlFor: a.id ?? a.propOverrides?.id,
61
+ "data-icon": a.iconLeading ?? a.icon,
62
+ "data-icon-trailing": a.iconTrailing,
63
+ "data-show-icon": i(a.showIconLeading ?? a.showIcon),
64
+ "data-show-icon-trailing": i(a.showIconTrailing),
65
+ "data-no-text": i(a.noText),
66
+ children: [
67
+ /* @__PURE__ */ u("input", {
68
+ type: "radio",
69
+ role: "tab",
70
+ disabled: r(a.disabled, "disabled"),
71
+ "aria-selected": m,
72
+ checked: r(a.checked, "checked"),
73
+ ref: p,
74
+ ...e(a, [
75
+ "data-icon-variant",
76
+ "data-icon-variant-before",
77
+ "data-icon-variant-after",
78
+ "data-icon-weight",
79
+ "data-icon-weight-before",
80
+ "data-icon-weight-after",
81
+ "data-interactive",
82
+ "data-force-mobile",
83
+ "data-color",
84
+ "data-container-color",
85
+ "data-bg-color",
86
+ "data-on-bg-color",
87
+ "data-color-scheme",
88
+ "data-font-size",
89
+ "data-headline-size",
90
+ "data-divider",
91
+ "data-focus",
92
+ "data-font",
93
+ "data-density"
94
+ ]),
95
+ name: g,
96
+ id: a.id ?? a.propOverrides?.id,
97
+ onInput: (e) => E(e)
98
+ }),
99
+ a.label ? /* @__PURE__ */ u(l, { children: a.label }) : null,
100
+ a.children
101
+ ]
102
+ })
103
+ });
76
104
  }
77
- const DBTabItem = forwardRef(DBTabItemFn);
78
- export default DBTabItem;
105
+ var p = a(f);
106
+ //#endregion
107
+ export { p as default };
@@ -1,4 +1,4 @@
1
- import { GlobalProps } from '../../shared/model';
1
+ import type { GlobalProps } from '../../shared/model';
2
2
  export type DBTabListDefaultProps = {};
3
3
  export type DBTabListProps = DBTabListDefaultProps & GlobalProps;
4
4
  export type DBTabListDefaultState = {};
@@ -1,13 +1,62 @@
1
1
  "use client";
2
- import * as React from "react";
3
- import { filterPassingProps, getRootProps } from "../../utils/react";
4
- import { useRef, forwardRef } from "react";
5
- import { cls } from "../../utils";
6
- function DBTabListFn(props, component) {
7
- var _a, _b;
8
- const _ref = component || useRef(component);
9
- return (React.createElement("div", Object.assign({ ref: _ref }, filterPassingProps(props, ["data-icon-variant", "data-icon-variant-before", "data-icon-variant-after", "data-icon-weight", "data-icon-weight-before", "data-icon-weight-after", "data-interactive", "data-force-mobile", "data-color", "data-container-color", "data-bg-color", "data-on-bg-color", "data-color-scheme", "data-font-size", "data-headline-size", "data-divider", "data-focus", "data-font", "data-density"]), { id: (_a = props.id) !== null && _a !== void 0 ? _a : (_b = props.propOverrides) === null || _b === void 0 ? void 0 : _b.id }, getRootProps(props, ["data-icon-variant", "data-icon-variant-before", "data-icon-variant-after", "data-icon-weight", "data-icon-weight-before", "data-icon-weight-after", "data-interactive", "data-force-mobile", "data-color", "data-container-color", "data-bg-color", "data-on-bg-color", "data-color-scheme", "data-font-size", "data-headline-size", "data-divider", "data-focus", "data-font", "data-density"]), { className: cls("db-tab-list", props.className) }),
10
- React.createElement("ul", { role: "tablist" }, props.children)));
2
+ import { filterPassingProps as e, getRootProps as t } from "../../utils/react.js";
3
+ import { cls as n } from "../../utils/index.js";
4
+ import { forwardRef as r, useRef as i } from "react";
5
+ import { jsx as a } from "react/jsx-runtime";
6
+ //#region src/components/tab-list/tab-list.tsx
7
+ function o(r, o) {
8
+ return /* @__PURE__ */ a("div", {
9
+ ref: o || i(o),
10
+ ...e(r, [
11
+ "data-icon-variant",
12
+ "data-icon-variant-before",
13
+ "data-icon-variant-after",
14
+ "data-icon-weight",
15
+ "data-icon-weight-before",
16
+ "data-icon-weight-after",
17
+ "data-interactive",
18
+ "data-force-mobile",
19
+ "data-color",
20
+ "data-container-color",
21
+ "data-bg-color",
22
+ "data-on-bg-color",
23
+ "data-color-scheme",
24
+ "data-font-size",
25
+ "data-headline-size",
26
+ "data-divider",
27
+ "data-focus",
28
+ "data-font",
29
+ "data-density"
30
+ ]),
31
+ id: r.id ?? r.propOverrides?.id,
32
+ ...t(r, [
33
+ "data-icon-variant",
34
+ "data-icon-variant-before",
35
+ "data-icon-variant-after",
36
+ "data-icon-weight",
37
+ "data-icon-weight-before",
38
+ "data-icon-weight-after",
39
+ "data-interactive",
40
+ "data-force-mobile",
41
+ "data-color",
42
+ "data-container-color",
43
+ "data-bg-color",
44
+ "data-on-bg-color",
45
+ "data-color-scheme",
46
+ "data-font-size",
47
+ "data-headline-size",
48
+ "data-divider",
49
+ "data-focus",
50
+ "data-font",
51
+ "data-density"
52
+ ]),
53
+ className: n("db-tab-list", r.className),
54
+ children: /* @__PURE__ */ a("ul", {
55
+ role: "tablist",
56
+ children: r.children
57
+ })
58
+ });
11
59
  }
12
- const DBTabList = forwardRef(DBTabListFn);
13
- export default DBTabList;
60
+ var s = r(o);
61
+ //#endregion
62
+ export { s as default };
@@ -1,4 +1,4 @@
1
- import { GlobalProps, GlobalState } from '../../shared/model';
1
+ import type { GlobalProps, GlobalState } from '../../shared/model';
2
2
  export type DBTabPanelDefaultProps = {
3
3
  /**
4
4
  * The content if you don't want to use children.