jy-headless 0.2.30 → 0.2.31

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.
@@ -0,0 +1,9 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import useDebouncing from '../../hooks/useDebouncing.js';
3
+
4
+ const Button = ({ onClick, loading = false, readOnly = false, disabled = false, useDebounce = false, timeout = 300, children, ...props }) => {
5
+ const handleClick = onClick && useDebounce ? useDebouncing(onClick, timeout || 300) : onClick;
6
+ return (jsx("button", { onClick: handleClick, disabled: disabled || loading || readOnly, ...props, children: children }));
7
+ };
8
+
9
+ export { Button as default };
@@ -1 +1 @@
1
- export { default } from './Button/Button';
1
+ export * as Button from './Button/Button';
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var useDebouncing = require('../../hooks/useDebouncing.js');
5
+
6
+ const Button = ({ onClick, loading = false, readOnly = false, disabled = false, useDebounce = false, timeout = 300, children, ...props }) => {
7
+ const handleClick = onClick && useDebounce ? useDebouncing(onClick, timeout || 300) : onClick;
8
+ return (jsxRuntime.jsx("button", { onClick: handleClick, disabled: disabled || loading || readOnly, ...props, children: children }));
9
+ };
10
+
11
+ module.exports = Button;
@@ -1 +1 @@
1
- export { default } from './Button/Button';
1
+ export * as Button from './Button/Button';
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ var react = require('react');
4
+
5
+ const useDebouncing = (callback, delay) => {
6
+ const timer = react.useRef(null);
7
+ return react.useCallback(() => {
8
+ if (timer.current)
9
+ clearTimeout(timer.current);
10
+ timer.current = setTimeout(() => {
11
+ callback();
12
+ }, delay);
13
+ }, [callback, delay]);
14
+ };
15
+
16
+ module.exports = useDebouncing;
package/cjs/index.js CHANGED
@@ -1,19 +1,23 @@
1
1
  'use strict';
2
2
 
3
- require('react/jsx-runtime');
4
- require('react');
3
+ var Button = require('./buttons/Button/Button.js');
5
4
  var Input = require('./inputs/Input/Input.js');
6
5
  var ImageInput = require('./inputs/ImageInput/ImageInput.js');
7
- require('./selectors/Dropdown/Dropdown.js');
6
+ var Dropdown = require('./selectors/Dropdown/Dropdown.js');
7
+ require('react');
8
8
  var useDropdown = require('./hooks/useDropdown.js');
9
9
 
10
10
  function _interopNamespaceDefaultOnly (e) { return Object.freeze({ __proto__: null, default: e }); }
11
11
 
12
+ var Button__namespace = /*#__PURE__*/_interopNamespaceDefaultOnly(Button);
12
13
  var Input__namespace = /*#__PURE__*/_interopNamespaceDefaultOnly(Input);
14
+ var Dropdown__namespace = /*#__PURE__*/_interopNamespaceDefaultOnly(Dropdown);
13
15
 
14
16
 
15
17
 
18
+ exports.Button = Button__namespace;
16
19
  exports.Input = Input__namespace;
17
- exports.ImageInputContext = ImageInput.ImageInputContext;
20
+ exports.ImageInput = ImageInput;
21
+ exports.Dropdown = Dropdown__namespace;
18
22
  exports.DropdownContext = useDropdown.DropdownContext;
19
23
  exports.useDropdownContext = useDropdown.useDropdownContext;
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  var jsxRuntime = require('react/jsx-runtime');
4
6
  var react = require('react');
5
7
 
@@ -65,9 +67,10 @@ const ImageInputPreview = ({ src: defaultSrc, ...props }) => {
65
67
  const { previewUrl } = context;
66
68
  return jsxRuntime.jsx("img", { ...props, src: previewUrl ?? defaultSrc ?? '' });
67
69
  };
68
- Object.assign(ImageInputRoot, {
70
+ const ImageInput = Object.assign(ImageInputRoot, {
69
71
  Preview: ImageInputPreview,
70
72
  Uploader: ImageInputUploader,
71
73
  });
72
74
 
73
75
  exports.ImageInputContext = ImageInputContext;
76
+ exports.default = ImageInput;
@@ -1,2 +1,2 @@
1
1
  export * as Input from './Input/Input';
2
- export * from './ImageInput/ImageInput';
2
+ export * as ImageInput from './ImageInput/ImageInput';
@@ -45,9 +45,11 @@ const DropdownOption = ({ children, value, ...props }) => {
45
45
  const { select } = useDropdown.useDropdownContext();
46
46
  return (jsxRuntime.jsx("div", { role: "option", onClick: () => select(value), ...props, children: children }));
47
47
  };
48
- Object.assign(DropdownRoot, {
48
+ const Dropdown = Object.assign(DropdownRoot, {
49
49
  Button: DropdownButton,
50
50
  Options: DropdownOptions,
51
51
  Option: DropdownOption,
52
52
  Viewer: DropdownViewer,
53
53
  });
54
+
55
+ module.exports = Dropdown;
@@ -1 +1 @@
1
- export { default } from './Dropdown/Dropdown';
1
+ export * as Dropdown from './Dropdown/Dropdown';
@@ -0,0 +1,14 @@
1
+ import { useRef, useCallback } from 'react';
2
+
3
+ const useDebouncing = (callback, delay) => {
4
+ const timer = useRef(null);
5
+ return useCallback(() => {
6
+ if (timer.current)
7
+ clearTimeout(timer.current);
8
+ timer.current = setTimeout(() => {
9
+ callback();
10
+ }, delay);
11
+ }, [callback, delay]);
12
+ };
13
+
14
+ export { useDebouncing as default };
package/index.js CHANGED
@@ -1,7 +1,10 @@
1
- import 'react/jsx-runtime';
2
- import 'react';
1
+ import * as Button from './buttons/Button/Button.js';
2
+ export { Button };
3
3
  import * as Input from './inputs/Input/Input.js';
4
4
  export { Input };
5
- export { ImageInputContext } from './inputs/ImageInput/ImageInput.js';
6
- import './selectors/Dropdown/Dropdown.js';
5
+ import * as ImageInput from './inputs/ImageInput/ImageInput.js';
6
+ export { ImageInput };
7
+ import * as Dropdown from './selectors/Dropdown/Dropdown.js';
8
+ export { Dropdown };
9
+ import 'react';
7
10
  export { DropdownContext, useDropdownContext } from './hooks/useDropdown.js';
@@ -63,9 +63,9 @@ const ImageInputPreview = ({ src: defaultSrc, ...props }) => {
63
63
  const { previewUrl } = context;
64
64
  return jsx("img", { ...props, src: previewUrl ?? defaultSrc ?? '' });
65
65
  };
66
- Object.assign(ImageInputRoot, {
66
+ const ImageInput = Object.assign(ImageInputRoot, {
67
67
  Preview: ImageInputPreview,
68
68
  Uploader: ImageInputUploader,
69
69
  });
70
70
 
71
- export { ImageInputContext };
71
+ export { ImageInputContext, ImageInput as default };
package/inputs/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export * as Input from './Input/Input';
2
- export * from './ImageInput/ImageInput';
2
+ export * as ImageInput from './ImageInput/ImageInput';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jy-headless",
3
- "version": "0.2.30",
3
+ "version": "0.2.31",
4
4
  "description": "A lightweight and customizable headless UI library for React components",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/yCZwIqY/jy-headless",
@@ -13,11 +13,21 @@
13
13
  "require": "./cjs/index.js",
14
14
  "types": "./index.d.ts"
15
15
  },
16
+ "./Button": {
17
+ "import": "./cjs/buttons/Button/Button.js",
18
+ "require": "./cjs/cjs/buttons/Button/Button.js",
19
+ "types": "./cjs/buttons/Button/Button.d.ts"
20
+ },
16
21
  "./cjs": {
17
22
  "import": "./cjs/index.js",
18
23
  "require": "./cjs/cjs/index.js",
19
24
  "types": "./cjs/index.d.ts"
20
25
  },
26
+ "./useDebouncing": {
27
+ "import": "./hooks/useDebouncing.js",
28
+ "require": "./cjs/hooks/useDebouncing.js",
29
+ "types": "./hooks/useDebouncing.d.ts"
30
+ },
21
31
  "./useDropdown": {
22
32
  "import": "./hooks/useDropdown.js",
23
33
  "require": "./cjs/hooks/useDropdown.js",
@@ -43,9 +43,11 @@ const DropdownOption = ({ children, value, ...props }) => {
43
43
  const { select } = useDropdownContext();
44
44
  return (jsx("div", { role: "option", onClick: () => select(value), ...props, children: children }));
45
45
  };
46
- Object.assign(DropdownRoot, {
46
+ const Dropdown = Object.assign(DropdownRoot, {
47
47
  Button: DropdownButton,
48
48
  Options: DropdownOptions,
49
49
  Option: DropdownOption,
50
50
  Viewer: DropdownViewer,
51
51
  });
52
+
53
+ export { Dropdown as default };
@@ -1 +1 @@
1
- export { default } from './Dropdown/Dropdown';
1
+ export * as Dropdown from './Dropdown/Dropdown';
package/version.txt CHANGED
@@ -1 +1 @@
1
- 0.2.30
1
+ 0.2.31