jclib-ui 1.1.13 → 1.1.14

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.
@@ -1,4 +1,7 @@
1
- import React, { useEffect, createContext, useContext, useState, useCallback, useRef, useMemo, useLayoutEffect, useImperativeHandle } from "react";
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+ import React, { useEffect, createContext, useContext, useState, useCallback, useRef, useMemo, useLayoutEffect, forwardRef, useImperativeHandle } from "react";
2
5
  import { isMobile, isDarkMode, random, formatData, formatDataHora, formatValor, isDesktop, getDateTimeStr, getHash, validarCNPJ, validarCPF, retirarAcentuacao } from "jcinfo-utils";
3
6
  import { useDragControls, motion } from "framer-motion";
4
7
  import styled from "styled-components";
@@ -958,7 +961,7 @@ function useLocalhostBadge() {
958
961
  }
959
962
  function useTestDomainBadge(testDomain) {
960
963
  function inTestServer() {
961
- const domains = testDomain ? [].concat(testDomain) : ["test.", "test-"];
964
+ const domains = testDomain ? [].concat(testDomain) : ["test.", "test-", "dev."];
962
965
  return Boolean(
963
966
  domains.some((domain) => window.location.hostname.includes(domain))
964
967
  );
@@ -4190,7 +4193,7 @@ class InputHistory {
4190
4193
  }
4191
4194
  }
4192
4195
  InputHistory.MAX_LENGTH = 100;
4193
- class InputMask {
4196
+ let InputMask$1 = class InputMask {
4194
4197
  /**
4195
4198
  View element
4196
4199
  */
@@ -4484,8 +4487,8 @@ class InputMask {
4484
4487
  this._listeners.length = 0;
4485
4488
  delete this.el;
4486
4489
  }
4487
- }
4488
- IMask.InputMask = InputMask;
4490
+ };
4491
+ IMask.InputMask = InputMask$1;
4489
4492
  class ChangeDetails {
4490
4493
  /** Inserted symbols */
4491
4494
  /** Additional offset if any changes occurred before tail */
@@ -5540,7 +5543,7 @@ class MaskedPattern extends Masked {
5540
5543
  if (bName) {
5541
5544
  const {
5542
5545
  expose,
5543
- repeat,
5546
+ repeat: repeat2,
5544
5547
  ...bOpts
5545
5548
  } = normalizeOpts(this.blocks[bName]);
5546
5549
  const blockOpts = {
@@ -5551,10 +5554,10 @@ class MaskedPattern extends Masked {
5551
5554
  overwrite: this.overwrite,
5552
5555
  autofix: this.autofix,
5553
5556
  ...bOpts,
5554
- repeat,
5557
+ repeat: repeat2,
5555
5558
  parent: this
5556
5559
  };
5557
- const maskedBlock = repeat != null ? new IMask.RepeatBlock(
5560
+ const maskedBlock = repeat2 != null ? new IMask.RepeatBlock(
5558
5561
  blockOpts
5559
5562
  /* TODO */
5560
5563
  ) : createMask(blockOpts);
@@ -6865,12 +6868,12 @@ class RepeatBlock extends MaskedPattern {
6865
6868
  _update(opts) {
6866
6869
  var _ref3, _ref4, _this$_blocks;
6867
6870
  const {
6868
- repeat,
6871
+ repeat: repeat2,
6869
6872
  ...blockOpts
6870
6873
  } = normalizeOpts(opts);
6871
6874
  this._blockOpts = Object.assign({}, this._blockOpts, blockOpts);
6872
6875
  const block = createMask(this._blockOpts);
6873
- this.repeat = (_ref3 = (_ref4 = repeat != null ? repeat : block.repeat) != null ? _ref4 : this.repeat) != null ? _ref3 : Infinity;
6876
+ this.repeat = (_ref3 = (_ref4 = repeat2 != null ? repeat2 : block.repeat) != null ? _ref4 : this.repeat) != null ? _ref3 : Infinity;
6874
6877
  super._update({
6875
6878
  mask: "m".repeat(Math.max(this.repeatTo === Infinity && ((_this$_blocks = this._blocks) == null ? void 0 : _this$_blocks.length) || 0, this.repeatFrom)),
6876
6879
  blocks: {
@@ -8827,6 +8830,765 @@ function InputOff({
8827
8830
  )
8828
8831
  ] });
8829
8832
  }
8833
+ function defer(fn) {
8834
+ return requestAnimationFrame(fn);
8835
+ }
8836
+ function cancelDefer(deferId) {
8837
+ cancelAnimationFrame(deferId);
8838
+ }
8839
+ function setInputSelection(input, start, end) {
8840
+ if (end === void 0) {
8841
+ end = start;
8842
+ }
8843
+ input.setSelectionRange(start, end);
8844
+ }
8845
+ function getInputSelection(input) {
8846
+ const start = input.selectionStart;
8847
+ const end = input.selectionEnd;
8848
+ return {
8849
+ start,
8850
+ end,
8851
+ length: end - start
8852
+ };
8853
+ }
8854
+ function isInputFocused(input) {
8855
+ const inputDocument = input.ownerDocument;
8856
+ return inputDocument.hasFocus() && inputDocument.activeElement === input;
8857
+ }
8858
+ function getElementDocument(element) {
8859
+ return element == null ? void 0 : element.ownerDocument;
8860
+ }
8861
+ function getElementWindow(element) {
8862
+ var _a;
8863
+ return (_a = getElementDocument(element)) == null ? void 0 : _a.defaultView;
8864
+ }
8865
+ function isDOMElement(element) {
8866
+ const elementWindow = getElementWindow(element);
8867
+ return !!elementWindow && element instanceof elementWindow.HTMLElement;
8868
+ }
8869
+ function isFunction(value) {
8870
+ return typeof value === "function";
8871
+ }
8872
+ function findLastIndex(array, predicate) {
8873
+ for (let i = array.length - 1; i >= 0; i--) {
8874
+ const x = array[i];
8875
+ if (predicate(x, i)) {
8876
+ return i;
8877
+ }
8878
+ }
8879
+ return -1;
8880
+ }
8881
+ function repeat(string, n = 1) {
8882
+ let result = "";
8883
+ for (let i = 0; i < n; i++) {
8884
+ result += string;
8885
+ }
8886
+ return result;
8887
+ }
8888
+ function toString(value) {
8889
+ return `${value}`;
8890
+ }
8891
+ function useInputElement(inputRef) {
8892
+ return useCallback(() => {
8893
+ let input = inputRef.current;
8894
+ const isDOMNode = typeof window !== "undefined" && isDOMElement(input);
8895
+ if (!input || !isDOMNode) {
8896
+ return null;
8897
+ }
8898
+ if (input.nodeName !== "INPUT") {
8899
+ input = input.querySelector("input");
8900
+ }
8901
+ if (!input) {
8902
+ throw new Error(
8903
+ "react-input-mask: inputComponent doesn't contain input node"
8904
+ );
8905
+ }
8906
+ return input;
8907
+ }, [inputRef]);
8908
+ }
8909
+ function useDeferLoop(callback) {
8910
+ const deferIdRef = useRef(null);
8911
+ const runLoop = useCallback(() => {
8912
+ if (deferIdRef.current !== null) {
8913
+ return;
8914
+ }
8915
+ function loop() {
8916
+ callback();
8917
+ deferIdRef.current = defer(loop);
8918
+ }
8919
+ loop();
8920
+ }, [callback]);
8921
+ const stopLoop = useCallback(() => {
8922
+ cancelDefer(deferIdRef.current);
8923
+ deferIdRef.current = null;
8924
+ }, []);
8925
+ useEffect(() => {
8926
+ if (deferIdRef.current) {
8927
+ stopLoop();
8928
+ runLoop();
8929
+ }
8930
+ }, [runLoop, stopLoop]);
8931
+ useEffect(cancelDefer, []);
8932
+ return [runLoop, stopLoop];
8933
+ }
8934
+ function useSelection(inputRef, isMasked) {
8935
+ const selectionRef = useRef({ start: null, end: null });
8936
+ const getInputElement = useInputElement(inputRef);
8937
+ const getSelection = useCallback(() => {
8938
+ const input = getInputElement();
8939
+ return getInputSelection(input);
8940
+ }, [getInputElement]);
8941
+ const getLastSelection = useCallback(() => {
8942
+ return selectionRef.current;
8943
+ }, []);
8944
+ const setSelection = useCallback(
8945
+ (selection) => {
8946
+ const input = getInputElement();
8947
+ if (!input || !isInputFocused(input)) {
8948
+ return;
8949
+ }
8950
+ setInputSelection(input, selection.start, selection.end);
8951
+ selectionRef.current = getSelection();
8952
+ },
8953
+ [getInputElement, getSelection]
8954
+ );
8955
+ const selectionLoop = useCallback(() => {
8956
+ selectionRef.current = getSelection();
8957
+ }, [getSelection]);
8958
+ const [runSelectionLoop, stopSelectionLoop] = useDeferLoop(selectionLoop);
8959
+ useLayoutEffect(() => {
8960
+ if (!isMasked) {
8961
+ return;
8962
+ }
8963
+ const input = getInputElement();
8964
+ if (!input) {
8965
+ return;
8966
+ }
8967
+ input.addEventListener("focus", runSelectionLoop);
8968
+ input.addEventListener("blur", stopSelectionLoop);
8969
+ if (isInputFocused(input)) {
8970
+ runSelectionLoop();
8971
+ }
8972
+ return () => {
8973
+ input.removeEventListener("focus", runSelectionLoop);
8974
+ input.removeEventListener("blur", stopSelectionLoop);
8975
+ stopSelectionLoop();
8976
+ };
8977
+ });
8978
+ return { getSelection, getLastSelection, setSelection };
8979
+ }
8980
+ function useValue(inputRef, initialValue) {
8981
+ const getInputElement = useInputElement(inputRef);
8982
+ const valueRef = useRef(initialValue);
8983
+ const getValue = useCallback(() => {
8984
+ const input = getInputElement();
8985
+ return input.value;
8986
+ }, [getInputElement]);
8987
+ const getLastValue = useCallback(() => {
8988
+ return valueRef.current;
8989
+ }, []);
8990
+ const setValue = useCallback(
8991
+ (newValue) => {
8992
+ valueRef.current = newValue;
8993
+ const input = getInputElement();
8994
+ if (input) {
8995
+ input.value = newValue;
8996
+ }
8997
+ },
8998
+ [getInputElement]
8999
+ );
9000
+ return {
9001
+ getValue,
9002
+ getLastValue,
9003
+ setValue
9004
+ };
9005
+ }
9006
+ function useInputState(initialValue, isMasked) {
9007
+ const inputRef = useRef();
9008
+ const { getSelection, getLastSelection, setSelection } = useSelection(
9009
+ inputRef,
9010
+ isMasked
9011
+ );
9012
+ const { getValue, getLastValue, setValue } = useValue(inputRef, initialValue);
9013
+ function getLastInputState() {
9014
+ return {
9015
+ value: getLastValue(),
9016
+ selection: getLastSelection()
9017
+ };
9018
+ }
9019
+ function getInputState() {
9020
+ return {
9021
+ value: getValue(),
9022
+ selection: getSelection()
9023
+ };
9024
+ }
9025
+ function setInputState({ value, selection }) {
9026
+ setValue(value);
9027
+ setSelection(selection);
9028
+ }
9029
+ return {
9030
+ inputRef,
9031
+ getInputState,
9032
+ getLastInputState,
9033
+ setInputState
9034
+ };
9035
+ }
9036
+ function usePrevious(value) {
9037
+ const ref = useRef();
9038
+ useEffect(() => {
9039
+ ref.current = value;
9040
+ });
9041
+ return ref.current;
9042
+ }
9043
+ const CONTROLLED_PROPS = [
9044
+ "disabled",
9045
+ "onBlur",
9046
+ "onChange",
9047
+ "onFocus",
9048
+ "onMouseDown",
9049
+ "readOnly",
9050
+ "value"
9051
+ ];
9052
+ const defaultFormatChars = {
9053
+ "9": /[0-9]/,
9054
+ a: /[A-Za-z]/,
9055
+ "*": /[A-Za-z0-9]/
9056
+ };
9057
+ function invariant(condition, message) {
9058
+ if (!condition) {
9059
+ throw new Error(message);
9060
+ }
9061
+ }
9062
+ function warning(condition, message) {
9063
+ if (!condition) {
9064
+ console.warn(message);
9065
+ }
9066
+ }
9067
+ function validateMaxLength(props) {
9068
+ warning(
9069
+ !props.maxLength || !props.mask,
9070
+ "react-input-mask: maxLength property shouldn't be passed to the masked input. It breaks masking and unnecessary because length is limited by the mask length."
9071
+ );
9072
+ }
9073
+ function validateMaskPlaceholder(props) {
9074
+ const { mask, maskPlaceholder } = props;
9075
+ invariant(
9076
+ !mask || !maskPlaceholder || maskPlaceholder.length === 1 || maskPlaceholder.length === mask.length,
9077
+ `react-input-mask: maskPlaceholder should either be a single character or have the same length as the mask:
9078
+ mask: ${mask}
9079
+ maskPlaceholder: ${maskPlaceholder}`
9080
+ );
9081
+ }
9082
+ function validateChildren(props, inputElement) {
9083
+ const conflictProps = CONTROLLED_PROPS.filter(
9084
+ (propId) => inputElement.props[propId] != null && inputElement.props[propId] !== props[propId]
9085
+ );
9086
+ invariant(
9087
+ !conflictProps.length,
9088
+ `react-input-mask: the following props should be passed to the InputMask component, not to children: ${conflictProps.join(
9089
+ ","
9090
+ )}`
9091
+ );
9092
+ }
9093
+ function parseMask({ mask, maskPlaceholder }) {
9094
+ const permanents = [];
9095
+ if (!mask) {
9096
+ return {
9097
+ maskPlaceholder: null,
9098
+ mask: null,
9099
+ prefix: null,
9100
+ lastEditablePosition: null,
9101
+ permanents: []
9102
+ };
9103
+ }
9104
+ if (typeof mask === "string") {
9105
+ let isPermanent = false;
9106
+ let parsedMaskString = "";
9107
+ mask.split("").forEach((character) => {
9108
+ if (!isPermanent && character === "\\") {
9109
+ isPermanent = true;
9110
+ } else {
9111
+ if (isPermanent || !defaultFormatChars[character]) {
9112
+ permanents.push(parsedMaskString.length);
9113
+ }
9114
+ parsedMaskString += character;
9115
+ isPermanent = false;
9116
+ }
9117
+ });
9118
+ mask = parsedMaskString.split("").map((character, index) => {
9119
+ if (permanents.indexOf(index) === -1) {
9120
+ return defaultFormatChars[character];
9121
+ }
9122
+ return character;
9123
+ });
9124
+ } else {
9125
+ mask.forEach((character, index) => {
9126
+ if (typeof character === "string") {
9127
+ permanents.push(index);
9128
+ }
9129
+ });
9130
+ }
9131
+ if (maskPlaceholder) {
9132
+ if (maskPlaceholder.length === 1) {
9133
+ maskPlaceholder = mask.map((character, index) => {
9134
+ if (permanents.indexOf(index) !== -1) {
9135
+ return character;
9136
+ }
9137
+ return maskPlaceholder;
9138
+ });
9139
+ } else {
9140
+ maskPlaceholder = maskPlaceholder.split("");
9141
+ }
9142
+ permanents.forEach((position) => {
9143
+ maskPlaceholder[position] = mask[position];
9144
+ });
9145
+ maskPlaceholder = maskPlaceholder.join("");
9146
+ }
9147
+ const prefix = permanents.filter((position, index) => position === index).map((position) => mask[position]).join("");
9148
+ let lastEditablePosition = mask.length - 1;
9149
+ while (permanents.indexOf(lastEditablePosition) !== -1) {
9150
+ lastEditablePosition--;
9151
+ }
9152
+ return {
9153
+ maskPlaceholder,
9154
+ prefix,
9155
+ mask,
9156
+ lastEditablePosition,
9157
+ permanents
9158
+ };
9159
+ }
9160
+ class MaskUtils {
9161
+ constructor(options) {
9162
+ __publicField(this, "isCharacterAllowedAtPosition", (character, position) => {
9163
+ const { maskPlaceholder } = this.maskOptions;
9164
+ if (this.isCharacterFillingPosition(character, position)) {
9165
+ return true;
9166
+ }
9167
+ if (!maskPlaceholder) {
9168
+ return false;
9169
+ }
9170
+ return maskPlaceholder[position] === character;
9171
+ });
9172
+ __publicField(this, "isCharacterFillingPosition", (character, position) => {
9173
+ const { mask } = this.maskOptions;
9174
+ if (!character || position >= mask.length) {
9175
+ return false;
9176
+ }
9177
+ if (!this.isPositionEditable(position)) {
9178
+ return mask[position] === character;
9179
+ }
9180
+ const charRule = mask[position];
9181
+ return new RegExp(charRule).test(character);
9182
+ });
9183
+ __publicField(this, "isPositionEditable", (position) => {
9184
+ const { mask, permanents } = this.maskOptions;
9185
+ return position < mask.length && permanents.indexOf(position) === -1;
9186
+ });
9187
+ __publicField(this, "isValueEmpty", (value) => {
9188
+ return value.split("").every((character, position) => {
9189
+ return !this.isPositionEditable(position) || !this.isCharacterFillingPosition(character, position);
9190
+ });
9191
+ });
9192
+ __publicField(this, "isValueFilled", (value) => {
9193
+ return this.getFilledLength(value) === this.maskOptions.lastEditablePosition + 1;
9194
+ });
9195
+ __publicField(this, "getDefaultSelectionForValue", (value) => {
9196
+ const filledLength = this.getFilledLength(value);
9197
+ const cursorPosition = this.getRightEditablePosition(filledLength);
9198
+ return { start: cursorPosition, end: cursorPosition };
9199
+ });
9200
+ __publicField(this, "getFilledLength", (value) => {
9201
+ const characters = value.split("");
9202
+ const lastFilledIndex = findLastIndex(characters, (character, position) => {
9203
+ return this.isPositionEditable(position) && this.isCharacterFillingPosition(character, position);
9204
+ });
9205
+ return lastFilledIndex + 1;
9206
+ });
9207
+ __publicField(this, "getStringFillingLengthAtPosition", (string, position) => {
9208
+ const characters = string.split("");
9209
+ const insertedValue = characters.reduce((value, character) => {
9210
+ return this.insertCharacterAtPosition(value, character, value.length);
9211
+ }, repeat(" ", position));
9212
+ return insertedValue.length - position;
9213
+ });
9214
+ __publicField(this, "getLeftEditablePosition", (position) => {
9215
+ for (let i = position; i >= 0; i--) {
9216
+ if (this.isPositionEditable(i)) {
9217
+ return i;
9218
+ }
9219
+ }
9220
+ return null;
9221
+ });
9222
+ __publicField(this, "getRightEditablePosition", (position) => {
9223
+ const { mask } = this.maskOptions;
9224
+ for (let i = position; i < mask.length; i++) {
9225
+ if (this.isPositionEditable(i)) {
9226
+ return i;
9227
+ }
9228
+ }
9229
+ return null;
9230
+ });
9231
+ __publicField(this, "formatValue", (value) => {
9232
+ const { maskPlaceholder, mask } = this.maskOptions;
9233
+ if (!maskPlaceholder) {
9234
+ value = this.insertStringAtPosition("", value, 0);
9235
+ while (value.length < mask.length && !this.isPositionEditable(value.length)) {
9236
+ value += mask[value.length];
9237
+ }
9238
+ return value;
9239
+ }
9240
+ return this.insertStringAtPosition(maskPlaceholder, value, 0);
9241
+ });
9242
+ __publicField(this, "clearRange", (value, start, len) => {
9243
+ if (!len) {
9244
+ return value;
9245
+ }
9246
+ const end = start + len;
9247
+ const { maskPlaceholder, mask } = this.maskOptions;
9248
+ const clearedValue = value.split("").map((character, i) => {
9249
+ const isEditable = this.isPositionEditable(i);
9250
+ if (!maskPlaceholder && i >= end && !isEditable) {
9251
+ return "";
9252
+ }
9253
+ if (i < start || i >= end) {
9254
+ return character;
9255
+ }
9256
+ if (!isEditable) {
9257
+ return mask[i];
9258
+ }
9259
+ if (maskPlaceholder) {
9260
+ return maskPlaceholder[i];
9261
+ }
9262
+ return "";
9263
+ }).join("");
9264
+ return this.formatValue(clearedValue);
9265
+ });
9266
+ __publicField(this, "insertCharacterAtPosition", (value, character, position) => {
9267
+ const { mask, maskPlaceholder } = this.maskOptions;
9268
+ if (position >= mask.length) {
9269
+ return value;
9270
+ }
9271
+ const isAllowed = this.isCharacterAllowedAtPosition(character, position);
9272
+ const isEditable = this.isPositionEditable(position);
9273
+ const nextEditablePosition = this.getRightEditablePosition(position);
9274
+ const isNextPlaceholder = maskPlaceholder && nextEditablePosition ? character === maskPlaceholder[nextEditablePosition] : null;
9275
+ const valueBefore = value.slice(0, position);
9276
+ if (isAllowed || !isEditable) {
9277
+ const insertedCharacter = isAllowed ? character : mask[position];
9278
+ value = valueBefore + insertedCharacter;
9279
+ }
9280
+ if (!isAllowed && !isEditable && !isNextPlaceholder) {
9281
+ value = this.insertCharacterAtPosition(value, character, position + 1);
9282
+ }
9283
+ return value;
9284
+ });
9285
+ __publicField(this, "insertStringAtPosition", (value, string, position) => {
9286
+ const { mask, maskPlaceholder } = this.maskOptions;
9287
+ if (!string || position >= mask.length) {
9288
+ return value;
9289
+ }
9290
+ const characters = string.split("");
9291
+ const isFixedLength = this.isValueFilled(value) || !!maskPlaceholder;
9292
+ const valueAfter = value.slice(position);
9293
+ value = characters.reduce((value2, character) => {
9294
+ return this.insertCharacterAtPosition(value2, character, value2.length);
9295
+ }, value.slice(0, position));
9296
+ if (isFixedLength) {
9297
+ value += valueAfter.slice(value.length - position);
9298
+ } else if (this.isValueFilled(value)) {
9299
+ value += mask.slice(value.length).join("");
9300
+ } else {
9301
+ const editableCharactersAfter = valueAfter.split("").filter((character, i) => {
9302
+ return this.isPositionEditable(position + i);
9303
+ });
9304
+ value = editableCharactersAfter.reduce((value2, character) => {
9305
+ const nextEditablePosition = this.getRightEditablePosition(
9306
+ value2.length
9307
+ );
9308
+ if (nextEditablePosition === null) {
9309
+ return value2;
9310
+ }
9311
+ if (!this.isPositionEditable(value2.length)) {
9312
+ value2 += mask.slice(value2.length, nextEditablePosition).join("");
9313
+ }
9314
+ return this.insertCharacterAtPosition(value2, character, value2.length);
9315
+ }, value);
9316
+ }
9317
+ return value;
9318
+ });
9319
+ __publicField(this, "processChange", (currentState, previousState) => {
9320
+ const { mask, prefix, lastEditablePosition } = this.maskOptions;
9321
+ const { value, selection } = currentState;
9322
+ const previousValue = previousState.value;
9323
+ const previousSelection = previousState.selection;
9324
+ let newValue = value;
9325
+ let enteredString = "";
9326
+ let formattedEnteredStringLength = 0;
9327
+ let removedLength = 0;
9328
+ let cursorPosition = Math.min(previousSelection.start, selection.start);
9329
+ if (selection.end > previousSelection.start) {
9330
+ enteredString = newValue.slice(previousSelection.start, selection.end);
9331
+ formattedEnteredStringLength = this.getStringFillingLengthAtPosition(
9332
+ enteredString,
9333
+ cursorPosition
9334
+ );
9335
+ if (!formattedEnteredStringLength) {
9336
+ removedLength = 0;
9337
+ } else {
9338
+ removedLength = previousSelection.length;
9339
+ }
9340
+ } else if (newValue.length < previousValue.length) {
9341
+ removedLength = previousValue.length - newValue.length;
9342
+ }
9343
+ newValue = previousValue;
9344
+ if (removedLength) {
9345
+ if (removedLength === 1 && !previousSelection.length) {
9346
+ const deleteFromRight = previousSelection.start === selection.start;
9347
+ cursorPosition = deleteFromRight ? this.getRightEditablePosition(selection.start) : this.getLeftEditablePosition(selection.start);
9348
+ }
9349
+ newValue = this.clearRange(newValue, cursorPosition, removedLength);
9350
+ }
9351
+ newValue = this.insertStringAtPosition(
9352
+ newValue,
9353
+ enteredString,
9354
+ cursorPosition
9355
+ );
9356
+ cursorPosition += formattedEnteredStringLength;
9357
+ if (cursorPosition >= mask.length) {
9358
+ cursorPosition = mask.length;
9359
+ } else if (cursorPosition < prefix.length && !formattedEnteredStringLength) {
9360
+ cursorPosition = prefix.length;
9361
+ } else if (cursorPosition >= prefix.length && cursorPosition < lastEditablePosition && formattedEnteredStringLength) {
9362
+ cursorPosition = this.getRightEditablePosition(cursorPosition);
9363
+ }
9364
+ newValue = this.formatValue(newValue);
9365
+ return {
9366
+ value: newValue,
9367
+ enteredString,
9368
+ selection: { start: cursorPosition, end: cursorPosition }
9369
+ };
9370
+ });
9371
+ this.maskOptions = parseMask(options);
9372
+ }
9373
+ }
9374
+ class InputMaskChildrenWrapper extends React.Component {
9375
+ render() {
9376
+ const { children, ...props } = this.props;
9377
+ return React.cloneElement(children, props);
9378
+ }
9379
+ }
9380
+ function resolveInputNode(ref) {
9381
+ if (!ref || isDOMElement(ref)) {
9382
+ return ref;
9383
+ }
9384
+ const candidate = ref.input || ref.inputRef || ref.innerRef;
9385
+ const node = candidate && "current" in candidate ? candidate.current : candidate;
9386
+ return isDOMElement(node) ? node : ref;
9387
+ }
9388
+ const InputMask2 = forwardRef(function InputMask22(props, forwardedRef) {
9389
+ const {
9390
+ alwaysShowMask = false,
9391
+ children,
9392
+ mask,
9393
+ maskPlaceholder = "_",
9394
+ beforeMaskedStateChange,
9395
+ ...restProps
9396
+ } = props;
9397
+ validateMaxLength(props);
9398
+ validateMaskPlaceholder(props);
9399
+ const maskUtils = new MaskUtils({ mask, maskPlaceholder });
9400
+ const isMasked = !!mask;
9401
+ const isEditable = !restProps.disabled && !restProps.readOnly;
9402
+ const isControlled = props.value !== null && props.value !== void 0;
9403
+ const previousIsMasked = usePrevious(isMasked);
9404
+ const initialValue = toString(
9405
+ (isControlled ? props.value : props.defaultValue) || ""
9406
+ );
9407
+ const { inputRef, getInputState, setInputState, getLastInputState } = useInputState(initialValue, isMasked);
9408
+ const getInputElement = useInputElement(inputRef);
9409
+ function onChange(event) {
9410
+ const currentState = getInputState();
9411
+ const previousState = getLastInputState();
9412
+ let newInputState = maskUtils.processChange(currentState, previousState);
9413
+ if (beforeMaskedStateChange) {
9414
+ newInputState = beforeMaskedStateChange({
9415
+ currentState,
9416
+ previousState,
9417
+ nextState: newInputState
9418
+ });
9419
+ }
9420
+ setInputState(newInputState);
9421
+ if (props.onChange) {
9422
+ props.onChange(event);
9423
+ }
9424
+ }
9425
+ function onFocus(event) {
9426
+ inputRef.current = event.target;
9427
+ const currentValue = getInputState().value;
9428
+ if (isMasked && !maskUtils.isValueFilled(currentValue)) {
9429
+ let newValue = maskUtils.formatValue(currentValue);
9430
+ let newSelection = maskUtils.getDefaultSelectionForValue(newValue);
9431
+ let newInputState = {
9432
+ value: newValue,
9433
+ selection: newSelection
9434
+ };
9435
+ if (beforeMaskedStateChange) {
9436
+ newInputState = beforeMaskedStateChange({
9437
+ currentState: getInputState(),
9438
+ nextState: newInputState
9439
+ });
9440
+ newValue = newInputState.value;
9441
+ }
9442
+ setInputState(newInputState);
9443
+ if (newValue !== currentValue && props.onChange) {
9444
+ props.onChange(event);
9445
+ }
9446
+ defer(() => {
9447
+ setInputState(getLastInputState());
9448
+ });
9449
+ }
9450
+ if (props.onFocus) {
9451
+ props.onFocus(event);
9452
+ }
9453
+ }
9454
+ function onBlur(event) {
9455
+ const currentValue = getInputState().value;
9456
+ const lastValue2 = getLastInputState().value;
9457
+ if (isMasked && !alwaysShowMask && maskUtils.isValueEmpty(lastValue2)) {
9458
+ let newValue = "";
9459
+ let newInputState = {
9460
+ value: newValue,
9461
+ selection: { start: null, end: null }
9462
+ };
9463
+ if (beforeMaskedStateChange) {
9464
+ newInputState = beforeMaskedStateChange({
9465
+ currentState: getInputState(),
9466
+ nextState: newInputState
9467
+ });
9468
+ newValue = newInputState.value;
9469
+ }
9470
+ setInputState(newInputState);
9471
+ if (newValue !== currentValue && props.onChange) {
9472
+ props.onChange(event);
9473
+ }
9474
+ }
9475
+ if (props.onBlur) {
9476
+ props.onBlur(event);
9477
+ }
9478
+ }
9479
+ function onMouseDown(event) {
9480
+ const input = getInputElement();
9481
+ const { value } = getInputState();
9482
+ const inputDocument = getElementDocument(input);
9483
+ if (!isInputFocused(input) && !maskUtils.isValueFilled(value)) {
9484
+ const mouseDownX = event.clientX;
9485
+ const mouseDownY = event.clientY;
9486
+ const mouseDownTime = (/* @__PURE__ */ new Date()).getTime();
9487
+ const mouseUpHandler = (mouseUpEvent) => {
9488
+ inputDocument.removeEventListener("mouseup", mouseUpHandler);
9489
+ if (!isInputFocused(input)) {
9490
+ return;
9491
+ }
9492
+ const deltaX = Math.abs(mouseUpEvent.clientX - mouseDownX);
9493
+ const deltaY = Math.abs(mouseUpEvent.clientY - mouseDownY);
9494
+ const axisDelta = Math.max(deltaX, deltaY);
9495
+ const timeDelta = (/* @__PURE__ */ new Date()).getTime() - mouseDownTime;
9496
+ if (axisDelta <= 10 && timeDelta <= 200 || axisDelta <= 5 && timeDelta <= 300) {
9497
+ const lastState2 = getLastInputState();
9498
+ const newSelection = maskUtils.getDefaultSelectionForValue(lastState2.value);
9499
+ const newState = {
9500
+ ...lastState2,
9501
+ selection: newSelection
9502
+ };
9503
+ setInputState(newState);
9504
+ }
9505
+ };
9506
+ inputDocument.addEventListener("mouseup", mouseUpHandler);
9507
+ }
9508
+ if (props.onMouseDown) {
9509
+ props.onMouseDown(event);
9510
+ }
9511
+ }
9512
+ if (isMasked && isControlled) {
9513
+ const input = getInputElement();
9514
+ const isFocused = input && isInputFocused(input);
9515
+ let newValue = isFocused || alwaysShowMask || props.value ? maskUtils.formatValue(props.value) : props.value;
9516
+ if (beforeMaskedStateChange) {
9517
+ newValue = beforeMaskedStateChange({
9518
+ nextState: { value: newValue, selection: { start: null, end: null } }
9519
+ }).value;
9520
+ }
9521
+ setInputState({
9522
+ ...getLastInputState(),
9523
+ value: newValue
9524
+ });
9525
+ }
9526
+ const lastState = getLastInputState();
9527
+ const lastSelection = lastState.selection;
9528
+ const lastValue = lastState.value;
9529
+ useLayoutEffect(() => {
9530
+ if (!isMasked) {
9531
+ return;
9532
+ }
9533
+ const input = getInputElement();
9534
+ if (!input) {
9535
+ return;
9536
+ }
9537
+ const isFocused = isInputFocused(input);
9538
+ const previousSelection = lastSelection;
9539
+ const currentState = getInputState();
9540
+ let newInputState = { ...currentState };
9541
+ if (!isControlled) {
9542
+ const currentValue = currentState.value;
9543
+ const formattedValue = maskUtils.formatValue(currentValue);
9544
+ const isValueEmpty = maskUtils.isValueEmpty(formattedValue);
9545
+ const shouldFormatValue = !isValueEmpty || isFocused || alwaysShowMask;
9546
+ if (shouldFormatValue) {
9547
+ newInputState.value = formattedValue;
9548
+ } else if (isValueEmpty && !isFocused) {
9549
+ newInputState.value = "";
9550
+ }
9551
+ }
9552
+ if (isFocused && !previousIsMasked) {
9553
+ newInputState.selection = maskUtils.getDefaultSelectionForValue(
9554
+ newInputState.value
9555
+ );
9556
+ } else if (isControlled && isFocused && previousSelection) {
9557
+ if (previousSelection.start !== null && previousSelection.end !== null) {
9558
+ newInputState.selection = previousSelection;
9559
+ }
9560
+ }
9561
+ if (beforeMaskedStateChange) {
9562
+ newInputState = beforeMaskedStateChange({
9563
+ currentState,
9564
+ nextState: newInputState
9565
+ });
9566
+ }
9567
+ setInputState(newInputState);
9568
+ });
9569
+ const inputProps = {
9570
+ ...restProps,
9571
+ onFocus,
9572
+ onBlur,
9573
+ onChange: isMasked && isEditable ? onChange : props.onChange,
9574
+ onMouseDown: isMasked && isEditable ? onMouseDown : props.onMouseDown,
9575
+ ref: (ref) => {
9576
+ inputRef.current = resolveInputNode(ref);
9577
+ if (isFunction(forwardedRef)) {
9578
+ forwardedRef(ref);
9579
+ } else if (forwardedRef !== null && typeof forwardedRef === "object") {
9580
+ forwardedRef.current = ref;
9581
+ }
9582
+ },
9583
+ value: isMasked && isControlled ? lastValue : props.value
9584
+ };
9585
+ if (children) {
9586
+ validateChildren(props, children);
9587
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(InputMaskChildrenWrapper, { ...inputProps, children });
9588
+ }
9589
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("input", { ...inputProps });
9590
+ });
9591
+ InputMask2.displayName = "InputMask";
8830
9592
  function LabelHint({ label, hint }) {
8831
9593
  const hintTitle = "Ajuda";
8832
9594
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "label-hint--container", children: [
@@ -11801,7 +12563,7 @@ var localforage$1 = { exports: {} };
11801
12563
  var DETECT_BLOB_SUPPORT_STORE = "local-forage-detect-blob-support";
11802
12564
  var supportsBlobs = void 0;
11803
12565
  var dbContexts = {};
11804
- var toString = Object.prototype.toString;
12566
+ var toString2 = Object.prototype.toString;
11805
12567
  var READ_ONLY = "readonly";
11806
12568
  var READ_WRITE = "readwrite";
11807
12569
  function _binStringToArrayBuffer(bin) {
@@ -12182,7 +12944,7 @@ var localforage$1 = { exports: {} };
12182
12944
  var dbInfo;
12183
12945
  self2.ready().then(function() {
12184
12946
  dbInfo = self2._dbInfo;
12185
- if (toString.call(value) === "[object Blob]") {
12947
+ if (toString2.call(value) === "[object Blob]") {
12186
12948
  return _checkBlobSupport(dbInfo.db).then(function(blobSupport) {
12187
12949
  if (blobSupport) {
12188
12950
  return value;
@@ -14637,6 +15399,7 @@ export {
14637
15399
  InputFinder$1 as InputFinder,
14638
15400
  InputFone,
14639
15401
  InputHora,
15402
+ InputMask2 as InputMask,
14640
15403
  InputOff,
14641
15404
  InputPassword,
14642
15405
  InputPercent,