jy-headless 0.0.23 → 0.0.25

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,4 @@
1
+ import { IconProps } from './index';
2
+ import React from 'react';
3
+ declare const DownArrowIcon: ({ color, size, bgColor, fill, }: IconProps) => React.JSX.Element;
4
+ export default DownArrowIcon;
@@ -0,0 +1,4 @@
1
+ import { IconProps } from './index';
2
+ import React from 'react';
3
+ declare const UpArrowIcon: ({ color, size, bgColor, fill, }: IconProps) => React.JSX.Element;
4
+ export default UpArrowIcon;
@@ -1,6 +1,6 @@
1
1
  import React, { CSSProperties, InputHTMLAttributes, ReactNode } from 'react';
2
- interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
3
- clearable?: boolean;
2
+ export interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
3
+ showLimit: boolean;
4
4
  containerStyle?: CSSProperties;
5
5
  containerClassName?: string;
6
6
  prefixElement?: ReactNode;
@@ -0,0 +1,11 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { InputProps } from './Input';
3
+ interface NumberInputProps extends InputProps {
4
+ increaseElement?: ReactNode;
5
+ decreaseElement?: ReactNode;
6
+ min?: number;
7
+ max?: number;
8
+ step?: number;
9
+ }
10
+ declare const NumberInput: React.FC<NumberInputProps>;
11
+ export default NumberInput;
@@ -1,4 +1,4 @@
1
- import React, { ReactNode } from 'react';
1
+ import React, { CSSProperties, ReactNode } from 'react';
2
2
  import { ButtonProps } from '../button/Button';
3
3
  interface ModalProps {
4
4
  opener: ReactNode;
@@ -14,5 +14,7 @@ interface ModalOverlayProps {
14
14
  backgroundColor?: string;
15
15
  zIndex?: number;
16
16
  children: ReactNode;
17
+ style?: CSSProperties;
18
+ className?: string;
17
19
  }
18
20
  export default Modal;
@@ -0,0 +1,11 @@
1
+ import { ReactNode } from 'react';
2
+ interface TabItem {
3
+ label: string;
4
+ id: string | number;
5
+ redner: ReactNode;
6
+ }
7
+ interface TabProps {
8
+ tab: TabItem[];
9
+ }
10
+ declare const Tab: ({ tab }: TabProps) => void;
11
+ export default Tab;
package/dist/index.esm.js CHANGED
@@ -54,7 +54,7 @@ const Spinner = ({ color = 'black', size = '1em', spinTime = '2s' }) => {
54
54
  React.createElement("title", null, "ic_fluent_spinner_ios_20_filled"),
55
55
  React.createElement("desc", null, "Created with Sketch."),
56
56
  React.createElement("g", { id: "\uD83D\uDD0D-System-Icons", stroke: "none", strokeWidth: "1", fill: "none", fillRule: "evenodd" },
57
- React.createElement("g", { id: "ic_fluent_spinner_ios_20_filled", fill: "#212121", fillRule: "nonzero" },
57
+ React.createElement("g", { id: "ic_fluent_spinner_ios_20_filled", fill: color, fillRule: "nonzero" },
58
58
  React.createElement("path", { d: "M10,3.5 C6.41015,3.5 3.5,6.41015 3.5,10 C3.5,10.4142 3.16421,10.75 2.75,10.75 C2.33579,10.75 2,10.4142 2,10 C2,5.58172 5.58172,2 10,2 C14.4183,2 18,5.58172 18,10 C18,14.4183 14.4183,18 10,18 C9.58579,18 9.25,17.6642 9.25,17.25 C9.25,16.8358 9.58579,16.5 10,16.5 C13.5899,16.5 16.5,13.5899 16.5,10 C16.5,6.41015 13.5899,3.5 10,3.5 Z", id: "\uD83C\uDFA8-Color" })))))));
59
59
  };
60
60
 
@@ -67,13 +67,22 @@ const Button = (_a) => {
67
67
  };
68
68
 
69
69
  const Input = (_a) => {
70
- var { prefixElement, suffixElement, className, style, containerStyle, containerClassName, showError = false, error } = _a, restProps = __rest(_a, ["prefixElement", "suffixElement", "className", "style", "containerStyle", "containerClassName", "showError", "error"]);
70
+ var _b;
71
+ var { prefixElement, suffixElement, className, style, containerStyle, containerClassName, showError = false, error, maxLength, showLimit = false } = _a, restProps = __rest(_a, ["prefixElement", "suffixElement", "className", "style", "containerStyle", "containerClassName", "showError", "error", "maxLength", "showLimit"]);
72
+ const [inputValue, setInputValue] = useState(restProps.value);
73
+ const onChange = (e) => {
74
+ setInputValue(e.target.value);
75
+ restProps.onChange(e);
76
+ };
71
77
  return (React.createElement("span", { className: containerClassName, style: Object.assign({ position: 'relative', display: 'inline-flex', alignItems: 'center' }, containerStyle) },
72
78
  prefixElement,
73
- React.createElement("input", Object.assign({}, restProps, { className: className, style: Object.assign({ all: 'unset' }, style) })),
79
+ React.createElement("input", Object.assign({}, restProps, { value: inputValue, onChange: onChange, maxLength: maxLength, className: className, style: Object.assign({ all: 'unset' }, style) })),
80
+ showLimit && maxLength && (React.createElement("span", { className: 'max-length' }, (_b = (inputValue !== null && inputValue !== undefined ? inputValue : '').toString().length) !== null && _b !== undefined ? _b : 0,
81
+ "/",
82
+ maxLength)),
74
83
  suffixElement,
75
84
  showError &&
76
- (typeof error === 'string' ? (React.createElement("span", { style: { position: 'absolute', top: '100%', left: 0 } }, error)) : (error))));
85
+ (typeof error === 'string' ? (React.createElement("span", { className: 'error-message', style: { position: 'absolute', top: '100%', left: 0 } }, error)) : (error))));
77
86
  };
78
87
 
79
88
  const functionRow = [
@@ -381,36 +390,31 @@ const ModalContext = createContext({
381
390
  setIsShow: (value) => { },
382
391
  });
383
392
 
384
- const Modal = ({ opener, children, targetSelector = 'root', }) => {
393
+ const Modal = ({ opener, children, targetSelector = '#root', }) => {
385
394
  const [isShow, setIsShow] = useState(false);
386
395
  const onHandleShow = () => {
387
396
  setIsShow(true);
388
397
  };
389
398
  return (React.createElement(ModalContext.Provider, { value: { isShow, setIsShow } },
390
- React.cloneElement(opener, {
391
- onClick: onHandleShow,
392
- }),
399
+ React.isValidElement(opener) &&
400
+ React.cloneElement(opener, {
401
+ onClick: onHandleShow,
402
+ }),
393
403
  isShow &&
394
404
  document.querySelector(targetSelector) &&
395
405
  createPortal(children, document.querySelector(targetSelector))));
396
406
  };
397
- const ModalOverlay = ({ backgroundColor = 'rgba(0,0,0,0.5)', children, zIndex = 999, }) => {
398
- return (React.createElement("div", { style: {
399
- position: 'fixed',
400
- display: 'flex',
401
- justifyContent: 'center',
402
- alignItems: 'center',
403
- top: 0,
404
- right: 0,
405
- bottom: 0,
406
- left: 0,
407
- zIndex,
408
- backgroundColor,
409
- } }, children));
407
+ const ModalOverlay = ({ backgroundColor = 'rgba(0,0,0,0.5)', children, style, className, zIndex = 999, }) => {
408
+ return (React.createElement("div", { className: className, style: Object.assign({ position: 'fixed', display: 'flex', justifyContent: 'center', alignItems: 'center', top: 0, right: 0, bottom: 0, left: 0, zIndex,
409
+ backgroundColor }, style) }, children));
410
410
  };
411
411
  const ModalCloseButton = (_a) => {
412
412
  var props = __rest(_a, []);
413
- const { setIsShow } = useContext(ModalContext);
413
+ const context = useContext(ModalContext);
414
+ if (!context) {
415
+ throw new Error('ModalCloseButton must be used within a ModalContext.Provider');
416
+ }
417
+ const { setIsShow } = context;
414
418
  return React.createElement(Button, Object.assign({}, props, { onClick: () => setIsShow(false) }));
415
419
  };
416
420
  Modal.Overlay = ModalOverlay;
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.js CHANGED
@@ -56,7 +56,7 @@ const Spinner = ({ color = 'black', size = '1em', spinTime = '2s' }) => {
56
56
  React.createElement("title", null, "ic_fluent_spinner_ios_20_filled"),
57
57
  React.createElement("desc", null, "Created with Sketch."),
58
58
  React.createElement("g", { id: "\uD83D\uDD0D-System-Icons", stroke: "none", strokeWidth: "1", fill: "none", fillRule: "evenodd" },
59
- React.createElement("g", { id: "ic_fluent_spinner_ios_20_filled", fill: "#212121", fillRule: "nonzero" },
59
+ React.createElement("g", { id: "ic_fluent_spinner_ios_20_filled", fill: color, fillRule: "nonzero" },
60
60
  React.createElement("path", { d: "M10,3.5 C6.41015,3.5 3.5,6.41015 3.5,10 C3.5,10.4142 3.16421,10.75 2.75,10.75 C2.33579,10.75 2,10.4142 2,10 C2,5.58172 5.58172,2 10,2 C14.4183,2 18,5.58172 18,10 C18,14.4183 14.4183,18 10,18 C9.58579,18 9.25,17.6642 9.25,17.25 C9.25,16.8358 9.58579,16.5 10,16.5 C13.5899,16.5 16.5,13.5899 16.5,10 C16.5,6.41015 13.5899,3.5 10,3.5 Z", id: "\uD83C\uDFA8-Color" })))))));
61
61
  };
62
62
 
@@ -69,13 +69,22 @@ const Button = (_a) => {
69
69
  };
70
70
 
71
71
  const Input = (_a) => {
72
- var { prefixElement, suffixElement, className, style, containerStyle, containerClassName, showError = false, error } = _a, restProps = __rest(_a, ["prefixElement", "suffixElement", "className", "style", "containerStyle", "containerClassName", "showError", "error"]);
72
+ var _b;
73
+ var { prefixElement, suffixElement, className, style, containerStyle, containerClassName, showError = false, error, maxLength, showLimit = false } = _a, restProps = __rest(_a, ["prefixElement", "suffixElement", "className", "style", "containerStyle", "containerClassName", "showError", "error", "maxLength", "showLimit"]);
74
+ const [inputValue, setInputValue] = React.useState(restProps.value);
75
+ const onChange = (e) => {
76
+ setInputValue(e.target.value);
77
+ restProps.onChange(e);
78
+ };
73
79
  return (React.createElement("span", { className: containerClassName, style: Object.assign({ position: 'relative', display: 'inline-flex', alignItems: 'center' }, containerStyle) },
74
80
  prefixElement,
75
- React.createElement("input", Object.assign({}, restProps, { className: className, style: Object.assign({ all: 'unset' }, style) })),
81
+ React.createElement("input", Object.assign({}, restProps, { value: inputValue, onChange: onChange, maxLength: maxLength, className: className, style: Object.assign({ all: 'unset' }, style) })),
82
+ showLimit && maxLength && (React.createElement("span", { className: 'max-length' }, (_b = (inputValue !== null && inputValue !== undefined ? inputValue : '').toString().length) !== null && _b !== undefined ? _b : 0,
83
+ "/",
84
+ maxLength)),
76
85
  suffixElement,
77
86
  showError &&
78
- (typeof error === 'string' ? (React.createElement("span", { style: { position: 'absolute', top: '100%', left: 0 } }, error)) : (error))));
87
+ (typeof error === 'string' ? (React.createElement("span", { className: 'error-message', style: { position: 'absolute', top: '100%', left: 0 } }, error)) : (error))));
79
88
  };
80
89
 
81
90
  const functionRow = [
@@ -383,36 +392,31 @@ const ModalContext = React.createContext({
383
392
  setIsShow: (value) => { },
384
393
  });
385
394
 
386
- const Modal = ({ opener, children, targetSelector = 'root', }) => {
395
+ const Modal = ({ opener, children, targetSelector = '#root', }) => {
387
396
  const [isShow, setIsShow] = React.useState(false);
388
397
  const onHandleShow = () => {
389
398
  setIsShow(true);
390
399
  };
391
400
  return (React.createElement(ModalContext.Provider, { value: { isShow, setIsShow } },
392
- React.cloneElement(opener, {
393
- onClick: onHandleShow,
394
- }),
401
+ React.isValidElement(opener) &&
402
+ React.cloneElement(opener, {
403
+ onClick: onHandleShow,
404
+ }),
395
405
  isShow &&
396
406
  document.querySelector(targetSelector) &&
397
407
  reactDom.createPortal(children, document.querySelector(targetSelector))));
398
408
  };
399
- const ModalOverlay = ({ backgroundColor = 'rgba(0,0,0,0.5)', children, zIndex = 999, }) => {
400
- return (React.createElement("div", { style: {
401
- position: 'fixed',
402
- display: 'flex',
403
- justifyContent: 'center',
404
- alignItems: 'center',
405
- top: 0,
406
- right: 0,
407
- bottom: 0,
408
- left: 0,
409
- zIndex,
410
- backgroundColor,
411
- } }, children));
409
+ const ModalOverlay = ({ backgroundColor = 'rgba(0,0,0,0.5)', children, style, className, zIndex = 999, }) => {
410
+ return (React.createElement("div", { className: className, style: Object.assign({ position: 'fixed', display: 'flex', justifyContent: 'center', alignItems: 'center', top: 0, right: 0, bottom: 0, left: 0, zIndex,
411
+ backgroundColor }, style) }, children));
412
412
  };
413
413
  const ModalCloseButton = (_a) => {
414
414
  var props = __rest(_a, []);
415
- const { setIsShow } = React.useContext(ModalContext);
415
+ const context = React.useContext(ModalContext);
416
+ if (!context) {
417
+ throw new Error('ModalCloseButton must be used within a ModalContext.Provider');
418
+ }
419
+ const { setIsShow } = context;
416
420
  return React.createElement(Button, Object.assign({}, props, { onClick: () => setIsShow(false) }));
417
421
  };
418
422
  Modal.Overlay = ModalOverlay;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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
4
  "description": "",
5
5
  "main": "dist/index.cjs",
6
6
  "typings": "dist/index.d.ts",