@elliemae/ds-form-toggle 3.70.0-next.43 → 3.70.0-next.45
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.
- package/dist/cjs/DSControlledToggle.js +50 -0
- package/dist/cjs/DSControlledToggle.js.map +7 -0
- package/dist/cjs/DSControlledToggleCTX.js +40 -0
- package/dist/cjs/DSControlledToggleCTX.js.map +7 -0
- package/dist/cjs/config/useDSControlledToggle.js +2 -17
- package/dist/cjs/config/useDSControlledToggle.js.map +2 -2
- package/dist/cjs/constants/index.js +0 -1
- package/dist/cjs/constants/index.js.map +2 -2
- package/dist/cjs/index.js +3 -3
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/parts/Button.js +102 -0
- package/dist/cjs/parts/Button.js.map +7 -0
- package/dist/cjs/parts/Container.js +61 -0
- package/dist/cjs/parts/Container.js.map +7 -0
- package/dist/cjs/parts/styles/styles.js +246 -0
- package/dist/cjs/parts/styles/styles.js.map +7 -0
- package/dist/cjs/parts/wcagViolation/Button.wcagViolationLabels.js +110 -0
- package/dist/cjs/parts/wcagViolation/Button.wcagViolationLabels.js.map +7 -0
- package/dist/cjs/{config → parts/wcagViolation}/useGetWidestLabelWidth.js.map +1 -1
- package/dist/cjs/react-desc-prop-types.js.map +2 -2
- package/dist/cjs/typescript-testing/slot-props.js +0 -2
- package/dist/cjs/typescript-testing/slot-props.js.map +2 -2
- package/dist/esm/DSControlledToggle.js +20 -0
- package/dist/esm/DSControlledToggle.js.map +7 -0
- package/dist/esm/DSControlledToggleCTX.js +10 -0
- package/dist/esm/DSControlledToggleCTX.js.map +7 -0
- package/dist/esm/config/useDSControlledToggle.js +2 -17
- package/dist/esm/config/useDSControlledToggle.js.map +2 -2
- package/dist/esm/constants/index.js +0 -1
- package/dist/esm/constants/index.js.map +2 -2
- package/dist/esm/index.js +4 -4
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/parts/Button.js +72 -0
- package/dist/esm/parts/Button.js.map +7 -0
- package/dist/esm/parts/Container.js +31 -0
- package/dist/esm/parts/Container.js.map +7 -0
- package/dist/esm/parts/styles/styles.js +216 -0
- package/dist/esm/parts/styles/styles.js.map +7 -0
- package/dist/esm/parts/wcagViolation/Button.wcagViolationLabels.js +86 -0
- package/dist/esm/parts/wcagViolation/Button.wcagViolationLabels.js.map +7 -0
- package/dist/esm/{config → parts/wcagViolation}/useGetWidestLabelWidth.js.map +1 -1
- package/dist/esm/react-desc-prop-types.js.map +2 -2
- package/dist/esm/typescript-testing/slot-props.js +0 -2
- package/dist/esm/typescript-testing/slot-props.js.map +2 -2
- package/dist/types/DSControlledToggleCTX.d.ts +4 -0
- package/dist/types/config/useDSControlledToggle.d.ts +8 -373
- package/dist/types/constants/index.d.ts +0 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/types/parts/Button.d.ts +3 -0
- package/dist/types/parts/Container.d.ts +1 -0
- package/dist/types/parts/styles/styles.d.ts +37 -0
- package/dist/types/parts/wcagViolation/Button.wcagViolationLabels.d.ts +3 -0
- package/dist/types/react-desc-prop-types.d.ts +0 -1
- package/package.json +8 -7
- package/dist/cjs/ControlledToggle.js +0 -127
- package/dist/cjs/ControlledToggle.js.map +0 -7
- package/dist/cjs/styles.js +0 -154
- package/dist/cjs/styles.js.map +0 -7
- package/dist/cjs/utils/styleHelpers.js +0 -116
- package/dist/cjs/utils/styleHelpers.js.map +0 -7
- package/dist/esm/ControlledToggle.js +0 -105
- package/dist/esm/ControlledToggle.js.map +0 -7
- package/dist/esm/styles.js +0 -134
- package/dist/esm/styles.js.map +0 -7
- package/dist/esm/utils/styleHelpers.js +0 -86
- package/dist/esm/utils/styleHelpers.js.map +0 -7
- package/dist/types/styles.d.ts +0 -44
- package/dist/types/utils/styleHelpers.d.ts +0 -41
- /package/dist/cjs/{config → parts/wcagViolation}/useGetWidestLabelWidth.js +0 -0
- /package/dist/esm/{config → parts/wcagViolation}/useGetWidestLabelWidth.js +0 -0
- /package/dist/types/{ControlledToggle.d.ts → DSControlledToggle.d.ts} +0 -0
- /package/dist/types/{config → parts/wcagViolation}/useGetWidestLabelWidth.d.ts +0 -0
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var styles_exports = {};
|
|
30
|
+
__export(styles_exports, {
|
|
31
|
+
RemBasedFontProperties: () => RemBasedFontProperties,
|
|
32
|
+
StyledButton: () => StyledButton,
|
|
33
|
+
StyledButtonContentWrapper: () => StyledButtonContentWrapper,
|
|
34
|
+
StyledCircle: () => StyledCircle,
|
|
35
|
+
StyledContainer: () => StyledContainer,
|
|
36
|
+
StyledTextWrapper: () => StyledTextWrapper
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(styles_exports);
|
|
39
|
+
var React = __toESM(require("react"));
|
|
40
|
+
var import_ds_button_v2 = require("@elliemae/ds-button-v2");
|
|
41
|
+
var import_ds_system = require("@elliemae/ds-system");
|
|
42
|
+
var import_ds_typography = require("@elliemae/ds-typography");
|
|
43
|
+
var import_constants = require("../../constants/index.js");
|
|
44
|
+
const containerHeight = {
|
|
45
|
+
s: "20px",
|
|
46
|
+
m: "28px",
|
|
47
|
+
l: "36px"
|
|
48
|
+
};
|
|
49
|
+
const StyledContainer = (0, import_ds_system.styled)("div", {
|
|
50
|
+
name: import_constants.DSControlledToggleName,
|
|
51
|
+
slot: import_constants.CONTROLLED_TOGGLE_SLOTS.CONTROLLED_CONTAINER
|
|
52
|
+
})`
|
|
53
|
+
display: inline-flex;
|
|
54
|
+
width: fit-content;
|
|
55
|
+
justify-content: center;
|
|
56
|
+
align-items: center;
|
|
57
|
+
height: ${({ $size }) => containerHeight[$size]};
|
|
58
|
+
padding: 2px;
|
|
59
|
+
border-radius: 20px;
|
|
60
|
+
:focus-within {
|
|
61
|
+
background-color: ${({ theme }) => theme.colors.neutral["000"]};
|
|
62
|
+
}
|
|
63
|
+
${import_ds_system.xStyledCommonProps}
|
|
64
|
+
`;
|
|
65
|
+
const SwitchButtonStateColors = import_ds_system.css`
|
|
66
|
+
${({ $disabled, $readOnly, $applyAriaDisabled, $checked, theme }) => {
|
|
67
|
+
if ($disabled)
|
|
68
|
+
return `
|
|
69
|
+
background-color: ${theme.colors.neutral["080"]};
|
|
70
|
+
border: 2px solid ${theme.colors.neutral["400"]};
|
|
71
|
+
`;
|
|
72
|
+
if ($readOnly || $applyAriaDisabled)
|
|
73
|
+
return `
|
|
74
|
+
background-color: ${theme.colors.neutral["050"]};
|
|
75
|
+
border: 2px solid ${theme.colors.neutral["400"]};
|
|
76
|
+
`;
|
|
77
|
+
if ($checked)
|
|
78
|
+
return `
|
|
79
|
+
background-color: ${theme.colors.brand["600"]};
|
|
80
|
+
border: 2px solid ${theme.colors.brand["700"]};
|
|
81
|
+
`;
|
|
82
|
+
return `
|
|
83
|
+
background-color: ${theme.colors.neutral["500"]};
|
|
84
|
+
border: 2px solid ${theme.colors.neutral["600"]};
|
|
85
|
+
`;
|
|
86
|
+
}}
|
|
87
|
+
`;
|
|
88
|
+
const SwitchCursors = import_ds_system.css`
|
|
89
|
+
${({ $disabled, $readOnly, $applyAriaDisabled }) => {
|
|
90
|
+
if ($disabled || $readOnly || $applyAriaDisabled)
|
|
91
|
+
return `
|
|
92
|
+
cursor: not-allowed;
|
|
93
|
+
`;
|
|
94
|
+
return `
|
|
95
|
+
cursor: pointer;
|
|
96
|
+
`;
|
|
97
|
+
}}
|
|
98
|
+
`;
|
|
99
|
+
const SwitchHoverColors = import_ds_system.css`
|
|
100
|
+
${({ $disabled, $readOnly, $applyAriaDisabled, $checked, theme }) => {
|
|
101
|
+
if ($disabled)
|
|
102
|
+
return `
|
|
103
|
+
background-color: ${theme.colors.neutral["080"]};
|
|
104
|
+
`;
|
|
105
|
+
if ($readOnly || $applyAriaDisabled)
|
|
106
|
+
return `
|
|
107
|
+
background-color: ${theme.colors.neutral["050"]};
|
|
108
|
+
`;
|
|
109
|
+
if ($checked)
|
|
110
|
+
return `
|
|
111
|
+
background-color: ${theme.colors.brand["700"]};
|
|
112
|
+
border-color: ${theme.colors.brand["800"]};
|
|
113
|
+
`;
|
|
114
|
+
return `
|
|
115
|
+
background-color: ${theme.colors.neutral["600"]};
|
|
116
|
+
border-color: ${theme.colors.neutral["700"]};
|
|
117
|
+
`;
|
|
118
|
+
}}
|
|
119
|
+
`;
|
|
120
|
+
const StyledButton = (0, import_ds_system.styled)(import_ds_button_v2.DSButtonV3, {
|
|
121
|
+
name: import_constants.DSControlledToggleName,
|
|
122
|
+
slot: import_constants.CONTROLLED_TOGGLE_SLOTS.TOGGLE_CHECKBOX
|
|
123
|
+
})`
|
|
124
|
+
margin: 0;
|
|
125
|
+
padding: 0;
|
|
126
|
+
border-radius: 20px;
|
|
127
|
+
${SwitchButtonStateColors}
|
|
128
|
+
transition: background-color 0.2s;
|
|
129
|
+
:focus {
|
|
130
|
+
outline: 2px solid ${({ theme }) => theme.colors.brand["700"]};
|
|
131
|
+
outline-offset: 1px;
|
|
132
|
+
}
|
|
133
|
+
&:hover {
|
|
134
|
+
${SwitchCursors}
|
|
135
|
+
${SwitchHoverColors}
|
|
136
|
+
}
|
|
137
|
+
`;
|
|
138
|
+
const labelHeight = {
|
|
139
|
+
s: "16px",
|
|
140
|
+
m: "24px",
|
|
141
|
+
l: "32px"
|
|
142
|
+
};
|
|
143
|
+
const margin = {
|
|
144
|
+
s: "26px",
|
|
145
|
+
m: "34px",
|
|
146
|
+
l: "42px"
|
|
147
|
+
};
|
|
148
|
+
const StyledButtonContentWrapper = (0, import_ds_system.styled)("div", {
|
|
149
|
+
name: import_constants.DSControlledToggleName,
|
|
150
|
+
slot: import_constants.CONTROLLED_TOGGLE_SLOTS.BUTTON_CONTENT_WRAPPER
|
|
151
|
+
})`
|
|
152
|
+
min-width: ${({ $width, $size }) => `calc(${$width}px + ${margin[$size]})`};
|
|
153
|
+
height: ${({ $size }) => labelHeight[$size]};
|
|
154
|
+
display: flex;
|
|
155
|
+
margin: 0;
|
|
156
|
+
padding: 0;
|
|
157
|
+
align-items: center;
|
|
158
|
+
height: 100%;
|
|
159
|
+
flex-direction: ${({ $checked }) => $checked ? "row-reverse" : "row"};
|
|
160
|
+
border-radius: 20px;
|
|
161
|
+
`;
|
|
162
|
+
const CircleColors = import_ds_system.css`
|
|
163
|
+
${({ theme, $disabled, $readOnly, $applyAriaDisabled }) => {
|
|
164
|
+
if ($disabled) {
|
|
165
|
+
return `
|
|
166
|
+
background-color: ${theme.colors.neutral["080"]};
|
|
167
|
+
outline: 2px solid ${theme.colors.neutral["400"]};
|
|
168
|
+
`;
|
|
169
|
+
}
|
|
170
|
+
if ($readOnly || $applyAriaDisabled) {
|
|
171
|
+
return `
|
|
172
|
+
background-color: ${theme.colors.neutral["000"]};
|
|
173
|
+
outline: 2px solid ${theme.colors.neutral["400"]};
|
|
174
|
+
`;
|
|
175
|
+
}
|
|
176
|
+
return `
|
|
177
|
+
background-color: ${theme.colors.neutral["000"]};
|
|
178
|
+
`;
|
|
179
|
+
}}
|
|
180
|
+
`;
|
|
181
|
+
const circleValues = {
|
|
182
|
+
s: "14px",
|
|
183
|
+
m: "20px",
|
|
184
|
+
l: "28px"
|
|
185
|
+
};
|
|
186
|
+
const StyledCircle = (0, import_ds_system.styled)("div", {
|
|
187
|
+
name: import_constants.DSControlledToggleName,
|
|
188
|
+
slot: import_constants.CONTROLLED_TOGGLE_SLOTS.CIRCLE
|
|
189
|
+
})`
|
|
190
|
+
height: ${({ $size }) => circleValues[$size]};
|
|
191
|
+
width: ${({ $size }) => circleValues[$size]};
|
|
192
|
+
border-radius: 50%;
|
|
193
|
+
${CircleColors}
|
|
194
|
+
`;
|
|
195
|
+
const TextWrapperColors = import_ds_system.css`
|
|
196
|
+
${({ theme, $disabled, $applyAriaDisabled, $readOnly }) => {
|
|
197
|
+
if ($disabled || $applyAriaDisabled || $readOnly) {
|
|
198
|
+
return `
|
|
199
|
+
color: ${theme.colors.neutral["600"]};
|
|
200
|
+
`;
|
|
201
|
+
}
|
|
202
|
+
return `
|
|
203
|
+
color: ${theme.colors.neutral["000"]};
|
|
204
|
+
`;
|
|
205
|
+
}}
|
|
206
|
+
`;
|
|
207
|
+
const RemBasedFontProperties = import_ds_system.css`
|
|
208
|
+
${({ theme, $size }) => {
|
|
209
|
+
if ($size === "s")
|
|
210
|
+
return `
|
|
211
|
+
font-size: 0.6875rem; // 11px -> 11/16 = 0.6875rem
|
|
212
|
+
line-height: 0.6875rem; // 11px -> 11/16 = 0.6875rem
|
|
213
|
+
@media (min-width: ${theme.breakpoints.small}) {
|
|
214
|
+
font-size: 0.84615rem; // 11px -> 11/13 = 0.84615rem
|
|
215
|
+
line-height: 0.84615rem; // 11px -> 11/13 = 0.84615rem
|
|
216
|
+
}
|
|
217
|
+
`;
|
|
218
|
+
if ($size === "l")
|
|
219
|
+
return `
|
|
220
|
+
font-size: 1.25rem; // 20px -> 20/16 = 1.25rem
|
|
221
|
+
line-height: 1.25rem; // 20px -> 20/16 = 1.25rem
|
|
222
|
+
@media (min-width: ${theme.breakpoints.small}) {
|
|
223
|
+
font-size: 1.53846rem; // 20px -> 20/13 = 1.53846rem
|
|
224
|
+
line-height: 1.53846rem; // 20px -> 20/13 = 1.53846rem
|
|
225
|
+
}
|
|
226
|
+
`;
|
|
227
|
+
return `
|
|
228
|
+
font-size: 0.9375rem; // 15px -> 15/16 = 0.9375rem
|
|
229
|
+
line-height: 0.9375rem; // 15px -> 15/16 = 0.9375rem
|
|
230
|
+
@media (min-width: ${theme.breakpoints.small}) {
|
|
231
|
+
font-size: 1.15385rem; // 15px -> 15/13 = 1.15385rem
|
|
232
|
+
line-height: 1.15385rem; // 15px -> 15/13 = 1.15385rem
|
|
233
|
+
}
|
|
234
|
+
`;
|
|
235
|
+
}}
|
|
236
|
+
`;
|
|
237
|
+
const StyledTextWrapper = (0, import_ds_system.styled)(import_ds_typography.DSTypography, {
|
|
238
|
+
name: import_constants.DSControlledToggleName,
|
|
239
|
+
slot: import_constants.CONTROLLED_TOGGLE_SLOTS.TEXT_WRAPPER
|
|
240
|
+
})`
|
|
241
|
+
flex-grow: 1;
|
|
242
|
+
font-weight: ${({ theme }) => theme.fontWeights.semibold};
|
|
243
|
+
${RemBasedFontProperties}
|
|
244
|
+
${TextWrapperColors}
|
|
245
|
+
`;
|
|
246
|
+
//# sourceMappingURL=styles.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/parts/styles/styles.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable max-lines */\nimport { DSButtonV3 } from '@elliemae/ds-button-v2';\nimport { css, styled, xStyledCommonProps } from '@elliemae/ds-system';\nimport { DSTypography, type DSTypographyT } from '@elliemae/ds-typography';\nimport { CONTROLLED_TOGGLE_SLOTS, DSControlledToggleName } from '../../constants/index.js';\nimport type { DSControlledToggleT } from '../../react-desc-prop-types.js';\n\ninterface StyledContainerT {\n $size: DSControlledToggleT.ToggleSize;\n}\nconst containerHeight = {\n s: '20px',\n m: '28px',\n l: '36px',\n};\nexport const StyledContainer = styled('div', {\n name: DSControlledToggleName,\n slot: CONTROLLED_TOGGLE_SLOTS.CONTROLLED_CONTAINER,\n})<StyledContainerT>`\n display: inline-flex;\n width: fit-content;\n justify-content: center;\n align-items: center;\n height: ${({ $size }) => containerHeight[$size]};\n padding: 2px;\n border-radius: 20px;\n :focus-within {\n background-color: ${({ theme }) => theme.colors.neutral['000']};\n }\n ${xStyledCommonProps}\n`;\ninterface StyledButtonT {\n $checked: boolean;\n $disabled: boolean;\n $applyAriaDisabled: boolean;\n $readOnly: boolean;\n}\nconst SwitchButtonStateColors = css<StyledButtonT>`\n ${({ $disabled, $readOnly, $applyAriaDisabled, $checked, theme }) => {\n // 1. disabled (standard HTML attribute)\n if ($disabled)\n return `\n background-color: ${theme.colors.neutral['080']};\n border: 2px solid ${theme.colors.neutral['400']};\n `;\n // 2. Aria-Read-Only / Aria-Disabled\n if ($readOnly || $applyAriaDisabled)\n return `\n background-color: ${theme.colors.neutral['050']};\n border: 2px solid ${theme.colors.neutral['400']};\n `;\n // 3. Enabled\n // a. Checked\n if ($checked)\n return `\n background-color: ${theme.colors.brand['600']};\n border: 2px solid ${theme.colors.brand['700']};\n `;\n // b. Not checked\n return `\n background-color: ${theme.colors.neutral['500']};\n border: 2px solid ${theme.colors.neutral['600']};\n `;\n }}\n`;\nconst SwitchCursors = css<StyledButtonT>`\n ${({ $disabled, $readOnly, $applyAriaDisabled }) => {\n // 1. truly disabled (standard HTML attribute)\n if ($disabled || $readOnly || $applyAriaDisabled)\n // /\\ this \"cursor: not-allowed\" for the aria-disabled/aria-readonly is not consistent what the spec says\n // as of today readonly/aria-disabled say \"arrow\" (default) but that is not consistent with other dimsum components\n // coordinated with QA, we ship this consistent with other dimsum components and if UX confirms the intention we change it later\n return `\n cursor: not-allowed;\n `;\n // 2. Enabled\n return `\n cursor: pointer;\n `;\n }}\n`;\nconst SwitchHoverColors = css<StyledButtonT>`\n ${({ $disabled, $readOnly, $applyAriaDisabled, $checked, theme }) => {\n // the button \"on hover\" overrides with background: transparent\n // disabled keeps the same color as before, no hover effect, but we compensate the transparent effect inherithed from the button hover.\n // 1. disabled (standard HTML attribute)\n if ($disabled)\n return `\n background-color: ${theme.colors.neutral['080']};\n `;\n // 2. Aria-Read-Only / Aria-Disabled\n // the button \"on hover\" overrides with background: transparent\n // disabled keeps the same color as before, no hover effect, but we compensate the transparent effect inherithed from the button hover.\n if ($readOnly || $applyAriaDisabled)\n return `\n background-color: ${theme.colors.neutral['050']};\n `;\n // 2. Enabled\n // a. Checked\n if ($checked)\n return `\n background-color: ${theme.colors.brand['700']};\n border-color: ${theme.colors.brand['800']};\n `;\n // b. Not checked\n return `\n background-color: ${theme.colors.neutral['600']};\n border-color: ${theme.colors.neutral['700']};\n `;\n }}\n`;\nexport const StyledButton = styled(DSButtonV3, {\n name: DSControlledToggleName,\n slot: CONTROLLED_TOGGLE_SLOTS.TOGGLE_CHECKBOX,\n})<StyledButtonT>`\n margin: 0;\n padding: 0;\n border-radius: 20px;\n ${SwitchButtonStateColors}\n transition: background-color 0.2s;\n :focus {\n outline: 2px solid ${({ theme }) => theme.colors.brand['700']};\n outline-offset: 1px;\n }\n &:hover {\n ${SwitchCursors}\n ${SwitchHoverColors}\n }\n`;\ninterface StyledButtonContentWrapperT {\n $size: DSControlledToggleT.ToggleSize;\n $width: number;\n $checked: boolean;\n}\nconst labelHeight = {\n s: '16px',\n m: '24px',\n l: '32px',\n};\nconst margin = {\n s: '26px',\n m: '34px',\n l: '42px',\n};\nexport const StyledButtonContentWrapper = styled('div', {\n name: DSControlledToggleName,\n slot: CONTROLLED_TOGGLE_SLOTS.BUTTON_CONTENT_WRAPPER,\n})<StyledButtonContentWrapperT>`\n min-width: ${({ $width, $size }) => `calc(${$width}px + ${margin[$size]})`};\n height: ${({ $size }) => labelHeight[$size]};\n display: flex;\n margin: 0;\n padding: 0;\n align-items: center;\n height: 100%;\n flex-direction: ${({ $checked }) => ($checked ? 'row-reverse' : 'row')};\n border-radius: 20px;\n`;\ninterface StyledCircleT {\n $size: DSControlledToggleT.ToggleSize;\n $disabled: boolean;\n $readOnly: boolean;\n $applyAriaDisabled: boolean;\n}\nconst CircleColors = css<StyledCircleT>`\n ${({ theme, $disabled, $readOnly, $applyAriaDisabled }) => {\n // 1. Truly disabled (standard HTML attribute)\n if ($disabled) {\n return `\n background-color: ${theme.colors.neutral['080']};\n outline: 2px solid ${theme.colors.neutral['400']};\n `;\n }\n\n // 2. Aria-disabled / aria-readonly\n if ($readOnly || $applyAriaDisabled) {\n return `\n background-color: ${theme.colors.neutral['000']};\n outline: 2px solid ${theme.colors.neutral['400']};\n `;\n }\n\n // 3. Enabled\n return `\n background-color: ${theme.colors.neutral['000']};\n `;\n }}\n`;\nconst circleValues = {\n s: '14px',\n m: '20px',\n l: '28px',\n};\nexport const StyledCircle = styled('div', {\n name: DSControlledToggleName,\n slot: CONTROLLED_TOGGLE_SLOTS.CIRCLE,\n})<StyledCircleT>`\n height: ${({ $size }) => circleValues[$size]};\n width: ${({ $size }) => circleValues[$size]};\n border-radius: 50%;\n ${CircleColors}\n`;\ninterface StyledTextWrapperT extends DSTypographyT.Props {\n $size: DSControlledToggleT.ToggleSize;\n $disabled: boolean;\n $applyAriaDisabled: boolean;\n $readOnly: boolean;\n}\nconst TextWrapperColors = css<StyledTextWrapperT>`\n ${({ theme, $disabled, $applyAriaDisabled, $readOnly }) => {\n // 1. Truly disabled, applyAriaDisabled, readOnly\n if ($disabled || $applyAriaDisabled || $readOnly) {\n return `\n color: ${theme.colors.neutral['600']};\n `;\n }\n // 2. Enabled\n return `\n color: ${theme.colors.neutral['000']};\n `;\n }}\n`;\nexport const RemBasedFontProperties = css<{ $size: DSControlledToggleT.ToggleSize }>`\n ${({ theme, $size }) => {\n if ($size === 's')\n return `\n font-size: 0.6875rem; // 11px -> 11/16 = 0.6875rem\n line-height: 0.6875rem; // 11px -> 11/16 = 0.6875rem\n @media (min-width: ${theme.breakpoints.small}) {\n font-size: 0.84615rem; // 11px -> 11/13 = 0.84615rem\n line-height: 0.84615rem; // 11px -> 11/13 = 0.84615rem\n }\n `;\n if ($size === 'l')\n return `\n font-size: 1.25rem; // 20px -> 20/16 = 1.25rem\n line-height: 1.25rem; // 20px -> 20/16 = 1.25rem\n @media (min-width: ${theme.breakpoints.small}) {\n font-size: 1.53846rem; // 20px -> 20/13 = 1.53846rem\n line-height: 1.53846rem; // 20px -> 20/13 = 1.53846rem\n }\n `;\n return `\n font-size: 0.9375rem; // 15px -> 15/16 = 0.9375rem\n line-height: 0.9375rem; // 15px -> 15/16 = 0.9375rem\n @media (min-width: ${theme.breakpoints.small}) {\n font-size: 1.15385rem; // 15px -> 15/13 = 1.15385rem\n line-height: 1.15385rem; // 15px -> 15/13 = 1.15385rem\n }\n `;\n }}\n`;\nexport const StyledTextWrapper = styled(DSTypography, {\n name: DSControlledToggleName,\n slot: CONTROLLED_TOGGLE_SLOTS.TEXT_WRAPPER,\n})<StyledTextWrapperT>`\n flex-grow: 1;\n font-weight: ${({ theme }) => theme.fontWeights.semibold};\n ${RemBasedFontProperties}\n ${TextWrapperColors}\n`;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var Button_wcagViolationLabels_exports = {};
|
|
30
|
+
__export(Button_wcagViolationLabels_exports, {
|
|
31
|
+
ButtonWCAGViolation: () => ButtonWCAGViolation
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(Button_wcagViolationLabels_exports);
|
|
34
|
+
var React = __toESM(require("react"));
|
|
35
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
|
+
var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
|
|
37
|
+
var import_ds_typography = require("@elliemae/ds-typography");
|
|
38
|
+
var import_ds_system = require("@elliemae/ds-system");
|
|
39
|
+
var import_react = __toESM(require("react"));
|
|
40
|
+
var import_DSControlledToggleCTX = require("../../DSControlledToggleCTX.js");
|
|
41
|
+
var import_styles = require("../styles/styles.js");
|
|
42
|
+
var import_useGetWidestLabelWidth = require("./useGetWidestLabelWidth.js");
|
|
43
|
+
const SetLabelWidth = import_ds_system.styled.div`
|
|
44
|
+
${import_styles.RemBasedFontProperties}
|
|
45
|
+
font-weight: ${({ theme }) => theme.fontWeights.semibold};
|
|
46
|
+
width: auto;
|
|
47
|
+
position: absolute;
|
|
48
|
+
white-space: nowrap;
|
|
49
|
+
visibility: hidden;
|
|
50
|
+
`;
|
|
51
|
+
const ButtonWCAGViolation = () => {
|
|
52
|
+
const { propsWithDefault, buttonProps } = import_react.default.useContext(import_DSControlledToggleCTX.ControlledToggleContext);
|
|
53
|
+
const { wcagViolationLabelOn, wcagViolationLabelOff, checked, size, disabled, applyAriaDisabled, readOnly } = propsWithDefault;
|
|
54
|
+
const { getOwnerProps, getOwnerPropsArguments } = (0, import_ds_props_helpers.useOwnerProps)(propsWithDefault);
|
|
55
|
+
const { width, handleRefOnLabelWidth, handleRefOffLabelWidth } = (0, import_useGetWidestLabelWidth.useGetWidestLabelWidth)();
|
|
56
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
57
|
+
import_styles.StyledButton,
|
|
58
|
+
{
|
|
59
|
+
...readOnly ? { "aria-readonly": "true" } : {},
|
|
60
|
+
...buttonProps,
|
|
61
|
+
$checked: checked,
|
|
62
|
+
$readOnly: readOnly,
|
|
63
|
+
$disabled: disabled,
|
|
64
|
+
$applyAriaDisabled: applyAriaDisabled,
|
|
65
|
+
getOwnerProps,
|
|
66
|
+
getOwnerPropsArguments,
|
|
67
|
+
children: [
|
|
68
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
69
|
+
import_styles.StyledButtonContentWrapper,
|
|
70
|
+
{
|
|
71
|
+
$width: width,
|
|
72
|
+
$checked: checked,
|
|
73
|
+
$size: size,
|
|
74
|
+
getOwnerProps,
|
|
75
|
+
getOwnerPropsArguments,
|
|
76
|
+
children: [
|
|
77
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
78
|
+
import_styles.StyledCircle,
|
|
79
|
+
{
|
|
80
|
+
$size: size,
|
|
81
|
+
$disabled: disabled,
|
|
82
|
+
$readOnly: readOnly,
|
|
83
|
+
$applyAriaDisabled: applyAriaDisabled,
|
|
84
|
+
getOwnerProps,
|
|
85
|
+
getOwnerPropsArguments
|
|
86
|
+
}
|
|
87
|
+
),
|
|
88
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
89
|
+
import_styles.StyledTextWrapper,
|
|
90
|
+
{
|
|
91
|
+
$size: size,
|
|
92
|
+
$disabled: disabled,
|
|
93
|
+
$readOnly: readOnly,
|
|
94
|
+
$applyAriaDisabled: applyAriaDisabled,
|
|
95
|
+
getOwnerProps,
|
|
96
|
+
getOwnerPropsArguments,
|
|
97
|
+
variant: import_ds_typography.TYPOGRAPHY_VARIANTS.B2,
|
|
98
|
+
children: checked ? wcagViolationLabelOn ?? "ON" : wcagViolationLabelOff ?? "OFF"
|
|
99
|
+
}
|
|
100
|
+
)
|
|
101
|
+
]
|
|
102
|
+
}
|
|
103
|
+
),
|
|
104
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SetLabelWidth, { $size: size, innerRef: handleRefOnLabelWidth, "aria-hidden": "true", children: wcagViolationLabelOn ?? "ON" }),
|
|
105
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SetLabelWidth, { $size: size, innerRef: handleRefOffLabelWidth, "aria-hidden": "true", children: wcagViolationLabelOff ?? "OFF" })
|
|
106
|
+
]
|
|
107
|
+
}
|
|
108
|
+
);
|
|
109
|
+
};
|
|
110
|
+
//# sourceMappingURL=Button.wcagViolationLabels.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/parts/wcagViolation/Button.wcagViolationLabels.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import { useOwnerProps } from '@elliemae/ds-props-helpers';\nimport { TYPOGRAPHY_VARIANTS } from '@elliemae/ds-typography';\nimport { styled } from '@elliemae/ds-system';\nimport React from 'react';\nimport { ControlledToggleContext } from '../../DSControlledToggleCTX.js';\nimport type { DSControlledToggleT } from '../../react-desc-prop-types.js';\nimport {\n RemBasedFontProperties,\n StyledButton,\n StyledButtonContentWrapper,\n StyledCircle,\n StyledTextWrapper,\n} from '../styles/styles.js';\nimport { useGetWidestLabelWidth } from './useGetWidestLabelWidth.js';\n\n/**\n * we are doing this to keep the wcagViolationLabelOn/wcagViolationLabelOff working\n * this calculates the width of the widest custom label and sets the width of both labels to that width to avoid layout shift on toggle\n *\n * ---\n *\n * this can be safely removed in favor of a sensible default min-width for the accessible ON/OFF labels when we can actually kill the wcagViolationLabelOn/wcagViolationLabelOff props\n */\nconst SetLabelWidth = styled.div<{ $size: DSControlledToggleT.ToggleSize }>`\n ${RemBasedFontProperties}\n font-weight: ${({ theme }) => theme.fontWeights.semibold};\n width: auto;\n position: absolute;\n white-space: nowrap;\n visibility: hidden;\n`;\n\nexport const ButtonWCAGViolation: React.ComponentType<DSControlledToggleT.Props> = () => {\n const { propsWithDefault, buttonProps } = React.useContext(ControlledToggleContext);\n const { wcagViolationLabelOn, wcagViolationLabelOff, checked, size, disabled, applyAriaDisabled, readOnly } =\n propsWithDefault;\n const { getOwnerProps, getOwnerPropsArguments } = useOwnerProps(propsWithDefault);\n const { width, handleRefOnLabelWidth, handleRefOffLabelWidth } = useGetWidestLabelWidth();\n\n return (\n <StyledButton\n // as per morning meeting, juan said \"readOnly\" in toggle should receive aria-readonly, aria-readonly is valid for switch role, the html readonly attribute is not\n {...(readOnly ? { 'aria-readonly': 'true' } : {})}\n {...buttonProps}\n $checked={checked}\n $readOnly={readOnly}\n $disabled={disabled}\n $applyAriaDisabled={applyAriaDisabled}\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={getOwnerPropsArguments}\n >\n <StyledButtonContentWrapper\n $width={width}\n $checked={checked}\n $size={size}\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={getOwnerPropsArguments}\n >\n <StyledCircle\n $size={size}\n $disabled={disabled}\n $readOnly={readOnly}\n $applyAriaDisabled={applyAriaDisabled}\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={getOwnerPropsArguments}\n />\n <StyledTextWrapper\n $size={size}\n $disabled={disabled}\n $readOnly={readOnly}\n $applyAriaDisabled={applyAriaDisabled}\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={getOwnerPropsArguments}\n variant={TYPOGRAPHY_VARIANTS.B2}\n >\n {checked ? (wcagViolationLabelOn ?? 'ON') : (wcagViolationLabelOff ?? 'OFF')}\n </StyledTextWrapper>\n </StyledButtonContentWrapper>\n <SetLabelWidth $size={size} innerRef={handleRefOnLabelWidth} aria-hidden=\"true\">\n {wcagViolationLabelOn ?? 'ON'}\n </SetLabelWidth>\n <SetLabelWidth $size={size} innerRef={handleRefOffLabelWidth} aria-hidden=\"true\">\n {wcagViolationLabelOff ?? 'OFF'}\n </SetLabelWidth>\n </StyledButton>\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADmDjB;AAnDN,8BAA8B;AAC9B,2BAAoC;AACpC,uBAAuB;AACvB,mBAAkB;AAClB,mCAAwC;AAExC,oBAMO;AACP,oCAAuC;AAUvC,MAAM,gBAAgB,wBAAO;AAAA,IACzB,oCAAsB;AAAA,iBACT,CAAC,EAAE,MAAM,MAAM,MAAM,YAAY,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAOnD,MAAM,sBAAsE,MAAM;AACvF,QAAM,EAAE,kBAAkB,YAAY,IAAI,aAAAA,QAAM,WAAW,oDAAuB;AAClF,QAAM,EAAE,sBAAsB,uBAAuB,SAAS,MAAM,UAAU,mBAAmB,SAAS,IACxG;AACF,QAAM,EAAE,eAAe,uBAAuB,QAAI,uCAAc,gBAAgB;AAChF,QAAM,EAAE,OAAO,uBAAuB,uBAAuB,QAAI,sDAAuB;AAExF,SACE;AAAA,IAAC;AAAA;AAAA,MAEE,GAAI,WAAW,EAAE,iBAAiB,OAAO,IAAI,CAAC;AAAA,MAC9C,GAAG;AAAA,MACJ,UAAU;AAAA,MACV,WAAW;AAAA,MACX,WAAW;AAAA,MACX,oBAAoB;AAAA,MACpB;AAAA,MACA;AAAA,MAEA;AAAA;AAAA,UAAC;AAAA;AAAA,YACC,QAAQ;AAAA,YACR,UAAU;AAAA,YACV,OAAO;AAAA,YACP;AAAA,YACA;AAAA,YAEA;AAAA;AAAA,gBAAC;AAAA;AAAA,kBACC,OAAO;AAAA,kBACP,WAAW;AAAA,kBACX,WAAW;AAAA,kBACX,oBAAoB;AAAA,kBACpB;AAAA,kBACA;AAAA;AAAA,cACF;AAAA,cACA;AAAA,gBAAC;AAAA;AAAA,kBACC,OAAO;AAAA,kBACP,WAAW;AAAA,kBACX,WAAW;AAAA,kBACX,oBAAoB;AAAA,kBACpB;AAAA,kBACA;AAAA,kBACA,SAAS,yCAAoB;AAAA,kBAE5B,oBAAW,wBAAwB,OAAS,yBAAyB;AAAA;AAAA,cACxE;AAAA;AAAA;AAAA,QACF;AAAA,QACA,4CAAC,iBAAc,OAAO,MAAM,UAAU,uBAAuB,eAAY,QACtE,kCAAwB,MAC3B;AAAA,QACA,4CAAC,iBAAc,OAAO,MAAM,UAAU,wBAAwB,eAAY,QACvE,mCAAyB,OAC5B;AAAA;AAAA;AAAA,EACF;AAEJ;",
|
|
6
|
+
"names": ["React"]
|
|
7
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["
|
|
3
|
+
"sources": ["../../../../src/parts/wcagViolation/useGetWidestLabelWidth.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["import { throttle } from 'lodash-es';\nimport React, { useState, useRef } from 'react';\n\n/**\n * This should not be required, we are doing this to keep the wcagViolationLabelOn/wcagViolationLabelOff working\n * this calculates the width of the widest custom label and sets the width of both labels to that width to avoid layout shift on toggle\n *\n * ---\n *\n * this can be safely removed in favor of a sensible default min-width for the accessible ON/OFF labels when we can actually kill the wcagViolationLabelOn/wcagViolationLabelOff props\n */\nexport const useGetWidestLabelWidth = () => {\n const [width, setWidth] = useState<number>(0);\n const onLabelWidthRef = useRef<number>(68);\n const offLabelWidthRef = useRef<number>(68);\n // typescript with debounce doesn't work well, so we need to disable the exhaustive deps rule here\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const setLongestWidth = React.useCallback(\n throttle(\n () => {\n const longest = Math.max(onLabelWidthRef.current, offLabelWidthRef.current);\n setWidth(longest);\n },\n 20,\n { leading: false, trailing: true },\n ),\n [],\n );\n const handleRefOnLabelWidth = React.useCallback<React.RefCallback<HTMLDivElement>>(\n (node) => {\n const { clientWidth } = node || {};\n onLabelWidthRef.current = clientWidth ?? onLabelWidthRef.current;\n setLongestWidth();\n },\n [setLongestWidth],\n );\n const handleRefOffLabelWidth = React.useCallback<React.RefCallback<HTMLDivElement>>(\n (node) => {\n const { clientWidth } = node || {};\n offLabelWidthRef.current = clientWidth ?? offLabelWidthRef.current;\n setLongestWidth();\n },\n [setLongestWidth],\n );\n return { width, handleRefOnLabelWidth, handleRefOffLabelWidth };\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,uBAAyB;AACzB,mBAAwC;AAUjC,MAAM,yBAAyB,MAAM;AAC1C,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAAiB,CAAC;AAC5C,QAAM,sBAAkB,qBAAe,EAAE;AACzC,QAAM,uBAAmB,qBAAe,EAAE;AAG1C,QAAM,kBAAkB,aAAAA,QAAM;AAAA,QAC5B;AAAA,MACE,MAAM;AACJ,cAAM,UAAU,KAAK,IAAI,gBAAgB,SAAS,iBAAiB,OAAO;AAC1E,iBAAS,OAAO;AAAA,MAClB;AAAA,MACA;AAAA,MACA,EAAE,SAAS,OAAO,UAAU,KAAK;AAAA,IACnC;AAAA,IACA,CAAC;AAAA,EACH;AACA,QAAM,wBAAwB,aAAAA,QAAM;AAAA,IAClC,CAAC,SAAS;AACR,YAAM,EAAE,YAAY,IAAI,QAAQ,CAAC;AACjC,sBAAgB,UAAU,eAAe,gBAAgB;AACzD,sBAAgB;AAAA,IAClB;AAAA,IACA,CAAC,eAAe;AAAA,EAClB;AACA,QAAM,yBAAyB,aAAAA,QAAM;AAAA,IACnC,CAAC,SAAS;AACR,YAAM,EAAE,YAAY,IAAI,QAAQ,CAAC;AACjC,uBAAiB,UAAU,eAAe,iBAAiB;AAC3D,sBAAgB;AAAA,IAClB;AAAA,IACA,CAAC,eAAe;AAAA,EAClB;AACA,SAAO,EAAE,OAAO,uBAAuB,uBAAuB;AAChE;",
|
|
6
6
|
"names": ["React"]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/react-desc-prop-types.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import type { DSButtonV3T } from '@elliemae/ds-button-v2';\nimport type { DSPropTypesSchema, GlobalAttributesT, ValidationMap, XstyledProps } from '@elliemae/ds-props-helpers';\nimport {\n PropTypes,\n globalAttributesPropTypes,\n xstyledPropTypes,\n getPropsPerSlotPropTypes,\n} from '@elliemae/ds-props-helpers';\nimport { type TypescriptHelpersT } from '@elliemae/ds-typescript-helpers';\nimport { TOGGLE_SIZES, DSControlledToggleName, CONTROLLED_TOGGLE_SLOTS } from './constants/index.js';\n\nexport declare namespace DSControlledToggleT {\n export type ToggleSize = ObjectValues<typeof TOGGLE_SIZES>;\n\n // One entry per slot in CONTROLLED_TOGGLE_SLOTS \u2014 the function (dynamic) form of slot props.\n // Exhaustiveness against the slots is enforced in typescript-testing/slot-props.ts.\n export type SlotFunctionArguments = {\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEvB,8BAKO;AAEP,uBAA8E;
|
|
4
|
+
"sourcesContent": ["import type { DSButtonV3T } from '@elliemae/ds-button-v2';\nimport type { DSPropTypesSchema, GlobalAttributesT, ValidationMap, XstyledProps } from '@elliemae/ds-props-helpers';\nimport {\n PropTypes,\n globalAttributesPropTypes,\n xstyledPropTypes,\n getPropsPerSlotPropTypes,\n} from '@elliemae/ds-props-helpers';\nimport { type TypescriptHelpersT } from '@elliemae/ds-typescript-helpers';\nimport { TOGGLE_SIZES, DSControlledToggleName, CONTROLLED_TOGGLE_SLOTS } from './constants/index.js';\n\nexport declare namespace DSControlledToggleT {\n export type ToggleSize = ObjectValues<typeof TOGGLE_SIZES>;\n\n // One entry per slot in CONTROLLED_TOGGLE_SLOTS \u2014 the function (dynamic) form of slot props.\n // Exhaustiveness against the slots is enforced in typescript-testing/slot-props.ts.\n export type SlotFunctionArguments = {\n dsFormtoggleButtonContentWrapper: () => object;\n dsFormtoggleCircle: () => object;\n dsFormtoggleTextWrapper: () => object;\n // legacy slot aliases \u2014 still injection points, see KNOWN_INTENTIONAL_DEVIATIONS.md\n dsFormtoggleControlledContainer: () => object;\n dsFormtoggleToggleCheckbox: () => object;\n };\n\n export interface DefaultProps {\n checked: boolean;\n onChange: (e: React.MouseEvent<HTMLButtonElement> | React.KeyboardEvent<HTMLButtonElement>) => void;\n size: ToggleSize;\n readOnly: boolean;\n disabled: boolean;\n applyAriaDisabled: boolean;\n }\n\n export interface RequiredProps {}\n\n export interface OptionalProps\n extends TypescriptHelpersT.PropsForGlobalOnSlots<typeof DSControlledToggleName, typeof CONTROLLED_TOGGLE_SLOTS> {\n containerProps?: Record<string, unknown>;\n id?: string;\n }\n\n // this interface is the \"last chance\" for apps to keep using the deprecated props before the major release that will remove them\n // this is meant to \"break\" those using the old prop, but still allow a last chance to gradually update (requiring them to change the prop name)\n export interface PostDeprecationETAPropsFallback {\n /**\n * @deprecated a custom wcagViolationLabelOn violates the role='switch' by design and it's impossible to make it WCAG compliant.\n * Do not use it, if you need a custom label, you don't need a toggle, use a checkbox instead.\n */\n wcagViolationLabelOn?: string; // used to be \"labelOn\"\n /**\n * @deprecated a custom wcagViolationLabelOff violates the role='switch' by design and it's impossible to make it WCAG compliant.\n * Do not use it, if you need a custom label, you don't need a toggle, use a checkbox instead.\n */\n wcagViolationLabelOff?: string; // used to be \"labelOff\"\n }\n export interface PreDeprecationETAProps {\n /**\n * @deprecated a custom wcagViolationLabelOn violates the role='switch' by design and it's impossible to make it WCAG compliant.\n * Do not use it, if you need a custom label, you don't need a toggle, use a checkbox instead.\n */\n labelOn?: string; // used to be \"labelOn\"\n /**\n * @deprecated a custom wcagViolationLabelOff violates the role='switch' by design and it's impossible to make it WCAG compliant.\n * Do not use it, if you need a custom label, you don't need a toggle, use a checkbox instead.\n */\n labelOff?: string; // used to be \"labelOff\"\n }\n\n export interface ButtonV3InherithedProps extends Omit<DSButtonV3T.Props, 'size' | 'children'> {}\n\n export interface Props\n extends Partial<DefaultProps>,\n OptionalProps,\n Omit<GlobalAttributesT<HTMLButtonElement>, keyof DefaultProps | keyof OptionalProps | keyof XstyledProps>,\n XstyledProps,\n RequiredProps,\n PreDeprecationETAProps,\n PostDeprecationETAPropsFallback {}\n\n export interface InternalProps\n extends DefaultProps,\n OptionalProps,\n Omit<GlobalAttributesT<HTMLButtonElement>, keyof DefaultProps | keyof OptionalProps | keyof XstyledProps>,\n XstyledProps,\n RequiredProps,\n PreDeprecationETAProps,\n PostDeprecationETAPropsFallback {}\n}\n\nexport const defaultProps: DSControlledToggleT.DefaultProps = {\n checked: false,\n onChange: () => null,\n size: TOGGLE_SIZES.MEDIUM,\n readOnly: false,\n disabled: false,\n applyAriaDisabled: false,\n};\n\nexport const DSControlledTogglePropTypes: DSPropTypesSchema<\n Omit<DSControlledToggleT.Props, keyof DSControlledToggleT.PostDeprecationETAPropsFallback> &\n DSControlledToggleT.PreDeprecationETAProps\n> = {\n ...globalAttributesPropTypes,\n ...xstyledPropTypes,\n ...getPropsPerSlotPropTypes(DSControlledToggleName, CONTROLLED_TOGGLE_SLOTS),\n checked: PropTypes.bool.description('Whether the toggle is checked or not').defaultValue('false'),\n onChange: PropTypes.func.description('OnClick callback').defaultValue('() => null'),\n size: PropTypes.oneOf(['s', 'm', 'l']).description('Size of toggle').defaultValue(TOGGLE_SIZES.MEDIUM),\n disabled: PropTypes.bool.description('Whether the toggle is disabled or not').defaultValue('false'),\n applyAriaDisabled: PropTypes.bool\n .description(\n 'Whether to apply disabled styling and announce as disabled in SR. CAN STILL RECEIVE FOCUS. PREVENTS ONLY MAIN ACTION.',\n )\n .defaultValue('false'),\n readOnly: PropTypes.bool.description('Whether the toggle is readOnly or not').defaultValue('false'),\n containerProps: PropTypes.object.description('Set of properties attached to the main container'),\n id: PropTypes.string.description('Unique id.'),\n labelOn: PropTypes.string\n .description('Past deprecation ETA, this fails WCAG, switch to appropiate designs')\n .deprecated({ version: '25.3' }),\n labelOff: PropTypes.string\n .description('Past deprecation ETA, this fails WCAG, switch to appropiate designs')\n .deprecated({ version: '25.3' }),\n};\n\nexport const DSControlledTogglePropTypesSchema =\n DSControlledTogglePropTypes as unknown as ValidationMap<DSControlledToggleT.Props>;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEvB,8BAKO;AAEP,uBAA8E;AAiFvE,MAAM,eAAiD;AAAA,EAC5D,SAAS;AAAA,EACT,UAAU,MAAM;AAAA,EAChB,MAAM,8BAAa;AAAA,EACnB,UAAU;AAAA,EACV,UAAU;AAAA,EACV,mBAAmB;AACrB;AAEO,MAAM,8BAGT;AAAA,EACF,GAAG;AAAA,EACH,GAAG;AAAA,EACH,OAAG,kDAAyB,yCAAwB,wCAAuB;AAAA,EAC3E,SAAS,kCAAU,KAAK,YAAY,sCAAsC,EAAE,aAAa,OAAO;AAAA,EAChG,UAAU,kCAAU,KAAK,YAAY,kBAAkB,EAAE,aAAa,YAAY;AAAA,EAClF,MAAM,kCAAU,MAAM,CAAC,KAAK,KAAK,GAAG,CAAC,EAAE,YAAY,gBAAgB,EAAE,aAAa,8BAAa,MAAM;AAAA,EACrG,UAAU,kCAAU,KAAK,YAAY,uCAAuC,EAAE,aAAa,OAAO;AAAA,EAClG,mBAAmB,kCAAU,KAC1B;AAAA,IACC;AAAA,EACF,EACC,aAAa,OAAO;AAAA,EACvB,UAAU,kCAAU,KAAK,YAAY,uCAAuC,EAAE,aAAa,OAAO;AAAA,EAClG,gBAAgB,kCAAU,OAAO,YAAY,kDAAkD;AAAA,EAC/F,IAAI,kCAAU,OAAO,YAAY,YAAY;AAAA,EAC7C,SAAS,kCAAU,OAChB,YAAY,qEAAqE,EACjF,WAAW,EAAE,SAAS,OAAO,CAAC;AAAA,EACjC,UAAU,kCAAU,OACjB,YAAY,qEAAqE,EACjF,WAAW,EAAE,SAAS,OAAO,CAAC;AACnC;AAEO,MAAM,oCACX;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -23,7 +23,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
23
|
));
|
|
24
24
|
var React = __toESM(require("react"));
|
|
25
25
|
const SlotPropsAsObject = {
|
|
26
|
-
dsFormtoggleContainerWithRadiusShape: { "aria-label": "just a typescript test" },
|
|
27
26
|
dsFormtoggleButtonContentWrapper: { "aria-label": "just a typescript test" },
|
|
28
27
|
dsFormtoggleCircle: { "aria-label": "just a typescript test" },
|
|
29
28
|
dsFormtoggleTextWrapper: { "aria-label": "just a typescript test" },
|
|
@@ -31,7 +30,6 @@ const SlotPropsAsObject = {
|
|
|
31
30
|
dsFormtoggleToggleCheckbox: { "aria-label": "just a typescript test" }
|
|
32
31
|
};
|
|
33
32
|
const SlotPropsAsFunctions = {
|
|
34
|
-
dsFormtoggleContainerWithRadiusShape: () => ({ "aria-label": "just a typescript test" }),
|
|
35
33
|
dsFormtoggleButtonContentWrapper: () => ({ "aria-label": "just a typescript test" }),
|
|
36
34
|
dsFormtoggleCircle: () => ({ "aria-label": "just a typescript test" }),
|
|
37
35
|
dsFormtoggleTextWrapper: () => ({ "aria-label": "just a typescript test" }),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/typescript-testing/slot-props.ts"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */\nimport { type TypescriptHelpersT } from '@elliemae/ds-typescript-helpers';\nimport type { DSControlledToggleT } from '../react-desc-prop-types.js';\nimport type { DSControlledToggleName, CONTROLLED_TOGGLE_SLOTS } from '../constants/index.js';\n\n// Exhaustiveness contract over CONTROLLED_TOGGLE_SLOTS \u2014 every slot must appear in SlotFunctionArguments.\n// The legacy aliases (dsFormtoggleControlledContainer, dsFormtoggleToggleCheckbox) are real injection\n// points kept for QA/consumer compatibility \u2014 see KNOWN_INTENTIONAL_DEVIATIONS.md.\n//\n// Slot props can be passed in two forms \u2014 object (static) and function (dynamic).\nconst SlotPropsAsObject: Partial<DSControlledToggleT.Props> = {\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA,YAAuB;ACUvB,MAAM,oBAAwD;AAAA,EAC5D,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */\nimport { type TypescriptHelpersT } from '@elliemae/ds-typescript-helpers';\nimport type { DSControlledToggleT } from '../react-desc-prop-types.js';\nimport type { DSControlledToggleName, CONTROLLED_TOGGLE_SLOTS } from '../constants/index.js';\n\n// Exhaustiveness contract over CONTROLLED_TOGGLE_SLOTS \u2014 every slot must appear in SlotFunctionArguments.\n// The legacy aliases (dsFormtoggleControlledContainer, dsFormtoggleToggleCheckbox) are real injection\n// points kept for QA/consumer compatibility \u2014 see KNOWN_INTENTIONAL_DEVIATIONS.md.\n//\n// Slot props can be passed in two forms \u2014 object (static) and function (dynamic).\nconst SlotPropsAsObject: Partial<DSControlledToggleT.Props> = {\n dsFormtoggleButtonContentWrapper: { 'aria-label': 'just a typescript test' },\n dsFormtoggleCircle: { 'aria-label': 'just a typescript test' },\n dsFormtoggleTextWrapper: { 'aria-label': 'just a typescript test' },\n dsFormtoggleControlledContainer: { 'aria-label': 'just a typescript test' },\n dsFormtoggleToggleCheckbox: { 'aria-label': 'just a typescript test' },\n};\n\nconst SlotPropsAsFunctions: DSControlledToggleT.SlotFunctionArguments = {\n dsFormtoggleButtonContentWrapper: () => ({ 'aria-label': 'just a typescript test' }),\n dsFormtoggleCircle: () => ({ 'aria-label': 'just a typescript test' }),\n dsFormtoggleTextWrapper: () => ({ 'aria-label': 'just a typescript test' }),\n dsFormtoggleControlledContainer: () => ({ 'aria-label': 'just a typescript test' }),\n dsFormtoggleToggleCheckbox: () => ({ 'aria-label': 'just a typescript test' }),\n};\n\n// Exhaustiveness check \u2014 fails compilation if a slot is missing from SlotFunctionArguments.\nconst EnsureAllSlotsExistInSlotFunctionArguments: Required<\n TypescriptHelpersT.PropsForSlots<typeof DSControlledToggleName, typeof CONTROLLED_TOGGLE_SLOTS>\n> = SlotPropsAsFunctions;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA,YAAuB;ACUvB,MAAM,oBAAwD;AAAA,EAC5D,kCAAkC,EAAE,cAAc,yBAAyB;AAAA,EAC3E,oBAAoB,EAAE,cAAc,yBAAyB;AAAA,EAC7D,yBAAyB,EAAE,cAAc,yBAAyB;AAAA,EAClE,iCAAiC,EAAE,cAAc,yBAAyB;AAAA,EAC1E,4BAA4B,EAAE,cAAc,yBAAyB;AACvE;AAEA,MAAM,uBAAkE;AAAA,EACtE,kCAAkC,OAAO,EAAE,cAAc,yBAAyB;AAAA,EAClF,oBAAoB,OAAO,EAAE,cAAc,yBAAyB;AAAA,EACpE,yBAAyB,OAAO,EAAE,cAAc,yBAAyB;AAAA,EACzE,iCAAiC,OAAO,EAAE,cAAc,yBAAyB;AAAA,EACjF,4BAA4B,OAAO,EAAE,cAAc,yBAAyB;AAC9E;AAGA,MAAM,6CAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { describe } from "@elliemae/ds-props-helpers";
|
|
4
|
+
import { useDSControlledToggle } from "./config/useDSControlledToggle.js";
|
|
5
|
+
import { DSControlledToggleName } from "./constants/index.js";
|
|
6
|
+
import { ControlledToggleContext } from "./DSControlledToggleCTX.js";
|
|
7
|
+
import { Container } from "./parts/Container.js";
|
|
8
|
+
import { DSControlledTogglePropTypesSchema } from "./react-desc-prop-types.js";
|
|
9
|
+
const DSControlledToggle = (props) => {
|
|
10
|
+
const ctx = useDSControlledToggle(props);
|
|
11
|
+
return /* @__PURE__ */ jsx(ControlledToggleContext.Provider, { value: ctx, children: /* @__PURE__ */ jsx(Container, {}) });
|
|
12
|
+
};
|
|
13
|
+
DSControlledToggle.displayName = DSControlledToggleName;
|
|
14
|
+
const DSControlledToggleWithSchema = describe(DSControlledToggle);
|
|
15
|
+
DSControlledToggleWithSchema.propTypes = DSControlledTogglePropTypesSchema;
|
|
16
|
+
export {
|
|
17
|
+
DSControlledToggle,
|
|
18
|
+
DSControlledToggleWithSchema
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=DSControlledToggle.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/DSControlledToggle.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { describe } from '@elliemae/ds-props-helpers';\nimport React from 'react';\nimport { useDSControlledToggle } from './config/useDSControlledToggle.js';\nimport { DSControlledToggleName } from './constants/index.js';\nimport { ControlledToggleContext } from './DSControlledToggleCTX.js';\nimport { Container } from './parts/Container.js';\nimport { DSControlledTogglePropTypesSchema, type DSControlledToggleT } from './react-desc-prop-types.js';\n\nconst DSControlledToggle: React.ComponentType<DSControlledToggleT.Props> = (props) => {\n const ctx = useDSControlledToggle(props);\n\n return (\n <ControlledToggleContext.Provider value={ctx}>\n <Container />\n </ControlledToggleContext.Provider>\n );\n};\n\nDSControlledToggle.displayName = DSControlledToggleName;\nconst DSControlledToggleWithSchema = describe(DSControlledToggle);\nDSControlledToggleWithSchema.propTypes = DSControlledTogglePropTypesSchema;\n\nexport { DSControlledToggle, DSControlledToggleWithSchema };\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACajB;AAbN,SAAS,gBAAgB;AAEzB,SAAS,6BAA6B;AACtC,SAAS,8BAA8B;AACvC,SAAS,+BAA+B;AACxC,SAAS,iBAAiB;AAC1B,SAAS,yCAAmE;AAE5E,MAAM,qBAAqE,CAAC,UAAU;AACpF,QAAM,MAAM,sBAAsB,KAAK;AAEvC,SACE,oBAAC,wBAAwB,UAAxB,EAAiC,OAAO,KACvC,8BAAC,aAAU,GACb;AAEJ;AAEA,mBAAmB,cAAc;AACjC,MAAM,+BAA+B,SAAS,kBAAkB;AAChE,6BAA6B,YAAY;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { createContext } from "react";
|
|
3
|
+
const defaultContext = {};
|
|
4
|
+
const ControlledToggleContext = createContext(defaultContext);
|
|
5
|
+
var DSControlledToggleCTX_default = ControlledToggleContext;
|
|
6
|
+
export {
|
|
7
|
+
ControlledToggleContext,
|
|
8
|
+
DSControlledToggleCTX_default as default
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=DSControlledToggleCTX.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/DSControlledToggleCTX.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { createContext } from 'react';\nimport type { ControlledToggleCTX } from './config/useDSControlledToggle.js';\n\nconst defaultContext = {} as ControlledToggleCTX;\n\n/** Context for cross component communication */\nexport const ControlledToggleContext = createContext<ControlledToggleCTX>(defaultContext);\n\nexport default ControlledToggleContext;\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,qBAAqB;AAG9B,MAAM,iBAAiB,CAAC;AAGjB,MAAM,0BAA0B,cAAmC,cAAc;AAExF,IAAO,gCAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -4,7 +4,6 @@ import React2, { useCallback } from "react";
|
|
|
4
4
|
import { uid } from "uid";
|
|
5
5
|
import { DSControlledTogglePropTypes, defaultProps } from "../react-desc-prop-types.js";
|
|
6
6
|
import { useGetButtonProps } from "./useGetButtonProps.js";
|
|
7
|
-
import { useGetWidestLabelWidth } from "./useGetWidestLabelWidth.js";
|
|
8
7
|
import { useValidateProps } from "./useValidateProps.js";
|
|
9
8
|
const useDSControlledToggle = (propsFromUser) => {
|
|
10
9
|
const propsWithDefault = useMemoMergePropsWithDefault(propsFromUser, defaultProps);
|
|
@@ -25,7 +24,6 @@ const useDSControlledToggle = (propsFromUser) => {
|
|
|
25
24
|
const xstyledProps = useGetXstyledProps(propsWithDefault);
|
|
26
25
|
const { id } = propsWithDefault;
|
|
27
26
|
const instanceUid = React2.useMemo(() => id || `ds-form-toggle-${uid(5)}`, [id]);
|
|
28
|
-
const { width, handleRefOnLabelWidth, handleRefOffLabelWidth } = useGetWidestLabelWidth();
|
|
29
27
|
const buttonProps = useGetButtonProps({
|
|
30
28
|
handleOnClick,
|
|
31
29
|
globalProps,
|
|
@@ -35,26 +33,13 @@ const useDSControlledToggle = (propsFromUser) => {
|
|
|
35
33
|
return React2.useMemo(
|
|
36
34
|
() => ({
|
|
37
35
|
propsWithDefault,
|
|
38
|
-
width,
|
|
39
|
-
handleRefOnLabelWidth,
|
|
40
|
-
handleRefOffLabelWidth,
|
|
41
36
|
globalProps,
|
|
42
|
-
buttonProps,
|
|
43
37
|
xstyledProps,
|
|
44
38
|
instanceUid,
|
|
45
|
-
handleOnClick
|
|
46
|
-
}),
|
|
47
|
-
[
|
|
48
|
-
propsWithDefault,
|
|
49
|
-
width,
|
|
50
|
-
handleRefOnLabelWidth,
|
|
51
|
-
handleRefOffLabelWidth,
|
|
52
|
-
globalProps,
|
|
53
39
|
buttonProps,
|
|
54
|
-
xstyledProps,
|
|
55
|
-
instanceUid,
|
|
56
40
|
handleOnClick
|
|
57
|
-
|
|
41
|
+
}),
|
|
42
|
+
[propsWithDefault, globalProps, buttonProps, xstyledProps, instanceUid, handleOnClick]
|
|
58
43
|
);
|
|
59
44
|
};
|
|
60
45
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/config/useDSControlledToggle.ts"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useGetGlobalAttributes, useGetXstyledProps, useMemoMergePropsWithDefault } from '@elliemae/ds-props-helpers';\nimport React, { useCallback } from 'react';\nimport { uid } from 'uid';\nimport { type DSControlledToggleT, DSControlledTogglePropTypes, defaultProps } from '../react-desc-prop-types.js';\nimport { useGetButtonProps } from './useGetButtonProps.js';\nimport {
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,wBAAwB,oBAAoB,oCAAoC;AACzF,OAAOA,UAAS,mBAAmB;AACnC,SAAS,WAAW;AACpB,SAAmC,6BAA6B,oBAAoB;AACpF,SAAS,yBAAyB;AAClC,SAAS,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useGetGlobalAttributes, useGetXstyledProps, useMemoMergePropsWithDefault } from '@elliemae/ds-props-helpers';\nimport React, { useCallback } from 'react';\nimport { uid } from 'uid';\nimport { type DSControlledToggleT, DSControlledTogglePropTypes, defaultProps } from '../react-desc-prop-types.js';\nimport { useGetButtonProps } from './useGetButtonProps.js';\nimport { useValidateProps } from './useValidateProps.js';\n\nexport interface ControlledToggleCTX {\n propsWithDefault: DSControlledToggleT.InternalProps;\n globalProps: ReturnType<typeof useGetGlobalAttributes>;\n xstyledProps: ReturnType<typeof useGetXstyledProps>;\n instanceUid: string;\n buttonProps: ReturnType<typeof useGetButtonProps>;\n handleOnClick: (e: React.KeyboardEvent<HTMLButtonElement> | React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;\n}\n\nexport const useDSControlledToggle = (propsFromUser: DSControlledToggleT.Props): ControlledToggleCTX => {\n // =============================================================================\n // MERGE WITH DEFAULT AND VALIDATE PROPS\n // =============================================================================\n const propsWithDefault = useMemoMergePropsWithDefault<DSControlledToggleT.InternalProps>(propsFromUser, defaultProps);\n useValidateProps(propsWithDefault, DSControlledTogglePropTypes);\n // =============================================================================\n // AD HOC PER COMPONENT LOGIC\n // =============================================================================\n const { disabled, applyAriaDisabled, readOnly, onChange } = propsWithDefault;\n const handleOnClick = useCallback(\n (e: React.KeyboardEvent<HTMLButtonElement> | React.MouseEvent<HTMLButtonElement, MouseEvent>) => {\n if (disabled || applyAriaDisabled || readOnly) return;\n if (onChange) {\n onChange(e);\n }\n },\n [disabled, applyAriaDisabled, readOnly, onChange],\n );\n // =============================================================================\n // GLOBAL ATTRIBUTES & XSTYLED PROPS\n // =============================================================================\n const globalProps = useGetGlobalAttributes<DSControlledToggleT.InternalProps>(propsWithDefault, {\n onClick: handleOnClick,\n });\n const xstyledProps = useGetXstyledProps(propsWithDefault);\n const { id } = propsWithDefault;\n const instanceUid = React.useMemo(() => id || `ds-form-toggle-${uid(5)}`, [id]);\n // =============================================================================\n // HELPERS HOOKS CONFIGS\n // =============================================================================\n const buttonProps = useGetButtonProps({\n handleOnClick,\n globalProps,\n instanceUid,\n propsWithDefault,\n });\n\n return React.useMemo(\n () => ({\n propsWithDefault,\n globalProps,\n xstyledProps,\n instanceUid,\n buttonProps,\n handleOnClick,\n }),\n [propsWithDefault, globalProps, buttonProps, xstyledProps, instanceUid, handleOnClick],\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,wBAAwB,oBAAoB,oCAAoC;AACzF,OAAOA,UAAS,mBAAmB;AACnC,SAAS,WAAW;AACpB,SAAmC,6BAA6B,oBAAoB;AACpF,SAAS,yBAAyB;AAClC,SAAS,wBAAwB;AAW1B,MAAM,wBAAwB,CAAC,kBAAkE;AAItG,QAAM,mBAAmB,6BAAgE,eAAe,YAAY;AACpH,mBAAiB,kBAAkB,2BAA2B;AAI9D,QAAM,EAAE,UAAU,mBAAmB,UAAU,SAAS,IAAI;AAC5D,QAAM,gBAAgB;AAAA,IACpB,CAAC,MAAgG;AAC/F,UAAI,YAAY,qBAAqB,SAAU;AAC/C,UAAI,UAAU;AACZ,iBAAS,CAAC;AAAA,MACZ;AAAA,IACF;AAAA,IACA,CAAC,UAAU,mBAAmB,UAAU,QAAQ;AAAA,EAClD;AAIA,QAAM,cAAc,uBAA0D,kBAAkB;AAAA,IAC9F,SAAS;AAAA,EACX,CAAC;AACD,QAAM,eAAe,mBAAmB,gBAAgB;AACxD,QAAM,EAAE,GAAG,IAAI;AACf,QAAM,cAAcA,OAAM,QAAQ,MAAM,MAAM,kBAAkB,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;AAI9E,QAAM,cAAc,kBAAkB;AAAA,IACpC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAED,SAAOA,OAAM;AAAA,IACX,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,CAAC,kBAAkB,aAAa,aAAa,cAAc,aAAa,aAAa;AAAA,EACvF;AACF;",
|
|
6
6
|
"names": ["React"]
|
|
7
7
|
}
|