@salt-ds/core 1.16.1 → 1.17.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.
- package/css/salt-core.css +107 -6
- package/dist-cjs/index.js +4 -0
- package/dist-cjs/index.js.map +1 -1
- package/dist-cjs/multiline-input/MultilineInput.css.js +1 -1
- package/dist-cjs/multiline-input/MultilineInput.js +17 -2
- package/dist-cjs/multiline-input/MultilineInput.js.map +1 -1
- package/dist-cjs/progress/CircularProgress/CircularProgress.css.js +6 -0
- package/dist-cjs/progress/CircularProgress/CircularProgress.css.js.map +1 -0
- package/dist-cjs/progress/CircularProgress/CircularProgress.js +93 -0
- package/dist-cjs/progress/CircularProgress/CircularProgress.js.map +1 -0
- package/dist-cjs/progress/LinearProgress/LinearProgress.css.js +6 -0
- package/dist-cjs/progress/LinearProgress/LinearProgress.css.js.map +1 -0
- package/dist-cjs/progress/LinearProgress/LinearProgress.js +70 -0
- package/dist-cjs/progress/LinearProgress/LinearProgress.js.map +1 -0
- package/dist-cjs/utils/useFloatingUI/useFloatingUI.js.map +1 -1
- package/dist-es/index.js +2 -0
- package/dist-es/index.js.map +1 -1
- package/dist-es/multiline-input/MultilineInput.css.js +1 -1
- package/dist-es/multiline-input/MultilineInput.js +18 -3
- package/dist-es/multiline-input/MultilineInput.js.map +1 -1
- package/dist-es/progress/CircularProgress/CircularProgress.css.js +4 -0
- package/dist-es/progress/CircularProgress/CircularProgress.css.js.map +1 -0
- package/dist-es/progress/CircularProgress/CircularProgress.js +89 -0
- package/dist-es/progress/CircularProgress/CircularProgress.js.map +1 -0
- package/dist-es/progress/LinearProgress/LinearProgress.css.js +4 -0
- package/dist-es/progress/LinearProgress/LinearProgress.css.js.map +1 -0
- package/dist-es/progress/LinearProgress/LinearProgress.js +66 -0
- package/dist-es/progress/LinearProgress/LinearProgress.js.map +1 -0
- package/dist-es/utils/useFloatingUI/useFloatingUI.js.map +1 -1
- package/dist-types/index.d.ts +1 -0
- package/dist-types/progress/CircularProgress/CircularProgress.d.ts +23 -0
- package/dist-types/progress/LinearProgress/LinearProgress.d.ts +23 -0
- package/dist-types/progress/index.d.ts +2 -0
- package/dist-types/utils/useFloatingUI/useFloatingUI.d.ts +3 -3
- package/package.json +1 -1
package/css/salt-core.css
CHANGED
|
@@ -1181,18 +1181,17 @@ a:link .saltInteractableCard * {
|
|
|
1181
1181
|
.saltMultilineInput-textarea {
|
|
1182
1182
|
background: none;
|
|
1183
1183
|
border: none;
|
|
1184
|
-
box-sizing:
|
|
1184
|
+
box-sizing: border-box;
|
|
1185
1185
|
color: inherit;
|
|
1186
1186
|
cursor: inherit;
|
|
1187
|
-
display: inline-flex;
|
|
1188
|
-
height: calc(var(--saltMultilineInput-rows, 3) * var(--salt-text-lineHeight));
|
|
1189
1187
|
flex-grow: 1;
|
|
1190
1188
|
font: inherit;
|
|
1191
1189
|
letter-spacing: 0;
|
|
1190
|
+
line-height: var(--salt-text-lineHeight);
|
|
1192
1191
|
margin: var(--salt-spacing-75) 0;
|
|
1193
1192
|
min-width: 0;
|
|
1194
|
-
|
|
1195
|
-
resize:
|
|
1193
|
+
min-height: 0;
|
|
1194
|
+
resize: vertical;
|
|
1196
1195
|
padding: 0;
|
|
1197
1196
|
}
|
|
1198
1197
|
.saltMultilineInput-textarea::placeholder {
|
|
@@ -2264,4 +2263,106 @@ label.saltText small,
|
|
|
2264
2263
|
--tooltip-status-borderColor: var(--salt-status-success-borderColor);
|
|
2265
2264
|
}
|
|
2266
2265
|
|
|
2267
|
-
/* src/
|
|
2266
|
+
/* src/progress/CircularProgress/CircularProgress.css */
|
|
2267
|
+
.saltCircularProgress {
|
|
2268
|
+
color: var(--salt-content-primary-foreground);
|
|
2269
|
+
display: inline-flex;
|
|
2270
|
+
position: relative;
|
|
2271
|
+
}
|
|
2272
|
+
.saltCircularProgress-progressLabel {
|
|
2273
|
+
align-items: center;
|
|
2274
|
+
color: var(--salt-content-primary-foreground);
|
|
2275
|
+
display: flex;
|
|
2276
|
+
height: 100%;
|
|
2277
|
+
justify-content: center;
|
|
2278
|
+
left: 0;
|
|
2279
|
+
position: absolute;
|
|
2280
|
+
width: 100%;
|
|
2281
|
+
}
|
|
2282
|
+
.saltCircularProgress-track {
|
|
2283
|
+
inline-size: calc(var(--salt-size-base) * 3);
|
|
2284
|
+
block-size: calc(var(--salt-size-base) * 3);
|
|
2285
|
+
border-style: var(--salt-track-borderStyle);
|
|
2286
|
+
border-width: var(--salt-size-bar-small);
|
|
2287
|
+
border-radius: calc(var(--salt-size-base) * 3);
|
|
2288
|
+
border-color: var(--salt-track-borderColor);
|
|
2289
|
+
}
|
|
2290
|
+
.saltCircularProgress-bar {
|
|
2291
|
+
inline-size: calc(var(--salt-size-base) * 3);
|
|
2292
|
+
block-size: calc(var(--salt-size-base) * 3);
|
|
2293
|
+
border-style: var(--salt-track-borderStyle);
|
|
2294
|
+
border-width: var(--salt-size-bar-strong);
|
|
2295
|
+
border-radius: calc(var(--salt-size-base) * 3);
|
|
2296
|
+
border-color: var(--salt-accent-background);
|
|
2297
|
+
}
|
|
2298
|
+
.saltCircularProgress-bars {
|
|
2299
|
+
position: absolute;
|
|
2300
|
+
inset-block-start: 0;
|
|
2301
|
+
inset-inline-start: 0;
|
|
2302
|
+
inline-size: 100%;
|
|
2303
|
+
block-size: 100%;
|
|
2304
|
+
}
|
|
2305
|
+
.saltCircularProgress-barOverlayRight,
|
|
2306
|
+
.saltCircularProgress-barOverlayLeft {
|
|
2307
|
+
inline-size: 50%;
|
|
2308
|
+
block-size: 100%;
|
|
2309
|
+
transform-origin: 100% center;
|
|
2310
|
+
transform: rotate(180deg);
|
|
2311
|
+
overflow: hidden;
|
|
2312
|
+
position: absolute;
|
|
2313
|
+
}
|
|
2314
|
+
.saltCircularProgress-barSubOverlayRight,
|
|
2315
|
+
.saltCircularProgress-barSubOverlayLeft {
|
|
2316
|
+
inline-size: 100%;
|
|
2317
|
+
block-size: 100%;
|
|
2318
|
+
transform-origin: 100% center;
|
|
2319
|
+
overflow: hidden;
|
|
2320
|
+
transform: rotate(-180deg);
|
|
2321
|
+
}
|
|
2322
|
+
.saltCircularProgress-barOverlayLeft {
|
|
2323
|
+
transform: rotate(0deg);
|
|
2324
|
+
}
|
|
2325
|
+
|
|
2326
|
+
/* src/progress/LinearProgress/LinearProgress.css */
|
|
2327
|
+
.saltLinearProgress {
|
|
2328
|
+
align-items: center;
|
|
2329
|
+
color: var(--salt-content-primary-foreground);
|
|
2330
|
+
display: flex;
|
|
2331
|
+
min-width: 400px;
|
|
2332
|
+
font-size: var(--linearProgress-fontSize);
|
|
2333
|
+
}
|
|
2334
|
+
.saltLinearProgress-barContainer {
|
|
2335
|
+
background: none;
|
|
2336
|
+
position: relative;
|
|
2337
|
+
width: 100%;
|
|
2338
|
+
overflow: hidden;
|
|
2339
|
+
height: var(--salt-size-bar-strong);
|
|
2340
|
+
}
|
|
2341
|
+
.saltLinearProgress-bar {
|
|
2342
|
+
width: 100%;
|
|
2343
|
+
position: absolute;
|
|
2344
|
+
left: 0;
|
|
2345
|
+
bottom: 0;
|
|
2346
|
+
top: 0;
|
|
2347
|
+
transition: transform 0.2s linear;
|
|
2348
|
+
transform-origin: left;
|
|
2349
|
+
background: var(--salt-accent-background);
|
|
2350
|
+
z-index: 2;
|
|
2351
|
+
}
|
|
2352
|
+
.saltLinearProgress-track {
|
|
2353
|
+
background: var(--salt-track-borderColor);
|
|
2354
|
+
width: 100%;
|
|
2355
|
+
height: var(--salt-size-bar-small);
|
|
2356
|
+
position: absolute;
|
|
2357
|
+
top: calc((var(--salt-size-bar-strong) - var(--salt-size-bar-small)) / 2);
|
|
2358
|
+
transition: transform 0.2s linear;
|
|
2359
|
+
transform-origin: left;
|
|
2360
|
+
}
|
|
2361
|
+
.saltLinearProgress-progressLabel {
|
|
2362
|
+
color: inherit;
|
|
2363
|
+
margin: 0;
|
|
2364
|
+
white-space: nowrap;
|
|
2365
|
+
padding-left: var(--salt-spacing-100);
|
|
2366
|
+
}
|
|
2367
|
+
|
|
2368
|
+
/* src/45f838e6-98fc-400c-bb44-d3f8cf38837e.css */
|
package/dist-cjs/index.js
CHANGED
|
@@ -50,6 +50,8 @@ var CompactPaginator = require('./pagination/CompactPaginator.js');
|
|
|
50
50
|
var GoToInput = require('./pagination/GoToInput.js');
|
|
51
51
|
var Panel = require('./panel/Panel.js');
|
|
52
52
|
var Pill = require('./pill/Pill.js');
|
|
53
|
+
var CircularProgress = require('./progress/CircularProgress/CircularProgress.js');
|
|
54
|
+
var LinearProgress = require('./progress/LinearProgress/LinearProgress.js');
|
|
53
55
|
var RadioButton = require('./radio-button/RadioButton.js');
|
|
54
56
|
var RadioButtonGroup = require('./radio-button/RadioButtonGroup.js');
|
|
55
57
|
var RadioButtonIcon = require('./radio-button/RadioButtonIcon.js');
|
|
@@ -155,6 +157,8 @@ exports.CompactPaginator = CompactPaginator.CompactPaginator;
|
|
|
155
157
|
exports.GoToInput = GoToInput.GoToInput;
|
|
156
158
|
exports.Panel = Panel.Panel;
|
|
157
159
|
exports.Pill = Pill.Pill;
|
|
160
|
+
exports.CircularProgress = CircularProgress.CircularProgress;
|
|
161
|
+
exports.LinearProgress = LinearProgress.LinearProgress;
|
|
158
162
|
exports.RadioButton = RadioButton.RadioButton;
|
|
159
163
|
exports.RadioButtonGroup = RadioButtonGroup.RadioButtonGroup;
|
|
160
164
|
exports.RadioButtonIcon = RadioButtonIcon.RadioButtonIcon;
|
package/dist-cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var css_248z = "/* Style applied to the root element */\n.saltMultilineInput {\n --multilineInput-borderColor: var(--salt-editable-borderColor);\n --multilineInput-borderStyle: var(--salt-editable-borderStyle);\n --multilineInput-outlineColor: var(--salt-focused-outlineColor);\n --multilineInput-border: none;\n --multilineInput-activationIndicator-borderWidth: var(--salt-size-border);\n\n align-items: center;\n background: var(--multilineInput-background);\n border: var(--multilineInput-border);\n color: var(--salt-content-primary-foreground);\n display: inline-flex;\n font-family: var(--salt-text-fontFamily);\n font-size: var(--salt-text-fontSize);\n height: auto;\n line-height: var(--salt-text-lineHeight);\n min-height: var(--salt-size-base);\n min-width: 4em;\n padding-left: var(--salt-spacing-100);\n padding-right: var(--salt-spacing-100);\n position: relative;\n width: 100%;\n}\n\n/* Style applied on hover */\n.saltMultilineInput:hover {\n --multilineInput-borderStyle: var(--salt-editable-borderStyle-hover);\n --multilineInput-borderColor: var(--salt-editable-borderColor-hover);\n\n background: var(--multilineInput-background-hover);\n cursor: var(--salt-editable-cursor-hover);\n}\n\n/* Style applied when active */\n.saltMultilineInput:active {\n --multilineInput-borderColor: var(--salt-editable-borderColor-active);\n --multilineInput-borderStyle: var(--salt-editable-borderStyle-active);\n --multilineInput-activationIndicator-borderWidth: var(--salt-editable-borderWidth-active);\n\n background: var(--multilineInput-background-active);\n cursor: var(--salt-editable-cursor-active);\n}\n\n/* Class applied if `variant=\"primary\"` */\n.saltMultilineInput-primary {\n --multilineInput-background: var(--salt-editable-primary-background);\n --multilineInput-background-active: var(--salt-editable-primary-background-active);\n --multilineInput-background-hover: var(--salt-editable-primary-background-hover);\n --multilineInput-background-disabled: var(--salt-editable-primary-background-disabled);\n --multilineInput-background-readonly: var(--salt-editable-primary-background-readonly);\n}\n\n/* Class applied if `variant=\"secondary\"` */\n.saltMultilineInput-secondary {\n --multilineInput-background: var(--salt-editable-secondary-background);\n --multilineInput-background-active: var(--salt-editable-secondary-background-active);\n --multilineInput-background-hover: var(--salt-editable-secondary-background-active);\n --multilineInput-background-disabled: var(--salt-editable-secondary-background-disabled);\n --multilineInput-background-readonly: var(--salt-editable-secondary-background-readonly);\n}\n\n/* Style applied to input if `validationState=\"error\"` */\n.saltMultilineInput-error,\n.saltMultilineInput-error:hover {\n --multilineInput-background: var(--salt-status-error-background);\n --multilineInput-background-active: var(--salt-status-error-background);\n --multilineInput-background-hover: var(--salt-status-error-background);\n --multilineInput-borderColor: var(--salt-status-error-borderColor);\n --multilineInput-outlineColor: var(--salt-status-error-borderColor);\n}\n\n/* Style applied to input if `validationState=\"warning\"` */\n.saltMultilineInput-warning,\n.saltMultilineInput-warning:hover {\n --multilineInput-background: var(--salt-status-warning-background);\n --multilineInput-background-active: var(--salt-status-warning-background);\n --multilineInput-background-hover: var(--salt-status-warning-background);\n --multilineInput-borderColor: var(--salt-status-warning-borderColor);\n --multilineInput-outlineColor: var(--salt-status-warning-borderColor);\n}\n\n/* Style applied to input if `validationState=\"success\"` */\n.saltMultilineInput-success,\n.saltMultilineInput-success:hover {\n --multilineInput-background: var(--salt-status-success-background);\n --multilineInput-background-active: var(--salt-status-success-background);\n --multilineInput-background-hover: var(--salt-status-success-background);\n --multilineInput-borderColor: var(--salt-status-success-borderColor);\n --multilineInput-outlineColor: var(--salt-status-success-borderColor);\n}\n\n.saltMultilineInput.saltMultilineInput-withAdornmentRow {\n display: flex;\n flex-wrap: wrap;\n}\n\n/* Style applied to inner textarea element */\n.saltMultilineInput-textarea {\n background: none;\n border: none;\n box-sizing:
|
|
3
|
+
var css_248z = "/* Style applied to the root element */\n.saltMultilineInput {\n --multilineInput-borderColor: var(--salt-editable-borderColor);\n --multilineInput-borderStyle: var(--salt-editable-borderStyle);\n --multilineInput-outlineColor: var(--salt-focused-outlineColor);\n --multilineInput-border: none;\n --multilineInput-activationIndicator-borderWidth: var(--salt-size-border);\n\n align-items: center;\n background: var(--multilineInput-background);\n border: var(--multilineInput-border);\n color: var(--salt-content-primary-foreground);\n display: inline-flex;\n font-family: var(--salt-text-fontFamily);\n font-size: var(--salt-text-fontSize);\n height: auto;\n line-height: var(--salt-text-lineHeight);\n min-height: var(--salt-size-base);\n min-width: 4em;\n padding-left: var(--salt-spacing-100);\n padding-right: var(--salt-spacing-100);\n position: relative;\n width: 100%;\n}\n\n/* Style applied on hover */\n.saltMultilineInput:hover {\n --multilineInput-borderStyle: var(--salt-editable-borderStyle-hover);\n --multilineInput-borderColor: var(--salt-editable-borderColor-hover);\n\n background: var(--multilineInput-background-hover);\n cursor: var(--salt-editable-cursor-hover);\n}\n\n/* Style applied when active */\n.saltMultilineInput:active {\n --multilineInput-borderColor: var(--salt-editable-borderColor-active);\n --multilineInput-borderStyle: var(--salt-editable-borderStyle-active);\n --multilineInput-activationIndicator-borderWidth: var(--salt-editable-borderWidth-active);\n\n background: var(--multilineInput-background-active);\n cursor: var(--salt-editable-cursor-active);\n}\n\n/* Class applied if `variant=\"primary\"` */\n.saltMultilineInput-primary {\n --multilineInput-background: var(--salt-editable-primary-background);\n --multilineInput-background-active: var(--salt-editable-primary-background-active);\n --multilineInput-background-hover: var(--salt-editable-primary-background-hover);\n --multilineInput-background-disabled: var(--salt-editable-primary-background-disabled);\n --multilineInput-background-readonly: var(--salt-editable-primary-background-readonly);\n}\n\n/* Class applied if `variant=\"secondary\"` */\n.saltMultilineInput-secondary {\n --multilineInput-background: var(--salt-editable-secondary-background);\n --multilineInput-background-active: var(--salt-editable-secondary-background-active);\n --multilineInput-background-hover: var(--salt-editable-secondary-background-active);\n --multilineInput-background-disabled: var(--salt-editable-secondary-background-disabled);\n --multilineInput-background-readonly: var(--salt-editable-secondary-background-readonly);\n}\n\n/* Style applied to input if `validationState=\"error\"` */\n.saltMultilineInput-error,\n.saltMultilineInput-error:hover {\n --multilineInput-background: var(--salt-status-error-background);\n --multilineInput-background-active: var(--salt-status-error-background);\n --multilineInput-background-hover: var(--salt-status-error-background);\n --multilineInput-borderColor: var(--salt-status-error-borderColor);\n --multilineInput-outlineColor: var(--salt-status-error-borderColor);\n}\n\n/* Style applied to input if `validationState=\"warning\"` */\n.saltMultilineInput-warning,\n.saltMultilineInput-warning:hover {\n --multilineInput-background: var(--salt-status-warning-background);\n --multilineInput-background-active: var(--salt-status-warning-background);\n --multilineInput-background-hover: var(--salt-status-warning-background);\n --multilineInput-borderColor: var(--salt-status-warning-borderColor);\n --multilineInput-outlineColor: var(--salt-status-warning-borderColor);\n}\n\n/* Style applied to input if `validationState=\"success\"` */\n.saltMultilineInput-success,\n.saltMultilineInput-success:hover {\n --multilineInput-background: var(--salt-status-success-background);\n --multilineInput-background-active: var(--salt-status-success-background);\n --multilineInput-background-hover: var(--salt-status-success-background);\n --multilineInput-borderColor: var(--salt-status-success-borderColor);\n --multilineInput-outlineColor: var(--salt-status-success-borderColor);\n}\n\n.saltMultilineInput.saltMultilineInput-withAdornmentRow {\n display: flex;\n flex-wrap: wrap;\n}\n\n/* Style applied to inner textarea element */\n.saltMultilineInput-textarea {\n background: none;\n border: none;\n box-sizing: border-box;\n color: inherit;\n cursor: inherit;\n flex-grow: 1;\n font: inherit;\n letter-spacing: 0;\n line-height: var(--salt-text-lineHeight);\n margin: var(--salt-spacing-75) 0;\n min-width: 0;\n min-height: 0;\n resize: vertical;\n padding: 0;\n}\n\n/* Style applied to placeholder */\n.saltMultilineInput-textarea::placeholder {\n font-weight: var(--salt-text-fontWeight-small);\n}\n\n/* Reset in the class */\n.saltMultilineInput-textarea:focus {\n outline: none;\n}\n\n/* Style applied to selected input */\n.saltMultilineInput-textarea::selection {\n background: var(--salt-content-foreground-highlight);\n}\n\n/* Styling when focused */\n.saltMultilineInput-focused {\n --multilineInput-borderColor: var(--multilineInput-outlineColor);\n --multilineInput-activationIndicator-borderWidth: var(--salt-editable-borderWidth-active);\n\n outline: var(--salt-focused-outlineWidth) var(--salt-focused-outlineStyle) var(--multilineInput-outlineColor);\n}\n\n/* Style applied if `readOnly={true}` */\n.saltMultilineInput-readOnly,\n.saltMultilineInput-readOnly:active,\n.saltMultilineInput-readOnly:hover {\n --multilineInput-borderColor: var(--salt-editable-borderColor-readonly);\n --multilineInput-borderStyle: var(--salt-editable-borderStyle-readonly);\n --multilineInput-activationIndicator-borderWidth: var(--salt-size-border);\n\n background: var(--multilineInput-background-readonly);\n cursor: var(--salt-editable-cursor-readonly);\n}\n\n/* Style applied to selected text if `disabled={true}` */\n.saltMultilineInput-disabled .saltMultilineInput-textarea::selection {\n background: none;\n}\n\n/* Style applied when `disabled={true}` */\n.saltMultilineInput-disabled,\n.saltMultilineInput-disabled:hover,\n.saltMultilineInput-disabled:active {\n --multilineInput-borderColor: var(--salt-editable-borderColor-disabled);\n --multilineInput-borderStyle: var(--salt-editable-borderStyle-disabled);\n --multilineInput-activationIndicator-borderWidth: var(--salt-size-border);\n\n background: var(--multilineInput-background-disabled);\n cursor: var(--salt-editable-cursor-disabled);\n color: var(--salt-content-primary-foreground-disabled);\n}\n\n/* Style for activation indicator */\n.saltMultilineInput-activationIndicator {\n left: 0;\n bottom: 0;\n width: 100%;\n position: absolute;\n border-bottom: var(--multilineInput-activationIndicator-borderWidth) var(--multilineInput-borderStyle) var(--multilineInput-borderColor);\n}\n\n/* Style applied if `bordered={true}` */\n.saltMultilineInput.saltMultilineInput-bordered {\n --multilineInput-border: var(--salt-size-border) var(--salt-container-borderStyle) var(--multilineInput-borderColor);\n --multilineInput-activationIndicator-borderWidth: 0;\n}\n\n/* Style applied if active or focused when `bordered={true}` */\n.saltMultilineInput-bordered:active,\n.saltMultilineInput-bordered.saltMultilineInput-focused {\n --multilineInput-activationIndicator-borderWidth: var(--salt-editable-borderWidth-active);\n}\n\n/* Styling when focused if `disabled={true}` or `readOnly={true}` when `bordered={true}` */\n.saltMultilineInput-bordered.saltMultilineInput-readOnly:hover,\n.saltMultilineInput-bordered.saltMultilineInput-disabled:hover {\n --multilineInput-activationIndicator-borderWidth: 0;\n}\n\n/* Style applied to adornment containers */\n.saltMultilineInput-endAdornmentContainer,\n.saltMultilineInput-startAdornmentContainer {\n align-items: center;\n display: inline-flex;\n min-height: var(--salt-size-base);\n column-gap: var(--salt-spacing-100);\n}\n\n/* Style applied to start adornment container */\n.saltMultilineInput-startAdornmentContainer {\n align-self: self-start;\n padding-right: var(--salt-spacing-100);\n}\n\n/* Style applied to suffix adornment container */\n.saltMultilineInput-suffixAdornments {\n align-self: self-end;\n}\n\n/* Style applied to suffix adornment container when end adornments are provided */\n.saltMultilineInput-withAdornmentRow .saltMultilineInput-suffixAdornments {\n display: inline-flex;\n flex-basis: 100%;\n justify-content: flex-end;\n}\n\n/* Style applied to end adornment container */\n.saltMultilineInput-endAdornmentContainer {\n padding-left: var(--salt-spacing-100);\n}\n\n/* Style applied to status adornment container */\n.saltMultilineInput-statusAdornmentContainer {\n align-self: self-end;\n display: inline-flex;\n min-height: var(--salt-size-base);\n}\n\n/* Style applied to button start adornment if first child */\n.saltMultilineInput-startAdornmentContainer .saltButton:first-child {\n margin-left: calc(var(--salt-spacing-50) * -1);\n}\n\n/* Style applied to button end adornment if last child */\n.saltMultilineInput-endAdornmentContainer .saltButton:last-child {\n margin-right: calc(var(--salt-spacing-50) * -1);\n}\n\n/* Style applied to button end adornment if last child */\n.saltMultilineInput-readOnly .saltMultilineInput-endAdornmentContainer .saltButton:last-child {\n margin-right: 0;\n}\n\n/* Styles for button adornment */\n.saltMultilineInput-startAdornmentContainer > .saltButton,\n.saltMultilineInput-endAdornmentContainer > .saltButton {\n --saltButton-padding: var(--salt-spacing-50);\n --saltButton-height: calc(var(--salt-size-base) - var(--salt-spacing-100));\n}\n";
|
|
4
4
|
|
|
5
5
|
module.exports = css_248z;
|
|
6
6
|
//# sourceMappingURL=MultilineInput.css.js.map
|
|
@@ -13,6 +13,7 @@ var StatusAdornment = require('../status-adornment/StatusAdornment.js');
|
|
|
13
13
|
var makePrefixer = require('../utils/makePrefixer.js');
|
|
14
14
|
var useControlled = require('../utils/useControlled.js');
|
|
15
15
|
require('../utils/useFloatingUI/useFloatingUI.js');
|
|
16
|
+
var useForkRef = require('../utils/useForkRef.js');
|
|
16
17
|
require('../utils/useId.js');
|
|
17
18
|
require('../salt-provider/SaltProvider.js');
|
|
18
19
|
require('../viewport/ViewportProvider.js');
|
|
@@ -43,6 +44,8 @@ const MultilineInput = React.forwardRef(
|
|
|
43
44
|
variant = "primary",
|
|
44
45
|
...other
|
|
45
46
|
}, ref) {
|
|
47
|
+
const inputRef = React.useRef(null);
|
|
48
|
+
const handleRef = useForkRef.useForkRef(inputRef, textAreaRef);
|
|
46
49
|
const targetWindow = window.useWindow();
|
|
47
50
|
styles.useComponentCssInjection({
|
|
48
51
|
testId: "salt-multiline-input",
|
|
@@ -84,10 +87,22 @@ const MultilineInput = React.forwardRef(
|
|
|
84
87
|
name: "MultilineInput",
|
|
85
88
|
state: "value"
|
|
86
89
|
});
|
|
90
|
+
const previousHeight = React.useRef(void 0);
|
|
87
91
|
const handleChange = (event) => {
|
|
88
92
|
const value2 = event.target.value;
|
|
89
93
|
setValue(value2);
|
|
90
94
|
onChange == null ? void 0 : onChange(event);
|
|
95
|
+
const input = event.target;
|
|
96
|
+
const hasBeenManuallyResized = previousHeight.current !== void 0 && input.style.height !== previousHeight.current;
|
|
97
|
+
if (!hasBeenManuallyResized) {
|
|
98
|
+
const previousOverflow = input.style.overflow;
|
|
99
|
+
input.style.overflow = "hidden";
|
|
100
|
+
input.style.height = "auto";
|
|
101
|
+
const newHeight = `${input.scrollHeight + (input.offsetHeight - input.clientHeight)}px`;
|
|
102
|
+
input.style.height = newHeight;
|
|
103
|
+
previousHeight.current = newHeight;
|
|
104
|
+
input.style.overflow = previousOverflow;
|
|
105
|
+
}
|
|
91
106
|
};
|
|
92
107
|
const handleBlur = (event) => {
|
|
93
108
|
onBlur == null ? void 0 : onBlur(event);
|
|
@@ -111,7 +126,7 @@ const MultilineInput = React.forwardRef(
|
|
|
111
126
|
[withBaseName("focused")]: !isDisabled && focused,
|
|
112
127
|
[withBaseName("disabled")]: isDisabled,
|
|
113
128
|
[withBaseName("readOnly")]: isReadOnly,
|
|
114
|
-
[withBaseName(validationStatus
|
|
129
|
+
[withBaseName(validationStatus != null ? validationStatus : "")]: validationStatus
|
|
115
130
|
},
|
|
116
131
|
classNameProp
|
|
117
132
|
),
|
|
@@ -130,7 +145,7 @@ const MultilineInput = React.forwardRef(
|
|
|
130
145
|
disabled: isDisabled,
|
|
131
146
|
id,
|
|
132
147
|
readOnly: isReadOnly,
|
|
133
|
-
ref:
|
|
148
|
+
ref: handleRef,
|
|
134
149
|
required: isRequired,
|
|
135
150
|
role,
|
|
136
151
|
rows,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultilineInput.js","sources":["../src/multiline-input/MultilineInput.tsx"],"sourcesContent":["import { clsx } from \"clsx\";\nimport {\n ChangeEvent,\n ComponentPropsWithoutRef,\n FocusEvent,\n forwardRef,\n ReactNode,\n Ref,\n TextareaHTMLAttributes,\n useState,\n} from \"react\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { useFormFieldProps } from \"../form-field-context\";\nimport { StatusAdornment } from \"../status-adornment\";\nimport { makePrefixer, useControlled } from \"../utils\";\n\nimport multilineInputCss from \"./MultilineInput.css\";\n\nconst withBaseName = makePrefixer(\"saltMultilineInput\");\n\nexport interface MultilineInputProps\n extends Omit<ComponentPropsWithoutRef<\"div\">, \"defaultValue\">,\n Pick<\n ComponentPropsWithoutRef<\"textarea\">,\n \"disabled\" | \"value\" | \"defaultValue\" | \"placeholder\"\n > {\n /**\n * Styling variant with full border. Defaults to false\n */\n bordered?: boolean;\n /**\n * End adornment component\n */\n endAdornment?: ReactNode;\n /**\n * If `true`, the component is read only.\n */\n readOnly?: boolean;\n /**\n * Number of rows. Defaults to 3\n */\n rows?: number;\n /**\n * Start adornment component\n */\n startAdornment?: ReactNode;\n /**\n * [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#Attributes) applied to the `textarea` element.\n */\n textAreaProps?: TextareaHTMLAttributes<HTMLTextAreaElement>;\n /**\n * Optional ref for the textarea component\n */\n textAreaRef?: Ref<HTMLTextAreaElement>;\n /**\n * Validation status.\n */\n validationStatus?: \"error\" | \"warning\" | \"success\";\n /**\n * Styling variant. Defaults to \"primary\".\n */\n variant?: \"primary\" | \"secondary\";\n}\n\nexport const MultilineInput = forwardRef<HTMLDivElement, MultilineInputProps>(\n function MultilineInput(\n {\n \"aria-activedescendant\": ariaActiveDescendant,\n \"aria-expanded\": ariaExpanded,\n \"aria-owns\": ariaOwns,\n bordered = false,\n className: classNameProp,\n disabled,\n endAdornment,\n id,\n placeholder,\n readOnly,\n role,\n rows = 3,\n startAdornment,\n style,\n textAreaProps = {},\n textAreaRef,\n value: valueProp,\n defaultValue: defaultValueProp = valueProp === undefined ? \"\" : undefined,\n validationStatus: validationStatusProp,\n variant = \"primary\",\n ...other\n },\n ref\n ) {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-multiline-input\",\n css: multilineInputCss,\n window: targetWindow,\n });\n\n const restA11yProps = {\n \"aria-activedescendant\": ariaActiveDescendant,\n \"aria-expanded\": ariaExpanded,\n \"aria-owns\": ariaOwns,\n };\n\n const [focused, setFocused] = useState(false);\n\n const {\n \"aria-describedby\": textAreaDescribedBy,\n \"aria-labelledby\": textAreaLabelledBy,\n onBlur,\n onChange,\n onFocus,\n required: textAreaRequired,\n ...restTextAreaProps\n } = textAreaProps;\n\n const {\n a11yProps: {\n \"aria-describedby\": formFieldDescribedBy,\n \"aria-labelledby\": formFieldLabelledBy,\n } = {},\n disabled: formFieldDisabled,\n readOnly: formFieldReadOnly,\n necessity: formFieldRequired,\n validationStatus: formFieldValidationStatus,\n } = useFormFieldProps();\n\n const isDisabled = disabled || formFieldDisabled;\n const isReadOnly = readOnly || formFieldReadOnly;\n const validationStatus = formFieldValidationStatus ?? validationStatusProp;\n const isRequired = formFieldRequired\n ? [\"required\", \"asterisk\"].includes(formFieldRequired)\n : textAreaRequired;\n\n const [value, setValue] = useControlled({\n controlled: valueProp,\n default: defaultValueProp,\n name: \"MultilineInput\",\n state: \"value\",\n });\n\n const handleChange = (event: ChangeEvent<HTMLTextAreaElement>) => {\n const value = event.target.value;\n setValue(value);\n onChange?.(event);\n };\n\n const handleBlur = (event: FocusEvent<HTMLTextAreaElement>) => {\n onBlur?.(event);\n setFocused(false);\n };\n\n const handleFocus = (event: FocusEvent<HTMLTextAreaElement>) => {\n onFocus?.(event);\n setFocused(true);\n };\n\n const multilineInputStyles = {\n \"--saltMultilineInput-rows\": rows,\n ...style,\n };\n\n return (\n <div\n className={clsx(\n withBaseName(),\n withBaseName(variant),\n {\n [withBaseName(\"withAdornmentRow\")]: endAdornment,\n [withBaseName(\"bordered\")]: bordered,\n [withBaseName(\"focused\")]: !isDisabled && focused,\n [withBaseName(\"disabled\")]: isDisabled,\n [withBaseName(\"readOnly\")]: isReadOnly,\n [withBaseName(validationStatus || \"\")]: validationStatus,\n },\n classNameProp\n )}\n ref={ref}\n style={multilineInputStyles}\n {...other}\n >\n {startAdornment && (\n <div className={withBaseName(\"startAdornmentContainer\")}>\n {startAdornment}\n </div>\n )}\n <textarea\n aria-describedby={clsx(formFieldDescribedBy, textAreaDescribedBy)}\n aria-labelledby={clsx(formFieldLabelledBy, textAreaLabelledBy)}\n className={clsx(withBaseName(\"textarea\"), textAreaProps?.className)}\n disabled={isDisabled}\n id={id}\n readOnly={isReadOnly}\n ref={textAreaRef}\n required={isRequired}\n role={role}\n rows={rows}\n tabIndex={isDisabled ? -1 : 0}\n onBlur={handleBlur}\n onChange={handleChange}\n onFocus={!isDisabled ? handleFocus : undefined}\n placeholder={placeholder}\n value={value}\n {...restA11yProps}\n {...restTextAreaProps}\n />\n <div className={withBaseName(\"suffixAdornments\")}>\n {!isDisabled && !isReadOnly && validationStatus && (\n <div className={withBaseName(\"statusAdornmentContainer\")}>\n <StatusAdornment status={validationStatus} />\n </div>\n )}\n {endAdornment && (\n <div className={withBaseName(\"endAdornmentContainer\")}>\n {endAdornment}\n </div>\n )}\n </div>\n <div className={withBaseName(\"activationIndicator\")} />\n </div>\n );\n }\n);\n"],"names":["makePrefixer","forwardRef","MultilineInput","useWindow","useComponentCssInjection","multilineInputCss","useState","useFormFieldProps","useControlled","value","jsxs","clsx","jsx","StatusAdornment"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmBA,MAAM,YAAA,GAAeA,0BAAa,oBAAoB,CAAA,CAAA;AA8C/C,MAAM,cAAiB,GAAAC,gBAAA;AAAA,EAC5B,SAASC,eACP,CAAA;AAAA,IACE,uBAAyB,EAAA,oBAAA;AAAA,IACzB,eAAiB,EAAA,YAAA;AAAA,IACjB,WAAa,EAAA,QAAA;AAAA,IACb,QAAW,GAAA,KAAA;AAAA,IACX,SAAW,EAAA,aAAA;AAAA,IACX,QAAA;AAAA,IACA,YAAA;AAAA,IACA,EAAA;AAAA,IACA,WAAA;AAAA,IACA,QAAA;AAAA,IACA,IAAA;AAAA,IACA,IAAO,GAAA,CAAA;AAAA,IACP,cAAA;AAAA,IACA,KAAA;AAAA,IACA,gBAAgB,EAAC;AAAA,IACjB,WAAA;AAAA,IACA,KAAO,EAAA,SAAA;AAAA,IACP,YAAc,EAAA,gBAAA,GAAmB,SAAc,KAAA,KAAA,CAAA,GAAY,EAAK,GAAA,KAAA,CAAA;AAAA,IAChE,gBAAkB,EAAA,oBAAA;AAAA,IAClB,OAAU,GAAA,SAAA;AAAA,IACP,GAAA,KAAA;AAAA,KAEL,GACA,EAAA;AACA,IAAA,MAAM,eAAeC,gBAAU,EAAA,CAAA;AAC/B,IAAyBC,+BAAA,CAAA;AAAA,MACvB,MAAQ,EAAA,sBAAA;AAAA,MACR,GAAK,EAAAC,gBAAA;AAAA,MACL,MAAQ,EAAA,YAAA;AAAA,KACT,CAAA,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,aAAa,0BAA0B,CAAA;AAAA,cACrD,QAAC,kBAAAA,cAAA,CAAAC,+BAAA,EAAA;AAAA,gBAAgB,MAAQ,EAAA,gBAAA;AAAA,eAAkB,CAAA;AAAA,aAC7C,CAAA;AAAA,YAED,gCACED,cAAA,CAAA,KAAA,EAAA;AAAA,cAAI,SAAA,EAAW,aAAa,uBAAuB,CAAA;AAAA,cACjD,QAAA,EAAA,YAAA;AAAA,aACH,CAAA;AAAA,WAAA;AAAA,SAEJ,CAAA;AAAA,wBACCA,cAAA,CAAA,KAAA,EAAA;AAAA,UAAI,SAAA,EAAW,aAAa,qBAAqB,CAAA;AAAA,SAAG,CAAA;AAAA,OAAA;AAAA,KACvD,CAAA,CAAA;AAAA,GAEJ;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"MultilineInput.js","sources":["../src/multiline-input/MultilineInput.tsx"],"sourcesContent":["import { clsx } from \"clsx\";\nimport {\n ChangeEvent,\n ComponentPropsWithoutRef,\n FocusEvent,\n forwardRef,\n ReactNode,\n Ref,\n TextareaHTMLAttributes,\n useRef,\n useState,\n} from \"react\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { useFormFieldProps } from \"../form-field-context\";\nimport { StatusAdornment } from \"../status-adornment\";\nimport { makePrefixer, useControlled, useForkRef } from \"../utils\";\n\nimport multilineInputCss from \"./MultilineInput.css\";\n\nconst withBaseName = makePrefixer(\"saltMultilineInput\");\n\nexport interface MultilineInputProps\n extends Omit<ComponentPropsWithoutRef<\"div\">, \"defaultValue\">,\n Pick<\n ComponentPropsWithoutRef<\"textarea\">,\n \"disabled\" | \"value\" | \"defaultValue\" | \"placeholder\"\n > {\n /**\n * Styling variant with full border. Defaults to false\n */\n bordered?: boolean;\n /**\n * End adornment component\n */\n endAdornment?: ReactNode;\n /**\n * If `true`, the component is read only.\n */\n readOnly?: boolean;\n /**\n * Number of rows. Defaults to 3\n */\n rows?: number;\n /**\n * Start adornment component\n */\n startAdornment?: ReactNode;\n /**\n * [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#Attributes) applied to the `textarea` element.\n */\n textAreaProps?: TextareaHTMLAttributes<HTMLTextAreaElement>;\n /**\n * Optional ref for the textarea component\n */\n textAreaRef?: Ref<HTMLTextAreaElement>;\n /**\n * Validation status.\n */\n validationStatus?: \"error\" | \"warning\" | \"success\";\n /**\n * Styling variant. Defaults to \"primary\".\n */\n variant?: \"primary\" | \"secondary\";\n}\n\nexport const MultilineInput = forwardRef<HTMLDivElement, MultilineInputProps>(\n function MultilineInput(\n {\n \"aria-activedescendant\": ariaActiveDescendant,\n \"aria-expanded\": ariaExpanded,\n \"aria-owns\": ariaOwns,\n bordered = false,\n className: classNameProp,\n disabled,\n endAdornment,\n id,\n placeholder,\n readOnly,\n role,\n rows = 3,\n startAdornment,\n style,\n textAreaProps = {},\n textAreaRef,\n value: valueProp,\n defaultValue: defaultValueProp = valueProp === undefined ? \"\" : undefined,\n validationStatus: validationStatusProp,\n variant = \"primary\",\n ...other\n },\n ref\n ) {\n const inputRef = useRef<HTMLTextAreaElement>(null);\n const handleRef = useForkRef(inputRef, textAreaRef);\n\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-multiline-input\",\n css: multilineInputCss,\n window: targetWindow,\n });\n\n const restA11yProps = {\n \"aria-activedescendant\": ariaActiveDescendant,\n \"aria-expanded\": ariaExpanded,\n \"aria-owns\": ariaOwns,\n };\n\n const [focused, setFocused] = useState(false);\n\n const {\n \"aria-describedby\": textAreaDescribedBy,\n \"aria-labelledby\": textAreaLabelledBy,\n onBlur,\n onChange,\n onFocus,\n required: textAreaRequired,\n ...restTextAreaProps\n } = textAreaProps;\n\n const {\n a11yProps: {\n \"aria-describedby\": formFieldDescribedBy,\n \"aria-labelledby\": formFieldLabelledBy,\n } = {},\n disabled: formFieldDisabled,\n readOnly: formFieldReadOnly,\n necessity: formFieldRequired,\n validationStatus: formFieldValidationStatus,\n } = useFormFieldProps();\n\n const isDisabled = disabled || formFieldDisabled;\n const isReadOnly = readOnly || formFieldReadOnly;\n const validationStatus = formFieldValidationStatus ?? validationStatusProp;\n const isRequired = formFieldRequired\n ? [\"required\", \"asterisk\"].includes(formFieldRequired)\n : textAreaRequired;\n\n const [value, setValue] = useControlled({\n controlled: valueProp,\n default: defaultValueProp,\n name: \"MultilineInput\",\n state: \"value\",\n });\n\n const previousHeight = useRef<string | undefined>(undefined);\n\n const handleChange = (event: ChangeEvent<HTMLTextAreaElement>) => {\n const value = event.target.value;\n setValue(value);\n onChange?.(event);\n const input = event.target;\n\n const hasBeenManuallyResized =\n previousHeight.current !== undefined &&\n input.style.height !== previousHeight.current;\n\n if (!hasBeenManuallyResized) {\n const previousOverflow = input.style.overflow;\n input.style.overflow = \"hidden\";\n input.style.height = \"auto\";\n input.scrollHeight; // Needed to work around Firefox bug. https://bugzilla.mozilla.org/show_bug.cgi?id=1787062\n const newHeight = `${\n input.scrollHeight + (input.offsetHeight - input.clientHeight)\n }px`;\n input.style.height = newHeight;\n previousHeight.current = newHeight;\n input.style.overflow = previousOverflow;\n }\n };\n\n const handleBlur = (event: FocusEvent<HTMLTextAreaElement>) => {\n onBlur?.(event);\n setFocused(false);\n };\n\n const handleFocus = (event: FocusEvent<HTMLTextAreaElement>) => {\n onFocus?.(event);\n setFocused(true);\n };\n\n const multilineInputStyles = {\n \"--saltMultilineInput-rows\": rows,\n ...style,\n };\n\n return (\n <div\n className={clsx(\n withBaseName(),\n withBaseName(variant),\n {\n [withBaseName(\"withAdornmentRow\")]: endAdornment,\n [withBaseName(\"bordered\")]: bordered,\n [withBaseName(\"focused\")]: !isDisabled && focused,\n [withBaseName(\"disabled\")]: isDisabled,\n [withBaseName(\"readOnly\")]: isReadOnly,\n [withBaseName(validationStatus ?? \"\")]: validationStatus,\n },\n classNameProp\n )}\n ref={ref}\n style={multilineInputStyles}\n {...other}\n >\n {startAdornment && (\n <div className={withBaseName(\"startAdornmentContainer\")}>\n {startAdornment}\n </div>\n )}\n <textarea\n aria-describedby={clsx(formFieldDescribedBy, textAreaDescribedBy)}\n aria-labelledby={clsx(formFieldLabelledBy, textAreaLabelledBy)}\n className={clsx(withBaseName(\"textarea\"), textAreaProps?.className)}\n disabled={isDisabled}\n id={id}\n readOnly={isReadOnly}\n ref={handleRef}\n required={isRequired}\n role={role}\n rows={rows}\n tabIndex={isDisabled ? -1 : 0}\n onBlur={handleBlur}\n onChange={handleChange}\n onFocus={!isDisabled ? handleFocus : undefined}\n placeholder={placeholder}\n value={value}\n {...restA11yProps}\n {...restTextAreaProps}\n />\n <div className={withBaseName(\"suffixAdornments\")}>\n {!isDisabled && !isReadOnly && validationStatus && (\n <div className={withBaseName(\"statusAdornmentContainer\")}>\n <StatusAdornment status={validationStatus} />\n </div>\n )}\n {endAdornment && (\n <div className={withBaseName(\"endAdornmentContainer\")}>\n {endAdornment}\n </div>\n )}\n </div>\n <div className={withBaseName(\"activationIndicator\")} />\n </div>\n );\n }\n);\n"],"names":["makePrefixer","forwardRef","MultilineInput","useRef","useForkRef","useWindow","useComponentCssInjection","multilineInputCss","useState","useFormFieldProps","useControlled","value","jsxs","clsx","jsx","StatusAdornment"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAoBA,MAAM,YAAA,GAAeA,0BAAa,oBAAoB,CAAA,CAAA;AA8C/C,MAAM,cAAiB,GAAAC,gBAAA;AAAA,EAC5B,SAASC,eACP,CAAA;AAAA,IACE,uBAAyB,EAAA,oBAAA;AAAA,IACzB,eAAiB,EAAA,YAAA;AAAA,IACjB,WAAa,EAAA,QAAA;AAAA,IACb,QAAW,GAAA,KAAA;AAAA,IACX,SAAW,EAAA,aAAA;AAAA,IACX,QAAA;AAAA,IACA,YAAA;AAAA,IACA,EAAA;AAAA,IACA,WAAA;AAAA,IACA,QAAA;AAAA,IACA,IAAA;AAAA,IACA,IAAO,GAAA,CAAA;AAAA,IACP,cAAA;AAAA,IACA,KAAA;AAAA,IACA,gBAAgB,EAAC;AAA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AAA,CAAC,UAAc,IAAA,gBAAA,oBAC5BE,cAAA,CAAA,KAAA,EAAA;AAAA,cAAI,SAAA,EAAW,aAAa,0BAA0B,CAAA;AAAA,cACrD,QAAC,kBAAAA,cAAA,CAAAC,+BAAA,EAAA;AAAA,gBAAgB,MAAQ,EAAA,gBAAA;AAAA,eAAkB,CAAA;AAAA,aAC7C,CAAA;AAAA,YAED,gCACED,cAAA,CAAA,KAAA,EAAA;AAAA,cAAI,SAAA,EAAW,aAAa,uBAAuB,CAAA;AAAA,cACjD,QAAA,EAAA,YAAA;AAAA,aACH,CAAA;AAAA,WAAA;AAAA,SAEJ,CAAA;AAAA,wBACCA,cAAA,CAAA,KAAA,EAAA;AAAA,UAAI,SAAA,EAAW,aAAa,qBAAqB,CAAA;AAAA,SAAG,CAAA;AAAA,OAAA;AAAA,KACvD,CAAA,CAAA;AAAA,GAEJ;AACF;;;;"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var css_248z = ".saltCircularProgress {\n color: var(--salt-content-primary-foreground);\n display: inline-flex;\n position: relative;\n}\n\n.saltCircularProgress-progressLabel {\n align-items: center;\n color: var(--salt-content-primary-foreground);\n display: flex;\n height: 100%;\n justify-content: center;\n left: 0;\n position: absolute;\n width: 100%;\n}\n\n.saltCircularProgress-track {\n inline-size: calc(var(--salt-size-base) * 3);\n block-size: calc(var(--salt-size-base) * 3);\n border-style: var(--salt-track-borderStyle);\n border-width: var(--salt-size-bar-small);\n border-radius: calc(var(--salt-size-base) * 3);\n border-color: var(--salt-track-borderColor);\n}\n\n.saltCircularProgress-bar {\n inline-size: calc(var(--salt-size-base) * 3);\n block-size: calc(var(--salt-size-base) * 3);\n border-style: var(--salt-track-borderStyle);\n border-width: var(--salt-size-bar-strong);\n border-radius: calc(var(--salt-size-base) * 3);\n border-color: var(--salt-accent-background);\n}\n\n.saltCircularProgress-bars {\n position: absolute;\n inset-block-start: 0;\n inset-inline-start: 0;\n inline-size: 100%;\n block-size: 100%;\n}\n\n.saltCircularProgress-barOverlayRight,\n.saltCircularProgress-barOverlayLeft {\n inline-size: 50%;\n block-size: 100%;\n transform-origin: 100% center;\n transform: rotate(180deg);\n overflow: hidden;\n position: absolute;\n}\n\n.saltCircularProgress-barSubOverlayRight,\n.saltCircularProgress-barSubOverlayLeft {\n inline-size: 100%;\n block-size: 100%;\n transform-origin: 100% center;\n overflow: hidden;\n transform: rotate(-180deg);\n}\n\n.saltCircularProgress-barOverlayLeft {\n transform: rotate(0deg);\n}\n";
|
|
4
|
+
|
|
5
|
+
module.exports = css_248z;
|
|
6
|
+
//# sourceMappingURL=CircularProgress.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CircularProgress.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var clsx = require('clsx');
|
|
8
|
+
var makePrefixer = require('../../utils/makePrefixer.js');
|
|
9
|
+
require('../../utils/useFloatingUI/useFloatingUI.js');
|
|
10
|
+
require('../../utils/useId.js');
|
|
11
|
+
require('../../salt-provider/SaltProvider.js');
|
|
12
|
+
require('../../viewport/ViewportProvider.js');
|
|
13
|
+
var Text = require('../../text/Text.js');
|
|
14
|
+
require('../../text/Display.js');
|
|
15
|
+
require('../../text/Headings.js');
|
|
16
|
+
require('../../text/Label.js');
|
|
17
|
+
require('../../text/TextNotation.js');
|
|
18
|
+
require('../../text/TextAction.js');
|
|
19
|
+
var window = require('@salt-ds/window');
|
|
20
|
+
var styles = require('@salt-ds/styles');
|
|
21
|
+
var CircularProgress$1 = require('./CircularProgress.css.js');
|
|
22
|
+
|
|
23
|
+
const withBaseName = makePrefixer.makePrefixer("saltCircularProgress");
|
|
24
|
+
const CircularProgress = React.forwardRef(function CircularProgress2({ className, hideLabel = false, max = 100, min = 0, value = 0, ...rest }, ref) {
|
|
25
|
+
const targetWindow = window.useWindow();
|
|
26
|
+
styles.useComponentCssInjection({
|
|
27
|
+
testId: "salt-circular-progress",
|
|
28
|
+
css: CircularProgress$1,
|
|
29
|
+
window: targetWindow
|
|
30
|
+
});
|
|
31
|
+
const subOverlayRightStyle = {};
|
|
32
|
+
const subOverlayLeftStyle = {};
|
|
33
|
+
const getRotationAngle = (progress2, shift = 0) => {
|
|
34
|
+
return -180 + (progress2 - shift) / 50 * 180;
|
|
35
|
+
};
|
|
36
|
+
const progress = (value - min) / (max - min) * 100;
|
|
37
|
+
if (progress <= 50) {
|
|
38
|
+
const rotationAngle = getRotationAngle(progress);
|
|
39
|
+
subOverlayRightStyle.transform = `rotate(${rotationAngle}deg)`;
|
|
40
|
+
subOverlayLeftStyle.transform = "rotate(-180deg)";
|
|
41
|
+
} else {
|
|
42
|
+
const rotationAngle = getRotationAngle(progress, 50);
|
|
43
|
+
subOverlayRightStyle.transform = "rotate(0deg)";
|
|
44
|
+
subOverlayLeftStyle.transform = `rotate(${rotationAngle}deg)`;
|
|
45
|
+
}
|
|
46
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
47
|
+
className: clsx.clsx(withBaseName(), className),
|
|
48
|
+
ref,
|
|
49
|
+
role: "progressbar",
|
|
50
|
+
"aria-valuemax": max,
|
|
51
|
+
"aria-valuemin": min,
|
|
52
|
+
"aria-valuenow": Math.round(value),
|
|
53
|
+
...rest,
|
|
54
|
+
children: [
|
|
55
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
56
|
+
className: withBaseName("track")
|
|
57
|
+
}),
|
|
58
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
59
|
+
className: withBaseName("bars"),
|
|
60
|
+
children: [
|
|
61
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
62
|
+
className: withBaseName("barOverlayRight"),
|
|
63
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
64
|
+
className: withBaseName("barSubOverlayRight"),
|
|
65
|
+
style: subOverlayRightStyle,
|
|
66
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
67
|
+
className: withBaseName("bar")
|
|
68
|
+
})
|
|
69
|
+
})
|
|
70
|
+
}),
|
|
71
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
72
|
+
className: withBaseName("barOverlayLeft"),
|
|
73
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
74
|
+
className: withBaseName("barSubOverlayLeft"),
|
|
75
|
+
style: subOverlayLeftStyle,
|
|
76
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
77
|
+
className: withBaseName("bar")
|
|
78
|
+
})
|
|
79
|
+
})
|
|
80
|
+
})
|
|
81
|
+
]
|
|
82
|
+
}),
|
|
83
|
+
!hideLabel && /* @__PURE__ */ jsxRuntime.jsx(Text.Text, {
|
|
84
|
+
styleAs: "h2",
|
|
85
|
+
className: withBaseName("progressLabel"),
|
|
86
|
+
children: `${Math.round(progress)} %`
|
|
87
|
+
})
|
|
88
|
+
]
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
exports.CircularProgress = CircularProgress;
|
|
93
|
+
//# sourceMappingURL=CircularProgress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CircularProgress.js","sources":["../src/progress/CircularProgress/CircularProgress.tsx"],"sourcesContent":["import { ComponentPropsWithoutRef, CSSProperties, forwardRef } from \"react\";\nimport { clsx } from \"clsx\";\nimport { makePrefixer } from \"../../utils\";\nimport { Text } from \"../../text\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\n\nimport circularProgressCSS from \"./CircularProgress.css\";\n\nconst withBaseName = makePrefixer(\"saltCircularProgress\");\n\nexport interface CircularProgressProps extends ComponentPropsWithoutRef<\"div\"> {\n /**\n * Whether to hide the text label within the progress. Defaults to `false`.\n */\n hideLabel?: boolean;\n /**\n * The value of the max progress indicator.\n * Default value is 100.\n */\n max?: number;\n /**\n * The value of the min progress indicator.\n * Default value is 0.\n */\n min?: number;\n /**\n * The value of the progress indicator.\n * Value between 0 and max.\n */\n value?: number;\n}\n\nexport const CircularProgress = forwardRef<\n HTMLDivElement,\n CircularProgressProps\n>(function CircularProgress(\n { className, hideLabel = false, max = 100, min = 0, value = 0, ...rest },\n ref\n) {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-circular-progress\",\n css: circularProgressCSS,\n window: targetWindow,\n });\n\n const subOverlayRightStyle: CSSProperties = {};\n const subOverlayLeftStyle: CSSProperties = {};\n\n const getRotationAngle = (progress: number, shift = 0) => {\n return -180 + ((progress - shift) / 50) * 180;\n };\n\n const progress = ((value - min) / (max - min)) * 100;\n\n if (progress <= 50) {\n const rotationAngle = getRotationAngle(progress);\n subOverlayRightStyle.transform = `rotate(${rotationAngle}deg)`;\n subOverlayLeftStyle.transform = \"rotate(-180deg)\";\n } else {\n const rotationAngle = getRotationAngle(progress, 50);\n subOverlayRightStyle.transform = \"rotate(0deg)\";\n subOverlayLeftStyle.transform = `rotate(${rotationAngle}deg)`;\n }\n\n return (\n <div\n className={clsx(withBaseName(), className)}\n ref={ref}\n role=\"progressbar\"\n aria-valuemax={max}\n aria-valuemin={min}\n aria-valuenow={Math.round(value)}\n {...rest}\n >\n <div className={withBaseName(\"track\")} />\n <div className={withBaseName(\"bars\")}>\n <div className={withBaseName(\"barOverlayRight\")}>\n <div\n className={withBaseName(\"barSubOverlayRight\")}\n style={subOverlayRightStyle}\n >\n <div className={withBaseName(\"bar\")} />\n </div>\n </div>\n <div className={withBaseName(\"barOverlayLeft\")}>\n <div\n className={withBaseName(\"barSubOverlayLeft\")}\n style={subOverlayLeftStyle}\n >\n <div className={withBaseName(\"bar\")} />\n </div>\n </div>\n </div>\n {!hideLabel && (\n <Text styleAs=\"h2\" className={withBaseName(\"progressLabel\")}>\n {`${Math.round(progress)} %`}\n </Text>\n )}\n </div>\n );\n});\n"],"names":["makePrefixer","forwardRef","CircularProgress","useWindow","useComponentCssInjection","circularProgressCSS","progress","jsxs","clsx","jsx","Text"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AASA,MAAM,YAAA,GAAeA,0BAAa,sBAAsB,CAAA,CAAA;AAwBjD,MAAM,mBAAmBC,gBAG9B,CAAA,SAASC,iBACT,CAAA,EAAE,WAAW,SAAY,GAAA,KAAA,EAAO,GAAM,GAAA,GAAA,EAAK,MAAM,CAAG,EAAA,KAAA,GAAQ,CAAM,EAAA,GAAA,IAAA,IAClE,GACA,EAAA;AACA,EAAA,MAAM,eAAeC,gBAAU,EAAA,CAAA;AAC/B,EAAyBC,+BAAA,CAAA;AAAA,IACvB,MAAQ,EAAA,wBAAA;AAAA,IACR,GAAK,EAAAC,kBAAA;AAAA,IACL,MAAQ,EAAA,YAAA;AAAA,GACT,CAAA,CAAA;AAED,EAAA,MAAM,uBAAsC,EAAC,CAAA;AAC7C,EAAA,MAAM,sBAAqC,EAAC,CAAA;AAE5C,EAAA,MAAM,gBAAmB,GAAA,CAACC,SAAkB,EAAA,KAAA,GAAQ,CAAM,KAAA;AACxD,IAAO,OAAA,CAAA,GAAA,GAAA,CAASA,SAAW,GAAA,KAAA,IAAS,EAAM,GAAA,GAAA,CAAA;AAAA,GAC5C,CAAA;AAEA,EAAA,MAAM,QAAa,GAAA,CAAA,KAAA,GAAQ,GAAQ,KAAA,GAAA,GAAM,GAAQ,CAAA,GAAA,GAAA,CAAA;AAEjD,EAAA,IAAI,YAAY,EAAI,EAAA;AAClB,IAAM,MAAA,aAAA,GAAgB,iBAAiB,QAAQ,CAAA,CAAA;AAC/C,IAAA,oBAAA,CAAqB,YAAY,CAAU,OAAA,EAAA,aAAA,CAAA,IAAA,CAAA,CAAA;AAC3C,IAAA,mBAAA,CA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AAAA,YAC3C,QAAC,kBAAAA,cAAA,CAAA,KAAA,EAAA;AAAA,cACC,SAAA,EAAW,aAAa,mBAAmB,CAAA;AAAA,cAC3C,KAAO,EAAA,mBAAA;AAAA,cAEP,QAAC,kBAAAA,cAAA,CAAA,KAAA,EAAA;AAAA,gBAAI,SAAA,EAAW,aAAa,KAAK,CAAA;AAAA,eAAG,CAAA;AAAA,aACvC,CAAA;AAAA,WACF,CAAA;AAAA,SAAA;AAAA,OACF,CAAA;AAAA,MACC,CAAC,6BACCA,cAAA,CAAAC,SAAA,EAAA;AAAA,QAAK,OAAQ,EAAA,IAAA;AAAA,QAAK,SAAA,EAAW,aAAa,eAAe,CAAA;AAAA,QACvD,QAAA,EAAA,CAAA,EAAG,IAAK,CAAA,KAAA,CAAM,QAAQ,CAAA,CAAA,EAAA,CAAA;AAAA,OACzB,CAAA;AAAA,KAAA;AAAA,GAEJ,CAAA,CAAA;AAEJ,CAAC;;;;"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var css_248z = ".saltLinearProgress {\n align-items: center;\n color: var(--salt-content-primary-foreground);\n display: flex;\n min-width: 400px;\n font-size: var(--linearProgress-fontSize);\n}\n\n.saltLinearProgress-barContainer {\n background: none;\n position: relative;\n width: 100%;\n overflow: hidden;\n height: var(--salt-size-bar-strong);\n}\n\n.saltLinearProgress-bar {\n width: 100%;\n position: absolute;\n left: 0;\n bottom: 0;\n top: 0;\n transition: transform 0.2s linear;\n transform-origin: left;\n background: var(--salt-accent-background);\n z-index: 2;\n}\n\n.saltLinearProgress-track {\n background: var(--salt-track-borderColor);\n width: 100%;\n height: var(--salt-size-bar-small);\n position: absolute;\n top: calc((var(--salt-size-bar-strong) - var(--salt-size-bar-small)) / 2);\n transition: transform 0.2s linear;\n transform-origin: left;\n}\n\n.saltLinearProgress-progressLabel {\n color: inherit;\n margin: 0;\n white-space: nowrap;\n padding-left: var(--salt-spacing-100);\n}\n";
|
|
4
|
+
|
|
5
|
+
module.exports = css_248z;
|
|
6
|
+
//# sourceMappingURL=LinearProgress.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LinearProgress.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var clsx = require('clsx');
|
|
8
|
+
var makePrefixer = require('../../utils/makePrefixer.js');
|
|
9
|
+
require('../../utils/useFloatingUI/useFloatingUI.js');
|
|
10
|
+
require('../../utils/useId.js');
|
|
11
|
+
require('../../salt-provider/SaltProvider.js');
|
|
12
|
+
require('../../viewport/ViewportProvider.js');
|
|
13
|
+
var Text = require('../../text/Text.js');
|
|
14
|
+
require('../../text/Display.js');
|
|
15
|
+
require('../../text/Headings.js');
|
|
16
|
+
require('../../text/Label.js');
|
|
17
|
+
require('../../text/TextNotation.js');
|
|
18
|
+
require('../../text/TextAction.js');
|
|
19
|
+
var window = require('@salt-ds/window');
|
|
20
|
+
var styles = require('@salt-ds/styles');
|
|
21
|
+
var LinearProgress$1 = require('./LinearProgress.css.js');
|
|
22
|
+
|
|
23
|
+
const withBaseName = makePrefixer.makePrefixer("saltLinearProgress");
|
|
24
|
+
const LinearProgress = React.forwardRef(
|
|
25
|
+
function LinearProgress2({ className, hideLabel = false, max = 100, min = 0, value = 0, ...rest }, ref) {
|
|
26
|
+
const targetWindow = window.useWindow();
|
|
27
|
+
styles.useComponentCssInjection({
|
|
28
|
+
testId: "salt-linear-progress",
|
|
29
|
+
css: LinearProgress$1,
|
|
30
|
+
window: targetWindow
|
|
31
|
+
});
|
|
32
|
+
const progress = (value - min) / (max - min) * 100;
|
|
33
|
+
const barStyle = {};
|
|
34
|
+
const trackStyle = {};
|
|
35
|
+
barStyle.transform = `translateX(${progress - 100}%)`;
|
|
36
|
+
trackStyle.transform = `translateX(${progress}%)`;
|
|
37
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
38
|
+
className: clsx.clsx(withBaseName(), className),
|
|
39
|
+
ref,
|
|
40
|
+
role: "progressbar",
|
|
41
|
+
"aria-valuemax": max,
|
|
42
|
+
"aria-valuemin": min,
|
|
43
|
+
"aria-valuenow": Math.round(value),
|
|
44
|
+
...rest,
|
|
45
|
+
children: [
|
|
46
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
47
|
+
className: withBaseName("barContainer"),
|
|
48
|
+
children: [
|
|
49
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
50
|
+
className: withBaseName("bar"),
|
|
51
|
+
style: barStyle
|
|
52
|
+
}),
|
|
53
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
54
|
+
className: withBaseName("track"),
|
|
55
|
+
style: trackStyle
|
|
56
|
+
})
|
|
57
|
+
]
|
|
58
|
+
}),
|
|
59
|
+
!hideLabel && /* @__PURE__ */ jsxRuntime.jsx(Text.Text, {
|
|
60
|
+
styleAs: "h2",
|
|
61
|
+
className: withBaseName("progressLabel"),
|
|
62
|
+
children: `${Math.round(progress)} %`
|
|
63
|
+
})
|
|
64
|
+
]
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
exports.LinearProgress = LinearProgress;
|
|
70
|
+
//# sourceMappingURL=LinearProgress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LinearProgress.js","sources":["../src/progress/LinearProgress/LinearProgress.tsx"],"sourcesContent":["import { ComponentPropsWithoutRef, CSSProperties, forwardRef } from \"react\";\nimport { clsx } from \"clsx\";\nimport { makePrefixer } from \"../../utils\";\nimport { Text } from \"../../text\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\n\nimport linearProgressCss from \"./LinearProgress.css\";\n\nconst withBaseName = makePrefixer(\"saltLinearProgress\");\n\nexport interface LinearProgressProps extends ComponentPropsWithoutRef<\"div\"> {\n /**\n * Whether to hide the text label within the progress. Defaults to `false`.\n */\n hideLabel?: boolean;\n /**\n * The value of the max progress indicator.\n * Default value is 100.\n */\n max?: number;\n /**\n * The value of the min progress indicator.\n * Default value is 0.\n */\n min?: number;\n /**\n * The value of the progress indicator.\n * Value between 0 and max.\n */\n value?: number;\n}\n\nexport const LinearProgress = forwardRef<HTMLDivElement, LinearProgressProps>(\n function LinearProgress(\n { className, hideLabel = false, max = 100, min = 0, value = 0, ...rest },\n ref\n ) {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-linear-progress\",\n css: linearProgressCss,\n window: targetWindow,\n });\n\n const progress = ((value - min) / (max - min)) * 100;\n\n const barStyle: CSSProperties = {};\n const trackStyle: CSSProperties = {};\n\n barStyle.transform = `translateX(${progress - 100}%)`;\n trackStyle.transform = `translateX(${progress}%)`;\n\n return (\n <div\n className={clsx(withBaseName(), className)}\n ref={ref}\n role=\"progressbar\"\n aria-valuemax={max}\n aria-valuemin={min}\n aria-valuenow={Math.round(value)}\n {...rest}\n >\n <div className={withBaseName(\"barContainer\")}>\n <div className={withBaseName(\"bar\")} style={barStyle} />\n <div className={withBaseName(\"track\")} style={trackStyle} />\n </div>\n {!hideLabel && (\n <Text styleAs=\"h2\" className={withBaseName(\"progressLabel\")}>\n {`${Math.round(progress)} %`}\n </Text>\n )}\n </div>\n );\n }\n);\n"],"names":["makePrefixer","forwardRef","LinearProgress","useWindow","useComponentCssInjection","linearProgressCss","jsxs","clsx","jsx","Text"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AASA,MAAM,YAAA,GAAeA,0BAAa,oBAAoB,CAAA,CAAA;AAwB/C,MAAM,cAAiB,GAAAC,gBAAA;AAAA,EAC5B,SAASC,eAAAA,CACP,EAAE,SAAA,EAAW,YAAY,KAAO,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AA;AAAA,cAAI,SAAA,EAAW,aAAa,OAAO,CAAA;AAAA,cAAG,KAAO,EAAA,UAAA;AAAA,aAAY,CAAA;AAAA,WAAA;AAAA,SAC5D,CAAA;AAAA,QACC,CAAC,6BACCA,cAAA,CAAAC,SAAA,EAAA;AAAA,UAAK,OAAQ,EAAA,IAAA;AAAA,UAAK,SAAA,EAAW,aAAa,eAAe,CAAA;AAAA,UACvD,QAAA,EAAA,CAAA,EAAG,IAAK,CAAA,KAAA,CAAM,QAAQ,CAAA,CAAA,EAAA,CAAA;AAAA,SACzB,CAAA;AAAA,OAAA;AAAA,KAEJ,CAAA,CAAA;AAAA,GAEJ;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFloatingUI.js","sources":["../src/utils/useFloatingUI/useFloatingUI.tsx"],"sourcesContent":["import {\n Middleware,\n Placement,\n Platform,\n Strategy,\n autoUpdate,\n flip,\n limitShift,\n platform,\n shift,\n useFloating,\n FloatingPortal,\n FloatingFocusManager,\n FloatingFocusManagerProps,\n} from \"@floating-ui/react\";\n\nimport {\n createContext,\n ReactNode,\n useContext,\n useMemo,\n forwardRef,\n ComponentPropsWithoutRef,\n} from \"react\";\n\nimport { SaltProvider } from \"../../salt-provider\";\n\nexport interface FloatingComponentProps\n extends ComponentPropsWithoutRef<\"div\"> {\n /**\n * Whether the floating component is open (used for determining whether to show the component)\n * We pass this as a prop rather than not rendering the component to allow more advanced use-cases e.g.\n * for caching windows and reusing them, rather than always spawning a new one\n */\n open: boolean;\n /**\n * Use this prop when `FloatingFocusManager` is needed for floating component\n */\n focusManagerProps?: Omit<FloatingFocusManagerProps, \"children\">;\n /**\n * Position props for the floating component\n */\n top
|
|
1
|
+
{"version":3,"file":"useFloatingUI.js","sources":["../src/utils/useFloatingUI/useFloatingUI.tsx"],"sourcesContent":["import {\n Middleware,\n Placement,\n Platform,\n Strategy,\n autoUpdate,\n flip,\n limitShift,\n platform,\n shift,\n useFloating,\n FloatingPortal,\n FloatingFocusManager,\n FloatingFocusManagerProps,\n} from \"@floating-ui/react\";\n\nimport {\n createContext,\n ReactNode,\n useContext,\n useMemo,\n forwardRef,\n ComponentPropsWithoutRef,\n} from \"react\";\n\nimport { SaltProvider } from \"../../salt-provider\";\n\nexport interface FloatingComponentProps\n extends ComponentPropsWithoutRef<\"div\"> {\n /**\n * Whether the floating component is open (used for determining whether to show the component)\n * We pass this as a prop rather than not rendering the component to allow more advanced use-cases e.g.\n * for caching windows and reusing them, rather than always spawning a new one\n */\n open: boolean;\n /**\n * Use this prop when `FloatingFocusManager` is needed for floating component\n */\n focusManagerProps?: Omit<FloatingFocusManagerProps, \"children\">;\n /**\n * Position props for the floating component\n */\n top?: number;\n left?: number;\n width?: number;\n height?: number;\n position?: Strategy;\n}\n\nconst DefaultFloatingComponent = forwardRef<\n HTMLDivElement,\n FloatingComponentProps\n>(function DefaultFloatingComponent(props, ref) {\n const {\n open,\n top,\n left,\n position,\n /* eslint-disable @typescript-eslint/no-unused-vars */\n width,\n height,\n /* eslint-enable @typescript-eslint/no-unused-vars */\n focusManagerProps,\n ...rest\n } = props;\n const style = {\n top,\n left,\n position,\n };\n\n if (focusManagerProps) {\n return (\n <FloatingPortal>\n <SaltProvider>\n <FloatingFocusManager {...focusManagerProps}>\n <div style={style} {...rest} ref={ref} />\n </FloatingFocusManager>\n </SaltProvider>\n </FloatingPortal>\n );\n }\n\n return open ? (\n <FloatingPortal>\n <SaltProvider>\n <div style={style} {...rest} ref={ref} />\n </SaltProvider>\n </FloatingPortal>\n ) : null;\n});\n\nexport interface FloatingComponentContextType {\n Component: typeof DefaultFloatingComponent;\n}\n\nconst FloatingComponentContext = createContext<FloatingComponentContextType>({\n Component: DefaultFloatingComponent,\n});\n\nif (process.env.NODE_ENV !== \"production\") {\n FloatingComponentContext.displayName = \"FloatingComponentContext\";\n}\n\nexport interface FloatingComponentProviderProps\n extends FloatingComponentContextType {\n children: ReactNode;\n}\n\nexport function FloatingComponentProvider(\n props: FloatingComponentProviderProps\n) {\n const { Component, children } = props;\n const value = useMemo(() => ({ Component }), [Component]);\n\n return (\n <FloatingComponentContext.Provider value={value}>\n {children}\n </FloatingComponentContext.Provider>\n );\n}\n\nexport function useFloatingComponent() {\n return useContext(FloatingComponentContext);\n}\n\nexport interface UseFloatingUIProps {\n /**\n * Sets position relative to trigger.\n */\n placement?: Placement;\n strategy?: Strategy;\n /**\n * Function to update the default middleware used to extend or replace it\n */\n middleware?: Middleware[];\n /**\n * Sets visible state.\n */\n open?: boolean;\n /**\n * Callback function triggered when open state changes.\n */\n onOpenChange?: (open: boolean) => void;\n}\n\ntype GetMiddleware = (middleware: Middleware[]) => Middleware[];\n\nconst defaultGetMiddleware: GetMiddleware = (defaultMiddleware) =>\n defaultMiddleware;\n\ninterface FloatingPlatformContextType {\n platform: Platform;\n middleware: GetMiddleware;\n animationFrame: boolean;\n}\n\nconst defaultFloatingPlaform: FloatingPlatformContextType = {\n platform,\n middleware: defaultGetMiddleware,\n animationFrame: false,\n};\n\nconst FloatingPlatformContext = createContext<FloatingPlatformContextType>(\n defaultFloatingPlaform\n);\n\nexport interface FloatingPlatformProviderProps {\n platform?: Platform;\n middleware?: GetMiddleware;\n children: ReactNode;\n animationFrame?: boolean;\n}\n\nexport function FloatingPlatformProvider(props: FloatingPlatformProviderProps) {\n const {\n platform: platformProp,\n middleware,\n animationFrame,\n children,\n } = props;\n\n const floatingPlatformContextValue = useMemo<FloatingPlatformContextType>(\n () => ({\n platform: platformProp ?? platform,\n middleware: middleware ?? defaultGetMiddleware,\n animationFrame: animationFrame || false,\n }),\n [platformProp, middleware, animationFrame]\n );\n\n return (\n <FloatingPlatformContext.Provider value={floatingPlatformContextValue}>\n {children}\n </FloatingPlatformContext.Provider>\n );\n}\n\nexport function useFloatingPlatform() {\n return useContext(FloatingPlatformContext);\n}\n\nexport const DEFAULT_FLOATING_UI_MIDDLEWARE = [\n flip(),\n shift({ limiter: limitShift() }),\n];\n\ntype UseFloatingRefs = ReturnType<typeof useFloating>[\"refs\"];\n\nexport interface UseFloatingUIReturn extends ReturnType<typeof useFloating> {\n reference: UseFloatingRefs[\"setReference\"];\n floating: UseFloatingRefs[\"setFloating\"];\n}\n\nexport function useFloatingUI(props: UseFloatingUIProps): UseFloatingUIReturn {\n const {\n placement,\n strategy,\n middleware = DEFAULT_FLOATING_UI_MIDDLEWARE,\n open = false,\n onOpenChange,\n } = props;\n\n const handleOpenChange = (open: boolean) => {\n update();\n onOpenChange?.(open);\n };\n\n const {\n platform: contextPlatform,\n middleware: contextMiddleware,\n animationFrame,\n } = useFloatingPlatform();\n\n const { refs, update, ...rest } = useFloating({\n placement,\n strategy,\n middleware: contextMiddleware(middleware),\n open,\n onOpenChange: handleOpenChange,\n whileElementsMounted: (...args) => {\n const cleanup = autoUpdate(...args, { animationFrame });\n\n return cleanup;\n },\n platform: contextPlatform,\n });\n\n return {\n reference: refs.setReference,\n floating: refs.setFloating,\n refs,\n update,\n ...rest,\n };\n}\n"],"names":["forwardRef","DefaultFloatingComponent","jsx","FloatingPortal","SaltProvider","FloatingFocusManager","createContext","useMemo","useContext","platform","flip","shift","limitShift","open","useFloating","autoUpdate"],"mappings":";;;;;;;;;AAiDA,MAAM,wBAA2B,GAAAA,gBAAA,CAG/B,SAASC,yBAAAA,CAAyB,OAAO,GAAK,EAAA;AAC9C,EAAM,MAAA;AAAA,IACJ,IAAA;AAAA,IACA,GAAA;AAAA,IACA,IAAA;AAAA,IACA,QAAA;AAAA,IAEA,KAAA;AAAA,IACA,MAAA;AAAA,IAEA,iBAAA;AAAA,IACG,GAAA,IAAA;AAAA,GACD,GAAA,KAAA,CAAA;AACJ,EAAA,MAAM,KAAQ,GAAA;AAAA,IACZ,GAAA;AAAA,IACA,IAAA;AAAA,IACA,QAAA;AAAA,GACF,CAAA;AAEA,EAAA,IAAI,iBAAmB,EAAA;AACrB,IAAA,uBACGC,cAAA,CAAAC,oBAAA,EAAA;AAAA,MACC,QAAC,kBAAAD,cAAA,CAAAE,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A;AAAA,GACE,GAAA,KAAA,CAAA;AAEJ,EAAM,MAAA,gBAAA,GAAmB,CAACC,KAAkB,KAAA;AAC1C,IAAO,MAAA,EAAA,CAAA;AACP,IAAeA,YAAAA,IAAAA,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,YAAAA,CAAAA,KAAAA,CAAAA,CAAAA;AAAA,GACjB,CAAA;AAEA,EAAM,MAAA;AAAA,IACJ,QAAU,EAAA,eAAA;AAAA,IACV,UAAY,EAAA,iBAAA;AAAA,IACZ,cAAA;AAAA,MACE,mBAAoB,EAAA,CAAA;AAExB,EAAA,MAAM,EAAE,IAAA,EAAM,MAAW,EAAA,GAAA,IAAA,KAASC,iBAAY,CAAA;AAAA,IAC5C,SAAA;AAAA,IACA,QAAA;AAAA,IACA,UAAA,EAAY,kBAAkB,UAAU,CAAA;AAAA,IACxC,IAAA;AAAA,IACA,YAAc,EAAA,gBAAA;AAAA,IACd,oBAAA,EAAsB,IAAI,IAAS,KAAA;AACjC,MAAA,MAAM,UAAUC,gBAAW,CAAA,GAAG,IAAM,EAAA,EAAE,gBAAgB,CAAA,CAAA;AAEtD,MAAO,OAAA,OAAA,CAAA;AAAA,KACT;AAAA,IACA,QAAU,EAAA,eAAA;AAAA,GACX,CAAA,CAAA;AAED,EAAO,OAAA;AAAA,IACL,WAAW,IAAK,CAAA,YAAA;AAAA,IAChB,UAAU,IAAK,CAAA,WAAA;AAAA,IACf,IAAA;AAAA,IACA,MAAA;AAAA,IACA,GAAG,IAAA;AAAA,GACL,CAAA;AACF;;;;;;;;;"}
|
package/dist-es/index.js
CHANGED
|
@@ -46,6 +46,8 @@ export { CompactPaginator } from './pagination/CompactPaginator.js';
|
|
|
46
46
|
export { GoToInput } from './pagination/GoToInput.js';
|
|
47
47
|
export { Panel } from './panel/Panel.js';
|
|
48
48
|
export { Pill } from './pill/Pill.js';
|
|
49
|
+
export { CircularProgress } from './progress/CircularProgress/CircularProgress.js';
|
|
50
|
+
export { LinearProgress } from './progress/LinearProgress/LinearProgress.js';
|
|
49
51
|
export { RadioButton } from './radio-button/RadioButton.js';
|
|
50
52
|
export { RadioButtonGroup } from './radio-button/RadioButtonGroup.js';
|
|
51
53
|
export { RadioButtonIcon } from './radio-button/RadioButtonIcon.js';
|
package/dist-es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var css_248z = "/* Style applied to the root element */\n.saltMultilineInput {\n --multilineInput-borderColor: var(--salt-editable-borderColor);\n --multilineInput-borderStyle: var(--salt-editable-borderStyle);\n --multilineInput-outlineColor: var(--salt-focused-outlineColor);\n --multilineInput-border: none;\n --multilineInput-activationIndicator-borderWidth: var(--salt-size-border);\n\n align-items: center;\n background: var(--multilineInput-background);\n border: var(--multilineInput-border);\n color: var(--salt-content-primary-foreground);\n display: inline-flex;\n font-family: var(--salt-text-fontFamily);\n font-size: var(--salt-text-fontSize);\n height: auto;\n line-height: var(--salt-text-lineHeight);\n min-height: var(--salt-size-base);\n min-width: 4em;\n padding-left: var(--salt-spacing-100);\n padding-right: var(--salt-spacing-100);\n position: relative;\n width: 100%;\n}\n\n/* Style applied on hover */\n.saltMultilineInput:hover {\n --multilineInput-borderStyle: var(--salt-editable-borderStyle-hover);\n --multilineInput-borderColor: var(--salt-editable-borderColor-hover);\n\n background: var(--multilineInput-background-hover);\n cursor: var(--salt-editable-cursor-hover);\n}\n\n/* Style applied when active */\n.saltMultilineInput:active {\n --multilineInput-borderColor: var(--salt-editable-borderColor-active);\n --multilineInput-borderStyle: var(--salt-editable-borderStyle-active);\n --multilineInput-activationIndicator-borderWidth: var(--salt-editable-borderWidth-active);\n\n background: var(--multilineInput-background-active);\n cursor: var(--salt-editable-cursor-active);\n}\n\n/* Class applied if `variant=\"primary\"` */\n.saltMultilineInput-primary {\n --multilineInput-background: var(--salt-editable-primary-background);\n --multilineInput-background-active: var(--salt-editable-primary-background-active);\n --multilineInput-background-hover: var(--salt-editable-primary-background-hover);\n --multilineInput-background-disabled: var(--salt-editable-primary-background-disabled);\n --multilineInput-background-readonly: var(--salt-editable-primary-background-readonly);\n}\n\n/* Class applied if `variant=\"secondary\"` */\n.saltMultilineInput-secondary {\n --multilineInput-background: var(--salt-editable-secondary-background);\n --multilineInput-background-active: var(--salt-editable-secondary-background-active);\n --multilineInput-background-hover: var(--salt-editable-secondary-background-active);\n --multilineInput-background-disabled: var(--salt-editable-secondary-background-disabled);\n --multilineInput-background-readonly: var(--salt-editable-secondary-background-readonly);\n}\n\n/* Style applied to input if `validationState=\"error\"` */\n.saltMultilineInput-error,\n.saltMultilineInput-error:hover {\n --multilineInput-background: var(--salt-status-error-background);\n --multilineInput-background-active: var(--salt-status-error-background);\n --multilineInput-background-hover: var(--salt-status-error-background);\n --multilineInput-borderColor: var(--salt-status-error-borderColor);\n --multilineInput-outlineColor: var(--salt-status-error-borderColor);\n}\n\n/* Style applied to input if `validationState=\"warning\"` */\n.saltMultilineInput-warning,\n.saltMultilineInput-warning:hover {\n --multilineInput-background: var(--salt-status-warning-background);\n --multilineInput-background-active: var(--salt-status-warning-background);\n --multilineInput-background-hover: var(--salt-status-warning-background);\n --multilineInput-borderColor: var(--salt-status-warning-borderColor);\n --multilineInput-outlineColor: var(--salt-status-warning-borderColor);\n}\n\n/* Style applied to input if `validationState=\"success\"` */\n.saltMultilineInput-success,\n.saltMultilineInput-success:hover {\n --multilineInput-background: var(--salt-status-success-background);\n --multilineInput-background-active: var(--salt-status-success-background);\n --multilineInput-background-hover: var(--salt-status-success-background);\n --multilineInput-borderColor: var(--salt-status-success-borderColor);\n --multilineInput-outlineColor: var(--salt-status-success-borderColor);\n}\n\n.saltMultilineInput.saltMultilineInput-withAdornmentRow {\n display: flex;\n flex-wrap: wrap;\n}\n\n/* Style applied to inner textarea element */\n.saltMultilineInput-textarea {\n background: none;\n border: none;\n box-sizing:
|
|
1
|
+
var css_248z = "/* Style applied to the root element */\n.saltMultilineInput {\n --multilineInput-borderColor: var(--salt-editable-borderColor);\n --multilineInput-borderStyle: var(--salt-editable-borderStyle);\n --multilineInput-outlineColor: var(--salt-focused-outlineColor);\n --multilineInput-border: none;\n --multilineInput-activationIndicator-borderWidth: var(--salt-size-border);\n\n align-items: center;\n background: var(--multilineInput-background);\n border: var(--multilineInput-border);\n color: var(--salt-content-primary-foreground);\n display: inline-flex;\n font-family: var(--salt-text-fontFamily);\n font-size: var(--salt-text-fontSize);\n height: auto;\n line-height: var(--salt-text-lineHeight);\n min-height: var(--salt-size-base);\n min-width: 4em;\n padding-left: var(--salt-spacing-100);\n padding-right: var(--salt-spacing-100);\n position: relative;\n width: 100%;\n}\n\n/* Style applied on hover */\n.saltMultilineInput:hover {\n --multilineInput-borderStyle: var(--salt-editable-borderStyle-hover);\n --multilineInput-borderColor: var(--salt-editable-borderColor-hover);\n\n background: var(--multilineInput-background-hover);\n cursor: var(--salt-editable-cursor-hover);\n}\n\n/* Style applied when active */\n.saltMultilineInput:active {\n --multilineInput-borderColor: var(--salt-editable-borderColor-active);\n --multilineInput-borderStyle: var(--salt-editable-borderStyle-active);\n --multilineInput-activationIndicator-borderWidth: var(--salt-editable-borderWidth-active);\n\n background: var(--multilineInput-background-active);\n cursor: var(--salt-editable-cursor-active);\n}\n\n/* Class applied if `variant=\"primary\"` */\n.saltMultilineInput-primary {\n --multilineInput-background: var(--salt-editable-primary-background);\n --multilineInput-background-active: var(--salt-editable-primary-background-active);\n --multilineInput-background-hover: var(--salt-editable-primary-background-hover);\n --multilineInput-background-disabled: var(--salt-editable-primary-background-disabled);\n --multilineInput-background-readonly: var(--salt-editable-primary-background-readonly);\n}\n\n/* Class applied if `variant=\"secondary\"` */\n.saltMultilineInput-secondary {\n --multilineInput-background: var(--salt-editable-secondary-background);\n --multilineInput-background-active: var(--salt-editable-secondary-background-active);\n --multilineInput-background-hover: var(--salt-editable-secondary-background-active);\n --multilineInput-background-disabled: var(--salt-editable-secondary-background-disabled);\n --multilineInput-background-readonly: var(--salt-editable-secondary-background-readonly);\n}\n\n/* Style applied to input if `validationState=\"error\"` */\n.saltMultilineInput-error,\n.saltMultilineInput-error:hover {\n --multilineInput-background: var(--salt-status-error-background);\n --multilineInput-background-active: var(--salt-status-error-background);\n --multilineInput-background-hover: var(--salt-status-error-background);\n --multilineInput-borderColor: var(--salt-status-error-borderColor);\n --multilineInput-outlineColor: var(--salt-status-error-borderColor);\n}\n\n/* Style applied to input if `validationState=\"warning\"` */\n.saltMultilineInput-warning,\n.saltMultilineInput-warning:hover {\n --multilineInput-background: var(--salt-status-warning-background);\n --multilineInput-background-active: var(--salt-status-warning-background);\n --multilineInput-background-hover: var(--salt-status-warning-background);\n --multilineInput-borderColor: var(--salt-status-warning-borderColor);\n --multilineInput-outlineColor: var(--salt-status-warning-borderColor);\n}\n\n/* Style applied to input if `validationState=\"success\"` */\n.saltMultilineInput-success,\n.saltMultilineInput-success:hover {\n --multilineInput-background: var(--salt-status-success-background);\n --multilineInput-background-active: var(--salt-status-success-background);\n --multilineInput-background-hover: var(--salt-status-success-background);\n --multilineInput-borderColor: var(--salt-status-success-borderColor);\n --multilineInput-outlineColor: var(--salt-status-success-borderColor);\n}\n\n.saltMultilineInput.saltMultilineInput-withAdornmentRow {\n display: flex;\n flex-wrap: wrap;\n}\n\n/* Style applied to inner textarea element */\n.saltMultilineInput-textarea {\n background: none;\n border: none;\n box-sizing: border-box;\n color: inherit;\n cursor: inherit;\n flex-grow: 1;\n font: inherit;\n letter-spacing: 0;\n line-height: var(--salt-text-lineHeight);\n margin: var(--salt-spacing-75) 0;\n min-width: 0;\n min-height: 0;\n resize: vertical;\n padding: 0;\n}\n\n/* Style applied to placeholder */\n.saltMultilineInput-textarea::placeholder {\n font-weight: var(--salt-text-fontWeight-small);\n}\n\n/* Reset in the class */\n.saltMultilineInput-textarea:focus {\n outline: none;\n}\n\n/* Style applied to selected input */\n.saltMultilineInput-textarea::selection {\n background: var(--salt-content-foreground-highlight);\n}\n\n/* Styling when focused */\n.saltMultilineInput-focused {\n --multilineInput-borderColor: var(--multilineInput-outlineColor);\n --multilineInput-activationIndicator-borderWidth: var(--salt-editable-borderWidth-active);\n\n outline: var(--salt-focused-outlineWidth) var(--salt-focused-outlineStyle) var(--multilineInput-outlineColor);\n}\n\n/* Style applied if `readOnly={true}` */\n.saltMultilineInput-readOnly,\n.saltMultilineInput-readOnly:active,\n.saltMultilineInput-readOnly:hover {\n --multilineInput-borderColor: var(--salt-editable-borderColor-readonly);\n --multilineInput-borderStyle: var(--salt-editable-borderStyle-readonly);\n --multilineInput-activationIndicator-borderWidth: var(--salt-size-border);\n\n background: var(--multilineInput-background-readonly);\n cursor: var(--salt-editable-cursor-readonly);\n}\n\n/* Style applied to selected text if `disabled={true}` */\n.saltMultilineInput-disabled .saltMultilineInput-textarea::selection {\n background: none;\n}\n\n/* Style applied when `disabled={true}` */\n.saltMultilineInput-disabled,\n.saltMultilineInput-disabled:hover,\n.saltMultilineInput-disabled:active {\n --multilineInput-borderColor: var(--salt-editable-borderColor-disabled);\n --multilineInput-borderStyle: var(--salt-editable-borderStyle-disabled);\n --multilineInput-activationIndicator-borderWidth: var(--salt-size-border);\n\n background: var(--multilineInput-background-disabled);\n cursor: var(--salt-editable-cursor-disabled);\n color: var(--salt-content-primary-foreground-disabled);\n}\n\n/* Style for activation indicator */\n.saltMultilineInput-activationIndicator {\n left: 0;\n bottom: 0;\n width: 100%;\n position: absolute;\n border-bottom: var(--multilineInput-activationIndicator-borderWidth) var(--multilineInput-borderStyle) var(--multilineInput-borderColor);\n}\n\n/* Style applied if `bordered={true}` */\n.saltMultilineInput.saltMultilineInput-bordered {\n --multilineInput-border: var(--salt-size-border) var(--salt-container-borderStyle) var(--multilineInput-borderColor);\n --multilineInput-activationIndicator-borderWidth: 0;\n}\n\n/* Style applied if active or focused when `bordered={true}` */\n.saltMultilineInput-bordered:active,\n.saltMultilineInput-bordered.saltMultilineInput-focused {\n --multilineInput-activationIndicator-borderWidth: var(--salt-editable-borderWidth-active);\n}\n\n/* Styling when focused if `disabled={true}` or `readOnly={true}` when `bordered={true}` */\n.saltMultilineInput-bordered.saltMultilineInput-readOnly:hover,\n.saltMultilineInput-bordered.saltMultilineInput-disabled:hover {\n --multilineInput-activationIndicator-borderWidth: 0;\n}\n\n/* Style applied to adornment containers */\n.saltMultilineInput-endAdornmentContainer,\n.saltMultilineInput-startAdornmentContainer {\n align-items: center;\n display: inline-flex;\n min-height: var(--salt-size-base);\n column-gap: var(--salt-spacing-100);\n}\n\n/* Style applied to start adornment container */\n.saltMultilineInput-startAdornmentContainer {\n align-self: self-start;\n padding-right: var(--salt-spacing-100);\n}\n\n/* Style applied to suffix adornment container */\n.saltMultilineInput-suffixAdornments {\n align-self: self-end;\n}\n\n/* Style applied to suffix adornment container when end adornments are provided */\n.saltMultilineInput-withAdornmentRow .saltMultilineInput-suffixAdornments {\n display: inline-flex;\n flex-basis: 100%;\n justify-content: flex-end;\n}\n\n/* Style applied to end adornment container */\n.saltMultilineInput-endAdornmentContainer {\n padding-left: var(--salt-spacing-100);\n}\n\n/* Style applied to status adornment container */\n.saltMultilineInput-statusAdornmentContainer {\n align-self: self-end;\n display: inline-flex;\n min-height: var(--salt-size-base);\n}\n\n/* Style applied to button start adornment if first child */\n.saltMultilineInput-startAdornmentContainer .saltButton:first-child {\n margin-left: calc(var(--salt-spacing-50) * -1);\n}\n\n/* Style applied to button end adornment if last child */\n.saltMultilineInput-endAdornmentContainer .saltButton:last-child {\n margin-right: calc(var(--salt-spacing-50) * -1);\n}\n\n/* Style applied to button end adornment if last child */\n.saltMultilineInput-readOnly .saltMultilineInput-endAdornmentContainer .saltButton:last-child {\n margin-right: 0;\n}\n\n/* Styles for button adornment */\n.saltMultilineInput-startAdornmentContainer > .saltButton,\n.saltMultilineInput-endAdornmentContainer > .saltButton {\n --saltButton-padding: var(--salt-spacing-50);\n --saltButton-height: calc(var(--salt-size-base) - var(--salt-spacing-100));\n}\n";
|
|
2
2
|
|
|
3
3
|
export { css_248z as default };
|
|
4
4
|
//# sourceMappingURL=MultilineInput.css.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { clsx } from 'clsx';
|
|
3
|
-
import { forwardRef, useState } from 'react';
|
|
3
|
+
import { forwardRef, useRef, useState } from 'react';
|
|
4
4
|
import { useComponentCssInjection } from '@salt-ds/styles';
|
|
5
5
|
import { useWindow } from '@salt-ds/window';
|
|
6
6
|
import '../form-field-context/FormFieldContext.js';
|
|
@@ -9,6 +9,7 @@ import { StatusAdornment } from '../status-adornment/StatusAdornment.js';
|
|
|
9
9
|
import { makePrefixer } from '../utils/makePrefixer.js';
|
|
10
10
|
import { useControlled } from '../utils/useControlled.js';
|
|
11
11
|
import '../utils/useFloatingUI/useFloatingUI.js';
|
|
12
|
+
import { useForkRef } from '../utils/useForkRef.js';
|
|
12
13
|
import '../utils/useId.js';
|
|
13
14
|
import '../salt-provider/SaltProvider.js';
|
|
14
15
|
import '../viewport/ViewportProvider.js';
|
|
@@ -39,6 +40,8 @@ const MultilineInput = forwardRef(
|
|
|
39
40
|
variant = "primary",
|
|
40
41
|
...other
|
|
41
42
|
}, ref) {
|
|
43
|
+
const inputRef = useRef(null);
|
|
44
|
+
const handleRef = useForkRef(inputRef, textAreaRef);
|
|
42
45
|
const targetWindow = useWindow();
|
|
43
46
|
useComponentCssInjection({
|
|
44
47
|
testId: "salt-multiline-input",
|
|
@@ -80,10 +83,22 @@ const MultilineInput = forwardRef(
|
|
|
80
83
|
name: "MultilineInput",
|
|
81
84
|
state: "value"
|
|
82
85
|
});
|
|
86
|
+
const previousHeight = useRef(void 0);
|
|
83
87
|
const handleChange = (event) => {
|
|
84
88
|
const value2 = event.target.value;
|
|
85
89
|
setValue(value2);
|
|
86
90
|
onChange == null ? void 0 : onChange(event);
|
|
91
|
+
const input = event.target;
|
|
92
|
+
const hasBeenManuallyResized = previousHeight.current !== void 0 && input.style.height !== previousHeight.current;
|
|
93
|
+
if (!hasBeenManuallyResized) {
|
|
94
|
+
const previousOverflow = input.style.overflow;
|
|
95
|
+
input.style.overflow = "hidden";
|
|
96
|
+
input.style.height = "auto";
|
|
97
|
+
const newHeight = `${input.scrollHeight + (input.offsetHeight - input.clientHeight)}px`;
|
|
98
|
+
input.style.height = newHeight;
|
|
99
|
+
previousHeight.current = newHeight;
|
|
100
|
+
input.style.overflow = previousOverflow;
|
|
101
|
+
}
|
|
87
102
|
};
|
|
88
103
|
const handleBlur = (event) => {
|
|
89
104
|
onBlur == null ? void 0 : onBlur(event);
|
|
@@ -107,7 +122,7 @@ const MultilineInput = forwardRef(
|
|
|
107
122
|
[withBaseName("focused")]: !isDisabled && focused,
|
|
108
123
|
[withBaseName("disabled")]: isDisabled,
|
|
109
124
|
[withBaseName("readOnly")]: isReadOnly,
|
|
110
|
-
[withBaseName(validationStatus
|
|
125
|
+
[withBaseName(validationStatus != null ? validationStatus : "")]: validationStatus
|
|
111
126
|
},
|
|
112
127
|
classNameProp
|
|
113
128
|
),
|
|
@@ -126,7 +141,7 @@ const MultilineInput = forwardRef(
|
|
|
126
141
|
disabled: isDisabled,
|
|
127
142
|
id,
|
|
128
143
|
readOnly: isReadOnly,
|
|
129
|
-
ref:
|
|
144
|
+
ref: handleRef,
|
|
130
145
|
required: isRequired,
|
|
131
146
|
role,
|
|
132
147
|
rows,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultilineInput.js","sources":["../src/multiline-input/MultilineInput.tsx"],"sourcesContent":["import { clsx } from \"clsx\";\nimport {\n ChangeEvent,\n ComponentPropsWithoutRef,\n FocusEvent,\n forwardRef,\n ReactNode,\n Ref,\n TextareaHTMLAttributes,\n useState,\n} from \"react\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { useFormFieldProps } from \"../form-field-context\";\nimport { StatusAdornment } from \"../status-adornment\";\nimport { makePrefixer, useControlled } from \"../utils\";\n\nimport multilineInputCss from \"./MultilineInput.css\";\n\nconst withBaseName = makePrefixer(\"saltMultilineInput\");\n\nexport interface MultilineInputProps\n extends Omit<ComponentPropsWithoutRef<\"div\">, \"defaultValue\">,\n Pick<\n ComponentPropsWithoutRef<\"textarea\">,\n \"disabled\" | \"value\" | \"defaultValue\" | \"placeholder\"\n > {\n /**\n * Styling variant with full border. Defaults to false\n */\n bordered?: boolean;\n /**\n * End adornment component\n */\n endAdornment?: ReactNode;\n /**\n * If `true`, the component is read only.\n */\n readOnly?: boolean;\n /**\n * Number of rows. Defaults to 3\n */\n rows?: number;\n /**\n * Start adornment component\n */\n startAdornment?: ReactNode;\n /**\n * [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#Attributes) applied to the `textarea` element.\n */\n textAreaProps?: TextareaHTMLAttributes<HTMLTextAreaElement>;\n /**\n * Optional ref for the textarea component\n */\n textAreaRef?: Ref<HTMLTextAreaElement>;\n /**\n * Validation status.\n */\n validationStatus?: \"error\" | \"warning\" | \"success\";\n /**\n * Styling variant. Defaults to \"primary\".\n */\n variant?: \"primary\" | \"secondary\";\n}\n\nexport const MultilineInput = forwardRef<HTMLDivElement, MultilineInputProps>(\n function MultilineInput(\n {\n \"aria-activedescendant\": ariaActiveDescendant,\n \"aria-expanded\": ariaExpanded,\n \"aria-owns\": ariaOwns,\n bordered = false,\n className: classNameProp,\n disabled,\n endAdornment,\n id,\n placeholder,\n readOnly,\n role,\n rows = 3,\n startAdornment,\n style,\n textAreaProps = {},\n textAreaRef,\n value: valueProp,\n defaultValue: defaultValueProp = valueProp === undefined ? \"\" : undefined,\n validationStatus: validationStatusProp,\n variant = \"primary\",\n ...other\n },\n ref\n ) {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-multiline-input\",\n css: multilineInputCss,\n window: targetWindow,\n });\n\n const restA11yProps = {\n \"aria-activedescendant\": ariaActiveDescendant,\n \"aria-expanded\": ariaExpanded,\n \"aria-owns\": ariaOwns,\n };\n\n const [focused, setFocused] = useState(false);\n\n const {\n \"aria-describedby\": textAreaDescribedBy,\n \"aria-labelledby\": textAreaLabelledBy,\n onBlur,\n onChange,\n onFocus,\n required: textAreaRequired,\n ...restTextAreaProps\n } = textAreaProps;\n\n const {\n a11yProps: {\n \"aria-describedby\": formFieldDescribedBy,\n \"aria-labelledby\": formFieldLabelledBy,\n } = {},\n disabled: formFieldDisabled,\n readOnly: formFieldReadOnly,\n necessity: formFieldRequired,\n validationStatus: formFieldValidationStatus,\n } = useFormFieldProps();\n\n const isDisabled = disabled || formFieldDisabled;\n const isReadOnly = readOnly || formFieldReadOnly;\n const validationStatus = formFieldValidationStatus ?? validationStatusProp;\n const isRequired = formFieldRequired\n ? [\"required\", \"asterisk\"].includes(formFieldRequired)\n : textAreaRequired;\n\n const [value, setValue] = useControlled({\n controlled: valueProp,\n default: defaultValueProp,\n name: \"MultilineInput\",\n state: \"value\",\n });\n\n const handleChange = (event: ChangeEvent<HTMLTextAreaElement>) => {\n const value = event.target.value;\n setValue(value);\n onChange?.(event);\n };\n\n const handleBlur = (event: FocusEvent<HTMLTextAreaElement>) => {\n onBlur?.(event);\n setFocused(false);\n };\n\n const handleFocus = (event: FocusEvent<HTMLTextAreaElement>) => {\n onFocus?.(event);\n setFocused(true);\n };\n\n const multilineInputStyles = {\n \"--saltMultilineInput-rows\": rows,\n ...style,\n };\n\n return (\n <div\n className={clsx(\n withBaseName(),\n withBaseName(variant),\n {\n [withBaseName(\"withAdornmentRow\")]: endAdornment,\n [withBaseName(\"bordered\")]: bordered,\n [withBaseName(\"focused\")]: !isDisabled && focused,\n [withBaseName(\"disabled\")]: isDisabled,\n [withBaseName(\"readOnly\")]: isReadOnly,\n [withBaseName(validationStatus || \"\")]: validationStatus,\n },\n classNameProp\n )}\n ref={ref}\n style={multilineInputStyles}\n {...other}\n >\n {startAdornment && (\n <div className={withBaseName(\"startAdornmentContainer\")}>\n {startAdornment}\n </div>\n )}\n <textarea\n aria-describedby={clsx(formFieldDescribedBy, textAreaDescribedBy)}\n aria-labelledby={clsx(formFieldLabelledBy, textAreaLabelledBy)}\n className={clsx(withBaseName(\"textarea\"), textAreaProps?.className)}\n disabled={isDisabled}\n id={id}\n readOnly={isReadOnly}\n ref={textAreaRef}\n required={isRequired}\n role={role}\n rows={rows}\n tabIndex={isDisabled ? -1 : 0}\n onBlur={handleBlur}\n onChange={handleChange}\n onFocus={!isDisabled ? handleFocus : undefined}\n placeholder={placeholder}\n value={value}\n {...restA11yProps}\n {...restTextAreaProps}\n />\n <div className={withBaseName(\"suffixAdornments\")}>\n {!isDisabled && !isReadOnly && validationStatus && (\n <div className={withBaseName(\"statusAdornmentContainer\")}>\n <StatusAdornment status={validationStatus} />\n </div>\n )}\n {endAdornment && (\n <div className={withBaseName(\"endAdornmentContainer\")}>\n {endAdornment}\n </div>\n )}\n </div>\n <div className={withBaseName(\"activationIndicator\")} />\n </div>\n );\n }\n);\n"],"names":["MultilineInput","multilineInputCss","value"],"mappings":";;;;;;;;;;;;;;;;AAmBA,MAAM,YAAA,GAAe,aAAa,oBAAoB,CAAA,CAAA;AA8C/C,MAAM,cAAiB,GAAA,UAAA;AAAA,EAC5B,SAASA,eACP,CAAA;AAAA,IACE,uBAAyB,EAAA,oBAAA;AAAA,IACzB,eAAiB,EAAA,YAAA;AAAA,IACjB,WAAa,EAAA,QAAA;AAAA,IACb,QAAW,GAAA,KAAA;AAAA,IACX,SAAW,EAAA,aAAA;AAAA,IACX,QAAA;AAAA,IACA,YAAA;AAAA,IACA,EAAA;AAAA,IACA,WAAA;AAAA,IACA,QAAA;AAAA,IACA,IAAA;AAAA,IACA,IAAO,GAAA,CAAA;AAAA,IACP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AAA,GAAA,CAAA;AAAA,UAC5B,MAAQ,EAAA,UAAA;AAAA,UACR,QAAU,EAAA,YAAA;AAAA,UACV,OAAA,EAAS,CAAC,UAAA,GAAa,WAAc,GAAA,KAAA,CAAA;AAAA,UACrC,WAAA;AAAA,UACA,KAAA;AAAA,UACC,GAAG,aAAA;AAAA,UACH,GAAG,iBAAA;AAAA,SACN,CAAA;AAAA,wBACC,IAAA,CAAA,KAAA,EAAA;AAAA,UAAI,SAAA,EAAW,aAAa,kBAAkB,CAAA;AAAA,UAC5C,QAAA,EAAA;AAAA,YAAA,CAAC,UAAc,IAAA,CAAC,UAAc,IAAA,gBAAA,oBAC5B,GAAA,CAAA,KAAA,EAAA;AAAA,cAAI,SAAA,EAAW,aAAa,0BAA0B,CAAA;AAAA,cACrD,QAAC,kBAAA,GAAA,CAAA,eAAA,EAAA;AAAA,gBAAgB,MAAQ,EAAA,gBAAA;AAAA,eAAkB,CAAA;AAAA,aAC7C,CAAA;AAAA,YAED,gCACE,GAAA,CAAA,KAAA,EAAA;AAAA,cAAI,SAAA,EAAW,aAAa,uBAAuB,CAAA;AAAA,cACjD,QAAA,EAAA,YAAA;AAAA,aACH,CAAA;AAAA,WAAA;AAAA,SAEJ,CAAA;AAAA,wBACC,GAAA,CAAA,KAAA,EAAA;AAAA,UAAI,SAAA,EAAW,aAAa,qBAAqB,CAAA;AAAA,SAAG,CAAA;AAAA,OAAA;AAAA,KACvD,CAAA,CAAA;AAAA,GAEJ;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"MultilineInput.js","sources":["../src/multiline-input/MultilineInput.tsx"],"sourcesContent":["import { clsx } from \"clsx\";\nimport {\n ChangeEvent,\n ComponentPropsWithoutRef,\n FocusEvent,\n forwardRef,\n ReactNode,\n Ref,\n TextareaHTMLAttributes,\n useRef,\n useState,\n} from \"react\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { useFormFieldProps } from \"../form-field-context\";\nimport { StatusAdornment } from \"../status-adornment\";\nimport { makePrefixer, useControlled, useForkRef } from \"../utils\";\n\nimport multilineInputCss from \"./MultilineInput.css\";\n\nconst withBaseName = makePrefixer(\"saltMultilineInput\");\n\nexport interface MultilineInputProps\n extends Omit<ComponentPropsWithoutRef<\"div\">, \"defaultValue\">,\n Pick<\n ComponentPropsWithoutRef<\"textarea\">,\n \"disabled\" | \"value\" | \"defaultValue\" | \"placeholder\"\n > {\n /**\n * Styling variant with full border. Defaults to false\n */\n bordered?: boolean;\n /**\n * End adornment component\n */\n endAdornment?: ReactNode;\n /**\n * If `true`, the component is read only.\n */\n readOnly?: boolean;\n /**\n * Number of rows. Defaults to 3\n */\n rows?: number;\n /**\n * Start adornment component\n */\n startAdornment?: ReactNode;\n /**\n * [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#Attributes) applied to the `textarea` element.\n */\n textAreaProps?: TextareaHTMLAttributes<HTMLTextAreaElement>;\n /**\n * Optional ref for the textarea component\n */\n textAreaRef?: Ref<HTMLTextAreaElement>;\n /**\n * Validation status.\n */\n validationStatus?: \"error\" | \"warning\" | \"success\";\n /**\n * Styling variant. Defaults to \"primary\".\n */\n variant?: \"primary\" | \"secondary\";\n}\n\nexport const MultilineInput = forwardRef<HTMLDivElement, MultilineInputProps>(\n function MultilineInput(\n {\n \"aria-activedescendant\": ariaActiveDescendant,\n \"aria-expanded\": ariaExpanded,\n \"aria-owns\": ariaOwns,\n bordered = false,\n className: classNameProp,\n disabled,\n endAdornment,\n id,\n placeholder,\n readOnly,\n role,\n rows = 3,\n startAdornment,\n style,\n textAreaProps = {},\n textAreaRef,\n value: valueProp,\n defaultValue: defaultValueProp = valueProp === undefined ? \"\" : undefined,\n validationStatus: validationStatusProp,\n variant = \"primary\",\n ...other\n },\n ref\n ) {\n const inputRef = useRef<HTMLTextAreaElement>(null);\n const handleRef = useForkRef(inputRef, textAreaRef);\n\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-multiline-input\",\n css: multilineInputCss,\n window: targetWindow,\n });\n\n const restA11yProps = {\n \"aria-activedescendant\": ariaActiveDescendant,\n \"aria-expanded\": ariaExpanded,\n \"aria-owns\": ariaOwns,\n };\n\n const [focused, setFocused] = useState(false);\n\n const {\n \"aria-describedby\": textAreaDescribedBy,\n \"aria-labelledby\": textAreaLabelledBy,\n onBlur,\n onChange,\n onFocus,\n required: textAreaRequired,\n ...restTextAreaProps\n } = textAreaProps;\n\n const {\n a11yProps: {\n \"aria-describedby\": formFieldDescribedBy,\n \"aria-labelledby\": formFieldLabelledBy,\n } = {},\n disabled: formFieldDisabled,\n readOnly: formFieldReadOnly,\n necessity: formFieldRequired,\n validationStatus: formFieldValidationStatus,\n } = useFormFieldProps();\n\n const isDisabled = disabled || formFieldDisabled;\n const isReadOnly = readOnly || formFieldReadOnly;\n const validationStatus = formFieldValidationStatus ?? validationStatusProp;\n const isRequired = formFieldRequired\n ? [\"required\", \"asterisk\"].includes(formFieldRequired)\n : textAreaRequired;\n\n const [value, setValue] = useControlled({\n controlled: valueProp,\n default: defaultValueProp,\n name: \"MultilineInput\",\n state: \"value\",\n });\n\n const previousHeight = useRef<string | undefined>(undefined);\n\n const handleChange = (event: ChangeEvent<HTMLTextAreaElement>) => {\n const value = event.target.value;\n setValue(value);\n onChange?.(event);\n const input = event.target;\n\n const hasBeenManuallyResized =\n previousHeight.current !== undefined &&\n input.style.height !== previousHeight.current;\n\n if (!hasBeenManuallyResized) {\n const previousOverflow = input.style.overflow;\n input.style.overflow = \"hidden\";\n input.style.height = \"auto\";\n input.scrollHeight; // Needed to work around Firefox bug. https://bugzilla.mozilla.org/show_bug.cgi?id=1787062\n const newHeight = `${\n input.scrollHeight + (input.offsetHeight - input.clientHeight)\n }px`;\n input.style.height = newHeight;\n previousHeight.current = newHeight;\n input.style.overflow = previousOverflow;\n }\n };\n\n const handleBlur = (event: FocusEvent<HTMLTextAreaElement>) => {\n onBlur?.(event);\n setFocused(false);\n };\n\n const handleFocus = (event: FocusEvent<HTMLTextAreaElement>) => {\n onFocus?.(event);\n setFocused(true);\n };\n\n const multilineInputStyles = {\n \"--saltMultilineInput-rows\": rows,\n ...style,\n };\n\n return (\n <div\n className={clsx(\n withBaseName(),\n withBaseName(variant),\n {\n [withBaseName(\"withAdornmentRow\")]: endAdornment,\n [withBaseName(\"bordered\")]: bordered,\n [withBaseName(\"focused\")]: !isDisabled && focused,\n [withBaseName(\"disabled\")]: isDisabled,\n [withBaseName(\"readOnly\")]: isReadOnly,\n [withBaseName(validationStatus ?? \"\")]: validationStatus,\n },\n classNameProp\n )}\n ref={ref}\n style={multilineInputStyles}\n {...other}\n >\n {startAdornment && (\n <div className={withBaseName(\"startAdornmentContainer\")}>\n {startAdornment}\n </div>\n )}\n <textarea\n aria-describedby={clsx(formFieldDescribedBy, textAreaDescribedBy)}\n aria-labelledby={clsx(formFieldLabelledBy, textAreaLabelledBy)}\n className={clsx(withBaseName(\"textarea\"), textAreaProps?.className)}\n disabled={isDisabled}\n id={id}\n readOnly={isReadOnly}\n ref={handleRef}\n required={isRequired}\n role={role}\n rows={rows}\n tabIndex={isDisabled ? -1 : 0}\n onBlur={handleBlur}\n onChange={handleChange}\n onFocus={!isDisabled ? handleFocus : undefined}\n placeholder={placeholder}\n value={value}\n {...restA11yProps}\n {...restTextAreaProps}\n />\n <div className={withBaseName(\"suffixAdornments\")}>\n {!isDisabled && !isReadOnly && validationStatus && (\n <div className={withBaseName(\"statusAdornmentContainer\")}>\n <StatusAdornment status={validationStatus} />\n </div>\n )}\n {endAdornment && (\n <div className={withBaseName(\"endAdornmentContainer\")}>\n {endAdornment}\n </div>\n )}\n </div>\n <div className={withBaseName(\"activationIndicator\")} />\n </div>\n );\n }\n);\n"],"names":["MultilineInput","multilineInputCss","value"],"mappings":";;;;;;;;;;;;;;;;;AAoBA,MAAM,YAAA,GAAe,aAAa,oBAAoB,CAAA,CAAA;AA8C/C,MAAM,cAAiB,GAAA,UAAA;AAAA,EAC5B,SAASA,eAC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A;AAAA,UACR,QAAU,EAAA,YAAA;AAAA,UACV,OAAA,EAAS,CAAC,UAAA,GAAa,WAAc,GAAA,KAAA,CAAA;AAAA,UACrC,WAAA;AAAA,UACA,KAAA;AAAA,UACC,GAAG,aAAA;AAAA,UACH,GAAG,iBAAA;AAAA,SACN,CAAA;AAAA,wBACC,IAAA,CAAA,KAAA,EAAA;AAAA,UAAI,SAAA,EAAW,aAAa,kBAAkB,CAAA;AAAA,UAC5C,QAAA,EAAA;AAAA,YAAA,CAAC,UAAc,IAAA,CAAC,UAAc,IAAA,gBAAA,oBAC5B,GAAA,CAAA,KAAA,EAAA;AAAA,cAAI,SAAA,EAAW,aAAa,0BAA0B,CAAA;AAAA,cACrD,QAAC,kBAAA,GAAA,CAAA,eAAA,EAAA;AAAA,gBAAgB,MAAQ,EAAA,gBAAA;AAAA,eAAkB,CAAA;AAAA,aAC7C,CAAA;AAAA,YAED,gCACE,GAAA,CAAA,KAAA,EAAA;AAAA,cAAI,SAAA,EAAW,aAAa,uBAAuB,CAAA;AAAA,cACjD,QAAA,EAAA,YAAA;AAAA,aACH,CAAA;AAAA,WAAA;AAAA,SAEJ,CAAA;AAAA,wBACC,GAAA,CAAA,KAAA,EAAA;AAAA,UAAI,SAAA,EAAW,aAAa,qBAAqB,CAAA;AAAA,SAAG,CAAA;AAAA,OAAA;AAAA,KACvD,CAAA,CAAA;AAAA,GAEJ;AACF;;;;"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var css_248z = ".saltCircularProgress {\n color: var(--salt-content-primary-foreground);\n display: inline-flex;\n position: relative;\n}\n\n.saltCircularProgress-progressLabel {\n align-items: center;\n color: var(--salt-content-primary-foreground);\n display: flex;\n height: 100%;\n justify-content: center;\n left: 0;\n position: absolute;\n width: 100%;\n}\n\n.saltCircularProgress-track {\n inline-size: calc(var(--salt-size-base) * 3);\n block-size: calc(var(--salt-size-base) * 3);\n border-style: var(--salt-track-borderStyle);\n border-width: var(--salt-size-bar-small);\n border-radius: calc(var(--salt-size-base) * 3);\n border-color: var(--salt-track-borderColor);\n}\n\n.saltCircularProgress-bar {\n inline-size: calc(var(--salt-size-base) * 3);\n block-size: calc(var(--salt-size-base) * 3);\n border-style: var(--salt-track-borderStyle);\n border-width: var(--salt-size-bar-strong);\n border-radius: calc(var(--salt-size-base) * 3);\n border-color: var(--salt-accent-background);\n}\n\n.saltCircularProgress-bars {\n position: absolute;\n inset-block-start: 0;\n inset-inline-start: 0;\n inline-size: 100%;\n block-size: 100%;\n}\n\n.saltCircularProgress-barOverlayRight,\n.saltCircularProgress-barOverlayLeft {\n inline-size: 50%;\n block-size: 100%;\n transform-origin: 100% center;\n transform: rotate(180deg);\n overflow: hidden;\n position: absolute;\n}\n\n.saltCircularProgress-barSubOverlayRight,\n.saltCircularProgress-barSubOverlayLeft {\n inline-size: 100%;\n block-size: 100%;\n transform-origin: 100% center;\n overflow: hidden;\n transform: rotate(-180deg);\n}\n\n.saltCircularProgress-barOverlayLeft {\n transform: rotate(0deg);\n}\n";
|
|
2
|
+
|
|
3
|
+
export { css_248z as default };
|
|
4
|
+
//# sourceMappingURL=CircularProgress.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CircularProgress.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { clsx } from 'clsx';
|
|
4
|
+
import { makePrefixer } from '../../utils/makePrefixer.js';
|
|
5
|
+
import '../../utils/useFloatingUI/useFloatingUI.js';
|
|
6
|
+
import '../../utils/useId.js';
|
|
7
|
+
import '../../salt-provider/SaltProvider.js';
|
|
8
|
+
import '../../viewport/ViewportProvider.js';
|
|
9
|
+
import { Text } from '../../text/Text.js';
|
|
10
|
+
import '../../text/Display.js';
|
|
11
|
+
import '../../text/Headings.js';
|
|
12
|
+
import '../../text/Label.js';
|
|
13
|
+
import '../../text/TextNotation.js';
|
|
14
|
+
import '../../text/TextAction.js';
|
|
15
|
+
import { useWindow } from '@salt-ds/window';
|
|
16
|
+
import { useComponentCssInjection } from '@salt-ds/styles';
|
|
17
|
+
import css_248z from './CircularProgress.css.js';
|
|
18
|
+
|
|
19
|
+
const withBaseName = makePrefixer("saltCircularProgress");
|
|
20
|
+
const CircularProgress = forwardRef(function CircularProgress2({ className, hideLabel = false, max = 100, min = 0, value = 0, ...rest }, ref) {
|
|
21
|
+
const targetWindow = useWindow();
|
|
22
|
+
useComponentCssInjection({
|
|
23
|
+
testId: "salt-circular-progress",
|
|
24
|
+
css: css_248z,
|
|
25
|
+
window: targetWindow
|
|
26
|
+
});
|
|
27
|
+
const subOverlayRightStyle = {};
|
|
28
|
+
const subOverlayLeftStyle = {};
|
|
29
|
+
const getRotationAngle = (progress2, shift = 0) => {
|
|
30
|
+
return -180 + (progress2 - shift) / 50 * 180;
|
|
31
|
+
};
|
|
32
|
+
const progress = (value - min) / (max - min) * 100;
|
|
33
|
+
if (progress <= 50) {
|
|
34
|
+
const rotationAngle = getRotationAngle(progress);
|
|
35
|
+
subOverlayRightStyle.transform = `rotate(${rotationAngle}deg)`;
|
|
36
|
+
subOverlayLeftStyle.transform = "rotate(-180deg)";
|
|
37
|
+
} else {
|
|
38
|
+
const rotationAngle = getRotationAngle(progress, 50);
|
|
39
|
+
subOverlayRightStyle.transform = "rotate(0deg)";
|
|
40
|
+
subOverlayLeftStyle.transform = `rotate(${rotationAngle}deg)`;
|
|
41
|
+
}
|
|
42
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
43
|
+
className: clsx(withBaseName(), className),
|
|
44
|
+
ref,
|
|
45
|
+
role: "progressbar",
|
|
46
|
+
"aria-valuemax": max,
|
|
47
|
+
"aria-valuemin": min,
|
|
48
|
+
"aria-valuenow": Math.round(value),
|
|
49
|
+
...rest,
|
|
50
|
+
children: [
|
|
51
|
+
/* @__PURE__ */ jsx("div", {
|
|
52
|
+
className: withBaseName("track")
|
|
53
|
+
}),
|
|
54
|
+
/* @__PURE__ */ jsxs("div", {
|
|
55
|
+
className: withBaseName("bars"),
|
|
56
|
+
children: [
|
|
57
|
+
/* @__PURE__ */ jsx("div", {
|
|
58
|
+
className: withBaseName("barOverlayRight"),
|
|
59
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
60
|
+
className: withBaseName("barSubOverlayRight"),
|
|
61
|
+
style: subOverlayRightStyle,
|
|
62
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
63
|
+
className: withBaseName("bar")
|
|
64
|
+
})
|
|
65
|
+
})
|
|
66
|
+
}),
|
|
67
|
+
/* @__PURE__ */ jsx("div", {
|
|
68
|
+
className: withBaseName("barOverlayLeft"),
|
|
69
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
70
|
+
className: withBaseName("barSubOverlayLeft"),
|
|
71
|
+
style: subOverlayLeftStyle,
|
|
72
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
73
|
+
className: withBaseName("bar")
|
|
74
|
+
})
|
|
75
|
+
})
|
|
76
|
+
})
|
|
77
|
+
]
|
|
78
|
+
}),
|
|
79
|
+
!hideLabel && /* @__PURE__ */ jsx(Text, {
|
|
80
|
+
styleAs: "h2",
|
|
81
|
+
className: withBaseName("progressLabel"),
|
|
82
|
+
children: `${Math.round(progress)} %`
|
|
83
|
+
})
|
|
84
|
+
]
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
export { CircularProgress };
|
|
89
|
+
//# sourceMappingURL=CircularProgress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CircularProgress.js","sources":["../src/progress/CircularProgress/CircularProgress.tsx"],"sourcesContent":["import { ComponentPropsWithoutRef, CSSProperties, forwardRef } from \"react\";\nimport { clsx } from \"clsx\";\nimport { makePrefixer } from \"../../utils\";\nimport { Text } from \"../../text\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\n\nimport circularProgressCSS from \"./CircularProgress.css\";\n\nconst withBaseName = makePrefixer(\"saltCircularProgress\");\n\nexport interface CircularProgressProps extends ComponentPropsWithoutRef<\"div\"> {\n /**\n * Whether to hide the text label within the progress. Defaults to `false`.\n */\n hideLabel?: boolean;\n /**\n * The value of the max progress indicator.\n * Default value is 100.\n */\n max?: number;\n /**\n * The value of the min progress indicator.\n * Default value is 0.\n */\n min?: number;\n /**\n * The value of the progress indicator.\n * Value between 0 and max.\n */\n value?: number;\n}\n\nexport const CircularProgress = forwardRef<\n HTMLDivElement,\n CircularProgressProps\n>(function CircularProgress(\n { className, hideLabel = false, max = 100, min = 0, value = 0, ...rest },\n ref\n) {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-circular-progress\",\n css: circularProgressCSS,\n window: targetWindow,\n });\n\n const subOverlayRightStyle: CSSProperties = {};\n const subOverlayLeftStyle: CSSProperties = {};\n\n const getRotationAngle = (progress: number, shift = 0) => {\n return -180 + ((progress - shift) / 50) * 180;\n };\n\n const progress = ((value - min) / (max - min)) * 100;\n\n if (progress <= 50) {\n const rotationAngle = getRotationAngle(progress);\n subOverlayRightStyle.transform = `rotate(${rotationAngle}deg)`;\n subOverlayLeftStyle.transform = \"rotate(-180deg)\";\n } else {\n const rotationAngle = getRotationAngle(progress, 50);\n subOverlayRightStyle.transform = \"rotate(0deg)\";\n subOverlayLeftStyle.transform = `rotate(${rotationAngle}deg)`;\n }\n\n return (\n <div\n className={clsx(withBaseName(), className)}\n ref={ref}\n role=\"progressbar\"\n aria-valuemax={max}\n aria-valuemin={min}\n aria-valuenow={Math.round(value)}\n {...rest}\n >\n <div className={withBaseName(\"track\")} />\n <div className={withBaseName(\"bars\")}>\n <div className={withBaseName(\"barOverlayRight\")}>\n <div\n className={withBaseName(\"barSubOverlayRight\")}\n style={subOverlayRightStyle}\n >\n <div className={withBaseName(\"bar\")} />\n </div>\n </div>\n <div className={withBaseName(\"barOverlayLeft\")}>\n <div\n className={withBaseName(\"barSubOverlayLeft\")}\n style={subOverlayLeftStyle}\n >\n <div className={withBaseName(\"bar\")} />\n </div>\n </div>\n </div>\n {!hideLabel && (\n <Text styleAs=\"h2\" className={withBaseName(\"progressLabel\")}>\n {`${Math.round(progress)} %`}\n </Text>\n )}\n </div>\n );\n});\n"],"names":["CircularProgress","circularProgressCSS","progress"],"mappings":";;;;;;;;;;;;;;;;;;AASA,MAAM,YAAA,GAAe,aAAa,sBAAsB,CAAA,CAAA;AAwBjD,MAAM,mBAAmB,UAG9B,CAAA,SAASA,iBACT,CAAA,EAAE,WAAW,SAAY,GAAA,KAAA,EAAO,GAAM,GAAA,GAAA,EAAK,MAAM,CAAG,EAAA,KAAA,GAAQ,CAAM,EAAA,GAAA,IAAA,IAClE,GACA,EAAA;AACA,EAAA,MAAM,eAAe,SAAU,EAAA,CAAA;AAC/B,EAAyB,wBAAA,CAAA;AAAA,IACvB,MAAQ,EAAA,wBAAA;AAAA,IACR,GAAK,EAAAC,QAAA;AAAA,IACL,MAAQ,EAAA,YAAA;AAAA,GACT,CAAA,CAAA;AAED,EAAA,MAAM,uBAAsC,EAAC,CAAA;AAC7C,EAAA,MAAM,sBAAqC,EAAC,CAAA;AAE5C,EAAA,MAAM,gBAAmB,GAAA,CAACC,SAAkB,EAAA,KAAA,GAAQ,CAAM,KAAA;AACxD,IAAO,OAAA,CAAA,GAAA,GAAA,CAASA,SAAW,GAAA,KAAA,IAAS,EAAM,GAAA,GAAA,CAAA;AAAA,GAC5C,CAAA;AAEA,EAAA,MAAM,QAAa,GAAA,CAAA,KAAA,GAAQ,GAAQ,KAAA,GAAA,GAAM,GAAQ,CAAA,GAAA,GAAA,CAAA;AAEjD,EAAA,IAAI,YAAY,EAAI,EAAA;AAClB,IAAM,MAAA,aAAA,GAAgB,iBAAiB,QAAQ,CAAA,CAAA;AAC/C,IAAA,oBAAA,CAAqB,YAAY,CAAU,OAAA,EAAA,aAAA,CAAA,IAAA,CAAA,CAAA;AAC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AAgB,CAAA;AAAA,YAC3C,QAAC,kBAAA,GAAA,CAAA,KAAA,EAAA;AAAA,cACC,SAAA,EAAW,aAAa,mBAAmB,CAAA;AAAA,cAC3C,KAAO,EAAA,mBAAA;AAAA,cAEP,QAAC,kBAAA,GAAA,CAAA,KAAA,EAAA;AAAA,gBAAI,SAAA,EAAW,aAAa,KAAK,CAAA;AAAA,eAAG,CAAA;AAAA,aACvC,CAAA;AAAA,WACF,CAAA;AAAA,SAAA;AAAA,OACF,CAAA;AAAA,MACC,CAAC,6BACC,GAAA,CAAA,IAAA,EAAA;AAAA,QAAK,OAAQ,EAAA,IAAA;AAAA,QAAK,SAAA,EAAW,aAAa,eAAe,CAAA;AAAA,QACvD,QAAA,EAAA,CAAA,EAAG,IAAK,CAAA,KAAA,CAAM,QAAQ,CAAA,CAAA,EAAA,CAAA;AAAA,OACzB,CAAA;AAAA,KAAA;AAAA,GAEJ,CAAA,CAAA;AAEJ,CAAC;;;;"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var css_248z = ".saltLinearProgress {\n align-items: center;\n color: var(--salt-content-primary-foreground);\n display: flex;\n min-width: 400px;\n font-size: var(--linearProgress-fontSize);\n}\n\n.saltLinearProgress-barContainer {\n background: none;\n position: relative;\n width: 100%;\n overflow: hidden;\n height: var(--salt-size-bar-strong);\n}\n\n.saltLinearProgress-bar {\n width: 100%;\n position: absolute;\n left: 0;\n bottom: 0;\n top: 0;\n transition: transform 0.2s linear;\n transform-origin: left;\n background: var(--salt-accent-background);\n z-index: 2;\n}\n\n.saltLinearProgress-track {\n background: var(--salt-track-borderColor);\n width: 100%;\n height: var(--salt-size-bar-small);\n position: absolute;\n top: calc((var(--salt-size-bar-strong) - var(--salt-size-bar-small)) / 2);\n transition: transform 0.2s linear;\n transform-origin: left;\n}\n\n.saltLinearProgress-progressLabel {\n color: inherit;\n margin: 0;\n white-space: nowrap;\n padding-left: var(--salt-spacing-100);\n}\n";
|
|
2
|
+
|
|
3
|
+
export { css_248z as default };
|
|
4
|
+
//# sourceMappingURL=LinearProgress.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LinearProgress.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { clsx } from 'clsx';
|
|
4
|
+
import { makePrefixer } from '../../utils/makePrefixer.js';
|
|
5
|
+
import '../../utils/useFloatingUI/useFloatingUI.js';
|
|
6
|
+
import '../../utils/useId.js';
|
|
7
|
+
import '../../salt-provider/SaltProvider.js';
|
|
8
|
+
import '../../viewport/ViewportProvider.js';
|
|
9
|
+
import { Text } from '../../text/Text.js';
|
|
10
|
+
import '../../text/Display.js';
|
|
11
|
+
import '../../text/Headings.js';
|
|
12
|
+
import '../../text/Label.js';
|
|
13
|
+
import '../../text/TextNotation.js';
|
|
14
|
+
import '../../text/TextAction.js';
|
|
15
|
+
import { useWindow } from '@salt-ds/window';
|
|
16
|
+
import { useComponentCssInjection } from '@salt-ds/styles';
|
|
17
|
+
import css_248z from './LinearProgress.css.js';
|
|
18
|
+
|
|
19
|
+
const withBaseName = makePrefixer("saltLinearProgress");
|
|
20
|
+
const LinearProgress = forwardRef(
|
|
21
|
+
function LinearProgress2({ className, hideLabel = false, max = 100, min = 0, value = 0, ...rest }, ref) {
|
|
22
|
+
const targetWindow = useWindow();
|
|
23
|
+
useComponentCssInjection({
|
|
24
|
+
testId: "salt-linear-progress",
|
|
25
|
+
css: css_248z,
|
|
26
|
+
window: targetWindow
|
|
27
|
+
});
|
|
28
|
+
const progress = (value - min) / (max - min) * 100;
|
|
29
|
+
const barStyle = {};
|
|
30
|
+
const trackStyle = {};
|
|
31
|
+
barStyle.transform = `translateX(${progress - 100}%)`;
|
|
32
|
+
trackStyle.transform = `translateX(${progress}%)`;
|
|
33
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
34
|
+
className: clsx(withBaseName(), className),
|
|
35
|
+
ref,
|
|
36
|
+
role: "progressbar",
|
|
37
|
+
"aria-valuemax": max,
|
|
38
|
+
"aria-valuemin": min,
|
|
39
|
+
"aria-valuenow": Math.round(value),
|
|
40
|
+
...rest,
|
|
41
|
+
children: [
|
|
42
|
+
/* @__PURE__ */ jsxs("div", {
|
|
43
|
+
className: withBaseName("barContainer"),
|
|
44
|
+
children: [
|
|
45
|
+
/* @__PURE__ */ jsx("div", {
|
|
46
|
+
className: withBaseName("bar"),
|
|
47
|
+
style: barStyle
|
|
48
|
+
}),
|
|
49
|
+
/* @__PURE__ */ jsx("div", {
|
|
50
|
+
className: withBaseName("track"),
|
|
51
|
+
style: trackStyle
|
|
52
|
+
})
|
|
53
|
+
]
|
|
54
|
+
}),
|
|
55
|
+
!hideLabel && /* @__PURE__ */ jsx(Text, {
|
|
56
|
+
styleAs: "h2",
|
|
57
|
+
className: withBaseName("progressLabel"),
|
|
58
|
+
children: `${Math.round(progress)} %`
|
|
59
|
+
})
|
|
60
|
+
]
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
export { LinearProgress };
|
|
66
|
+
//# sourceMappingURL=LinearProgress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LinearProgress.js","sources":["../src/progress/LinearProgress/LinearProgress.tsx"],"sourcesContent":["import { ComponentPropsWithoutRef, CSSProperties, forwardRef } from \"react\";\nimport { clsx } from \"clsx\";\nimport { makePrefixer } from \"../../utils\";\nimport { Text } from \"../../text\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\n\nimport linearProgressCss from \"./LinearProgress.css\";\n\nconst withBaseName = makePrefixer(\"saltLinearProgress\");\n\nexport interface LinearProgressProps extends ComponentPropsWithoutRef<\"div\"> {\n /**\n * Whether to hide the text label within the progress. Defaults to `false`.\n */\n hideLabel?: boolean;\n /**\n * The value of the max progress indicator.\n * Default value is 100.\n */\n max?: number;\n /**\n * The value of the min progress indicator.\n * Default value is 0.\n */\n min?: number;\n /**\n * The value of the progress indicator.\n * Value between 0 and max.\n */\n value?: number;\n}\n\nexport const LinearProgress = forwardRef<HTMLDivElement, LinearProgressProps>(\n function LinearProgress(\n { className, hideLabel = false, max = 100, min = 0, value = 0, ...rest },\n ref\n ) {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-linear-progress\",\n css: linearProgressCss,\n window: targetWindow,\n });\n\n const progress = ((value - min) / (max - min)) * 100;\n\n const barStyle: CSSProperties = {};\n const trackStyle: CSSProperties = {};\n\n barStyle.transform = `translateX(${progress - 100}%)`;\n trackStyle.transform = `translateX(${progress}%)`;\n\n return (\n <div\n className={clsx(withBaseName(), className)}\n ref={ref}\n role=\"progressbar\"\n aria-valuemax={max}\n aria-valuemin={min}\n aria-valuenow={Math.round(value)}\n {...rest}\n >\n <div className={withBaseName(\"barContainer\")}>\n <div className={withBaseName(\"bar\")} style={barStyle} />\n <div className={withBaseName(\"track\")} style={trackStyle} />\n </div>\n {!hideLabel && (\n <Text styleAs=\"h2\" className={withBaseName(\"progressLabel\")}>\n {`${Math.round(progress)} %`}\n </Text>\n )}\n </div>\n );\n }\n);\n"],"names":["LinearProgress","linearProgressCss"],"mappings":";;;;;;;;;;;;;;;;;;AASA,MAAM,YAAA,GAAe,aAAa,oBAAoB,CAAA,CAAA;AAwB/C,MAAM,cAAiB,GAAA,UAAA;AAAA,EAC5B,SAASA,eAAAA,CACP,EAAE,SAAA,EAAW,YAAY,KAAO,EAAA,GAAA,GAAM,GAAK,EAAA,GAAA,GAAM,CAAG,EAAA,KAAA,GAAQ,CAAM,EAAA,GAAA,IAAA,IAClE,GACA,EAAA;AACA,IAAA,MAAM,eAAe,SAAU,EAAA,CAAA;AAC/B,IAAyB,wBAAA,CAAA;AAAA,MACvB,MAAQ,EAAA,sBAAA;AAAA,MACR,GAAK,EAAAC,QAAA;A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A,UACvD,QAAA,EAAA,CAAA,EAAG,IAAK,CAAA,KAAA,CAAM,QAAQ,CAAA,CAAA,EAAA,CAAA;AAAA,SACzB,CAAA;AAAA,OAAA;AAAA,KAEJ,CAAA,CAAA;AAAA,GAEJ;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFloatingUI.js","sources":["../src/utils/useFloatingUI/useFloatingUI.tsx"],"sourcesContent":["import {\n Middleware,\n Placement,\n Platform,\n Strategy,\n autoUpdate,\n flip,\n limitShift,\n platform,\n shift,\n useFloating,\n FloatingPortal,\n FloatingFocusManager,\n FloatingFocusManagerProps,\n} from \"@floating-ui/react\";\n\nimport {\n createContext,\n ReactNode,\n useContext,\n useMemo,\n forwardRef,\n ComponentPropsWithoutRef,\n} from \"react\";\n\nimport { SaltProvider } from \"../../salt-provider\";\n\nexport interface FloatingComponentProps\n extends ComponentPropsWithoutRef<\"div\"> {\n /**\n * Whether the floating component is open (used for determining whether to show the component)\n * We pass this as a prop rather than not rendering the component to allow more advanced use-cases e.g.\n * for caching windows and reusing them, rather than always spawning a new one\n */\n open: boolean;\n /**\n * Use this prop when `FloatingFocusManager` is needed for floating component\n */\n focusManagerProps?: Omit<FloatingFocusManagerProps, \"children\">;\n /**\n * Position props for the floating component\n */\n top
|
|
1
|
+
{"version":3,"file":"useFloatingUI.js","sources":["../src/utils/useFloatingUI/useFloatingUI.tsx"],"sourcesContent":["import {\n Middleware,\n Placement,\n Platform,\n Strategy,\n autoUpdate,\n flip,\n limitShift,\n platform,\n shift,\n useFloating,\n FloatingPortal,\n FloatingFocusManager,\n FloatingFocusManagerProps,\n} from \"@floating-ui/react\";\n\nimport {\n createContext,\n ReactNode,\n useContext,\n useMemo,\n forwardRef,\n ComponentPropsWithoutRef,\n} from \"react\";\n\nimport { SaltProvider } from \"../../salt-provider\";\n\nexport interface FloatingComponentProps\n extends ComponentPropsWithoutRef<\"div\"> {\n /**\n * Whether the floating component is open (used for determining whether to show the component)\n * We pass this as a prop rather than not rendering the component to allow more advanced use-cases e.g.\n * for caching windows and reusing them, rather than always spawning a new one\n */\n open: boolean;\n /**\n * Use this prop when `FloatingFocusManager` is needed for floating component\n */\n focusManagerProps?: Omit<FloatingFocusManagerProps, \"children\">;\n /**\n * Position props for the floating component\n */\n top?: number;\n left?: number;\n width?: number;\n height?: number;\n position?: Strategy;\n}\n\nconst DefaultFloatingComponent = forwardRef<\n HTMLDivElement,\n FloatingComponentProps\n>(function DefaultFloatingComponent(props, ref) {\n const {\n open,\n top,\n left,\n position,\n /* eslint-disable @typescript-eslint/no-unused-vars */\n width,\n height,\n /* eslint-enable @typescript-eslint/no-unused-vars */\n focusManagerProps,\n ...rest\n } = props;\n const style = {\n top,\n left,\n position,\n };\n\n if (focusManagerProps) {\n return (\n <FloatingPortal>\n <SaltProvider>\n <FloatingFocusManager {...focusManagerProps}>\n <div style={style} {...rest} ref={ref} />\n </FloatingFocusManager>\n </SaltProvider>\n </FloatingPortal>\n );\n }\n\n return open ? (\n <FloatingPortal>\n <SaltProvider>\n <div style={style} {...rest} ref={ref} />\n </SaltProvider>\n </FloatingPortal>\n ) : null;\n});\n\nexport interface FloatingComponentContextType {\n Component: typeof DefaultFloatingComponent;\n}\n\nconst FloatingComponentContext = createContext<FloatingComponentContextType>({\n Component: DefaultFloatingComponent,\n});\n\nif (process.env.NODE_ENV !== \"production\") {\n FloatingComponentContext.displayName = \"FloatingComponentContext\";\n}\n\nexport interface FloatingComponentProviderProps\n extends FloatingComponentContextType {\n children: ReactNode;\n}\n\nexport function FloatingComponentProvider(\n props: FloatingComponentProviderProps\n) {\n const { Component, children } = props;\n const value = useMemo(() => ({ Component }), [Component]);\n\n return (\n <FloatingComponentContext.Provider value={value}>\n {children}\n </FloatingComponentContext.Provider>\n );\n}\n\nexport function useFloatingComponent() {\n return useContext(FloatingComponentContext);\n}\n\nexport interface UseFloatingUIProps {\n /**\n * Sets position relative to trigger.\n */\n placement?: Placement;\n strategy?: Strategy;\n /**\n * Function to update the default middleware used to extend or replace it\n */\n middleware?: Middleware[];\n /**\n * Sets visible state.\n */\n open?: boolean;\n /**\n * Callback function triggered when open state changes.\n */\n onOpenChange?: (open: boolean) => void;\n}\n\ntype GetMiddleware = (middleware: Middleware[]) => Middleware[];\n\nconst defaultGetMiddleware: GetMiddleware = (defaultMiddleware) =>\n defaultMiddleware;\n\ninterface FloatingPlatformContextType {\n platform: Platform;\n middleware: GetMiddleware;\n animationFrame: boolean;\n}\n\nconst defaultFloatingPlaform: FloatingPlatformContextType = {\n platform,\n middleware: defaultGetMiddleware,\n animationFrame: false,\n};\n\nconst FloatingPlatformContext = createContext<FloatingPlatformContextType>(\n defaultFloatingPlaform\n);\n\nexport interface FloatingPlatformProviderProps {\n platform?: Platform;\n middleware?: GetMiddleware;\n children: ReactNode;\n animationFrame?: boolean;\n}\n\nexport function FloatingPlatformProvider(props: FloatingPlatformProviderProps) {\n const {\n platform: platformProp,\n middleware,\n animationFrame,\n children,\n } = props;\n\n const floatingPlatformContextValue = useMemo<FloatingPlatformContextType>(\n () => ({\n platform: platformProp ?? platform,\n middleware: middleware ?? defaultGetMiddleware,\n animationFrame: animationFrame || false,\n }),\n [platformProp, middleware, animationFrame]\n );\n\n return (\n <FloatingPlatformContext.Provider value={floatingPlatformContextValue}>\n {children}\n </FloatingPlatformContext.Provider>\n );\n}\n\nexport function useFloatingPlatform() {\n return useContext(FloatingPlatformContext);\n}\n\nexport const DEFAULT_FLOATING_UI_MIDDLEWARE = [\n flip(),\n shift({ limiter: limitShift() }),\n];\n\ntype UseFloatingRefs = ReturnType<typeof useFloating>[\"refs\"];\n\nexport interface UseFloatingUIReturn extends ReturnType<typeof useFloating> {\n reference: UseFloatingRefs[\"setReference\"];\n floating: UseFloatingRefs[\"setFloating\"];\n}\n\nexport function useFloatingUI(props: UseFloatingUIProps): UseFloatingUIReturn {\n const {\n placement,\n strategy,\n middleware = DEFAULT_FLOATING_UI_MIDDLEWARE,\n open = false,\n onOpenChange,\n } = props;\n\n const handleOpenChange = (open: boolean) => {\n update();\n onOpenChange?.(open);\n };\n\n const {\n platform: contextPlatform,\n middleware: contextMiddleware,\n animationFrame,\n } = useFloatingPlatform();\n\n const { refs, update, ...rest } = useFloating({\n placement,\n strategy,\n middleware: contextMiddleware(middleware),\n open,\n onOpenChange: handleOpenChange,\n whileElementsMounted: (...args) => {\n const cleanup = autoUpdate(...args, { animationFrame });\n\n return cleanup;\n },\n platform: contextPlatform,\n });\n\n return {\n reference: refs.setReference,\n floating: refs.setFloating,\n refs,\n update,\n ...rest,\n };\n}\n"],"names":["DefaultFloatingComponent","open"],"mappings":";;;;;AAiDA,MAAM,wBAA2B,GAAA,UAAA,CAG/B,SAASA,yBAAAA,CAAyB,OAAO,GAAK,EAAA;AAC9C,EAAM,MAAA;AAAA,IACJ,IAAA;AAAA,IACA,GAAA;AAAA,IACA,IAAA;AAAA,IACA,QAAA;AAAA,IAEA,KAAA;AAAA,IACA,MAAA;AAAA,IAEA,iBAAA;AAAA,IACG,GAAA,IAAA;AAAA,GACD,GAAA,KAAA,CAAA;AACJ,EAAA,MAAM,KAAQ,GAAA;AAAA,IACZ,GAAA;AAAA,IACA,IAAA;AAAA,IACA,QAAA;AAAA,GACF,CAAA;AAEA,EAAA,IAAI,iBAAmB,EAAA;AACrB,IAAA,uBACG,GAAA,CAAA,cAAA,EAAA;AAAA,MACC,QAAC,kBAAA,GAAA,CAAA,YAAA,EAAA;AAAA,QACC,QAAC,kBAAA,GAAA,CAAA,oBAAA,EAAA;AAAA,UAAsB,GAAG,iBAAA;AAAA,UACxB,QAAC,kBAAA,GAAA,CAAA,KAAA,EAAA;AAAA,YAAI,KAAA;AAAA,YAAe,GAAG,IAAA;AAAA,YAAM,GAAA;AAAA,WAAU,CAAA;AAAA,SACzC,CAAA;AAAA,OACF,CAAA;AAAA,KACF,CAAA,CAAA;AAAA,GAEJ;AAEA,EAAA,OAAO,uBACJ,GAAA,CAAA,cAAA,EAAA;AAAA,IACC,QAAC,k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AA,EAAM,MAAW,EAAA,GAAA,IAAA,KAAS,WAAY,CAAA;AAAA,IAC5C,SAAA;AAAA,IACA,QAAA;AAAA,IACA,UAAA,EAAY,kBAAkB,UAAU,CAAA;AAAA,IACxC,IAAA;AAAA,IACA,YAAc,EAAA,gBAAA;AAAA,IACd,oBAAA,EAAsB,IAAI,IAAS,KAAA;AACjC,MAAA,MAAM,UAAU,UAAW,CAAA,GAAG,IAAM,EAAA,EAAE,gBAAgB,CAAA,CAAA;AAEtD,MAAO,OAAA,OAAA,CAAA;AAAA,KACT;AAAA,IACA,QAAU,EAAA,eAAA;AAAA,GACX,CAAA,CAAA;AAED,EAAO,OAAA;AAAA,IACL,WAAW,IAAK,CAAA,YAAA;AAAA,IAChB,UAAU,IAAK,CAAA,WAAA;AAAA,IACf,IAAA;AAAA,IACA,MAAA;AAAA,IACA,GAAG,IAAA;AAAA,GACL,CAAA;AACF;;;;"}
|
package/dist-types/index.d.ts
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef } from "react";
|
|
2
|
+
export interface CircularProgressProps extends ComponentPropsWithoutRef<"div"> {
|
|
3
|
+
/**
|
|
4
|
+
* Whether to hide the text label within the progress. Defaults to `false`.
|
|
5
|
+
*/
|
|
6
|
+
hideLabel?: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* The value of the max progress indicator.
|
|
9
|
+
* Default value is 100.
|
|
10
|
+
*/
|
|
11
|
+
max?: number;
|
|
12
|
+
/**
|
|
13
|
+
* The value of the min progress indicator.
|
|
14
|
+
* Default value is 0.
|
|
15
|
+
*/
|
|
16
|
+
min?: number;
|
|
17
|
+
/**
|
|
18
|
+
* The value of the progress indicator.
|
|
19
|
+
* Value between 0 and max.
|
|
20
|
+
*/
|
|
21
|
+
value?: number;
|
|
22
|
+
}
|
|
23
|
+
export declare const CircularProgress: import("react").ForwardRefExoticComponent<CircularProgressProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef } from "react";
|
|
2
|
+
export interface LinearProgressProps extends ComponentPropsWithoutRef<"div"> {
|
|
3
|
+
/**
|
|
4
|
+
* Whether to hide the text label within the progress. Defaults to `false`.
|
|
5
|
+
*/
|
|
6
|
+
hideLabel?: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* The value of the max progress indicator.
|
|
9
|
+
* Default value is 100.
|
|
10
|
+
*/
|
|
11
|
+
max?: number;
|
|
12
|
+
/**
|
|
13
|
+
* The value of the min progress indicator.
|
|
14
|
+
* Default value is 0.
|
|
15
|
+
*/
|
|
16
|
+
min?: number;
|
|
17
|
+
/**
|
|
18
|
+
* The value of the progress indicator.
|
|
19
|
+
* Value between 0 and max.
|
|
20
|
+
*/
|
|
21
|
+
value?: number;
|
|
22
|
+
}
|
|
23
|
+
export declare const LinearProgress: import("react").ForwardRefExoticComponent<LinearProgressProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -14,11 +14,11 @@ export interface FloatingComponentProps extends ComponentPropsWithoutRef<"div">
|
|
|
14
14
|
/**
|
|
15
15
|
* Position props for the floating component
|
|
16
16
|
*/
|
|
17
|
-
top
|
|
18
|
-
left
|
|
17
|
+
top?: number;
|
|
18
|
+
left?: number;
|
|
19
19
|
width?: number;
|
|
20
20
|
height?: number;
|
|
21
|
-
position
|
|
21
|
+
position?: Strategy;
|
|
22
22
|
}
|
|
23
23
|
declare const DefaultFloatingComponent: import("react").ForwardRefExoticComponent<FloatingComponentProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
24
24
|
export interface FloatingComponentContextType {
|