jclib-ui 1.1.13 → 1.1.15

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