@progress/kendo-react-inputs 7.2.4-develop.2 → 7.2.4-develop.4
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/checkbox/Checkbox.js +8 -0
- package/checkbox/Checkbox.mjs +214 -0
- package/colors/ColorContrastLabels.js +8 -0
- package/colors/ColorContrastLabels.mjs +24 -0
- package/colors/ColorContrastSvg.js +8 -0
- package/colors/ColorContrastSvg.mjs +52 -0
- package/colors/ColorGradient.js +8 -0
- package/colors/ColorGradient.mjs +293 -0
- package/colors/ColorInput.js +8 -0
- package/colors/ColorInput.mjs +122 -0
- package/colors/ColorPalette.js +8 -0
- package/colors/ColorPalette.mjs +191 -0
- package/colors/ColorPicker.js +8 -0
- package/colors/ColorPicker.mjs +253 -0
- package/colors/FlatColorPicker.js +8 -0
- package/colors/FlatColorPicker.mjs +216 -0
- package/colors/HexInput.js +8 -0
- package/colors/HexInput.mjs +39 -0
- package/colors/Picker.js +8 -0
- package/colors/Picker.mjs +42 -0
- package/colors/models/palette-presets.js +8 -0
- package/colors/models/palette-presets.mjs +61 -0
- package/colors/utils/color-cache.js +8 -0
- package/colors/utils/color-cache.mjs +51 -0
- package/colors/utils/color-palette.service.js +8 -0
- package/colors/utils/color-palette.service.mjs +50 -0
- package/colors/utils/color-parser.js +8 -0
- package/colors/utils/color-parser.mjs +61 -0
- package/colors/utils/misc.js +8 -0
- package/colors/utils/misc.mjs +13 -0
- package/colors/utils/svg-calc.js +8 -0
- package/colors/utils/svg-calc.mjs +36 -0
- package/dist/cdn/js/kendo-react-inputs.js +8 -21
- package/index.d.mts +4275 -5
- package/index.d.ts +4275 -75
- package/index.js +8 -21
- package/index.mjs +97 -5042
- package/input/Input.js +8 -0
- package/input/Input.mjs +185 -0
- package/input/InputClearValue.js +8 -0
- package/input/InputClearValue.mjs +24 -0
- package/input/InputPrefix.js +8 -0
- package/input/InputPrefix.mjs +24 -0
- package/input/InputSeparator.js +8 -0
- package/input/InputSeparator.mjs +24 -0
- package/input/InputSuffix.js +8 -0
- package/input/InputSuffix.mjs +24 -0
- package/input/InputValidationIcon.js +8 -0
- package/input/InputValidationIcon.mjs +15 -0
- package/maskedtextbox/MaskedTextBox.js +8 -0
- package/maskedtextbox/MaskedTextBox.mjs +322 -0
- package/maskedtextbox/masking.service.js +8 -0
- package/maskedtextbox/masking.service.mjs +121 -0
- package/maskedtextbox/parsing/combinators.js +8 -0
- package/maskedtextbox/parsing/combinators.mjs +20 -0
- package/maskedtextbox/parsing/parsers.js +8 -0
- package/maskedtextbox/parsing/parsers.mjs +80 -0
- package/maskedtextbox/parsing/result.js +8 -0
- package/maskedtextbox/parsing/result.mjs +35 -0
- package/maskedtextbox/parsing/stream.js +8 -0
- package/maskedtextbox/parsing/stream.mjs +41 -0
- package/maskedtextbox/utils.js +8 -0
- package/maskedtextbox/utils.mjs +43 -0
- package/messages/index.js +8 -0
- package/messages/index.mjs +77 -0
- package/numerictextbox/NumericTextBox.js +8 -0
- package/numerictextbox/NumericTextBox.mjs +415 -0
- package/numerictextbox/utils/index.js +8 -0
- package/numerictextbox/utils/index.mjs +218 -0
- package/package-metadata.js +8 -0
- package/package-metadata.mjs +19 -0
- package/package.json +8 -8
- package/radiobutton/RadioButton.js +8 -0
- package/radiobutton/RadioButton.mjs +138 -0
- package/radiobutton/RadioGroup.js +8 -0
- package/radiobutton/RadioGroup.mjs +135 -0
- package/range-slider/RangeSlider.js +20 -0
- package/range-slider/RangeSlider.mjs +337 -0
- package/range-slider/range-raducer.js +8 -0
- package/range-slider/range-raducer.mjs +90 -0
- package/rating/Rating.js +12 -0
- package/rating/Rating.mjs +323 -0
- package/rating/RatingItem.js +8 -0
- package/rating/RatingItem.mjs +144 -0
- package/rating/rating-reducer.js +8 -0
- package/rating/rating-reducer.mjs +34 -0
- package/rating/utils/index.js +8 -0
- package/rating/utils/index.mjs +28 -0
- package/signature/Signature.js +8 -0
- package/signature/Signature.mjs +335 -0
- package/signature/utils/index.js +8 -0
- package/signature/utils/index.mjs +17 -0
- package/slider/Slider.js +8 -0
- package/slider/Slider.mjs +223 -0
- package/slider/SliderLabel.js +8 -0
- package/slider/SliderLabel.mjs +39 -0
- package/switch/Switch.js +8 -0
- package/switch/Switch.mjs +228 -0
- package/textarea/TextArea.js +8 -0
- package/textarea/TextArea.mjs +196 -0
- package/textbox/Textbox.js +8 -0
- package/textbox/Textbox.mjs +125 -0
- package/checkbox/Checkbox.d.ts +0 -36
- package/checkbox/interfaces/CheckboxBlurEvent.d.ts +0 -11
- package/checkbox/interfaces/CheckboxChangeEvent.d.ts +0 -15
- package/checkbox/interfaces/CheckboxFocusEvent.d.ts +0 -11
- package/checkbox/interfaces/CheckboxProps.d.ts +0 -126
- package/colors/ColorContrastLabels.d.ts +0 -19
- package/colors/ColorContrastSvg.d.ts +0 -22
- package/colors/ColorGradient.d.ts +0 -191
- package/colors/ColorInput.d.ts +0 -34
- package/colors/ColorPalette.d.ts +0 -127
- package/colors/ColorPicker.d.ts +0 -34
- package/colors/FlatColorPicker.d.ts +0 -139
- package/colors/HexInput.d.ts +0 -33
- package/colors/Picker.d.ts +0 -10
- package/colors/interfaces/ColorGradientChangeEvent.d.ts +0 -15
- package/colors/interfaces/ColorGradientProps.d.ts +0 -101
- package/colors/interfaces/ColorPaletteChangeEvent.d.ts +0 -19
- package/colors/interfaces/ColorPaletteProps.d.ts +0 -87
- package/colors/interfaces/ColorPickerActiveColorClick.d.ts +0 -21
- package/colors/interfaces/ColorPickerBlurEvent.d.ts +0 -17
- package/colors/interfaces/ColorPickerChangeEvent.d.ts +0 -21
- package/colors/interfaces/ColorPickerFocusEvent.d.ts +0 -17
- package/colors/interfaces/ColorPickerGradientSettings.d.ts +0 -22
- package/colors/interfaces/ColorPickerPaletteSettings.d.ts +0 -36
- package/colors/interfaces/ColorPickerPopupSettings.d.ts +0 -18
- package/colors/interfaces/ColorPickerProps.d.ts +0 -165
- package/colors/interfaces/ColorPickerView.d.ts +0 -14
- package/colors/interfaces/PickerPopupSettings.d.ts +0 -22
- package/colors/interfaces/PickerProps.d.ts +0 -46
- package/colors/models/hsva.d.ts +0 -13
- package/colors/models/output-format.d.ts +0 -8
- package/colors/models/palette-presets.d.ts +0 -57
- package/colors/models/rgb.d.ts +0 -12
- package/colors/models/rgba.d.ts +0 -13
- package/colors/models/table-cell.d.ts +0 -11
- package/colors/models/tile-size.d.ts +0 -15
- package/colors/utils/color-cache.d.ts +0 -34
- package/colors/utils/color-palette.service.d.ts +0 -16
- package/colors/utils/color-parser.d.ts +0 -69
- package/colors/utils/misc.d.ts +0 -19
- package/colors/utils/svg-calc.d.ts +0 -66
- package/input/Input.d.ts +0 -171
- package/input/InputClearValue.d.ts +0 -19
- package/input/InputPrefix.d.ts +0 -29
- package/input/InputSeparator.d.ts +0 -29
- package/input/InputSuffix.d.ts +0 -29
- package/input/InputValidationIcon.d.ts +0 -18
- package/input/interfaces/InputChangeEvent.d.ts +0 -15
- package/interfaces/Direction.d.ts +0 -5
- package/interfaces/ToggleBaseProps.d.ts +0 -12
- package/maskedtextbox/MaskedTextBox.d.ts +0 -238
- package/maskedtextbox/MaskedTextBoxProps.d.ts +0 -200
- package/maskedtextbox/masking.service.d.ts +0 -45
- package/maskedtextbox/parsing/combinators.d.ts +0 -13
- package/maskedtextbox/parsing/parsers.d.ts +0 -51
- package/maskedtextbox/parsing/result.d.ts +0 -27
- package/maskedtextbox/parsing/stream.d.ts +0 -26
- package/maskedtextbox/utils.d.ts +0 -20
- package/messages/index.d.ts +0 -169
- package/numerictextbox/NumericTextBox.d.ts +0 -18
- package/numerictextbox/interfaces/NumericTextBoxBlurEvent.d.ts +0 -11
- package/numerictextbox/interfaces/NumericTextBoxChangeEvent.d.ts +0 -15
- package/numerictextbox/interfaces/NumericTextBoxFocusEvent.d.ts +0 -11
- package/numerictextbox/interfaces/NumericTextBoxHandle.d.ts +0 -43
- package/numerictextbox/interfaces/NumericTextBoxProps.d.ts +0 -188
- package/numerictextbox/interfaces/NumericTextBoxState.d.ts +0 -19
- package/numerictextbox/utils/index.d.ts +0 -123
- package/package-metadata.d.ts +0 -9
- package/radiobutton/RadioButton.d.ts +0 -27
- package/radiobutton/RadioGroup.d.ts +0 -27
- package/radiobutton/interfaces/RadioButtonBlurEvent.d.ts +0 -11
- package/radiobutton/interfaces/RadioButtonChangeEvent.d.ts +0 -15
- package/radiobutton/interfaces/RadioButtonFocusEvent.d.ts +0 -11
- package/radiobutton/interfaces/RadioButtonProps.d.ts +0 -101
- package/radiobutton/interfaces/RadioGroupChangeEvent.d.ts +0 -15
- package/radiobutton/interfaces/RadioGroupFocusEvent.d.ts +0 -11
- package/radiobutton/interfaces/RadioGroupProps.d.ts +0 -90
- package/range-slider/RangeSlider.d.ts +0 -142
- package/range-slider/range-raducer.d.ts +0 -40
- package/rating/Rating.d.ts +0 -170
- package/rating/RatingItem.d.ts +0 -108
- package/rating/models/index.d.ts +0 -88
- package/rating/rating-reducer.d.ts +0 -36
- package/rating/utils/index.d.ts +0 -28
- package/signature/Signature.d.ts +0 -18
- package/signature/interfaces/SignatureBlurEvent.d.ts +0 -11
- package/signature/interfaces/SignatureChangeEvent.d.ts +0 -15
- package/signature/interfaces/SignatureCloseEvent.d.ts +0 -11
- package/signature/interfaces/SignatureFocusEvent.d.ts +0 -11
- package/signature/interfaces/SignatureHandle.d.ts +0 -46
- package/signature/interfaces/SignatureOpenEvent.d.ts +0 -11
- package/signature/interfaces/SignatureProps.d.ts +0 -198
- package/signature/interfaces/index.d.ts +0 -11
- package/signature/utils/index.d.ts +0 -8
- package/slider/Slider.d.ts +0 -197
- package/slider/SliderLabel.d.ts +0 -38
- package/switch/Switch.d.ts +0 -294
- package/textarea/TextArea.d.ts +0 -40
- package/textarea/interfaces/TextAreaBlurEvent.d.ts +0 -11
- package/textarea/interfaces/TextAreaChangeEvent.d.ts +0 -15
- package/textarea/interfaces/TextAreaFocusEvent.d.ts +0 -11
- package/textarea/interfaces/TextAreaProps.d.ts +0 -140
- package/textbox/Textbox.d.ts +0 -80
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";
|
|
9
|
+
import * as p from "react";
|
|
10
|
+
import e from "prop-types";
|
|
11
|
+
import { MaskingService as k } from "./masking.service.mjs";
|
|
12
|
+
import { defaultRules as v, maskingChanged as P, returnFalse as m } from "./utils.mjs";
|
|
13
|
+
import { validatePackage as _, useCustomComponent as g, classNames as C, kendoThemeMaps as y, getTabIndex as S, createPropsContext as x, withIdHOC as E, withPropsContext as V } from "@progress/kendo-react-common";
|
|
14
|
+
import { FloatingLabel as O } from "@progress/kendo-react-labels";
|
|
15
|
+
import { packageMetadata as M } from "../package-metadata.mjs";
|
|
16
|
+
const l = class l extends p.Component {
|
|
17
|
+
constructor(s) {
|
|
18
|
+
super(s), this.state = {}, this._inputId = `k-${this.props.id}`, this._service = new k(), this._isPasted = !1, this._selection = [null, null], this._input = null, this.focus = () => {
|
|
19
|
+
this._input && this._input.focus();
|
|
20
|
+
}, this.pasteHandler = (t) => {
|
|
21
|
+
const { selectionStart: r, selectionEnd: i } = t.target;
|
|
22
|
+
i !== r && (this._isPasted = !0, this._selection = [r || 0, i || 0]);
|
|
23
|
+
}, this.onChangeHandler = (t) => {
|
|
24
|
+
const r = t.currentTarget, i = r.value, n = this._selection[0] || 0, a = this._selection[1] || 0;
|
|
25
|
+
if (!this.props.mask) {
|
|
26
|
+
this._isPasted = !1, this._selection = [null, null], this.triggerOnChange(i, t);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const d = this.value;
|
|
30
|
+
let o;
|
|
31
|
+
if (this._isPasted) {
|
|
32
|
+
this._isPasted = !1;
|
|
33
|
+
const u = d.length - a, h = i.length - u;
|
|
34
|
+
o = this._service.maskInRange(i.slice(n, h), d, n, a);
|
|
35
|
+
} else
|
|
36
|
+
o = this._service.maskInput(i, d, r.selectionStart || 0);
|
|
37
|
+
this._selection = [o.selection, o.selection], this.triggerOnChange(o.value, t);
|
|
38
|
+
}, this.focusHandler = (t) => {
|
|
39
|
+
this.state.focused || (this.setState({ focused: !0 }), this.props.onFocus && this.props.onFocus.call(void 0, {
|
|
40
|
+
target: this,
|
|
41
|
+
syntheticEvent: t,
|
|
42
|
+
nativeEvent: t.nativeEvent
|
|
43
|
+
}));
|
|
44
|
+
}, this.blurHandler = (t) => {
|
|
45
|
+
this.state.focused && (this.setState({ focused: !1 }), this.props.onBlur && this.props.onBlur.call(void 0, {
|
|
46
|
+
target: this,
|
|
47
|
+
syntheticEvent: t,
|
|
48
|
+
nativeEvent: t.nativeEvent
|
|
49
|
+
}));
|
|
50
|
+
}, this.setValidity = () => {
|
|
51
|
+
this.element && this.element.setCustomValidity(
|
|
52
|
+
this.validity.valid ? "" : this.props.validationMessage || ""
|
|
53
|
+
);
|
|
54
|
+
}, _(M);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Gets the element of the MaskedTextBox.
|
|
58
|
+
*
|
|
59
|
+
* @return - An `HTMLInputElement`.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```jsx
|
|
63
|
+
* class App extends React.Component {
|
|
64
|
+
* constructor(props) {
|
|
65
|
+
* super(props);
|
|
66
|
+
* }
|
|
67
|
+
* element = null;
|
|
68
|
+
* render() {
|
|
69
|
+
* return (
|
|
70
|
+
* <div>
|
|
71
|
+
* <MaskedTextBox
|
|
72
|
+
* ref={(component) =>
|
|
73
|
+
* this.element = component ? component.element : null}
|
|
74
|
+
* />
|
|
75
|
+
* <button onClick={() => console.log(this.element)}>console.log the element</button>
|
|
76
|
+
* </div>
|
|
77
|
+
* );
|
|
78
|
+
* }
|
|
79
|
+
* }
|
|
80
|
+
*
|
|
81
|
+
* ReactDOM.render(
|
|
82
|
+
* <App />,
|
|
83
|
+
* document.getElementsByTagName('my-app')[0]
|
|
84
|
+
* );
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
get element() {
|
|
88
|
+
return this._input;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Gets the value with the mask of the MaskedTextBox.
|
|
92
|
+
*/
|
|
93
|
+
get value() {
|
|
94
|
+
return this._valueDuringOnChange !== void 0 ? this._valueDuringOnChange : this.props.value !== void 0 ? this.props.value : this.state.value !== void 0 ? this.state.value : this.props.defaultValue !== void 0 ? this.props.defaultValue : "";
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Gets the raw value without the mask of the MaskedTextBox.
|
|
98
|
+
*/
|
|
99
|
+
get rawValue() {
|
|
100
|
+
return this._service.rawValue(this.value);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Represents the validity state into which the MaskedTextBox is set.
|
|
104
|
+
*/
|
|
105
|
+
get validity() {
|
|
106
|
+
const s = this.value, t = this._service.validationValue(s), r = this.props.validationMessage !== void 0, i = this.props.valid !== void 0 ? this.props.valid : (!this.required || !!t) && (!this.props.maskValidation || !this.props.prompt || s.indexOf(this.props.prompt) === -1);
|
|
107
|
+
return {
|
|
108
|
+
customError: r,
|
|
109
|
+
valid: i,
|
|
110
|
+
valueMissing: !t
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* @hidden
|
|
115
|
+
*/
|
|
116
|
+
get validityStyles() {
|
|
117
|
+
return this.props.validityStyles !== void 0 ? this.props.validityStyles : l.defaultProps.validityStyles;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* @hidden
|
|
121
|
+
*/
|
|
122
|
+
get required() {
|
|
123
|
+
return this.props.required !== void 0 ? this.props.required : l.defaultProps.required;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Gets the `name` property of the MaskedTextBox.
|
|
127
|
+
*/
|
|
128
|
+
get name() {
|
|
129
|
+
return this.props.name;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* @hidden
|
|
133
|
+
*/
|
|
134
|
+
componentDidUpdate(s, t) {
|
|
135
|
+
if (this.element && this.state.focused && t.focused) {
|
|
136
|
+
let [r, i] = this._selection;
|
|
137
|
+
const n = s.selection, a = this.props.selection;
|
|
138
|
+
(!n && a || n && a && (n.start !== a.start || n.end !== a.end)) && (r = a.start, i = a.end), r !== null && i !== null && this.element.setSelectionRange(r, i);
|
|
139
|
+
}
|
|
140
|
+
P(s, this.props) && this.updateService(), this.setValidity();
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* @hidden
|
|
144
|
+
*/
|
|
145
|
+
componentDidMount() {
|
|
146
|
+
this.updateService(), this.setValidity();
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* @hidden
|
|
150
|
+
*/
|
|
151
|
+
render() {
|
|
152
|
+
const {
|
|
153
|
+
size: s = l.defaultProps.size,
|
|
154
|
+
fillMode: t = l.defaultProps.fillMode,
|
|
155
|
+
rounded: r = l.defaultProps.rounded
|
|
156
|
+
} = this.props, i = this.props.id || this._inputId, n = !this.validityStyles || this.validity.valid, a = this.props.style || {}, {
|
|
157
|
+
prefix: d = l.defaultProps.prefix,
|
|
158
|
+
suffix: o = l.defaultProps.suffix
|
|
159
|
+
} = this.props, [u] = g(d), [h] = g(o), f = /* @__PURE__ */ p.createElement(
|
|
160
|
+
"span",
|
|
161
|
+
{
|
|
162
|
+
dir: this.props.dir,
|
|
163
|
+
className: C(
|
|
164
|
+
"k-maskedtextbox k-input",
|
|
165
|
+
{
|
|
166
|
+
[`k-input-${y.sizeMap[s] || s}`]: s,
|
|
167
|
+
[`k-input-${t}`]: t,
|
|
168
|
+
[`k-rounded-${y.roundedMap[r] || r}`]: r,
|
|
169
|
+
"k-invalid": !n,
|
|
170
|
+
"k-required": this.required,
|
|
171
|
+
"k-disabled": this.props.disabled
|
|
172
|
+
},
|
|
173
|
+
this.props.className
|
|
174
|
+
),
|
|
175
|
+
style: this.props.label ? a : { width: this.props.width, ...a }
|
|
176
|
+
},
|
|
177
|
+
/* @__PURE__ */ p.createElement(u, null),
|
|
178
|
+
/* @__PURE__ */ p.createElement(
|
|
179
|
+
"input",
|
|
180
|
+
{
|
|
181
|
+
type: "text",
|
|
182
|
+
autoComplete: "off",
|
|
183
|
+
autoCorrect: "off",
|
|
184
|
+
autoCapitalize: "off",
|
|
185
|
+
spellCheck: !1,
|
|
186
|
+
className: "k-input-inner",
|
|
187
|
+
value: this.value,
|
|
188
|
+
id: i,
|
|
189
|
+
"aria-labelledby": this.props.ariaLabelledBy,
|
|
190
|
+
"aria-describedby": this.props.ariaDescribedBy,
|
|
191
|
+
"aria-placeholder": this.props.mask,
|
|
192
|
+
name: this.props.name,
|
|
193
|
+
tabIndex: S(this.props.tabIndex, this.props.disabled, !0),
|
|
194
|
+
accessKey: this.props.accessKey,
|
|
195
|
+
title: this.props.title,
|
|
196
|
+
disabled: this.props.disabled || void 0,
|
|
197
|
+
readOnly: this.props.readonly || void 0,
|
|
198
|
+
placeholder: this.props.placeholder,
|
|
199
|
+
ref: (b) => this._input = b,
|
|
200
|
+
onChange: this.onChangeHandler,
|
|
201
|
+
onPaste: this.pasteHandler,
|
|
202
|
+
onFocus: this.focusHandler,
|
|
203
|
+
onBlur: this.blurHandler,
|
|
204
|
+
onDragStart: m,
|
|
205
|
+
onDrop: m
|
|
206
|
+
}
|
|
207
|
+
),
|
|
208
|
+
/* @__PURE__ */ p.createElement(h, null)
|
|
209
|
+
);
|
|
210
|
+
return this.props.label ? /* @__PURE__ */ p.createElement(
|
|
211
|
+
O,
|
|
212
|
+
{
|
|
213
|
+
label: this.props.label,
|
|
214
|
+
editorId: i,
|
|
215
|
+
editorValue: this.value,
|
|
216
|
+
editorValid: n,
|
|
217
|
+
editorDisabled: this.props.disabled,
|
|
218
|
+
editorPlaceholder: this.props.placeholder,
|
|
219
|
+
children: f,
|
|
220
|
+
style: { width: this.props.width },
|
|
221
|
+
dir: this.props.dir
|
|
222
|
+
}
|
|
223
|
+
) : f;
|
|
224
|
+
}
|
|
225
|
+
triggerOnChange(s, t) {
|
|
226
|
+
if (this.setState({
|
|
227
|
+
value: s
|
|
228
|
+
}), this.props.onChange) {
|
|
229
|
+
this._valueDuringOnChange = s;
|
|
230
|
+
const r = {
|
|
231
|
+
syntheticEvent: t,
|
|
232
|
+
nativeEvent: t.nativeEvent,
|
|
233
|
+
selectionStart: this._selection[0],
|
|
234
|
+
selectionEnd: this._selection[1],
|
|
235
|
+
target: this,
|
|
236
|
+
value: this.value
|
|
237
|
+
};
|
|
238
|
+
this.props.onChange.call(void 0, r), this._valueDuringOnChange = void 0;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
updateService(s) {
|
|
242
|
+
const t = Object.assign({
|
|
243
|
+
includeLiterals: this.props.includeLiterals,
|
|
244
|
+
mask: this.props.mask,
|
|
245
|
+
prompt: this.props.prompt,
|
|
246
|
+
promptPlaceholder: this.props.promptPlaceholder,
|
|
247
|
+
rules: this.rules
|
|
248
|
+
}, s);
|
|
249
|
+
this._service.update(t);
|
|
250
|
+
}
|
|
251
|
+
get rules() {
|
|
252
|
+
return Object.assign({}, v, this.props.rules);
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
l.displayName = "MaskedTextBox", l.propTypes = {
|
|
256
|
+
value: e.string,
|
|
257
|
+
defaultValue: e.string,
|
|
258
|
+
placeholder: e.string,
|
|
259
|
+
title: e.string,
|
|
260
|
+
dir: e.string,
|
|
261
|
+
id: e.string,
|
|
262
|
+
style: e.object,
|
|
263
|
+
className: e.string,
|
|
264
|
+
prefix: e.any,
|
|
265
|
+
suffix: e.any,
|
|
266
|
+
ariaLabelledBy: e.string,
|
|
267
|
+
ariaDescribedBy: e.string,
|
|
268
|
+
width: e.oneOfType([
|
|
269
|
+
e.string,
|
|
270
|
+
e.number
|
|
271
|
+
]),
|
|
272
|
+
tabIndex: e.number,
|
|
273
|
+
accessKey: e.string,
|
|
274
|
+
disabled: e.bool,
|
|
275
|
+
readonly: e.bool,
|
|
276
|
+
prompt: e.string,
|
|
277
|
+
promptPlaceholder: e.string,
|
|
278
|
+
includeLiterals: e.bool,
|
|
279
|
+
maskValidation: e.bool,
|
|
280
|
+
mask: e.string,
|
|
281
|
+
rules: function(s, t, r) {
|
|
282
|
+
const i = s.rules;
|
|
283
|
+
return i !== void 0 && !Object.entries(i).some((a) => typeof a != "string" || !(i[a] instanceof RegExp)) ? new Error(
|
|
284
|
+
"Invalid prop `" + t + "` supplied to `" + r + "`. Validation failed."
|
|
285
|
+
) : null;
|
|
286
|
+
},
|
|
287
|
+
selection: e.shape({
|
|
288
|
+
start: e.number.isRequired,
|
|
289
|
+
end: e.number.isRequired
|
|
290
|
+
}),
|
|
291
|
+
name: e.string,
|
|
292
|
+
label: e.string,
|
|
293
|
+
validationMessage: e.string,
|
|
294
|
+
required: e.bool,
|
|
295
|
+
valid: e.bool,
|
|
296
|
+
validityStyles: e.bool,
|
|
297
|
+
onChange: e.func,
|
|
298
|
+
size: e.oneOf([null, "small", "medium", "large"]),
|
|
299
|
+
rounded: e.oneOf([null, "small", "medium", "large", "full"]),
|
|
300
|
+
fillMode: e.oneOf([null, "solid", "flat", "outline"])
|
|
301
|
+
}, l.defaultProps = {
|
|
302
|
+
prompt: "_",
|
|
303
|
+
promptPlaceholder: " ",
|
|
304
|
+
includeLiterals: !1,
|
|
305
|
+
maskValidation: !0,
|
|
306
|
+
rules: v,
|
|
307
|
+
required: !1,
|
|
308
|
+
validityStyles: !0,
|
|
309
|
+
prefix: (s) => null,
|
|
310
|
+
suffix: (s) => null,
|
|
311
|
+
size: "medium",
|
|
312
|
+
rounded: "medium",
|
|
313
|
+
fillMode: "solid"
|
|
314
|
+
};
|
|
315
|
+
let c = l;
|
|
316
|
+
const I = x(), q = E(V(I, c));
|
|
317
|
+
q.displayName = "KendoReactMaskedTextBox";
|
|
318
|
+
export {
|
|
319
|
+
q as MaskedTextBox,
|
|
320
|
+
I as MaskedTextBoxPropsContext,
|
|
321
|
+
c as MaskedTextBoxWithoutContext
|
|
322
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./parsing/combinators.js"),a=require("./parsing/parsers.js");class u{constructor(){this.rules={},this.prompt="_",this.mask="",this.promptPlaceholder=" ",this.includeLiterals=!1,this.maskTokens=[],this.unmaskTokens=[],this.rawTokens=[],this.validationTokens=[]}update({mask:e="",prompt:s="",promptPlaceholder:t=" ",rules:r={},includeLiterals:n=!1}){this.mask=e,this.prompt=s,this.promptPlaceholder=t,this.rules=r,this.includeLiterals=n,this.tokenize()}validationValue(e=""){let s=e;return i.sequence(this.validationTokens).run(e).fold(t=>{s=t.join("")}),s}rawValue(e=""){let s=e;return this.rawTokens.length&&i.sequence(this.rawTokens).run(e).fold(t=>{s=t.join("")}),s}maskRaw(e=""){let s=e;return this.maskTokens.length&&i.sequence(this.maskTokens).run(e).fold(t=>{s=t.join("")}),s}maskInput(e,s,t){return e.length<s.length?this.maskRemoved(e,s,t):this.maskInserted(e,s,t)}maskInRange(e,s,t,r){let n="",l=r;const o=s.split("").slice(0,t),h=s.split("").slice(r);return i.sequence(this.maskTokens.slice(t,r)).run(e).fold(k=>{n=o.concat(k).concat(h).join("")}),{selection:l,value:n}}maskRemoved(e,s,t){let r="",n=t;const l=e.split("").slice(t),o=e.split("").slice(0,t).join(""),h=this.maskTokens.length-(e.length-t);return i.sequence(this.maskTokens.slice(0,h)).run(o,s).fold(k=>{n=this.adjustPosition(k,n),r=k.concat(l).join("")}),{selection:n,value:r}}adjustPosition(e,s){const t=e[s];return!this.maskTokens[s].isLiteral(t)&&t!==this.prompt?s+1:s}maskInserted(e,s,t){let r="",n=t;const l=e.slice(0,t);return i.sequence(this.unmaskTokens).run(l,s).chain(o=>{n=o.join("").length;const h=s.slice(n);return i.sequence(this.maskTokens).run(o.join("")+h,s)}).fold(o=>{r=o.join("")}),{selection:n,value:r}}get maskTokenCreator(){const{prompt:e,promptPlaceholder:s}=this;return{literal:t=>a.literal(t),mask:t=>a.mask({prompt:e,promptPlaceholder:s})(t)}}get unmaskTokenCreator(){return{literal:e=>a.unliteral(e),mask:e=>a.unmask(this.prompt)(e)}}get rawTokenCreator(){const{prompt:e,promptPlaceholder:s,includeLiterals:t}=this;return{literal:r=>a.rawLiteral(t),mask:r=>a.rawMask({prompt:e,promptPlaceholder:s})}}get validationTokenCreator(){const{prompt:e}=this;return{literal:s=>a.rawLiteral(!1),mask:s=>a.rawMask({prompt:e,promptPlaceholder:""})}}tokenize(){i.greedy(a.token(this.rules,this.maskTokenCreator)).run(this.mask).fold((e,s)=>{this.maskTokens=e}),i.greedy(a.token(this.rules,this.unmaskTokenCreator)).run(this.mask).fold((e,s)=>{this.unmaskTokens=e}),i.greedy(a.token(this.rules,this.rawTokenCreator)).run(this.mask).fold((e,s)=>{this.rawTokens=e}),i.greedy(a.token(this.rules,this.validationTokenCreator)).run(this.mask).fold((e,s)=>{this.validationTokens=e})}}exports.MaskingService=u;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";
|
|
9
|
+
import { sequence as i, greedy as k } from "./parsing/combinators.mjs";
|
|
10
|
+
import { literal as d, mask as T, unliteral as p, unmask as f, rawLiteral as m, rawMask as c, token as u } from "./parsing/parsers.mjs";
|
|
11
|
+
class C {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.rules = {}, this.prompt = "_", this.mask = "", this.promptPlaceholder = " ", this.includeLiterals = !1, this.maskTokens = [], this.unmaskTokens = [], this.rawTokens = [], this.validationTokens = [];
|
|
14
|
+
}
|
|
15
|
+
update({ mask: e = "", prompt: s = "", promptPlaceholder: t = " ", rules: r = {}, includeLiterals: n = !1 }) {
|
|
16
|
+
this.mask = e, this.prompt = s, this.promptPlaceholder = t, this.rules = r, this.includeLiterals = n, this.tokenize();
|
|
17
|
+
}
|
|
18
|
+
validationValue(e = "") {
|
|
19
|
+
let s = e;
|
|
20
|
+
return i(this.validationTokens).run(e).fold((t) => {
|
|
21
|
+
s = t.join("");
|
|
22
|
+
}), s;
|
|
23
|
+
}
|
|
24
|
+
rawValue(e = "") {
|
|
25
|
+
let s = e;
|
|
26
|
+
return this.rawTokens.length && i(this.rawTokens).run(e).fold((t) => {
|
|
27
|
+
s = t.join("");
|
|
28
|
+
}), s;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* @hidden
|
|
32
|
+
*/
|
|
33
|
+
maskRaw(e = "") {
|
|
34
|
+
let s = e;
|
|
35
|
+
return this.maskTokens.length && i(this.maskTokens).run(e).fold((t) => {
|
|
36
|
+
s = t.join("");
|
|
37
|
+
}), s;
|
|
38
|
+
}
|
|
39
|
+
maskInput(e, s, t) {
|
|
40
|
+
return e.length < s.length ? this.maskRemoved(e, s, t) : this.maskInserted(e, s, t);
|
|
41
|
+
}
|
|
42
|
+
maskInRange(e, s, t, r) {
|
|
43
|
+
let n = "", o = r;
|
|
44
|
+
const a = s.split("").slice(0, t), l = s.split("").slice(r);
|
|
45
|
+
return i(this.maskTokens.slice(t, r)).run(e).fold((h) => {
|
|
46
|
+
n = a.concat(h).concat(l).join("");
|
|
47
|
+
}), {
|
|
48
|
+
selection: o,
|
|
49
|
+
value: n
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
maskRemoved(e, s, t) {
|
|
53
|
+
let r = "", n = t;
|
|
54
|
+
const o = e.split("").slice(t), a = e.split("").slice(0, t).join(""), l = this.maskTokens.length - (e.length - t);
|
|
55
|
+
return i(this.maskTokens.slice(0, l)).run(a, s).fold((h) => {
|
|
56
|
+
n = this.adjustPosition(h, n), r = h.concat(o).join("");
|
|
57
|
+
}), {
|
|
58
|
+
selection: n,
|
|
59
|
+
value: r
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
adjustPosition(e, s) {
|
|
63
|
+
const t = e[s];
|
|
64
|
+
return !this.maskTokens[s].isLiteral(t) && t !== this.prompt ? s + 1 : s;
|
|
65
|
+
}
|
|
66
|
+
maskInserted(e, s, t) {
|
|
67
|
+
let r = "", n = t;
|
|
68
|
+
const o = e.slice(0, t);
|
|
69
|
+
return i(this.unmaskTokens).run(o, s).chain((a) => {
|
|
70
|
+
n = a.join("").length;
|
|
71
|
+
const l = s.slice(n);
|
|
72
|
+
return i(this.maskTokens).run(a.join("") + l, s);
|
|
73
|
+
}).fold((a) => {
|
|
74
|
+
r = a.join("");
|
|
75
|
+
}), {
|
|
76
|
+
selection: n,
|
|
77
|
+
value: r
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
get maskTokenCreator() {
|
|
81
|
+
const { prompt: e, promptPlaceholder: s } = this;
|
|
82
|
+
return {
|
|
83
|
+
literal: (t) => d(t),
|
|
84
|
+
mask: (t) => T({ prompt: e, promptPlaceholder: s })(t)
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
get unmaskTokenCreator() {
|
|
88
|
+
return {
|
|
89
|
+
literal: (e) => p(e),
|
|
90
|
+
mask: (e) => f(this.prompt)(e)
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
get rawTokenCreator() {
|
|
94
|
+
const { prompt: e, promptPlaceholder: s, includeLiterals: t } = this;
|
|
95
|
+
return {
|
|
96
|
+
literal: (r) => m(t),
|
|
97
|
+
mask: (r) => c({ prompt: e, promptPlaceholder: s })
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
get validationTokenCreator() {
|
|
101
|
+
const { prompt: e } = this;
|
|
102
|
+
return {
|
|
103
|
+
literal: (s) => m(!1),
|
|
104
|
+
mask: (s) => c({ prompt: e, promptPlaceholder: "" })
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
tokenize() {
|
|
108
|
+
k(u(this.rules, this.maskTokenCreator)).run(this.mask).fold((e, s) => {
|
|
109
|
+
this.maskTokens = e;
|
|
110
|
+
}), k(u(this.rules, this.unmaskTokenCreator)).run(this.mask).fold((e, s) => {
|
|
111
|
+
this.unmaskTokens = e;
|
|
112
|
+
}), k(u(this.rules, this.rawTokenCreator)).run(this.mask).fold((e, s) => {
|
|
113
|
+
this.rawTokens = e;
|
|
114
|
+
}), k(u(this.rules, this.validationTokenCreator)).run(this.mask).fold((e, s) => {
|
|
115
|
+
this.validationTokens = e;
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
export {
|
|
120
|
+
C as MaskingService
|
|
121
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./parsers.js"),s=require("./result.js"),u=n=>new t.Parser(e=>new s.Result(n,e)),o=(n,e)=>n.chain(r=>e.map(c=>r.concat([c]))),l=n=>n.reduce((e,r)=>o(e,r),u([])),a=n=>new t.Parser(e=>{let r=new s.Result([],e);for(;!e.eof();)r=r.concat(n.run(e));return r});exports.greedy=a;exports.sequence=l;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";
|
|
9
|
+
import { Parser as o } from "./parsers.mjs";
|
|
10
|
+
import { Result as t } from "./result.mjs";
|
|
11
|
+
const s = (n) => new o((e) => new t(n, e)), u = (n, e) => n.chain((c) => e.map((r) => c.concat([r]))), p = (n) => n.reduce((e, c) => u(e, c), s([])), w = (n) => new o((e) => {
|
|
12
|
+
let c = new t([], e);
|
|
13
|
+
for (; !e.eof(); )
|
|
14
|
+
c = c.concat(n.run(e));
|
|
15
|
+
return c;
|
|
16
|
+
});
|
|
17
|
+
export {
|
|
18
|
+
w as greedy,
|
|
19
|
+
p as sequence
|
|
20
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./result.js"),o=require("./stream.js"),w=r=>(r||"").split(""),a="\\";class s{constructor(t){this.parse=t}run(t,e=""){return t instanceof o.Stream?this.parse(t):this.parse(new o.Stream(w(t),w(e)))}map(t){return new s(e=>this.parse(e).map(t))}chain(t){return new s(e=>this.parse(e).chain((l,u)=>t(l).run(u)))}isLiteral(t){return this.run(t).type===n.ResultType.Literal}}const p=r=>t=>new s(e=>{const{prompt:l,promptPlaceholder:u}=r;for(;!e.eof();){const{char:i,control:c}=e.peek();if(i===c&&c===l)return e.eat(),new n.Result(l,e,n.ResultType.Mask);if(t.test(i))return e.eat(),new n.Result(i,e,n.ResultType.Mask);if(i===u)return e.eat(),new n.Result(l,e,n.ResultType.Mask);e.eat_input()}return e.eat(),new n.Result(l,e,n.ResultType.Mask)}),R=r=>new s(t=>t.peek().char===r?(t.eat(),new n.Result(r,t,n.ResultType.Literal)):new n.Result(r,t,n.ResultType.Literal)),h=r=>t=>new s(e=>{for(;!e.eof();){const{char:l,control:u}=e.peek();if(l===r&&u===r)return e.eat(),new n.Result(l,e);if(t.test(l))return e.eat(),new n.Result(l,e);e.eat_input()}return e.eat(),new n.Result("",e)}),f=r=>new s(t=>{if(t.eof())return new n.Result("",t);const{char:e}=t.peek();return e===r&&t.eat(),new n.Result(r,t)}),k=(r,t)=>new s(e=>{let{char:l}=e.next();const u=r[l];return l===a?(l=e.next().char,new n.Result(t.literal(l),e)):u?new n.Result(t.mask(u),e):new n.Result(t.literal(l),e)}),y=r=>new s(t=>{const{prompt:e,promptPlaceholder:l}=r;let{char:u}=t.next();return u===e?new n.Result(l,t):new n.Result(u,t)}),T=r=>new s(t=>{let{char:e}=t.next();return r?new n.Result(e,t):new n.Result("",t)});exports.Parser=s;exports.literal=R;exports.mask=p;exports.rawLiteral=T;exports.rawMask=y;exports.token=k;exports.unliteral=f;exports.unmask=h;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";
|
|
9
|
+
import { Result as i, ResultType as l } from "./result.mjs";
|
|
10
|
+
import { Stream as p } from "./stream.mjs";
|
|
11
|
+
const h = (t) => (t || "").split(""), a = "\\";
|
|
12
|
+
class u {
|
|
13
|
+
constructor(e) {
|
|
14
|
+
this.parse = e;
|
|
15
|
+
}
|
|
16
|
+
run(e, n = "") {
|
|
17
|
+
return e instanceof p ? this.parse(e) : this.parse(new p(h(e), h(n)));
|
|
18
|
+
}
|
|
19
|
+
// map :: Functor f => f a ~> (a -> b) -> f b
|
|
20
|
+
map(e) {
|
|
21
|
+
return new u((n) => this.parse(n).map(e));
|
|
22
|
+
}
|
|
23
|
+
// chain :: Chain m => m a ~> (a -> m b) -> m b
|
|
24
|
+
chain(e) {
|
|
25
|
+
return new u((n) => this.parse(n).chain((r, c) => e(r).run(c)));
|
|
26
|
+
}
|
|
27
|
+
isLiteral(e) {
|
|
28
|
+
return this.run(e).type === l.Literal;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const k = (t) => (e) => new u((n) => {
|
|
32
|
+
const { prompt: r, promptPlaceholder: c } = t;
|
|
33
|
+
for (; !n.eof(); ) {
|
|
34
|
+
const { char: o, control: w } = n.peek();
|
|
35
|
+
if (o === w && w === r)
|
|
36
|
+
return n.eat(), new i(r, n, l.Mask);
|
|
37
|
+
if (e.test(o))
|
|
38
|
+
return n.eat(), new i(o, n, l.Mask);
|
|
39
|
+
if (o === c)
|
|
40
|
+
return n.eat(), new i(r, n, l.Mask);
|
|
41
|
+
n.eat_input();
|
|
42
|
+
}
|
|
43
|
+
return n.eat(), new i(r, n, l.Mask);
|
|
44
|
+
}), x = (t) => new u((e) => e.peek().char === t ? (e.eat(), new i(t, e, l.Literal)) : new i(t, e, l.Literal)), L = (t) => (e) => new u((n) => {
|
|
45
|
+
for (; !n.eof(); ) {
|
|
46
|
+
const { char: r, control: c } = n.peek();
|
|
47
|
+
if (r === t && c === t)
|
|
48
|
+
return n.eat(), new i(r, n);
|
|
49
|
+
if (e.test(r))
|
|
50
|
+
return n.eat(), new i(r, n);
|
|
51
|
+
n.eat_input();
|
|
52
|
+
}
|
|
53
|
+
return n.eat(), new i("", n);
|
|
54
|
+
}), M = (t) => new u((e) => {
|
|
55
|
+
if (e.eof())
|
|
56
|
+
return new i("", e);
|
|
57
|
+
const { char: n } = e.peek();
|
|
58
|
+
return n === t && e.eat(), new i(t, e);
|
|
59
|
+
}), A = (t, e) => new u((n) => {
|
|
60
|
+
let { char: r } = n.next();
|
|
61
|
+
const c = t[r];
|
|
62
|
+
return r === a ? (r = n.next().char, new i(e.literal(r), n)) : c ? new i(e.mask(c), n) : new i(e.literal(r), n);
|
|
63
|
+
}), R = (t) => new u((e) => {
|
|
64
|
+
const { prompt: n, promptPlaceholder: r } = t;
|
|
65
|
+
let { char: c } = e.next();
|
|
66
|
+
return c === n ? new i(r, e) : new i(c, e);
|
|
67
|
+
}), y = (t) => new u((e) => {
|
|
68
|
+
let { char: n } = e.next();
|
|
69
|
+
return t ? new i(n, e) : new i("", e);
|
|
70
|
+
});
|
|
71
|
+
export {
|
|
72
|
+
u as Parser,
|
|
73
|
+
x as literal,
|
|
74
|
+
k as mask,
|
|
75
|
+
y as rawLiteral,
|
|
76
|
+
R as rawMask,
|
|
77
|
+
A as token,
|
|
78
|
+
M as unliteral,
|
|
79
|
+
L as unmask
|
|
80
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var a=(e=>(e[e.Literal=0]="Literal",e[e.Mask=1]="Mask",e[e.Undefined=2]="Undefined",e))(a||{});class s{constructor(t,r,i=2){this.value=t,this.rest=r,this.type=i}map(t){return new s(t(this.value),this.rest)}chain(t){return t(this.value,this.rest)}fold(t,r){return t(this.value,this.rest)}concat(t){return this.map((r,i)=>t.chain((n,u)=>r.concat([n])))}toString(){return`Result({ value: '${this.value}', rest: ${this.rest} })`}}exports.Result=s;exports.ResultType=a;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";
|
|
9
|
+
var n = /* @__PURE__ */ ((r) => (r[r.Literal = 0] = "Literal", r[r.Mask = 1] = "Mask", r[r.Undefined = 2] = "Undefined", r))(n || {});
|
|
10
|
+
class s {
|
|
11
|
+
constructor(t, e, i = 2) {
|
|
12
|
+
this.value = t, this.rest = e, this.type = i;
|
|
13
|
+
}
|
|
14
|
+
// map :: Functor f => f a ~> (a -> b) -> f b
|
|
15
|
+
map(t) {
|
|
16
|
+
return new s(t(this.value), this.rest);
|
|
17
|
+
}
|
|
18
|
+
// chain :: Chain m => m a ~> (a -> m b) -> m b
|
|
19
|
+
chain(t) {
|
|
20
|
+
return t(this.value, this.rest);
|
|
21
|
+
}
|
|
22
|
+
fold(t, e) {
|
|
23
|
+
return t(this.value, this.rest);
|
|
24
|
+
}
|
|
25
|
+
concat(t) {
|
|
26
|
+
return this.map((e, i) => t.chain((a, h) => e.concat([a])));
|
|
27
|
+
}
|
|
28
|
+
toString() {
|
|
29
|
+
return `Result({ value: '${this.value}', rest: ${this.rest} })`;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export {
|
|
33
|
+
s as Result,
|
|
34
|
+
n as ResultType
|
|
35
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class o{constructor(t=[],r=[]){this.input=t,this.control=r,this.inputCursor=0,this.controlCursor=0}eof(){return this.inputCursor>=this.input.length}next(){return{char:this.input[this.inputCursor++],control:this.control[this.controlCursor++]}}peek(){return{char:this.input[this.inputCursor],control:this.control[this.controlCursor]}}eat_input(){this.inputCursor++}eat_control(){this.controlCursor++}eat(){this.inputCursor++,this.controlCursor++}}exports.Stream=o;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";
|
|
9
|
+
class s {
|
|
10
|
+
constructor(t = [], r = []) {
|
|
11
|
+
this.input = t, this.control = r, this.inputCursor = 0, this.controlCursor = 0;
|
|
12
|
+
}
|
|
13
|
+
eof() {
|
|
14
|
+
return this.inputCursor >= this.input.length;
|
|
15
|
+
}
|
|
16
|
+
// Get the first value from the input.
|
|
17
|
+
next() {
|
|
18
|
+
return {
|
|
19
|
+
char: this.input[this.inputCursor++],
|
|
20
|
+
control: this.control[this.controlCursor++]
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
peek() {
|
|
24
|
+
return {
|
|
25
|
+
char: this.input[this.inputCursor],
|
|
26
|
+
control: this.control[this.controlCursor]
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
eat_input() {
|
|
30
|
+
this.inputCursor++;
|
|
31
|
+
}
|
|
32
|
+
eat_control() {
|
|
33
|
+
this.controlCursor++;
|
|
34
|
+
}
|
|
35
|
+
eat() {
|
|
36
|
+
this.inputCursor++, this.controlCursor++;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
s as Stream
|
|
41
|
+
};
|