@elliemae/ds-form 3.5.0-rc.9 → 3.5.1-next.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/dist/cjs/CheckboxGroup/DSCheckboxGroup.js +31 -27
- package/dist/cjs/CheckboxGroup/DSCheckboxGroup.js.map +1 -1
- package/dist/cjs/ComboBoxFreeSolo/ComboBoxFreeSolo.js +2 -2
- package/dist/cjs/ComboBoxFreeSolo/ComboBoxFreeSolo.js.map +2 -2
- package/dist/cjs/ComboBoxFreeSolo/components/MultiValueLabel.js +13 -5
- package/dist/cjs/ComboBoxFreeSolo/components/MultiValueLabel.js.map +2 -2
- package/dist/cjs/ComboBoxFreeSolo/components/MultiValueRemove.js +7 -4
- package/dist/cjs/ComboBoxFreeSolo/components/MultiValueRemove.js.map +2 -2
- package/dist/cjs/ComboBoxFreeSolo/components/SingleValue.js +6 -5
- package/dist/cjs/ComboBoxFreeSolo/components/SingleValue.js.map +2 -2
- package/dist/cjs/ComboBoxFreeSolo/components/SingleValueRemove.js +14 -13
- package/dist/cjs/ComboBoxFreeSolo/components/SingleValueRemove.js.map +2 -2
- package/dist/cjs/DateInput/DSDateInput.js +4 -3
- package/dist/cjs/DateInput/DSDateInput.js.map +2 -2
- package/dist/cjs/DateInput/components/DateInputImpl.js +19 -17
- package/dist/cjs/DateInput/components/DateInputImpl.js.map +2 -2
- package/dist/cjs/DateInput/components/DateInputs.js +15 -12
- package/dist/cjs/DateInput/components/DateInputs.js.map +1 -1
- package/dist/cjs/DateInputV2/components/DSDateInput.js +3 -3
- package/dist/cjs/DateInputV2/components/DSDateInput.js.map +2 -2
- package/dist/cjs/DateInputV2/components/DateInputs.js +19 -13
- package/dist/cjs/DateInputV2/components/DateInputs.js.map +1 -1
- package/dist/cjs/ExpandableInput/DSExpandableInput.js +5 -4
- package/dist/cjs/ExpandableInput/DSExpandableInput.js.map +2 -2
- package/dist/cjs/ExpandableInput/ExpandableInputImpl.js +16 -13
- package/dist/cjs/ExpandableInput/ExpandableInputImpl.js.map +1 -1
- package/dist/cjs/FloatingLabelInput/DSFloatingLabelInput.js +2 -2
- package/dist/cjs/FloatingLabelInput/DSFloatingLabelInput.js.map +2 -2
- package/dist/cjs/FloatingLabelInput/FloatingLabelInputImpl.js +31 -16
- package/dist/cjs/FloatingLabelInput/FloatingLabelInputImpl.js.map +1 -1
- package/dist/cjs/FormItem/DSFormItemLayout.js +64 -34
- package/dist/cjs/FormItem/DSFormItemLayout.js.map +2 -2
- package/dist/cjs/FormItem/Error/DSError.js +5 -4
- package/dist/cjs/FormItem/Error/DSError.js.map +2 -2
- package/dist/cjs/FormItem/Feedback.js +5 -4
- package/dist/cjs/FormItem/Feedback.js.map +2 -2
- package/dist/cjs/FormItem/Label/DSLabel.js +15 -9
- package/dist/cjs/FormItem/Label/DSLabel.js.map +2 -2
- package/dist/cjs/InputGroup/AddonWrapper.js +14 -4
- package/dist/cjs/InputGroup/AddonWrapper.js.map +2 -2
- package/dist/cjs/InputGroup/DSInputGroup.js +5 -4
- package/dist/cjs/InputGroup/DSInputGroup.js.map +2 -2
- package/dist/cjs/InputMask/DSInputMask.js +3 -2
- package/dist/cjs/InputMask/DSInputMask.js.map +2 -2
- package/dist/cjs/InputMask/DSInputMaskDeprecated.js +2 -1
- package/dist/cjs/InputMask/DSInputMaskDeprecated.js.map +1 -1
- package/dist/cjs/InputMask/mask_types/DateInputMask.js +3 -2
- package/dist/cjs/InputMask/mask_types/DateInputMask.js.map +2 -2
- package/dist/cjs/InputMask/mask_types/DateTimeInputMask.js +3 -2
- package/dist/cjs/InputMask/mask_types/DateTimeInputMask.js.map +2 -2
- package/dist/cjs/InputMask/mask_types/DictionaryInputMask.js +3 -2
- package/dist/cjs/InputMask/mask_types/DictionaryInputMask.js.map +2 -2
- package/dist/cjs/InputMask/mask_types/NumberInputMask.js +3 -2
- package/dist/cjs/InputMask/mask_types/NumberInputMask.js.map +2 -2
- package/dist/cjs/InputMask/mask_types/PhoneInputMask.js +3 -2
- package/dist/cjs/InputMask/mask_types/PhoneInputMask.js.map +2 -2
- package/dist/cjs/InputMask/mask_types/PhoneInternationalInputMask.js +3 -2
- package/dist/cjs/InputMask/mask_types/PhoneInternationalInputMask.js.map +2 -2
- package/dist/cjs/InputMask/mask_types/SsnInputMask.js +3 -2
- package/dist/cjs/InputMask/mask_types/SsnInputMask.js.map +2 -2
- package/dist/cjs/InputMask/mask_types/UsZipCodeInputMask.js +3 -2
- package/dist/cjs/InputMask/mask_types/UsZipCodeInputMask.js.map +2 -2
- package/dist/cjs/InputMask/mask_types/ZipCodeSearchInputMask.js +3 -2
- package/dist/cjs/InputMask/mask_types/ZipCodeSearchInputMask.js.map +2 -2
- package/dist/cjs/InputMask/mask_types/index.js +11 -11
- package/dist/cjs/InputMask/mask_types/index.js.map +2 -2
- package/dist/cjs/InputProtected/DSInputProtected.js +34 -30
- package/dist/cjs/InputProtected/DSInputProtected.js.map +2 -2
- package/dist/cjs/LargeInputText/DSLargeInputText.js +49 -40
- package/dist/cjs/LargeInputText/DSLargeInputText.js.map +2 -2
- package/dist/cjs/Radio/Circle.js +10 -9
- package/dist/cjs/Radio/Circle.js.map +2 -2
- package/dist/cjs/Radio/DSRadio.js +61 -48
- package/dist/cjs/Radio/DSRadio.js.map +2 -2
- package/dist/cjs/RadioGroup/DSRadioGroup.js +32 -28
- package/dist/cjs/RadioGroup/DSRadioGroup.js.map +1 -1
- package/dist/cjs/RequiredMark/RequiredMark.js +9 -7
- package/dist/cjs/RequiredMark/RequiredMark.js.map +2 -2
- package/dist/cjs/TimeInput/DSTimeInput.js +3 -3
- package/dist/cjs/TimeInput/DSTimeInput.js.map +2 -2
- package/dist/cjs/TimeInput/TimeInputImpl.js +17 -15
- package/dist/cjs/TimeInput/TimeInputImpl.js.map +2 -2
- package/dist/cjs/TimeInput/TimeInputs.js +16 -13
- package/dist/cjs/TimeInput/TimeInputs.js.map +2 -2
- package/dist/cjs/Toggle/DSToggle.js +2 -2
- package/dist/cjs/Toggle/DSToggle.js.map +2 -2
- package/dist/cjs/Toggle/DSToggleImpl.js +2 -1
- package/dist/cjs/Toggle/DSToggleImpl.js.map +1 -1
- package/dist/cjs/Toggle/DSToggleRender.js +42 -34
- package/dist/cjs/Toggle/DSToggleRender.js.map +2 -2
- package/dist/esm/CheckboxGroup/DSCheckboxGroup.js +31 -27
- package/dist/esm/CheckboxGroup/DSCheckboxGroup.js.map +1 -1
- package/dist/esm/ComboBoxFreeSolo/ComboBoxFreeSolo.js +2 -2
- package/dist/esm/ComboBoxFreeSolo/ComboBoxFreeSolo.js.map +2 -2
- package/dist/esm/ComboBoxFreeSolo/components/MultiValueLabel.js +13 -5
- package/dist/esm/ComboBoxFreeSolo/components/MultiValueLabel.js.map +2 -2
- package/dist/esm/ComboBoxFreeSolo/components/MultiValueRemove.js +7 -4
- package/dist/esm/ComboBoxFreeSolo/components/MultiValueRemove.js.map +2 -2
- package/dist/esm/ComboBoxFreeSolo/components/SingleValue.js +6 -5
- package/dist/esm/ComboBoxFreeSolo/components/SingleValue.js.map +2 -2
- package/dist/esm/ComboBoxFreeSolo/components/SingleValueRemove.js +14 -13
- package/dist/esm/ComboBoxFreeSolo/components/SingleValueRemove.js.map +2 -2
- package/dist/esm/DateInput/DSDateInput.js +4 -3
- package/dist/esm/DateInput/DSDateInput.js.map +2 -2
- package/dist/esm/DateInput/components/DateInputImpl.js +19 -17
- package/dist/esm/DateInput/components/DateInputImpl.js.map +2 -2
- package/dist/esm/DateInput/components/DateInputs.js +15 -12
- package/dist/esm/DateInput/components/DateInputs.js.map +1 -1
- package/dist/esm/DateInputV2/components/DSDateInput.js +3 -3
- package/dist/esm/DateInputV2/components/DSDateInput.js.map +2 -2
- package/dist/esm/DateInputV2/components/DateInputs.js +19 -13
- package/dist/esm/DateInputV2/components/DateInputs.js.map +1 -1
- package/dist/esm/ExpandableInput/DSExpandableInput.js +5 -4
- package/dist/esm/ExpandableInput/DSExpandableInput.js.map +2 -2
- package/dist/esm/ExpandableInput/ExpandableInputImpl.js +16 -13
- package/dist/esm/ExpandableInput/ExpandableInputImpl.js.map +1 -1
- package/dist/esm/FloatingLabelInput/DSFloatingLabelInput.js +2 -2
- package/dist/esm/FloatingLabelInput/DSFloatingLabelInput.js.map +2 -2
- package/dist/esm/FloatingLabelInput/FloatingLabelInputImpl.js +31 -16
- package/dist/esm/FloatingLabelInput/FloatingLabelInputImpl.js.map +1 -1
- package/dist/esm/FormItem/DSFormItemLayout.js +64 -34
- package/dist/esm/FormItem/DSFormItemLayout.js.map +2 -2
- package/dist/esm/FormItem/Error/DSError.js +5 -4
- package/dist/esm/FormItem/Error/DSError.js.map +2 -2
- package/dist/esm/FormItem/Feedback.js +5 -4
- package/dist/esm/FormItem/Feedback.js.map +2 -2
- package/dist/esm/FormItem/Label/DSLabel.js +15 -9
- package/dist/esm/FormItem/Label/DSLabel.js.map +2 -2
- package/dist/esm/InputGroup/AddonWrapper.js +14 -4
- package/dist/esm/InputGroup/AddonWrapper.js.map +2 -2
- package/dist/esm/InputGroup/DSInputGroup.js +5 -4
- package/dist/esm/InputGroup/DSInputGroup.js.map +2 -2
- package/dist/esm/InputMask/DSInputMask.js +3 -2
- package/dist/esm/InputMask/DSInputMask.js.map +2 -2
- package/dist/esm/InputMask/DSInputMaskDeprecated.js +2 -1
- package/dist/esm/InputMask/DSInputMaskDeprecated.js.map +1 -1
- package/dist/esm/InputMask/mask_types/DateInputMask.js +3 -2
- package/dist/esm/InputMask/mask_types/DateInputMask.js.map +2 -2
- package/dist/esm/InputMask/mask_types/DateTimeInputMask.js +3 -2
- package/dist/esm/InputMask/mask_types/DateTimeInputMask.js.map +2 -2
- package/dist/esm/InputMask/mask_types/DictionaryInputMask.js +3 -2
- package/dist/esm/InputMask/mask_types/DictionaryInputMask.js.map +2 -2
- package/dist/esm/InputMask/mask_types/NumberInputMask.js +3 -2
- package/dist/esm/InputMask/mask_types/NumberInputMask.js.map +2 -2
- package/dist/esm/InputMask/mask_types/PhoneInputMask.js +3 -2
- package/dist/esm/InputMask/mask_types/PhoneInputMask.js.map +2 -2
- package/dist/esm/InputMask/mask_types/PhoneInternationalInputMask.js +3 -2
- package/dist/esm/InputMask/mask_types/PhoneInternationalInputMask.js.map +2 -2
- package/dist/esm/InputMask/mask_types/SsnInputMask.js +3 -2
- package/dist/esm/InputMask/mask_types/SsnInputMask.js.map +2 -2
- package/dist/esm/InputMask/mask_types/UsZipCodeInputMask.js +3 -2
- package/dist/esm/InputMask/mask_types/UsZipCodeInputMask.js.map +2 -2
- package/dist/esm/InputMask/mask_types/ZipCodeSearchInputMask.js +3 -2
- package/dist/esm/InputMask/mask_types/ZipCodeSearchInputMask.js.map +2 -2
- package/dist/esm/InputMask/mask_types/index.js +11 -11
- package/dist/esm/InputMask/mask_types/index.js.map +2 -2
- package/dist/esm/InputProtected/DSInputProtected.js +34 -30
- package/dist/esm/InputProtected/DSInputProtected.js.map +2 -2
- package/dist/esm/LargeInputText/DSLargeInputText.js +49 -40
- package/dist/esm/LargeInputText/DSLargeInputText.js.map +2 -2
- package/dist/esm/Radio/Circle.js +10 -9
- package/dist/esm/Radio/Circle.js.map +2 -2
- package/dist/esm/Radio/DSRadio.js +61 -48
- package/dist/esm/Radio/DSRadio.js.map +2 -2
- package/dist/esm/RadioGroup/DSRadioGroup.js +32 -28
- package/dist/esm/RadioGroup/DSRadioGroup.js.map +1 -1
- package/dist/esm/RequiredMark/RequiredMark.js +9 -7
- package/dist/esm/RequiredMark/RequiredMark.js.map +2 -2
- package/dist/esm/TimeInput/DSTimeInput.js +3 -3
- package/dist/esm/TimeInput/DSTimeInput.js.map +2 -2
- package/dist/esm/TimeInput/TimeInputImpl.js +17 -15
- package/dist/esm/TimeInput/TimeInputImpl.js.map +2 -2
- package/dist/esm/TimeInput/TimeInputs.js +16 -13
- package/dist/esm/TimeInput/TimeInputs.js.map +1 -1
- package/dist/esm/Toggle/DSToggle.js +2 -2
- package/dist/esm/Toggle/DSToggle.js.map +2 -2
- package/dist/esm/Toggle/DSToggleImpl.js +2 -1
- package/dist/esm/Toggle/DSToggleImpl.js.map +1 -1
- package/dist/esm/Toggle/DSToggleRender.js +42 -34
- package/dist/esm/Toggle/DSToggleRender.js.map +2 -2
- package/package.json +12 -12
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { aggregatedClasses } from "@elliemae/ds-classnames";
|
|
4
4
|
import { describe, getComponentFromProps } from "@elliemae/ds-utilities";
|
|
5
5
|
import { Group } from "@elliemae/ds-shared";
|
|
@@ -59,7 +59,7 @@ const DSFormItemLayout = ({
|
|
|
59
59
|
containerProps,
|
|
60
60
|
...rest
|
|
61
61
|
}) => {
|
|
62
|
-
const isGroup = InputComponent.type === (/* @__PURE__ */
|
|
62
|
+
const isGroup = InputComponent.type === (/* @__PURE__ */ jsx(Group, {})).type;
|
|
63
63
|
const floatingLabelOverride = floatingLabel === "UNSAFE";
|
|
64
64
|
const WrapperContentComp = !isGroup ? WrapperContent : WrapperContentGroup;
|
|
65
65
|
const inputProps = {
|
|
@@ -83,12 +83,13 @@ const DSFormItemLayout = ({
|
|
|
83
83
|
required,
|
|
84
84
|
...rest
|
|
85
85
|
};
|
|
86
|
-
const renderInput = (Input) => leftAddon || rightAddon ? /* @__PURE__ */
|
|
86
|
+
const renderInput = (Input) => leftAddon || rightAddon ? /* @__PURE__ */ jsx(DSInputGroup, {
|
|
87
87
|
leftAddon,
|
|
88
88
|
rightAddon,
|
|
89
|
-
variant
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
variant,
|
|
90
|
+
children: Input
|
|
91
|
+
}) : Input;
|
|
92
|
+
const renderFloating = /* @__PURE__ */ jsx(DSFloatingLabelInput, {
|
|
92
93
|
...inputProps,
|
|
93
94
|
extraInputProps,
|
|
94
95
|
focused,
|
|
@@ -99,16 +100,21 @@ const DSFormItemLayout = ({
|
|
|
99
100
|
required,
|
|
100
101
|
variant
|
|
101
102
|
});
|
|
102
|
-
const InputWithLabel = floatingLabelOverride ? renderInput(renderFloating) : /* @__PURE__ */
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
103
|
+
const InputWithLabel = floatingLabelOverride ? renderInput(renderFloating) : /* @__PURE__ */ jsxs(Fragment, {
|
|
104
|
+
children: [
|
|
105
|
+
/* @__PURE__ */ jsx(LabelComponent, {
|
|
106
|
+
htmlFor: id || name,
|
|
107
|
+
label: labelText,
|
|
108
|
+
optional,
|
|
109
|
+
required,
|
|
110
|
+
isGroup,
|
|
111
|
+
truncateText
|
|
112
|
+
}),
|
|
113
|
+
renderInput(getComponentFromProps(InputComponent, inputProps))
|
|
114
|
+
]
|
|
115
|
+
});
|
|
110
116
|
if (suffix) {
|
|
111
|
-
return /* @__PURE__ */
|
|
117
|
+
return /* @__PURE__ */ jsx(Wrapper, {
|
|
112
118
|
classProps: {
|
|
113
119
|
disabled,
|
|
114
120
|
readOnly,
|
|
@@ -118,21 +124,36 @@ const DSFormItemLayout = ({
|
|
|
118
124
|
fitContent,
|
|
119
125
|
withHighlight
|
|
120
126
|
},
|
|
121
|
-
...containerProps
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
127
|
+
...containerProps,
|
|
128
|
+
children: /* @__PURE__ */ jsxs(SuffixWrapper, {
|
|
129
|
+
className: "suffix-wrapper",
|
|
130
|
+
children: [
|
|
131
|
+
/* @__PURE__ */ jsxs(SuffixInputWrapper, {
|
|
132
|
+
className: "suffix-input-wrapper",
|
|
133
|
+
children: [
|
|
134
|
+
/* @__PURE__ */ jsxs(WrapperContentComp, {
|
|
135
|
+
children: [
|
|
136
|
+
InputWithLabel,
|
|
137
|
+
extraContent
|
|
138
|
+
]
|
|
139
|
+
}),
|
|
140
|
+
/* @__PURE__ */ jsx(FeedbackComponent, {
|
|
141
|
+
hasError,
|
|
142
|
+
text: validationState || hasError ? validationMessage : feedbackMessage
|
|
143
|
+
})
|
|
144
|
+
]
|
|
145
|
+
}),
|
|
146
|
+
/* @__PURE__ */ jsx(Suffix, {
|
|
147
|
+
className: "suffix-label",
|
|
148
|
+
label: !!labelText,
|
|
149
|
+
withFeedback: Boolean(validationMessage || feedbackMessage),
|
|
150
|
+
children: suffix
|
|
151
|
+
})
|
|
152
|
+
]
|
|
153
|
+
})
|
|
154
|
+
});
|
|
134
155
|
}
|
|
135
|
-
return /* @__PURE__ */
|
|
156
|
+
return /* @__PURE__ */ jsxs(Wrapper, {
|
|
136
157
|
classProps: {
|
|
137
158
|
disabled,
|
|
138
159
|
readOnly,
|
|
@@ -142,11 +163,20 @@ const DSFormItemLayout = ({
|
|
|
142
163
|
fitContent,
|
|
143
164
|
withHighlight
|
|
144
165
|
},
|
|
145
|
-
...containerProps
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
166
|
+
...containerProps,
|
|
167
|
+
children: [
|
|
168
|
+
/* @__PURE__ */ jsxs(WrapperContentComp, {
|
|
169
|
+
children: [
|
|
170
|
+
InputWithLabel,
|
|
171
|
+
extraContent
|
|
172
|
+
]
|
|
173
|
+
}),
|
|
174
|
+
/* @__PURE__ */ jsx(FeedbackComponent, {
|
|
175
|
+
hasError,
|
|
176
|
+
text: validationState || hasError ? validationMessage : feedbackMessage
|
|
177
|
+
})
|
|
178
|
+
]
|
|
179
|
+
});
|
|
150
180
|
};
|
|
151
181
|
DSFormItemLayout.propTypes = props;
|
|
152
182
|
DSFormItemLayout.defaultProps = defaultProps;
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/FormItem/DSFormItemLayout.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\n/* eslint-disable max-lines */\nimport React from 'react';\nimport { aggregatedClasses } from '@elliemae/ds-classnames';\nimport { describe, getComponentFromProps } from '@elliemae/ds-utilities';\nimport { Group } from '@elliemae/ds-shared';\nimport { DSInputGroup } from '../InputGroup';\nimport { DSFloatingLabelInput } from '../FloatingLabelInput';\nimport { DSError } from './Error/DSError';\nimport { props } from './props';\nimport { defaultProps } from './defaultProps';\nimport { FORMITEM_LAYOUT_VARIANTS } from './variants';\nimport { Suffix, SuffixInputWrapper, SuffixWrapper } from './Suffix/Suffix';\n// import { maskTypes } from '../InputMask/MaskTypes';\n\nexport { DSError, FORMITEM_LAYOUT_VARIANTS };\n\nconst blockName = 'form-item';\n\nconst Wrapper = aggregatedClasses('div')(blockName, null, ({ leftLabel, variant, fitContent, withHighlight }) => ({\n 'with-left-label': leftLabel,\n 'fit-content': fitContent,\n [variant]: variant,\n 'with-highlight': withHighlight,\n}));\n\nconst WrapperContent = aggregatedClasses('div')(`${blockName}-content`);\nconst WrapperContentGroup = aggregatedClasses('fieldset')(`${blockName}-content`);\n\nconst DSFormItemLayout = ({\n leftLabel,\n floatingLabel,\n name,\n id,\n value,\n inputComponent: InputComponent,\n labelComponent: LabelComponent,\n feedbackComponent: FeedbackComponent,\n labelText,\n truncateText,\n hasError,\n // orientation = 'vertical', // one of [ vertical, horizontal ]\n validationState, // one of [ success, error, warning ]\n validationMessage,\n feedbackMessage,\n readOnly,\n focused,\n type,\n autoFocus,\n disabled,\n onChange,\n onBlur,\n onFocus,\n onPaste,\n onKeyUp,\n extraInputProps,\n extraContent,\n leftAddon,\n rightAddon,\n required,\n optional,\n mask,\n useSubfix,\n suffix,\n variant,\n fitContent,\n withHighlight,\n containerProps,\n ...rest\n}) => {\n const isGroup = InputComponent.type === (<Group />).type;\n const floatingLabelOverride = floatingLabel === 'UNSAFE';\n const WrapperContentComp = !isGroup ? WrapperContent : WrapperContentGroup;\n\n // group the input props to not duplicate it inside the specific inputComponent (floating or not)\n const inputProps = {\n ...extraInputProps,\n disabled,\n hasError: hasError || validationState === 'error',\n id,\n name,\n type,\n autoFocus,\n onBlur,\n onChange,\n onFocus,\n onPaste,\n onKeyUp,\n readOnly,\n value,\n mask,\n useSubfix,\n variant,\n required,\n ...rest,\n };\n\n const renderInput = (Input) =>\n leftAddon || rightAddon ? (\n <DSInputGroup leftAddon={leftAddon} rightAddon={rightAddon} variant={variant}>\n {Input}\n </DSInputGroup>\n ) : (\n Input\n );\n\n const renderFloating = (\n <DSFloatingLabelInput\n {...inputProps}\n extraInputProps={extraInputProps}\n focused={focused}\n inputComponent={InputComponent}\n labelComponent={LabelComponent}\n labelText={labelText}\n optional={optional}\n required={required}\n variant={variant}\n />\n );\n\n const InputWithLabel = floatingLabelOverride ? (\n renderInput(renderFloating)\n ) : (\n <>\n <LabelComponent\n htmlFor={id || name}\n label={labelText}\n optional={optional}\n required={required}\n isGroup={isGroup}\n truncateText={truncateText}\n />\n {renderInput(getComponentFromProps(InputComponent, inputProps))}\n </>\n );\n\n if (suffix) {\n return (\n <Wrapper\n classProps={{\n disabled,\n readOnly,\n hasError,\n leftLabel,\n variant,\n fitContent,\n withHighlight,\n }}\n {...containerProps}\n >\n <SuffixWrapper className=\"suffix-wrapper\">\n <SuffixInputWrapper className=\"suffix-input-wrapper\">\n <WrapperContentComp>\n {InputWithLabel}\n {extraContent}\n </WrapperContentComp>\n <FeedbackComponent\n hasError={hasError}\n text={validationState || hasError ? validationMessage : feedbackMessage}\n />\n </SuffixInputWrapper>\n <Suffix\n className=\"suffix-label\"\n label={!!labelText}\n withFeedback={Boolean(validationMessage || feedbackMessage)}\n >\n {suffix}\n </Suffix>\n </SuffixWrapper>\n </Wrapper>\n );\n }\n\n return (\n <Wrapper\n classProps={{\n disabled,\n readOnly,\n hasError,\n leftLabel,\n variant,\n fitContent,\n withHighlight,\n }}\n {...containerProps}\n >\n <WrapperContentComp>\n {InputWithLabel}\n {extraContent}\n </WrapperContentComp>\n <FeedbackComponent hasError={hasError} text={validationState || hasError ? validationMessage : feedbackMessage} />\n </Wrapper>\n );\n};\n\nDSFormItemLayout.propTypes = props;\nDSFormItemLayout.defaultProps = defaultProps;\nDSFormItemLayout.displayName = 'DSFormItemLayout';\nconst DSFormItemLayoutWithSchema = describe(DSFormItemLayout);\nDSFormItemLayoutWithSchema.propTypes = props;\n\nexport default DSFormItemLayout;\nexport { DSFormItemLayoutWithSchema, DSFormItemLayout };\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAGA,SAAS,yBAAyB;AAClC,SAAS,UAAU,6BAA6B;AAChD,SAAS,aAAa;AACtB,SAAS,oBAAoB;AAC7B,SAAS,4BAA4B;AACrC,SAAS,eAAe;AACxB,SAAS,aAAa;AACtB,SAAS,oBAAoB;AAC7B,SAAS,gCAAgC;AACzC,SAAS,QAAQ,oBAAoB,qBAAqB;AAK1D,MAAM,YAAY;AAElB,MAAM,UAAU,kBAAkB,KAAK,EAAE,WAAW,MAAM,CAAC,EAAE,WAAW,SAAS,YAAY,cAAc,OAAO;AAAA,EAChH,mBAAmB;AAAA,EACnB,eAAe;AAAA,EACf,CAAC,UAAU;AAAA,EACX,kBAAkB;AACpB,EAAE;AAEF,MAAM,iBAAiB,kBAAkB,KAAK,EAAE,GAAG,mBAAmB;AACtE,MAAM,sBAAsB,kBAAkB,UAAU,EAAE,GAAG,mBAAmB;AAEhF,MAAM,mBAAmB,CAAC;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,mBAAmB;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;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AAAA,MACC,GAAG;AAAA,MAEJ,+BAAC;AAAA,QAAc,WAAU;AAAA,QACvB;AAAA,+BAAC;AAAA,YAAmB,WAAU;AAAA,YAC5B;AAAA,mCAAC;AAAA,gBACE;AAAA;AAAA,kBACA;AAAA;AAAA,eACH;AAAA,cACA,oBAAC;AAAA,gBACC;AAAA,gBACA,MAAM,mBAAmB,WAAW,oBAAoB;AAAA,eAC1D;AAAA;AAAA,WACF;AAAA,UACA,oBAAC;AAAA,YACC,WAAU;AAAA,YACV,OAAO,CAAC,CAAC;AAAA,YACT,cAAc,QAAQ,qBAAqB,eAAe;AAAA,YAEzD;AAAA,WACH;AAAA;AAAA,OACF;AAAA,KACF;AAAA,EAEJ;AAEA,SACE,qBAAC;AAAA,IACC,YAAY;AAAA,MACV;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACC,GAAG;AAAA,IAEJ;AAAA,2BAAC;AAAA,QACE;AAAA;AAAA,UACA;AAAA;AAAA,OACH;AAAA,MACA,oBAAC;AAAA,QAAkB;AAAA,QAAoB,MAAM,mBAAmB,WAAW,oBAAoB;AAAA,OAAiB;AAAA;AAAA,GAClH;AAEJ;AAEA,iBAAiB,YAAY;AAC7B,iBAAiB,eAAe;AAChC,iBAAiB,cAAc;AAC/B,MAAM,6BAA6B,SAAS,gBAAgB;AAC5D,2BAA2B,YAAY;AAEvC,IAAO,2BAAQ;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
import { PropTypes, describe } from "@elliemae/ds-utilities";
|
|
4
4
|
const DSError = ({ hasError = false, errorText = "Error" }) => {
|
|
5
5
|
if (!hasError)
|
|
6
6
|
return null;
|
|
7
|
-
return /* @__PURE__ */
|
|
8
|
-
className: "em-ds-error"
|
|
9
|
-
|
|
7
|
+
return /* @__PURE__ */ jsx("div", {
|
|
8
|
+
className: "em-ds-error",
|
|
9
|
+
children: errorText
|
|
10
|
+
});
|
|
10
11
|
};
|
|
11
12
|
const props = {
|
|
12
13
|
hasError: PropTypes.bool.description("error state"),
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/FormItem/Error/DSError.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { PropTypes, describe } from '@elliemae/ds-utilities';\n\nconst DSError = ({ hasError = false, errorText = 'Error' }) => {\n if (!hasError) return null;\n return <div className=\"em-ds-error\">{errorText}</div>;\n};\n\nconst props = {\n /** error state */\n hasError: PropTypes.bool.description('error state'),\n /** error label text */\n errorText: PropTypes.string.description('error label text'),\n};\n\nDSError.propTypes = props;\nDSError.displayName = 'DSError';\nconst DSErrorWithSchema = describe(DSError);\n\nDSErrorWithSchema.propTypes = props;\n\nexport default DSError;\nexport { DSErrorWithSchema, DSError };\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AACA,SAAS,WAAW,gBAAgB;AAEpC,MAAM,UAAU,CAAC,EAAE,WAAW,OAAO,YAAY,QAAQ,MAAM;AAC7D,MAAI,CAAC;AAAU,WAAO;AACtB,SAAO,oBAAC;AAAA,IAAI,WAAU;AAAA,IAAe;AAAA,GAAU;AACjD;AAEA,MAAM,QAAQ;AAAA,EAEZ,UAAU,UAAU,KAAK,YAAY,aAAa;AAAA,EAElD,WAAW,UAAU,OAAO,YAAY,kBAAkB;AAC5D;AAEA,QAAQ,YAAY;AACpB,QAAQ,cAAc;AACtB,MAAM,oBAAoB,SAAS,OAAO;AAE1C,kBAAkB,YAAY;AAE9B,IAAO,kBAAQ;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
import { aggregatedClasses } from "@elliemae/ds-classnames";
|
|
4
4
|
const blockName = "form-item";
|
|
5
5
|
const FeedbackSpan = aggregatedClasses("span")(blockName, "feedback");
|
|
6
6
|
const Feedback = ({ text, hasError }) => {
|
|
7
7
|
if (!text)
|
|
8
8
|
return null;
|
|
9
|
-
return /* @__PURE__ */
|
|
10
|
-
classProps: hasError
|
|
11
|
-
|
|
9
|
+
return /* @__PURE__ */ jsx(FeedbackSpan, {
|
|
10
|
+
classProps: hasError,
|
|
11
|
+
children: text
|
|
12
|
+
});
|
|
12
13
|
};
|
|
13
14
|
var Feedback_default = Feedback;
|
|
14
15
|
export {
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/FormItem/Feedback.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { aggregatedClasses } from '@elliemae/ds-classnames';\n\nconst blockName = 'form-item';\n\nconst FeedbackSpan = aggregatedClasses('span')(blockName, 'feedback');\n\nconst Feedback = ({ text, hasError }) => {\n if (!text) return null;\n return <FeedbackSpan classProps={hasError}>{text}</FeedbackSpan>;\n};\n\nexport { Feedback };\nexport default Feedback;\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AACA,SAAS,yBAAyB;AAElC,MAAM,YAAY;AAElB,MAAM,eAAe,kBAAkB,MAAM,EAAE,WAAW,UAAU;AAEpE,MAAM,WAAW,CAAC,EAAE,MAAM,SAAS,MAAM;AACvC,MAAI,CAAC;AAAM,WAAO;AAClB,SAAO,oBAAC;AAAA,IAAa,YAAY;AAAA,IAAW;AAAA,GAAK;AACnD;AAGA,IAAO,mBAAQ;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import { aggregatedClasses } from "@elliemae/ds-classnames";
|
|
5
5
|
import { DSTruncatedTooltipText } from "@elliemae/ds-truncated-tooltip-text";
|
|
@@ -16,15 +16,21 @@ const DSLabel = ({
|
|
|
16
16
|
isGroup = false
|
|
17
17
|
}) => {
|
|
18
18
|
const Tag = isGroup ? "legend" : "label";
|
|
19
|
-
return /* @__PURE__ */
|
|
19
|
+
return /* @__PURE__ */ jsxs(Tag, {
|
|
20
20
|
className: `${blockName}${isGroup ? ` ${blockName}--group` : ""}`,
|
|
21
|
-
htmlFor
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
htmlFor,
|
|
22
|
+
children: [
|
|
23
|
+
truncateText ? /* @__PURE__ */ jsx(DSTruncatedTooltipText, {
|
|
24
|
+
value: children || label
|
|
25
|
+
}) : /* @__PURE__ */ jsx(Text, {
|
|
26
|
+
children: label
|
|
27
|
+
}),
|
|
28
|
+
/* @__PURE__ */ jsx(RequiredMark, {
|
|
29
|
+
optional,
|
|
30
|
+
required
|
|
31
|
+
})
|
|
32
|
+
]
|
|
33
|
+
});
|
|
28
34
|
};
|
|
29
35
|
DSLabel.propTypes = {
|
|
30
36
|
children: PropTypes.string,
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/FormItem/Label/DSLabel.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable jsx-a11y/label-has-associated-control */\n/* eslint-disable react/no-unknown-property, jsx-a11y/label-has-for */\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport { aggregatedClasses } from '@elliemae/ds-classnames';\nimport { DSTruncatedTooltipText } from '@elliemae/ds-truncated-tooltip-text';\nimport { RequiredMark } from '../../RequiredMark';\n\nconst blockName = 'em-ds-label';\n\nconst Text = aggregatedClasses('span')(blockName, 'text');\n\nconst DSLabel = ({\n children,\n label,\n htmlFor,\n required,\n optional,\n truncateText = true,\n isGroup = false,\n}) => {\n const Tag = isGroup ? 'legend' : 'label';\n\n return (\n <Tag\n className={`${blockName}${isGroup ? ` ${blockName}--group` : ''}`}\n htmlFor={htmlFor}\n >\n {truncateText ? (\n <DSTruncatedTooltipText value={children || label} />\n ) : (\n <Text>{label}</Text>\n )}\n <RequiredMark optional={optional} required={required} />\n </Tag>\n );\n};\n\nDSLabel.propTypes = {\n children: PropTypes.string,\n label: PropTypes.string,\n htmlFor: PropTypes.string,\n required: PropTypes.bool,\n optional: PropTypes.bool,\n truncateText: PropTypes.bool,\n isGroup: PropTypes.bool,\n};\n\nexport { DSLabel };\nexport default DSLabel;\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAGA,OAAO,eAAe;AACtB,SAAS,yBAAyB;AAClC,SAAS,8BAA8B;AACvC,SAAS,oBAAoB;AAE7B,MAAM,YAAY;AAElB,MAAM,OAAO,kBAAkB,MAAM,EAAE,WAAW,MAAM;AAExD,MAAM,UAAU,CAAC;AAAA,EACf;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAAe;AAAA,EACf,UAAU;AACZ,MAAM;AACJ,QAAM,MAAM,UAAU,WAAW;AAEjC,SACE,qBAAC;AAAA,IACC,WAAW,GAAG,YAAY,UAAU,IAAI,qBAAqB;AAAA,IAC7D;AAAA,IAEC;AAAA,qBACC,oBAAC;AAAA,QAAuB,OAAO,YAAY;AAAA,OAAO,IAElD,oBAAC;AAAA,QAAM;AAAA,OAAM;AAAA,MAEf,oBAAC;AAAA,QAAa;AAAA,QAAoB;AAAA,OAAoB;AAAA;AAAA,GACxD;AAEJ;AAEA,QAAQ,YAAY;AAAA,EAClB,UAAU,UAAU;AAAA,EACpB,OAAO,UAAU;AAAA,EACjB,SAAS,UAAU;AAAA,EACnB,UAAU,UAAU;AAAA,EACpB,UAAU,UAAU;AAAA,EACpB,cAAc,UAAU;AAAA,EACxB,SAAS,UAAU;AACrB;AAGA,IAAO,kBAAQ;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Component } from "react";
|
|
3
4
|
import { aggregatedClasses } from "@elliemae/ds-classnames";
|
|
4
5
|
const blockName = "input-addon-group";
|
|
5
6
|
const Container = aggregatedClasses("div")(blockName);
|
|
@@ -18,10 +19,19 @@ class AddonWrapper extends Component {
|
|
|
18
19
|
containerProps
|
|
19
20
|
} = this.props;
|
|
20
21
|
const childType = inputComponent && inputComponent.type && inputComponent.type.name ? inputComponent.type.name.toLowerCase() : "default";
|
|
21
|
-
return /* @__PURE__ */
|
|
22
|
+
return /* @__PURE__ */ jsxs(Container, {
|
|
22
23
|
className: `${className} ${blockName}--${childType}`,
|
|
23
|
-
...containerProps
|
|
24
|
-
|
|
24
|
+
...containerProps,
|
|
25
|
+
children: [
|
|
26
|
+
leftAddon && /* @__PURE__ */ jsx(InputAddon, {
|
|
27
|
+
children: leftAddon
|
|
28
|
+
}),
|
|
29
|
+
inputComponent,
|
|
30
|
+
rightAddon && /* @__PURE__ */ jsx(InputAddon, {
|
|
31
|
+
children: rightAddon
|
|
32
|
+
})
|
|
33
|
+
]
|
|
34
|
+
});
|
|
25
35
|
}
|
|
26
36
|
}
|
|
27
37
|
AddonWrapper.defaultProps = {};
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/InputGroup/AddonWrapper.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { Component } from 'react';\nimport { aggregatedClasses } from '@elliemae/ds-classnames';\n\nconst blockName = 'input-addon-group';\n\nconst Container = aggregatedClasses('div')(blockName);\nconst InputAddon = aggregatedClasses('span')(blockName, 'addon');\n\nclass AddonWrapper extends Component {\n static defaultProps = {};\n\n state = {};\n\n render() {\n const {\n leftAddon,\n rightAddon,\n children: inputComponent,\n className,\n containerProps,\n } = this.props;\n const childType =\n inputComponent && inputComponent.type && inputComponent.type.name\n ? inputComponent.type.name.toLowerCase()\n : 'default';\n return (\n <Container\n className={`${className} ${blockName}--${childType}`}\n {...containerProps}\n >\n {leftAddon && <InputAddon>{leftAddon}</InputAddon>}\n {inputComponent}\n {rightAddon && <InputAddon>{rightAddon}</InputAddon>}\n </Container>\n );\n }\n}\n\nexport { AddonWrapper };\nexport default AddonWrapper;\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAAA,SAAgB,iBAAiB;AACjC,SAAS,yBAAyB;AAElC,MAAM,YAAY;AAElB,MAAM,YAAY,kBAAkB,KAAK,EAAE,SAAS;AACpD,MAAM,aAAa,kBAAkB,MAAM,EAAE,WAAW,OAAO;AAE/D,MAAM,qBAAqB,UAAU;AAAA,EAArC;AAAA;AAGE,iBAAQ,CAAC;AAAA;AAAA,EAET,SAAS;AACP,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA,UAAU;AAAA,MACV;AAAA,MACA;AAAA,IACF,IAAI,KAAK;AACT,UAAM,YACJ,kBAAkB,eAAe,QAAQ,eAAe,KAAK,OACzD,eAAe,KAAK,KAAK,YAAY,IACrC;AACN,WACE,qBAAC;AAAA,MACC,WAAW,GAAG,aAAa,cAAc;AAAA,MACxC,GAAG;AAAA,MAEH;AAAA,qBAAa,oBAAC;AAAA,UAAY;AAAA,SAAU;AAAA,QACpC;AAAA,QACA,cAAc,oBAAC;AAAA,UAAY;AAAA,SAAW;AAAA;AAAA,KACzC;AAAA,EAEJ;AACF;AA5BM,aACG,eAAe,CAAC;AA8BzB,IAAO,uBAAQ;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
import { describe } from "@elliemae/ds-utilities";
|
|
4
4
|
import { AddonWrapper } from "./AddonWrapper";
|
|
5
5
|
import { props } from "./props";
|
|
@@ -12,14 +12,15 @@ const DSInputGroup = ({
|
|
|
12
12
|
leftAddon,
|
|
13
13
|
rightAddon,
|
|
14
14
|
children: InputComponents
|
|
15
|
-
}) => /* @__PURE__ */
|
|
15
|
+
}) => /* @__PURE__ */ jsx(AddonWrapper, {
|
|
16
16
|
ref: innerRef,
|
|
17
17
|
className,
|
|
18
18
|
containerProps,
|
|
19
19
|
leftAddon,
|
|
20
20
|
rightAddon,
|
|
21
|
-
style
|
|
22
|
-
|
|
21
|
+
style,
|
|
22
|
+
children: InputComponents
|
|
23
|
+
});
|
|
23
24
|
DSInputGroup.propTypes = props;
|
|
24
25
|
DSInputGroup.defaultProps = defaultProps;
|
|
25
26
|
DSInputGroup.displayName = "DSInputGroup";
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/InputGroup/DSInputGroup.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { describe } from '@elliemae/ds-utilities';\nimport { AddonWrapper } from './AddonWrapper';\nimport { props } from './props';\nimport { defaultProps } from './defaultProps';\n\nconst DSInputGroup = ({\n containerProps,\n innerRef,\n className,\n style,\n leftAddon,\n rightAddon,\n children: InputComponents, // as InputComponents,\n}) => (\n <AddonWrapper\n ref={innerRef}\n className={className}\n containerProps={containerProps}\n leftAddon={leftAddon}\n rightAddon={rightAddon}\n style={style}\n >\n {InputComponents}\n </AddonWrapper>\n);\n\nDSInputGroup.propTypes = props;\nDSInputGroup.defaultProps = defaultProps;\nDSInputGroup.displayName = 'DSInputGroup';\nconst DSInputGroupWithSchema = describe(DSInputGroup);\n\nDSInputGroupWithSchema.propTypes = props;\n\nexport default DSInputGroup;\nexport { DSInputGroupWithSchema, DSInputGroup };\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AACA,SAAS,gBAAgB;AACzB,SAAS,oBAAoB;AAC7B,SAAS,aAAa;AACtB,SAAS,oBAAoB;AAE7B,MAAM,eAAe,CAAC;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AACZ,MACE,oBAAC;AAAA,EACC,KAAK;AAAA,EACL;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEC;AAAA,CACH;AAGF,aAAa,YAAY;AACzB,aAAa,eAAe;AAC5B,aAAa,cAAc;AAC3B,MAAM,yBAAyB,SAAS,YAAY;AAEpD,uBAAuB,YAAY;AAEnC,IAAO,uBAAQ;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback, useEffect, useState } from "react";
|
|
3
4
|
import { describe } from "@elliemae/ds-utilities";
|
|
4
5
|
import { MASK_TYPES } from "./MaskTypes";
|
|
5
6
|
import { MASK_PIPES } from "./MaskPipes";
|
|
@@ -88,7 +89,7 @@ const DSInputMask = ({
|
|
|
88
89
|
return MASK_TYPES.DATE_TIME_DEPRECATED;
|
|
89
90
|
return mask;
|
|
90
91
|
};
|
|
91
|
-
return /* @__PURE__ */
|
|
92
|
+
return /* @__PURE__ */ jsx(DSInputMaskDeprecated, {
|
|
92
93
|
...rest,
|
|
93
94
|
"aria-label": ariaLabel,
|
|
94
95
|
autoFocus,
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/InputMask/DSInputMask.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\nimport React, { useCallback, useEffect, useState } from 'react';\nimport { describe } from '@elliemae/ds-utilities';\nimport { MASK_TYPES } from './MaskTypes';\nimport { MASK_PIPES } from './MaskPipes';\nimport { DSInputMaskDeprecated } from './DSInputMaskDeprecated';\nimport { inputProps } from './props';\nimport { defaultProps } from './defaultProps';\nimport { OutOfTheBoxMaskTypes } from './mask_types';\n\nconst isStringMask = (mask: any) => typeof mask === 'string';\n\nconst isObjectMask = (mask: any) => typeof mask === 'object' && mask.type;\n\nconst getRawMask = (mask: any, rawValue: string) =>\n typeof mask === 'function' ? mask(rawValue) : mask;\n\nconst getValueFromEventOrString = (e: any): string => {\n let value = e;\n if (e && e.target) {\n const {\n target: { value: eValue },\n } = e;\n value = eValue;\n }\n return value;\n};\n\nconst DSInputMask = ({\n 'aria-label': ariaLabel = 'Input Mask',\n autoFocus,\n innerRef,\n mask,\n pipe,\n value: valueOrEvent,\n ...rest\n}) => {\n const [rawValue, setRawValue] = useState(\n getValueFromEventOrString(valueOrEvent),\n );\n\n useEffect(() => {\n setRawValue(getValueFromEventOrString(valueOrEvent));\n }, [valueOrEvent]);\n\n const [rawMask, setRawMask] = useState<any>(getRawMask(mask, rawValue));\n\n const [focus, setFocus] = useState(autoFocus);\n\n const [lastkey, setLastkey] = useState<{ code: number; key: string }>({\n code: null,\n key: null,\n });\n\n const [cursorPosition, setCursorPosition] = useState({ current: 0 });\n\n const handleSetMask = useCallback(\n (newValue) => {\n setRawMask(getRawMask(mask, newValue));\n },\n [mask],\n );\n\n if (!pipe && isStringMask(rawMask)) {\n return OutOfTheBoxMaskTypes[rawMask]({\n ...rest,\n 'aria-label': ariaLabel,\n innerRef,\n value: rawValue,\n focus,\n setFocus,\n setRawMask: handleSetMask,\n cursorPosition,\n setCursorPosition,\n lastkey,\n setLastkey,\n setRawValue,\n });\n }\n\n if (!pipe && isObjectMask(rawMask)) {\n // we should change rawMask.type to rawMask.maskType\n // to avoid override standard props\n return OutOfTheBoxMaskTypes[rawMask.type]({\n ...rawMask,\n ...rest,\n 'aria-label': ariaLabel,\n innerRef,\n value: rawValue,\n focus,\n setFocus,\n setRawMask: handleSetMask,\n cursorPosition,\n setCursorPosition,\n lastkey,\n setLastkey,\n setRawValue,\n });\n }\n\n const getDeprecatedMask = () => {\n if (mask === MASK_TYPES.DATE) return MASK_TYPES.DATE_DEPRECATED;\n if (mask === MASK_TYPES.DATE_TIME) return MASK_TYPES.DATE_TIME_DEPRECATED;\n return mask;\n };\n return (\n <DSInputMaskDeprecated\n {...rest}\n aria-label={ariaLabel}\n autoFocus={autoFocus}\n innerRef={innerRef}\n mask={getDeprecatedMask()}\n pipe={pipe}\n value={rawValue}\n />\n );\n};\n\nDSInputMask.propTypes = inputProps;\nDSInputMask.defaultProps = defaultProps;\nDSInputMask.displayName = 'DSInputMask';\nconst DSInputMaskWithSchema = describe(DSInputMask).description(\n 'Masking input for custom formats',\n);\nDSInputMaskWithSchema.propTypes = inputProps;\n\nexport { MASK_TYPES, MASK_PIPES, DSInputMaskWithSchema, DSInputMask };\nexport default DSInputMask;\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AACA,SAAgB,aAAa,WAAW,gBAAgB;AACxD,SAAS,gBAAgB;AACzB,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AO,GAAG;AAClC,WAAO,qBAAqB,SAAS;AAAA,MACnC,GAAG;AAAA,MACH,cAAc;AAAA,MACd;AAAA,MACA,OAAO;AAAA,MACP;AAAA,MACA;AAAA,MACA,YAAY;AAAA,MACZ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AAEA,MAAI,CAAC,QAAQ,aAAa,OAAO,GAAG;AAGlC,WAAO,qBAAqB,QAAQ,MAAM;AAAA,MACxC,GAAG;AAAA,MACH,GAAG;AAAA,MACH,cAAc;AAAA,MACd;AAAA,MACA,OAAO;AAAA,MACP;AAAA,MACA;AAAA,MACA,YAAY;AAAA,MACZ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AAEA,QAAM,oBAAoB,MAAM;AAC9B,QAAI,SAAS,WAAW;AAAM,aAAO,WAAW;AAChD,QAAI,SAAS,WAAW;AAAW,aAAO,WAAW;AACrD,WAAO;AAAA,EACT;AACA,SACE,oBAAC;AAAA,IACE,GAAG;AAAA,IACJ,cAAY;AAAA,IACZ;AAAA,IACA;AAAA,IACA,MAAM,kBAAkB;AAAA,IACxB;AAAA,IACA,OAAO;AAAA,GACT;AAEJ;AAEA,YAAY,YAAY;AACxB,YAAY,eAAe;AAC3B,YAAY,cAAc;AAC1B,MAAM,wBAAwB,SAAS,WAAW,EAAE;AAAA,EAClD;AACF;AACA,sBAAsB,YAAY;AAGlC,IAAO,sBAAQ;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
3
|
import React2, { Component } from "react";
|
|
3
4
|
import { isEqual } from "lodash";
|
|
4
5
|
import PropTypes from "prop-types";
|
|
@@ -223,7 +224,7 @@ class DSInputMaskDeprecated extends Component {
|
|
|
223
224
|
const { maskedValue, focus } = this.state;
|
|
224
225
|
const propsValue = getValueFromEventOrString(value);
|
|
225
226
|
const finalValue = typeof propsValue === "string" || typeof propsValue === "number" ? propsValue : maskedValue;
|
|
226
|
-
return /* @__PURE__ */
|
|
227
|
+
return /* @__PURE__ */ jsx(DSTextBox, {
|
|
227
228
|
...rest,
|
|
228
229
|
"aria-label": rest["aria-label"],
|
|
229
230
|
className,
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/InputMask/DSInputMaskDeprecated.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-statements */\n/* eslint-disable react/prop-types */\n/* eslint-disable complexity */\n/* eslint-disable max-lines */\nimport React, { Component } from 'react';\nimport { isEqual } from 'lodash';\nimport PropTypes from 'prop-types';\nimport { adjustCaretPosition, conformToMask } from 'text-mask-core';\nimport { setCaretPosition } from './utils/setCaretPosition';\nimport { DSTextBox } from '../TextBox';\n\nconst getValueFromEventOrString = (e) => {\n let value = e;\n if (e && e.target) {\n const {\n target: { value: eValue },\n } = e;\n value = eValue;\n }\n return value;\n};\n\nconst getRawMask = (mask, rawValue = '') => (typeof mask === 'function' ? mask(rawValue) : mask);\n\n// this is not safe because we don't take in consideration a lot of cases\n// just a monkeypatch untill we get the v2 going,\n// this work with \"internal\" masks...\nconst UNSAFEGetRawValue = (value, mask) => {\n const safeValue = getValueFromEventOrString(value);\n if (!safeValue) return '';\n const rawMask = getRawMask(mask, value);\n const characterToStrip = rawMask.filter((char) => typeof char === 'string');\n\n return safeValue\n ?.split('')\n ?.filter((char) => {\n const indexCharToStrip = characterToStrip.findIndex((strip) => strip === char);\n if (indexCharToStrip >= 0) {\n characterToStrip.splice(indexCharToStrip, 1);\n return false;\n }\n return true;\n })\n ?.join('');\n};\n\n// this is not safe because we don't take in consideration a lot of cases\n// just a monkeypatch untill we get the v2 going,\n// this work with \"internal\" masks...\nconst UNSAFEIsRawValue = (value, mask) => {\n const safeValue = getValueFromEventOrString(value);\n if (!safeValue) return false;\n const rawMask = getRawMask(mask, safeValue);\n const characterToStrip = rawMask.filter((char) => typeof char === 'string');\n if (safeValue)\n safeValue?.split('')?.forEach((char) => {\n const indexCharToStrip = characterToStrip.findIndex((strip) => strip === char);\n if (indexCharToStrip >= 0) {\n characterToStrip.splice(indexCharToStrip, 1);\n }\n });\n // if we matched all the character to strip, this is not a raw value\n // unsafe, but \"good enough\" for most masks...\n return characterToStrip.length !== 0;\n};\n\nclass DSInputMaskDeprecated extends Component {\n lastkey = null;\n\n lastkeycode = null;\n\n constructor(props) {\n super(props);\n this.inputref = React.createRef();\n\n this.state = {\n maskedValue: '',\n previousConformedValue: '',\n };\n this.conformValue = this.conformValue.bind(this);\n }\n\n conformValue = (\n rawValueOrEvent,\n currentCaretPosition,\n { skipCaretPositioning = false, skipOnChangeCallback = false } = {},\n ) => {\n const { previousConformedValue } = this.state;\n const { onChange, mask, placeholderChar = '_', pipe } = this.props;\n const rawValue = getValueFromEventOrString(rawValueOrEvent);\n\n // short-circuit logic if user cleared the input\n if (rawValue.length === 0) {\n this.setState(\n {\n maskedValue: rawValue,\n previousConformedValue: rawValue,\n focus: true,\n },\n () => {\n const event = {\n target: {\n value: rawValue,\n originalValue: rawValue,\n },\n lastkey: this.lastkey,\n };\n onChange(event);\n },\n );\n return;\n }\n const rawMaskWithTraps = getRawMask(mask, rawValue);\n const rawMask = rawMaskWithTraps.filter((val) => val !== '[]');\n\n // generate the final result we want to put in the state and in the input box\n const conformToMaskResults = conformToMask(rawValue, rawMask, {\n guide: false,\n placeholderChar,\n ...(previousConformedValue && { previousConformedValue }),\n });\n\n const { conformedValue: pipelessConformed } = conformToMaskResults;\n // when the last character must be always preserved we need to manually ensure it\n // because\n // conformToMask -> guide: false will interpeter the last character\n // will remove the last character if it's part of the mask\n // we may want to add a prop for this in the future?\n // this is used for example with \"decimal\" and \"percentage\" masks\n let conformedValueEnsureLastMaskChar = pipelessConformed;\n const lastMaskChar = rawMask[rawMask.length - 1];\n const lastValueChar = pipelessConformed.charAt(pipelessConformed.length - 1);\n if (typeof lastMaskChar === 'string' && lastMaskChar !== lastValueChar) {\n conformedValueEnsureLastMaskChar = pipelessConformed + lastMaskChar;\n }\n\n let pipeResult = {\n indexesOfPipedChars: [],\n value: conformedValueEnsureLastMaskChar,\n valid: true,\n };\n if (typeof pipe === 'function') pipeResult = pipe()(conformedValueEnsureLastMaskChar);\n\n // if the pipe results in an invalid value, we don't allow the change\n // meaning the final result will be like the user never tried to change the input\n // this is because the user will have to inject the validation in his pipe\n // probably pipe is never used, because this never worked before...\n // we will deprecate the \"pipe\" props in the future\n const conformedValue = pipeResult.valid ? pipeResult.value : previousConformedValue;\n\n // generate the \"placeholder\" used in calculating new caret position\n // this means we need\n // empty string as a value\n // guide:true\n // we can ignore \"previousConformedValue\" parameter\n const generatedPlaceHolder = conformToMask('', rawMask, {\n guide: true,\n placeholderChar,\n });\n const { indexesOfPipedChars } = pipeResult;\n const adjustCaretPositionOpts = {\n previousConformedValue,\n conformedValue,\n currentCaretPosition,\n rawValue,\n placeholderChar,\n placeholder: generatedPlaceHolder.conformedValue,\n indexesOfPipedChars,\n caretTrapIndexes: [],\n };\n const caretPos = adjustCaretPosition(adjustCaretPositionOpts);\n\n this.setState(\n {\n maskedValue: conformedValue,\n previousConformedValue: conformedValue,\n focus: true,\n },\n () => {\n const event = {\n target: {\n value: conformedValue,\n originalValue: rawValue,\n },\n lastkey: this.lastkey,\n };\n if (!skipOnChangeCallback) onChange(event);\n if (!skipCaretPositioning) setTimeout(() => setCaretPosition(this.inputref, caretPos));\n },\n );\n };\n\n // eslint-disable-next-line max-statements\n handleOnChange = (e) => {\n const rawValue = e?.target?.value || '';\n const { selectionEnd } = e.target;\n const currentCaretPosition = selectionEnd;\n this.conformValue(rawValue, currentCaretPosition);\n };\n\n handleKeyDown = (e) => {\n e.stopPropagation();\n const { onKeyDown } = this.props;\n this.lastkey = e.key;\n this.lastkeycode = e.keyCode;\n onKeyDown(e);\n };\n\n handleBlur = (e) => {\n const { onBlur } = this.props;\n this.setState({ focus: false });\n onBlur(e);\n };\n\n componentDidMount() {\n const { value, mask } = this.props;\n const isAlreadyRaw = UNSAFEIsRawValue(value, mask);\n const rawVal = isAlreadyRaw ? value : UNSAFEGetRawValue(value, mask);\n if (rawVal === '') return;\n // if value from props is raw, we invoke onChange\n // not invoking onChange on a raw value breaks the internal components depending on this...\n const shouldSkipOnChange = !isAlreadyRaw;\n\n this.conformValue(rawVal, rawVal.length, {\n skipCaretPositioning: true,\n skipOnChangeCallback: shouldSkipOnChange,\n });\n }\n\n componentDidUpdate(prevProps) {\n // ensure the mask is re-applied when value/mask props changes.\n // this is required by internal implementations like DSDateRangePicker\n const { value: prevValOrEvent, mask: prevMask } = prevProps;\n const { value: valOrEvent, mask } = this.props;\n const value = getValueFromEventOrString(valOrEvent);\n const isAlreadyRaw = UNSAFEIsRawValue(value, mask);\n const rawVal = isAlreadyRaw ? value : UNSAFEGetRawValue(value, mask);\n if (rawVal === '') return;\n const rawMask = getRawMask(mask, rawVal);\n\n const prevVal = getValueFromEventOrString(prevValOrEvent);\n const prevIsAlreadyRaw = UNSAFEIsRawValue(prevVal, prevMask);\n const prevRawVal = prevIsAlreadyRaw ? prevVal : UNSAFEGetRawValue(prevVal, prevMask);\n const prevRawMask = getRawMask(prevMask, prevRawVal);\n\n // we need to compare \"raw\" masks, because mask sometimes are functions\n // and if we don't compare raw mask, isEqual will produce unexpected result\n // which would lead to infinite loops\n if (prevVal !== value || !isEqual(prevRawMask, rawMask)) {\n // if value from props is raw, we invoke onChange\n // not invoking onChange on a raw value breaks the internal components depending on this...\n const shouldSkipOnChange = !isAlreadyRaw;\n this.conformValue(rawVal, rawVal.length, {\n skipCaretPositioning: true,\n skipOnChangeCallback: shouldSkipOnChange,\n });\n }\n }\n\n render() {\n const {\n autoFocus,\n style,\n disabled,\n className,\n name,\n maxLength,\n minLength,\n fluidWidth,\n placeholder,\n onKeyDown,\n onClick,\n onChange,\n onFocus,\n onBlur,\n onPaste,\n onKeyUp,\n hasError,\n readOnly,\n type,\n innerRef,\n clearable = false,\n leftComponent,\n rightComponent,\n value,\n ...rest\n } = this.props;\n const { maskedValue, focus } = this.state;\n // if component is \"controlled\" we print the value from the props\n // if it's not controlled we use the internal state\n // handleOnChange has the logic to invoke the onChange with the mask applied\n // if the dev controls the component but pass down a value not conformed to the mask\n // it's a problem to be fixed on the dev side.\n // this means no \"get derived state from props\" mumbo-jumbos\n const propsValue = getValueFromEventOrString(value);\n const finalValue = typeof propsValue === 'string' || typeof propsValue === 'number' ? propsValue : maskedValue;\n\n return (\n <DSTextBox\n {...rest}\n aria-label={rest['aria-label']}\n className={className}\n clearable={clearable}\n disabled={disabled}\n fluidWidth={fluidWidth}\n hasError={hasError}\n isActive={focus}\n leftComponent={leftComponent}\n maxLength={maxLength}\n minLength={minLength}\n name={name}\n onBlur={this.handleBlur}\n onChange={this.handleOnChange}\n onClick={onClick}\n onFocus={onFocus}\n onKeyDown={this.handleKeyDown}\n onKeyUp={onKeyUp}\n onPaste={onPaste}\n placeholder={placeholder}\n readOnly={readOnly}\n rightComponent={rightComponent}\n style={style}\n type={type}\n value={finalValue}\n />\n );\n }\n}\n\nDSInputMaskDeprecated.propTypes = {\n autoFocus: PropTypes.bool,\n style: PropTypes.object,\n disabled: PropTypes.bool,\n className: PropTypes.string,\n name: PropTypes.string,\n maxLength: PropTypes.number,\n minLength: PropTypes.number,\n fluidWidth: PropTypes.bool,\n placeholder: PropTypes.string,\n value: PropTypes.string,\n onChange: PropTypes.func,\n onKeyDown: PropTypes.func,\n leftComponent: PropTypes.element,\n rightComponent: PropTypes.element,\n onFocus: PropTypes.func,\n onBlur: PropTypes.func,\n onPaste: PropTypes.func,\n onKeyUp: PropTypes.func,\n hasError: PropTypes.bool,\n readOnly: PropTypes.bool,\n onClick: PropTypes.func,\n clearable: PropTypes.bool,\n type: PropTypes.string,\n /**\n * Ref for the component\n */\n innerRef: PropTypes.any,\n /**\n * Mask type\n */\n mask: PropTypes.any,\n placeholderChar: PropTypes.string,\n};\n\nexport { DSInputMaskDeprecated };\nexport default DSInputMaskDeprecated;\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAIA,OAAOA,UAAS,iBAAiB;AACjC,SAAS,eAAe;AACxB,OAAO,eAAe;AACtB,SAAS,qBAAqB,qBAAqB;AACnD,SAAS,wBAAwB;AACjC,SAAS,iBAAiB;AAE1B,MAAM,4BAA4B,CAAC,MAAM;AACvC,MAAI,QAAQ;AACZ,MAAI,KAAK,EAAE,QAAQ;AACjB,UAAM;AAAA,MACJ,QAAQ,EAAE,OAAO,OAAO;AAAA,IAC1B,IAAI;AACJ,YAAQ;AAAA,EACV;AACA,SAAO;AACT;AAEA,MAAM,aAAa,CAAC,MAAM,WAAW,OAAQ,OAAO,SAAS,aAAa,KAAK,QAAQ,IAAI;AAK3F,MAAM,oBAAoB,CAAC,OAAO,SAAS;AACzC,QAAM,YAAY,0BAA0B,KAAK;AACjD,MAAI,CAAC;AAAW,WAAO;AACvB,QAAM,UAAU,WAAW,MAAM,KAAK;AACtC,QAAM,mBAAmB,QAAQ,OAAO,CAAC,SAAS,OAAO,SAAS,QAAQ;AAE1E,SAAO,WACH,MAAM,EAAE,GACR,OAAO,CAAC,SAAS;AACjB,UAAM,mBAAmB,iBAAiB,UAAU,CAAC,UAAU,UAAU,IAAI;AAC7E,QAAI,oBAAoB,GAAG;AACzB,uBAAiB,OAAO,kBAAkB,CAAC;AAC3C,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT,CAAC,GACC,KAAK,EAAE;AACb;AAKA,MAAM,mBAAmB,CAAC,OAAO,SAAS;AACxC,QAAM,YAAY,0BAA0B,KAAK;AACjD,MAAI,CAAC;AAAW,WAAO;AACvB,QAAM,UAAU,WAAW,MAAM,SAAS;AAC1C,QAAM,mBAAmB,QAAQ,OA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EACtB,aAAa,UAAU;AAAA,EACvB,OAAO,UAAU;AAAA,EACjB,UAAU,UAAU;AAAA,EACpB,WAAW,UAAU;AAAA,EACrB,eAAe,UAAU;AAAA,EACzB,gBAAgB,UAAU;AAAA,EAC1B,SAAS,UAAU;AAAA,EACnB,QAAQ,UAAU;AAAA,EAClB,SAAS,UAAU;AAAA,EACnB,SAAS,UAAU;AAAA,EACnB,UAAU,UAAU;AAAA,EACpB,UAAU,UAAU;AAAA,EACpB,SAAS,UAAU;AAAA,EACnB,WAAW,UAAU;AAAA,EACrB,MAAM,UAAU;AAAA,EAIhB,UAAU,UAAU;AAAA,EAIpB,MAAM,UAAU;AAAA,EAChB,iBAAiB,UAAU;AAC7B;AAGA,IAAO,gCAAQ;",
|
|
6
6
|
"names": ["React"]
|
|
7
7
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback, useLayoutEffect, useRef, useState } from "react";
|
|
3
4
|
import { DSTextBox } from "../../TextBox";
|
|
4
5
|
import { setCaretPosition } from "../utils/setCaretPosition";
|
|
5
6
|
const conformValue = (rawValue, cursorPos, lastkeycode) => {
|
|
@@ -128,7 +129,7 @@ const DateInputMask = ({
|
|
|
128
129
|
},
|
|
129
130
|
[onBlur]
|
|
130
131
|
);
|
|
131
|
-
return /* @__PURE__ */
|
|
132
|
+
return /* @__PURE__ */ jsx(DSTextBox, {
|
|
132
133
|
...rest,
|
|
133
134
|
className,
|
|
134
135
|
clearable,
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/InputMask/mask_types/DateInputMask.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\n/* eslint-disable complexity */\nimport React, { useCallback, useLayoutEffect, useRef, useState } from 'react';\nimport { PropTypes } from '@elliemae/ds-utilities';\nimport { DSTextBox } from '../../TextBox';\nimport { TCharsToAdd } from '../types';\nimport { setCaretPosition } from '../utils/setCaretPosition';\n\nconst conformValue = (\n rawValue: string,\n cursorPos: number,\n lastkeycode: number,\n) => {\n const nextMaskedValue = rawValue\n .split('')\n .filter((char) => char >= '0' && char <= '9')\n .slice(0, 8);\n\n let maskedPos = 0;\n for (let i = 0; i < cursorPos; i += 1) {\n if (nextMaskedValue[maskedPos] === rawValue[i]) maskedPos += 1;\n }\n\n // list of [string to add, position to add]\n const charactersToAdd: TCharsToAdd = [\n ['/', 2],\n ['/', 5],\n ];\n\n charactersToAdd.forEach(([chars, pos]) => {\n if (nextMaskedValue.length > pos) {\n nextMaskedValue.splice(pos, 0, chars);\n if (maskedPos >= pos) maskedPos += chars.length;\n }\n });\n\n if (lastkeycode !== 8 && maskedPos < nextMaskedValue.length) {\n charactersToAdd.forEach(([chars, pos]) => {\n if (maskedPos === pos) maskedPos += chars.length;\n });\n } else if (lastkeycode === 8 && maskedPos) {\n charactersToAdd.forEach(([chars, pos]) => {\n if (maskedPos === pos + 1) maskedPos -= chars.length;\n });\n }\n\n return { nextMaskedValue: nextMaskedValue.join(''), maskedPos };\n};\n\nconst DateInputMask = ({\n focus,\n setFocus,\n setRawMask,\n cursorPosition,\n setCursorPosition,\n lastkey,\n setLastkey,\n setRawValue,\n style,\n disabled,\n className,\n name,\n maxLength,\n minLength,\n fluidWidth,\n placeholder,\n onKeyDown,\n onClick,\n onChange,\n onFocus,\n onBlur,\n onPaste,\n onKeyUp,\n hasError,\n readOnly,\n type,\n innerRef,\n clearable = false,\n leftComponent,\n rightComponent,\n value,\n ...rest\n}) => {\n const inputRef = useRef();\n const [maskedValue, setMaskedValue] = useState(value);\n\n const conform = useCallback(\n ({ rawValue, cursorPos, lastkeycode, shouldUpdateCursorPos = true }) => {\n const { nextMaskedValue, maskedPos } = conformValue(\n rawValue,\n cursorPos,\n lastkeycode,\n );\n const event = {\n target: {\n value: nextMaskedValue,\n originalValue: rawValue,\n },\n };\n if (onChange && nextMaskedValue !== maskedValue) onChange(event);\n\n setMaskedValue(nextMaskedValue);\n setRawValue(nextMaskedValue);\n\n if (shouldUpdateCursorPos) setCursorPosition({ current: maskedPos });\n },\n [maskedValue, onChange],\n );\n\n const handleOnChange = useCallback(\n (e) => {\n const { value: rawValue, selectionEnd } = e.target;\n setRawMask(rawValue);\n setRawValue(rawValue);\n setCursorPosition({ current: selectionEnd });\n setFocus(true);\n },\n [setRawMask, setRawValue, setCursorPosition, setFocus, lastkey.code],\n );\n\n useLayoutEffect(() => {\n if (focus) setCaretPosition(inputRef.current, cursorPosition.current);\n }, [focus, cursorPosition]);\n\n useLayoutEffect(() => {\n // if the value changes, then re-conform the mask\n conform({\n rawValue: value,\n cursorPos: cursorPosition.current,\n lastkeycode: lastkey.code,\n shouldUpdateCursorPos: focus,\n });\n }, [focus, value, cursorPosition.current]);\n\n const handleKeyDown = useCallback(\n (e) => {\n e.stopPropagation();\n setLastkey({ key: e.key, code: e.keyCode });\n onKeyDown(e);\n },\n [onKeyDown],\n );\n\n const handleBlur = useCallback(\n (e) => {\n setFocus(false);\n onBlur(e);\n },\n [onBlur],\n );\n\n return (\n <DSTextBox\n {...rest}\n className={className}\n clearable={clearable}\n disabled={disabled}\n fluidWidth={fluidWidth}\n hasError={hasError}\n innerRef={(ref) => {\n inputRef.current = ref;\n if (innerRef) innerRef(ref);\n }}\n isActive={focus}\n leftComponent={leftComponent}\n maxLength={maxLength}\n minLength={minLength}\n name={name}\n onBlur={handleBlur}\n onChange={handleOnChange}\n onClick={onClick}\n onFocus={onFocus}\n onKeyDown={handleKeyDown}\n onKeyUp={onKeyUp}\n onPaste={onPaste}\n placeholder={placeholder}\n readOnly={readOnly}\n rightComponent={rightComponent}\n style={style}\n type={type}\n value={maskedValue}\n />\n );\n};\n\nexport { DateInputMask };\nexport default DateInputMask;\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|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AAA,MAC1B,aAAa,QAAQ;AAAA,MACrB,uBAAuB;AAAA,IACzB,CAAC;AAAA,EACH,GAAG,CAAC,OAAO,OAAO,eAAe,OAAO,CAAC;AAEzC,QAAM,gBAAgB;AAAA,IACpB,CAAC,MAAM;AACL,QAAE,gBAAgB;AAClB,iBAAW,EAAE,KAAK,EAAE,KAAK,MAAM,EAAE,QAAQ,CAAC;AAC1C,gBAAU,CAAC;AAAA,IACb;AAAA,IACA,CAAC,SAAS;AAAA,EACZ;AAEA,QAAM,aAAa;AAAA,IACjB,CAAC,MAAM;AACL,eAAS,KAAK;AACd,aAAO,CAAC;AAAA,IACV;AAAA,IACA,CAAC,MAAM;AAAA,EACT;AAEA,SACE,oBAAC;AAAA,IACE,GAAG;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU,CAAC,QAAQ;AACjB,eAAS,UAAU;AACnB,UAAI;AAAU,iBAAS,GAAG;AAAA,IAC5B;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO;AAAA,GACT;AAEJ;AAGA,IAAO,wBAAQ;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback, useLayoutEffect, useRef, useState } from "react";
|
|
3
4
|
import { DSTextBox } from "../../TextBox";
|
|
4
5
|
import { setCaretPosition } from "../utils/setCaretPosition";
|
|
5
6
|
const conformValue = (rawValue, cursorPos, lastkeycode) => {
|
|
@@ -134,7 +135,7 @@ const DateTimeInputMask = ({
|
|
|
134
135
|
},
|
|
135
136
|
[onBlur]
|
|
136
137
|
);
|
|
137
|
-
return /* @__PURE__ */
|
|
138
|
+
return /* @__PURE__ */ jsx(DSTextBox, {
|
|
138
139
|
...rest,
|
|
139
140
|
className,
|
|
140
141
|
clearable,
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/InputMask/mask_types/DateTimeInputMask.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-statements */\n/* eslint-disable max-lines */\n/* eslint-disable complexity */\nimport React, { useCallback, useLayoutEffect, useRef, useState } from 'react';\nimport { PropTypes } from '@elliemae/ds-utilities';\nimport { DSTextBox } from '../../TextBox';\nimport { TCharsToAdd } from '../types';\nimport { setCaretPosition } from '../utils/setCaretPosition';\n\nconst conformValue = (\n rawValue: string,\n cursorPos: number,\n lastkeycode: number,\n) => {\n const nextMaskedValue = rawValue\n .split('')\n .filter((char) => char >= '0' && char <= '9')\n .slice(0, 12);\n\n while (nextMaskedValue.length > 8 && !nextMaskedValue[8].match(/[0-2]/))\n nextMaskedValue.splice(8, 1);\n while (nextMaskedValue.length > 10 && !nextMaskedValue[10].match(/[0-5]/))\n nextMaskedValue.splice(10, 1);\n\n let maskedPos = 0;\n for (let i = 0; i < cursorPos; i += 1) {\n if (nextMaskedValue[maskedPos] === rawValue[i]) maskedPos += 1;\n }\n\n // list of [string to add, position to add]\n const charactersToAdd: TCharsToAdd = [\n ['/', 2],\n ['/', 5],\n [' ', 10],\n [':', 13],\n ];\n\n charactersToAdd.forEach(([chars, pos]) => {\n if (nextMaskedValue.length > pos) {\n nextMaskedValue.splice(pos, 0, chars);\n if (maskedPos >= pos) maskedPos += chars.length;\n }\n });\n\n if (lastkeycode !== 8 && maskedPos < nextMaskedValue.length) {\n charactersToAdd.forEach(([chars, pos]) => {\n if (maskedPos === pos) maskedPos += chars.length;\n });\n } else if (lastkeycode === 8 && maskedPos) {\n charactersToAdd.forEach(([chars, pos]) => {\n if (maskedPos === pos + 1) maskedPos -= chars.length;\n });\n }\n\n return { nextMaskedValue: nextMaskedValue.join(''), maskedPos };\n};\n\nconst DateTimeInputMask = ({\n focus,\n setFocus,\n setRawMask,\n cursorPosition,\n setCursorPosition,\n lastkey,\n setLastkey,\n setRawValue,\n style,\n disabled,\n className,\n name,\n maxLength,\n minLength,\n fluidWidth,\n placeholder,\n onKeyDown,\n onClick,\n onChange,\n onFocus,\n onBlur,\n onPaste,\n onKeyUp,\n hasError,\n readOnly,\n type,\n innerRef,\n clearable = false,\n leftComponent,\n rightComponent,\n value,\n ...rest\n}) => {\n const inputRef = useRef();\n const [maskedValue, setMaskedValue] = useState(value);\n\n const conform = useCallback(\n ({ rawValue, cursorPos, lastkeycode, shouldUpdateCursorPos = true }) => {\n const { nextMaskedValue, maskedPos } = conformValue(\n rawValue,\n cursorPos,\n lastkeycode,\n );\n const event = {\n target: {\n value: nextMaskedValue,\n originalValue: rawValue,\n },\n };\n if (onChange && nextMaskedValue !== maskedValue) onChange(event);\n\n setMaskedValue(nextMaskedValue);\n setRawValue(nextMaskedValue);\n\n if (shouldUpdateCursorPos) setCursorPosition({ current: maskedPos });\n },\n [maskedValue, onChange],\n );\n\n const handleOnChange = useCallback(\n (e) => {\n const { value: rawValue, selectionEnd } = e.target;\n setRawMask(rawValue);\n setRawValue(rawValue);\n setCursorPosition({ current: selectionEnd });\n setFocus(true);\n },\n [setRawMask, setRawValue, setCursorPosition, setFocus, lastkey.code],\n );\n\n useLayoutEffect(() => {\n if (focus) setCaretPosition(inputRef.current, cursorPosition.current);\n }, [focus, cursorPosition]);\n\n useLayoutEffect(() => {\n // if the value changes, then re-conform the mask\n conform({\n rawValue: value,\n cursorPos: cursorPosition.current,\n lastkeycode: lastkey.code,\n shouldUpdateCursorPos: focus,\n });\n }, [focus, value, cursorPosition.current]);\n\n const handleKeyDown = useCallback(\n (e) => {\n e.stopPropagation();\n setLastkey({ key: e.key, code: e.keyCode });\n onKeyDown(e);\n },\n [onKeyDown],\n );\n\n const handleBlur = useCallback(\n (e) => {\n setFocus(false);\n onBlur(e);\n },\n [onBlur],\n );\n\n return (\n <DSTextBox\n {...rest}\n className={className}\n clearable={clearable}\n disabled={disabled}\n fluidWidth={fluidWidth}\n hasError={hasError}\n innerRef={(ref) => {\n inputRef.current = ref;\n if (innerRef) innerRef(ref);\n }}\n isActive={focus}\n leftComponent={leftComponent}\n maxLength={maxLength}\n minLength={minLength}\n name={name}\n onBlur={handleBlur}\n onChange={handleOnChange}\n onClick={onClick}\n onFocus={onFocus}\n onKeyDown={handleKeyDown}\n onKeyUp={onKeyUp}\n onPaste={onPaste}\n placeholder={placeholder}\n readOnly={readOnly}\n rightComponent={rightComponent}\n style={style}\n type={type}\n value={maskedValue}\n />\n );\n};\n\nexport { DateTimeInputMask };\nexport default DateTimeInputMask;\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAGA,SAAgB,aAAa,iBAAiB,QAAQ,gBAAgB;AAEtE,SAAS,iBAAiB;AAE1B,SAAS,wBAAwB;AAEjC,MAAM,eAAe,CACnB,UACA,WACA,gBACG;AACH,QAAM,kBAAkB,SACrB,MAAM,EAAE,EACR,OAAO,CAAC,SAAS,QAAQ,OAAO,QAAQ,GAAG,EAC3C,MAAM,GAAG,EAAE;AAEd,SAAO,gBAAgB,SAAS,KAAK,CAAC,gBAAgB,GAAG,MAAM,OAAO;AACpE,oBAAgB,OAAO,GAAG,CAAC;AAC7B,SAAO,gBAAgB,SAAS,MAAM,CAAC,gBAAgB,IAAI,MAAM,OAAO;AACtE,oBAAgB,OAAO,IAAI,CAAC;AAE9B,MAAI,YAAY;AAChB,WAAS,IAAI,GAAG,IAAI,WAAW,KAAK,GAAG;AACrC,QAAI,gBAAgB,eAAe,SAAS;AAAI,mBAAa;AAAA,EAC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