jy-headless 0.3.6 → 0.3.11

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.
Files changed (65) hide show
  1. package/README.md +62 -0
  2. package/dist/Autocomplete/Autocomplete.d.ts +8 -0
  3. package/dist/Autocomplete/Autocomplete.js +309 -0
  4. package/dist/Autocomplete/Autocomplete.type.d.ts +36 -0
  5. package/dist/Autocomplete/index.d.ts +1 -0
  6. package/{cjs → dist}/Input/TextInput.type.d.ts +2 -2
  7. package/dist/Input/index.d.ts +2 -0
  8. package/dist/Select/Select.js +176 -0
  9. package/dist/Select/index.d.ts +1 -0
  10. package/dist/cjs/Autocomplete/Autocomplete.d.ts +8 -0
  11. package/dist/cjs/Autocomplete/Autocomplete.js +311 -0
  12. package/dist/cjs/Autocomplete/Autocomplete.type.d.ts +36 -0
  13. package/dist/cjs/Autocomplete/index.d.ts +1 -0
  14. package/{Input → dist/cjs/Input}/TextInput.type.d.ts +2 -2
  15. package/dist/cjs/Input/index.d.ts +2 -0
  16. package/dist/cjs/Select/Select.js +178 -0
  17. package/dist/cjs/Select/index.d.ts +1 -0
  18. package/dist/cjs/index.d.ts +5 -0
  19. package/{cjs → dist/cjs}/index.js +3 -0
  20. package/dist/index.d.ts +5 -0
  21. package/{index.js → dist/index.js} +2 -0
  22. package/package.json +66 -45
  23. package/Popover/Popover.d.ts +0 -2
  24. package/Popover/Popover.js +0 -75
  25. package/Popover/Popover.type.d.ts +0 -9
  26. package/Popover/index.d.ts +0 -2
  27. package/cjs/Popover/Popover.d.ts +0 -2
  28. package/cjs/Popover/Popover.js +0 -77
  29. package/cjs/Popover/Popover.type.d.ts +0 -9
  30. package/cjs/Popover/index.d.ts +0 -2
  31. package/cjs/index.d.ts +0 -4
  32. package/index.d.ts +0 -4
  33. package/version.txt +0 -1
  34. /package/{Input → dist/Input}/NumberInput.d.ts +0 -0
  35. /package/{Input → dist/Input}/NumberInput.type.d.ts +0 -0
  36. /package/{Input → dist/Input}/TextInput.d.ts +0 -0
  37. /package/{Select → dist/Select}/Select.d.ts +0 -0
  38. /package/{Select → dist/Select}/Select.type.d.ts +0 -0
  39. /package/{Tooltip → dist/Tooltip}/Tooltip.d.ts +0 -0
  40. /package/{Tooltip → dist/Tooltip}/Tooltip.js +0 -0
  41. /package/{Tooltip → dist/Tooltip}/Tooltip.type.d.ts +0 -0
  42. /package/{Tooltip → dist/Tooltip}/index.d.ts +0 -0
  43. /package/{cjs → dist/cjs}/Input/NumberInput.d.ts +0 -0
  44. /package/{cjs → dist/cjs}/Input/NumberInput.type.d.ts +0 -0
  45. /package/{cjs → dist/cjs}/Input/TextInput.d.ts +0 -0
  46. /package/{cjs → dist/cjs}/Select/Select.d.ts +0 -0
  47. /package/{cjs → dist/cjs}/Select/Select.type.d.ts +0 -0
  48. /package/{cjs → dist/cjs}/Tooltip/Tooltip.d.ts +0 -0
  49. /package/{cjs → dist/cjs}/Tooltip/Tooltip.js +0 -0
  50. /package/{cjs → dist/cjs}/Tooltip/Tooltip.type.d.ts +0 -0
  51. /package/{cjs → dist/cjs}/Tooltip/index.d.ts +0 -0
  52. /package/{cjs → dist/cjs}/hooks/index.d.ts +0 -0
  53. /package/{cjs → dist/cjs}/hooks/useDebounce.d.ts +0 -0
  54. /package/{cjs → dist/cjs}/hooks/useDebounce.js +0 -0
  55. /package/{cjs → dist/cjs}/hooks/usePortal.d.ts +0 -0
  56. /package/{cjs → dist/cjs}/hooks/usePortal.js +0 -0
  57. /package/{cjs → dist/cjs}/hooks/useThrottle.d.ts +0 -0
  58. /package/{cjs → dist/cjs}/hooks/useThrottle.js +0 -0
  59. /package/{hooks → dist/hooks}/index.d.ts +0 -0
  60. /package/{hooks → dist/hooks}/useDebounce.d.ts +0 -0
  61. /package/{hooks → dist/hooks}/useDebounce.js +0 -0
  62. /package/{hooks → dist/hooks}/usePortal.d.ts +0 -0
  63. /package/{hooks → dist/hooks}/usePortal.js +0 -0
  64. /package/{hooks → dist/hooks}/useThrottle.d.ts +0 -0
  65. /package/{hooks → dist/hooks}/useThrottle.js +0 -0
package/package.json CHANGED
@@ -1,52 +1,25 @@
1
1
  {
2
2
  "name": "jy-headless",
3
- "version": "0.3.6",
3
+ "version": "0.3.11",
4
4
  "description": "A lightweight and customizable headless UI library for React components",
5
- "license": "MIT",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.js",
7
+ "types": "dist/index.d.ts",
6
8
  "repository": "https://github.com/yCZwIqY/jy-headless",
7
- "main": "./cjs/index.js",
8
- "module": "./index.js",
9
- "types": "./index.d.ts",
9
+ "scripts": {
10
+ "build": " rollup -c",
11
+ "build-publish": "pnpm run build && node setupPackage.mjs && cd dist && npm publish",
12
+ "storybook": "storybook dev -p 6006",
13
+ "build-storybook": "storybook build"
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
10
18
  "exports": {
11
19
  ".": {
12
- "import": "./index.js",
13
- "require": "./cjs/index.js",
14
- "types": "./index.d.ts"
15
- },
16
- "./cjs": {
17
- "import": "./cjs/index.js",
18
- "require": "./cjs/cjs/index.js",
19
- "types": "./cjs/index.d.ts"
20
- },
21
- "./useDebounce": {
22
- "import": "./hooks/useDebounce.js",
23
- "require": "./cjs/hooks/useDebounce.js",
24
- "types": "./hooks/useDebounce.d.ts"
25
- },
26
- "./usePortal": {
27
- "import": "./hooks/usePortal.js",
28
- "require": "./cjs/hooks/usePortal.js",
29
- "types": "./hooks/usePortal.d.ts"
30
- },
31
- "./useThrottle": {
32
- "import": "./hooks/useThrottle.js",
33
- "require": "./cjs/hooks/useThrottle.js",
34
- "types": "./hooks/useThrottle.d.ts"
35
- },
36
- "./index": {
37
- "import": "./index.js",
38
- "require": "./cjs/index.js",
39
- "types": "./index.d.ts"
40
- },
41
- "./Popover": {
42
- "import": "./Popover/Popover.js",
43
- "require": "./cjs/Popover/Popover.js",
44
- "types": "./Popover/Popover.d.ts"
45
- },
46
- "./Tooltip": {
47
- "import": "./Tooltip/Tooltip.js",
48
- "require": "./cjs/Tooltip/Tooltip.js",
49
- "types": "./Tooltip/Tooltip.d.ts"
20
+ "import": "./dist/index.js",
21
+ "require": "./dist/cjs/index.js",
22
+ "types": "./dist/index.d.ts"
50
23
  }
51
24
  },
52
25
  "keywords": [
@@ -56,5 +29,53 @@
56
29
  "ui-library",
57
30
  "tailwind",
58
31
  "storybook"
59
- ]
60
- }
32
+ ],
33
+ "author": "",
34
+ "license": "MIT",
35
+ "type": "module",
36
+ "devDependencies": {
37
+ "@babel/core": "^7.26.10",
38
+ "@babel/preset-env": "^7.26.7",
39
+ "@babel/preset-react": "^7.26.3",
40
+ "@chromatic-com/storybook": "3.2.4",
41
+ "@rollup/plugin-babel": "^6.0.4",
42
+ "@rollup/plugin-commonjs": "^28.0.2",
43
+ "@rollup/plugin-node-resolve": "^16.0.0",
44
+ "@storybook/addon-essentials": "^8.5.1",
45
+ "@storybook/addon-interactions": "^8.5.1",
46
+ "@storybook/addon-onboarding": "^8.5.1",
47
+ "@storybook/addon-postcss": "^2.0.0",
48
+ "@storybook/blocks": "^8.5.1",
49
+ "@storybook/react": "^8.5.1",
50
+ "@storybook/react-vite": "^8.5.1",
51
+ "@storybook/test": "^8.5.1",
52
+ "@testing-library/jest-dom": "^6.6.3",
53
+ "@testing-library/react": "^16.2.0",
54
+ "@types/jest": "^29.5.14",
55
+ "@types/react": "^19.0.7",
56
+ "@types/react-dom": "^19.0.3",
57
+ "babel-jest": "^29.7.0",
58
+ "chromatic": "^11.25.1",
59
+ "jest": "^29.7.0",
60
+ "jest-environment-jsdom": "^29.7.0",
61
+ "postcss": "^8.5.1",
62
+ "prettier": "^3.4.2",
63
+ "react": "^19.0.0",
64
+ "react-dom": "^19.0.0",
65
+ "rollup": "^4.31.0",
66
+ "rollup-plugin-postcss": "^4.0.2",
67
+ "rollup-plugin-typescript2": "^0.36.0",
68
+ "storybook": "^8.5.1",
69
+ "ts-jest": "^29.2.5",
70
+ "typescript": "^5.7.3"
71
+ },
72
+ "dependencies": {
73
+ "@testing-library/user-event": "^14.6.1",
74
+ "rollup-plugin-peer-deps-external": "^2.2.4",
75
+ "tslib": "^2.8.1"
76
+ },
77
+ "peerDependencies": {
78
+ "react": "^18.0.0 || ^19.0.0",
79
+ "react-dom": "^18.0.0 || ^19.0.0"
80
+ }
81
+ }
@@ -1,2 +0,0 @@
1
- import { HoverProps } from './Popover.type';
2
- export declare const Popover: ({ children, direction, popover, domNode, rootId, key }: HoverProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,75 +0,0 @@
1
- import { jsxs, jsx } from 'react/jsx-runtime';
2
- import { useState, useRef, useCallback, useLayoutEffect } from 'react';
3
- import { createPortal } from 'react-dom';
4
-
5
- const Popover = ({ children, direction, popover, domNode, rootId, key }) => {
6
- const [visible, setVisible] = useState(false);
7
- const [position, setPosition] = useState({ top: 0, left: 0 });
8
- const rootDom = domNode ?? document.getElementById(rootId ?? 'root');
9
- const targetRef = useRef(null);
10
- const popoverRef = useRef(null);
11
- const getPopoverPosition = useCallback((targetRect, popoverRect) => {
12
- let top = 0;
13
- let left = 0;
14
- switch (direction) {
15
- case 'top-left':
16
- top = targetRect.top - popoverRect.height;
17
- left = targetRect.left;
18
- break;
19
- case 'top-center':
20
- case 'top':
21
- top = targetRect.top - popoverRect.height;
22
- left = targetRect.left + (targetRect.width - popoverRect.width) / 2;
23
- break;
24
- case 'top-right':
25
- top = targetRect.top - popoverRect.height;
26
- left = targetRect.right - popoverRect.width;
27
- break;
28
- case 'left':
29
- top = targetRect.top + (targetRect.height - popoverRect.height) / 2;
30
- left = targetRect.left - popoverRect.width;
31
- break;
32
- case 'right':
33
- top = targetRect.top + (targetRect.height - popoverRect.height) / 2;
34
- left = targetRect.right;
35
- break;
36
- case 'bottom-left':
37
- top = targetRect.bottom;
38
- left = targetRect.left;
39
- break;
40
- case 'bottom-center':
41
- case 'bottom':
42
- top = targetRect.bottom;
43
- left = targetRect.left + (targetRect.width - popoverRect.width) / 2;
44
- break;
45
- case 'bottom-right':
46
- top = targetRect.bottom;
47
- left = targetRect.right - popoverRect.width;
48
- break;
49
- }
50
- return { top, left };
51
- }, [direction]);
52
- const handleMouseEnter = () => {
53
- setVisible(true);
54
- };
55
- const handleMouseLeave = () => {
56
- setVisible(false);
57
- };
58
- useLayoutEffect(() => {
59
- if (visible && targetRef.current && popoverRef.current) {
60
- const targetRect = targetRef.current.getBoundingClientRect();
61
- const popoverRect = popoverRef.current.getBoundingClientRect();
62
- const { top, left } = getPopoverPosition(targetRect, popoverRect);
63
- setPosition({ top: top + window.scrollY, left: left + window.scrollX });
64
- }
65
- }, [visible, popover, getPopoverPosition]);
66
- return (jsxs("span", { onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, ref: targetRef, children: [children, rootDom &&
67
- visible &&
68
- createPortal(jsx("span", { ref: popoverRef, style: {
69
- position: 'absolute',
70
- top: `${position.top}px`,
71
- left: `${position.left}px`,
72
- }, children: popover }), rootDom, key)] }));
73
- };
74
-
75
- export { Popover };
@@ -1,9 +0,0 @@
1
- import { ReactNode } from 'react';
2
- export interface HoverProps {
3
- children: ReactNode;
4
- popover: ReactNode;
5
- direction: 'top-left' | 'top-center' | 'top' | 'top-right' | 'left' | 'right' | 'bottom-left' | 'bottom' | 'bottom-center' | 'bottom-right';
6
- rootId?: string;
7
- domNode?: Element;
8
- key?: string;
9
- }
@@ -1,2 +0,0 @@
1
- export * from './Popover';
2
- export * from './Popover.type';
@@ -1,2 +0,0 @@
1
- import { HoverProps } from './Popover.type';
2
- export declare const Popover: ({ children, direction, popover, domNode, rootId, key }: HoverProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,77 +0,0 @@
1
- 'use strict';
2
-
3
- var jsxRuntime = require('react/jsx-runtime');
4
- var react = require('react');
5
- var reactDom = require('react-dom');
6
-
7
- const Popover = ({ children, direction, popover, domNode, rootId, key }) => {
8
- const [visible, setVisible] = react.useState(false);
9
- const [position, setPosition] = react.useState({ top: 0, left: 0 });
10
- const rootDom = domNode ?? document.getElementById(rootId ?? 'root');
11
- const targetRef = react.useRef(null);
12
- const popoverRef = react.useRef(null);
13
- const getPopoverPosition = react.useCallback((targetRect, popoverRect) => {
14
- let top = 0;
15
- let left = 0;
16
- switch (direction) {
17
- case 'top-left':
18
- top = targetRect.top - popoverRect.height;
19
- left = targetRect.left;
20
- break;
21
- case 'top-center':
22
- case 'top':
23
- top = targetRect.top - popoverRect.height;
24
- left = targetRect.left + (targetRect.width - popoverRect.width) / 2;
25
- break;
26
- case 'top-right':
27
- top = targetRect.top - popoverRect.height;
28
- left = targetRect.right - popoverRect.width;
29
- break;
30
- case 'left':
31
- top = targetRect.top + (targetRect.height - popoverRect.height) / 2;
32
- left = targetRect.left - popoverRect.width;
33
- break;
34
- case 'right':
35
- top = targetRect.top + (targetRect.height - popoverRect.height) / 2;
36
- left = targetRect.right;
37
- break;
38
- case 'bottom-left':
39
- top = targetRect.bottom;
40
- left = targetRect.left;
41
- break;
42
- case 'bottom-center':
43
- case 'bottom':
44
- top = targetRect.bottom;
45
- left = targetRect.left + (targetRect.width - popoverRect.width) / 2;
46
- break;
47
- case 'bottom-right':
48
- top = targetRect.bottom;
49
- left = targetRect.right - popoverRect.width;
50
- break;
51
- }
52
- return { top, left };
53
- }, [direction]);
54
- const handleMouseEnter = () => {
55
- setVisible(true);
56
- };
57
- const handleMouseLeave = () => {
58
- setVisible(false);
59
- };
60
- react.useLayoutEffect(() => {
61
- if (visible && targetRef.current && popoverRef.current) {
62
- const targetRect = targetRef.current.getBoundingClientRect();
63
- const popoverRect = popoverRef.current.getBoundingClientRect();
64
- const { top, left } = getPopoverPosition(targetRect, popoverRect);
65
- setPosition({ top: top + window.scrollY, left: left + window.scrollX });
66
- }
67
- }, [visible, popover, getPopoverPosition]);
68
- return (jsxRuntime.jsxs("span", { onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, ref: targetRef, children: [children, rootDom &&
69
- visible &&
70
- reactDom.createPortal(jsxRuntime.jsx("span", { ref: popoverRef, style: {
71
- position: 'absolute',
72
- top: `${position.top}px`,
73
- left: `${position.left}px`,
74
- }, children: popover }), rootDom, key)] }));
75
- };
76
-
77
- exports.Popover = Popover;
@@ -1,9 +0,0 @@
1
- import { ReactNode } from 'react';
2
- export interface HoverProps {
3
- children: ReactNode;
4
- popover: ReactNode;
5
- direction: 'top-left' | 'top-center' | 'top' | 'top-right' | 'left' | 'right' | 'bottom-left' | 'bottom' | 'bottom-center' | 'bottom-right';
6
- rootId?: string;
7
- domNode?: Element;
8
- key?: string;
9
- }
@@ -1,2 +0,0 @@
1
- export * from './Popover';
2
- export * from './Popover.type';
package/cjs/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export * from './hooks';
2
- export * from './Tooltip';
3
- export * from './Input/TextInput';
4
- export * from './Input/NumberInput';
package/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export * from './hooks';
2
- export * from './Tooltip';
3
- export * from './Input/TextInput';
4
- export * from './Input/NumberInput';
package/version.txt DELETED
@@ -1 +0,0 @@
1
- 0.3.6
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes