@ctlyst.id/internal-ui 3.3.2 → 3.3.3

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.mjs CHANGED
@@ -4654,8 +4654,85 @@ import { Code, CodeProps, Heading, HeadingProps, Link as Link5, LinkProps, Text
4654
4654
  // src/components/time-input/components/index.tsx
4655
4655
  import { Box as Box29, Flex as Flex17, forwardRef as forwardRef12, Input as Input3, InputGroup as InputGroup5 } from "@chakra-ui/react";
4656
4656
  import { Clock } from "@ctlyst.id/internal-icon";
4657
- import { useEffect as useEffect2, useImperativeHandle as useImperativeHandle2 } from "react";
4658
- import { useTimescape } from "timescape/react";
4657
+ import { useEffect as useEffect3, useImperativeHandle as useImperativeHandle2 } from "react";
4658
+
4659
+ // src/components/time-input/components/integration.tsx
4660
+ import {
4661
+ useEffect as useEffect2,
4662
+ useLayoutEffect,
4663
+ useRef,
4664
+ useState as useState4
4665
+ } from "react";
4666
+ import { $NOW, TimescapeManager } from "timescape";
4667
+ import { marry } from "timescape";
4668
+ var useTimescape = (options = {}) => {
4669
+ var _a;
4670
+ const { date, onChangeDate, ...rest } = options;
4671
+ const [manager] = useState4(() => new TimescapeManager(date, rest));
4672
+ const onChangeDateRef = useRef(onChangeDate);
4673
+ useLayoutEffect(() => {
4674
+ onChangeDateRef.current = onChangeDate;
4675
+ }, [onChangeDate]);
4676
+ const [optionsState, update] = useState4(() => ({
4677
+ date,
4678
+ ...rest
4679
+ }));
4680
+ useEffect2(() => {
4681
+ manager.resync();
4682
+ return () => {
4683
+ manager.remove();
4684
+ };
4685
+ }, [manager]);
4686
+ useEffect2(() => {
4687
+ return manager.on("changeDate", (nextDate) => {
4688
+ var _a2;
4689
+ (_a2 = onChangeDateRef.current) == null ? void 0 : _a2.call(onChangeDateRef, nextDate);
4690
+ update((value) => ({ ...value, date: nextDate }));
4691
+ });
4692
+ }, [manager]);
4693
+ const timestamp = (_a = optionsState.date) == null ? void 0 : _a.getTime();
4694
+ useEffect2(() => {
4695
+ manager.date = timestamp;
4696
+ manager.minDate = optionsState.minDate;
4697
+ manager.maxDate = optionsState.maxDate;
4698
+ manager.hour12 = optionsState.hour12;
4699
+ manager.wrapAround = optionsState.wrapAround;
4700
+ manager.digits = optionsState.digits;
4701
+ manager.snapToStep = optionsState.snapToStep;
4702
+ }, [
4703
+ manager,
4704
+ timestamp,
4705
+ optionsState.minDate,
4706
+ optionsState.maxDate,
4707
+ optionsState.hour12,
4708
+ optionsState.wrapAround,
4709
+ optionsState.digits,
4710
+ optionsState.snapToStep
4711
+ ]);
4712
+ return {
4713
+ _manager: manager,
4714
+ getInputProps: (type, opts) => ({
4715
+ _ref: (element) => {
4716
+ if (!element) return;
4717
+ manager.registerElement(element, type, opts == null ? void 0 : opts.autofocus);
4718
+ if (opts == null ? void 0 : opts.ref) opts.ref.current = element;
4719
+ },
4720
+ get ref() {
4721
+ return this._ref;
4722
+ },
4723
+ set ref(value) {
4724
+ this._ref = value;
4725
+ }
4726
+ }),
4727
+ getRootProps: () => ({
4728
+ ref: (element) => element && manager.registerRoot(element)
4729
+ }),
4730
+ options: optionsState,
4731
+ update
4732
+ };
4733
+ };
4734
+
4735
+ // src/components/time-input/components/index.tsx
4659
4736
  import { Fragment as Fragment10, jsx as jsx63, jsxs as jsxs29 } from "react/jsx-runtime";
4660
4737
  var Time = class {
4661
4738
  constructor(hours, minutes, seconds) {
@@ -4712,7 +4789,7 @@ var TimeInput2 = forwardRef12(
4712
4789
  date,
4713
4790
  ...config2
4714
4791
  });
4715
- useEffect2(() => {
4792
+ useEffect3(() => {
4716
4793
  var _a, _b, _c, _d, _e, _f;
4717
4794
  timeValue.hours = (_b = (_a = options == null ? void 0 : options.date) == null ? void 0 : _a.getHours()) != null ? _b : 0;
4718
4795
  timeValue.minutes = (_d = (_c = options == null ? void 0 : options.date) == null ? void 0 : _c.getMinutes()) != null ? _d : 0;
@@ -4938,7 +5015,7 @@ import {
4938
5015
  UnorderedList as UnorderedList2
4939
5016
  } from "@chakra-ui/react";
4940
5017
  import { Close as X, Plus } from "@ctlyst.id/internal-icon";
4941
- import { useCallback as useCallback2, useEffect as useEffect3, useRef, useState as useState4 } from "react";
5018
+ import { useCallback as useCallback2, useEffect as useEffect4, useRef as useRef2, useState as useState5 } from "react";
4942
5019
  import { useDropzone } from "react-dropzone";
4943
5020
 
4944
5021
  // src/components/uploader/constants.ts
@@ -4998,8 +5075,8 @@ var Uploader = ({
4998
5075
  size: size2 = "lg",
4999
5076
  ...props
5000
5077
  }) => {
5001
- const inputRef = useRef(null);
5002
- const [filePreview, setFilePreview] = useState4();
5078
+ const inputRef = useRef2(null);
5079
+ const [filePreview, setFilePreview] = useState5();
5003
5080
  const toast2 = useToast();
5004
5081
  const handleRejection = useCallback2(
5005
5082
  (message, file, image) => {
@@ -5068,7 +5145,7 @@ var Uploader = ({
5068
5145
  onHandleUploadFile == null ? void 0 : onHandleUploadFile(null, null);
5069
5146
  acceptedFiles.pop();
5070
5147
  };
5071
- useEffect3(() => {
5148
+ useEffect4(() => {
5072
5149
  if (value) {
5073
5150
  if (typeof value === "string") {
5074
5151
  setFilePreview(value);
@@ -6902,7 +6979,7 @@ import { useMemo as useMemo5 } from "react";
6902
6979
 
6903
6980
  // src/provider/components/provider.tsx
6904
6981
  import axios from "axios";
6905
- import { createContext as createContext2, useContext, useEffect as useEffect4, useMemo as useMemo4, useRef as useRef2 } from "react";
6982
+ import { createContext as createContext2, useContext, useEffect as useEffect5, useMemo as useMemo4, useRef as useRef3 } from "react";
6906
6983
  import { ToastContainer as ToastContainer2 } from "react-toastify";
6907
6984
  import { jsx as jsx67, jsxs as jsxs32 } from "react/jsx-runtime";
6908
6985
  var ProviderContext = createContext2({
@@ -6913,8 +6990,8 @@ var useInternalUI = () => {
6913
6990
  return { instance };
6914
6991
  };
6915
6992
  var Provider = ({ children, config: config2, requestInterceptors, responseInterceptors }) => {
6916
- const instanceRef = useRef2(axios.create(config2));
6917
- useEffect4(() => {
6993
+ const instanceRef = useRef3(axios.create(config2));
6994
+ useEffect5(() => {
6918
6995
  requestInterceptors == null ? void 0 : requestInterceptors.forEach((interceptor) => {
6919
6996
  instanceRef.current.interceptors.request.use(interceptor);
6920
6997
  });