armtek-uikit-react 1.0.269 → 1.0.270

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,6 +1,6 @@
1
1
  import { jsx, Fragment, jsxs } from "react/jsx-runtime";
2
2
  import { TextField } from "../TextField/TextField.js";
3
- import { forwardRef, useState, useRef, useImperativeHandle, useMemo } from "react";
3
+ import { forwardRef, useState, useRef, useImperativeHandle, useLayoutEffect, useMemo } from "react";
4
4
  import clsx from "clsx";
5
5
  import useClickOutside from "../../../lib/hooks/useClickOutside.js";
6
6
  import ButtonIcon from "../../ButtonIcon/ButtonIcon.js";
@@ -37,6 +37,8 @@ function Select(props, ref) {
37
37
  beforeList,
38
38
  query,
39
39
  optionClassName,
40
+ onBlur: inputOnBlur,
41
+ onFocus: inputOnFocus,
40
42
  ...inputProps
41
43
  } = props;
42
44
  let [active, setActive] = useState(!!defaultOpen);
@@ -49,6 +51,40 @@ function Select(props, ref) {
49
51
  useImperativeHandle(ref, () => {
50
52
  return inputRef.current;
51
53
  }, []);
54
+ useLayoutEffect(() => {
55
+ var _a2;
56
+ if (value !== void 0 || multiple || search) return;
57
+ if (!inputRef.current) return;
58
+ const inputElement = inputRef.current;
59
+ const syncSelectedValue = (nextInputValue) => {
60
+ setSelected((prevSelected) => {
61
+ if (Array.isArray(prevSelected)) return prevSelected;
62
+ if (!nextInputValue) return prevSelected === "" ? prevSelected : "";
63
+ const optionExists = options.some((item) => getOptionValue(item) === nextInputValue);
64
+ if (!optionExists || prevSelected === nextInputValue) return prevSelected;
65
+ return nextInputValue;
66
+ });
67
+ };
68
+ syncSelectedValue(inputElement.value);
69
+ const inputValueDescriptor = Object.getOwnPropertyDescriptor(inputElement, "value");
70
+ if (!(inputValueDescriptor == null ? void 0 : inputValueDescriptor.get) || !(inputValueDescriptor == null ? void 0 : inputValueDescriptor.set)) return;
71
+ Object.defineProperty(inputElement, "value", {
72
+ configurable: true,
73
+ enumerable: (_a2 = inputValueDescriptor.enumerable) != null ? _a2 : true,
74
+ get() {
75
+ var _a3;
76
+ return (_a3 = inputValueDescriptor.get) == null ? void 0 : _a3.call(this);
77
+ },
78
+ set(nextValue) {
79
+ var _a3;
80
+ (_a3 = inputValueDescriptor.set) == null ? void 0 : _a3.call(this, nextValue);
81
+ syncSelectedValue(nextValue);
82
+ }
83
+ });
84
+ return () => {
85
+ Object.defineProperty(inputElement, "value", inputValueDescriptor);
86
+ };
87
+ }, [multiple, options, search, value]);
52
88
  const handleOpen = () => {
53
89
  if (open !== void 0) return;
54
90
  if (!inputProps.disabled) {
@@ -92,12 +128,14 @@ function Select(props, ref) {
92
128
  const handleSearch = (e) => {
93
129
  setQ(e.target.value);
94
130
  };
95
- const handleFocus = search ? () => {
131
+ const handleFocus = search ? (e) => {
96
132
  setFocused(true);
97
- } : void 0;
98
- const handleBlur = !!search ? () => {
133
+ if (inputOnFocus) inputOnFocus(e);
134
+ } : inputOnFocus;
135
+ const handleBlur = !!search ? (e) => {
99
136
  setFocused(false);
100
- } : void 0;
137
+ if (inputOnBlur) inputOnBlur(e);
138
+ } : inputOnBlur;
101
139
  const handleSelectAll = (e) => {
102
140
  if (props.disabled) return;
103
141
  let value2 = options.filter((item) => !item.disabled).map((item) => getOptionValue(item));
@@ -5,6 +5,7 @@ declare const TimeField: import("react").ForwardRefExoticComponent<{
5
5
  value?: Date | string | null;
6
6
  showTime?: boolean;
7
7
  showTimeOnly?: boolean;
8
+ preserveIncompleteTimeInput?: boolean;
8
9
  inputProps?: Omit<import("../TextField").TextFieldProps, "onChange" | "value"> & import("../../../types/theme").DataAttributes;
9
10
  showMonthYearPicker?: boolean;
10
11
  showYearPicker?: boolean;
@@ -21,6 +22,7 @@ declare const TimeField: import("react").ForwardRefExoticComponent<{
21
22
  value?: Date | string | null;
22
23
  showTime?: boolean;
23
24
  showTimeOnly?: boolean;
25
+ preserveIncompleteTimeInput?: boolean;
24
26
  inputProps?: Omit<import("../TextField").TextFieldProps, "onChange" | "value"> & import("../../../types/theme").DataAttributes;
25
27
  showMonthYearPicker?: boolean;
26
28
  showYearPicker?: boolean;
@@ -2,7 +2,7 @@ import { jsx, Fragment } from "react/jsx-runtime";
2
2
  import { DateField } from "../DateField/DateField.js";
3
3
  import { forwardRef } from "react";
4
4
  const TimeField = forwardRef((props, ref) => {
5
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(DateField, { ...props, showTime: true, ref, showTimeOnly: true }) });
5
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(DateField, { ...props, showTime: true, ref, showTimeOnly: true, preserveIncompleteTimeInput: true }) });
6
6
  });
7
7
  export {
8
8
  TimeField as default
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "armtek-uikit-react",
3
- "version": "1.0.269",
3
+ "version": "1.0.270",
4
4
  "description": "Armtek UIKit for React",
5
5
  "main": "lib/cjs/index.cjs",
6
6
  "module": "lib/esm/index.js",
@@ -26,7 +26,7 @@
26
26
  "scripts": {
27
27
  "start": "storybook dev -p 3001 --no-open --config-dir ./config/storybook",
28
28
  "build:storybook": "storybook build --config-dir ./config/storybook",
29
- "clean:build": "node -e \"const fs=require('fs'); fs.rmSync('lib',{recursive:true,force:true}); fs.rmSync('types',{recursive:true,force:true});\"",
29
+ "clean:build": "node -e \"const fs=require('fs'); const path=require('path'); const rmOpts={recursive:true,force:true,maxRetries:10,retryDelay:200}; const clean=(dir)=>{ if(!fs.existsSync(dir)) return; for (const entry of fs.readdirSync(dir)) fs.rmSync(path.join(dir, entry), rmOpts); }; clean('lib'); clean('types');\"",
30
30
  "build:esm": "vite build --config vite.config.ts --mode esm",
31
31
  "build:cjs": "vite build --config vite.config.ts --mode cjs",
32
32
  "build": "npm run clean:build && npm run build-types && npm run build:esm && npm run build:cjs && node config/postbuild-vite.mjs",
@@ -74,11 +74,11 @@
74
74
  "eslint-plugin-jsx-a11y": "^6.7.1",
75
75
  "eslint-plugin-react": "^7.33.1",
76
76
  "eslint-plugin-react-hooks": "^4.6.0",
77
- "eslint-plugin-storybook": "^9.1.7",
78
77
  "fs-extra": "^11.1.1",
79
78
  "identity-obj-proxy": "^3.0.0",
80
79
  "jsdom": "^26.1.0",
81
80
  "prettier": "^3.0.1",
81
+ "react-hook-form": "^7.73.1",
82
82
  "sass": "^1.84.0",
83
83
  "storybook": "^10.3.5",
84
84
  "ts-node": "^10.9.1",