jy-headless 0.0.20 → 0.0.22

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,6 @@
1
+ interface ModalContextType {
2
+ isShow: boolean;
3
+ setIsShow: (value: boolean) => void;
4
+ }
5
+ declare const ModalContext: import("react").Context<ModalContextType>;
6
+ export default ModalContext;
package/dist/index.d.ts CHANGED
@@ -4,5 +4,6 @@ import DesktopKeyboardInput from './components/input/DesktopKeyboardInput';
4
4
  import Spinner from './components/spinner/Spinner';
5
5
  import RadioInput from './components/radio/RadioInput';
6
6
  import RadioGroup from './components/radio/RadioGroup';
7
+ import Modal from './components/modal/Modal';
7
8
  import { CallIcon, CloseIcon, HomeIcon, SearchIcon } from './components/icons';
8
- export { Button, Input, DesktopKeyboardInput, Spinner, CallIcon, CloseIcon, HomeIcon, SearchIcon, RadioInput, RadioGroup, };
9
+ export { Button, Input, DesktopKeyboardInput, Spinner, CallIcon, CloseIcon, HomeIcon, SearchIcon, RadioInput, RadioGroup, Modal, };
package/dist/index.esm.js CHANGED
@@ -1,4 +1,5 @@
1
- import React, { useState, useEffect, useMemo } from 'react';
1
+ import React, { useState, useEffect, useMemo, createContext, useContext } from 'react';
2
+ import { createPortal } from 'react-dom';
2
3
 
3
4
  /******************************************************************************
4
5
  Copyright (c) Microsoft Corporation.
@@ -375,6 +376,46 @@ const RadioGroupItem = (_a) => {
375
376
  };
376
377
  RadioGroup.Item = RadioGroupItem;
377
378
 
379
+ const ModalContext = createContext({
380
+ isShow: false,
381
+ setIsShow: (value) => { },
382
+ });
383
+
384
+ const Modal = ({ opener, children, targetSelector = 'root', }) => {
385
+ const [isShow, setIsShow] = useState(false);
386
+ const onHandleShow = () => {
387
+ setIsShow(true);
388
+ };
389
+ return (React.createElement(ModalContext, { value: { isShow, setIsShow } },
390
+ React.cloneElement(opener, {
391
+ onClick: onHandleShow,
392
+ }),
393
+ isShow &&
394
+ document.querySelector(targetSelector) &&
395
+ createPortal(children, document.querySelector(targetSelector))));
396
+ };
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));
410
+ };
411
+ const ModalCloseButton = (_a) => {
412
+ var props = __rest(_a, []);
413
+ const { setIsShow } = useContext(ModalContext);
414
+ return React.createElement(Button, Object.assign({}, props, { onClick: () => setIsShow(false) }));
415
+ };
416
+ Modal.Overlay = ModalOverlay;
417
+ Modal.Closer = ModalCloseButton;
418
+
378
419
  const CloseIcon = ({ color = '#000', size = '1em', bgColor = 'transparent', }) => {
379
420
  return (React.createElement("svg", { viewBox: "0 0 24 24", width: size, height: size, fill: "none", style: { backgroundColor: bgColor }, xmlns: "http://www.w3.org/2000/svg" },
380
421
  React.createElement("g", { id: "SVGRepo_bgCarrier", strokeWidth: "0" }),
@@ -425,5 +466,5 @@ const SearchIcon = ({ color = '#000', size = '1em', bgColor = 'transparent', fil
425
466
  // AUTHOR: Ankush Syal
426
467
  // https://www.svgrepo.com/svg/520583/call
427
468
 
428
- export { Button, CallIcon, CloseIcon, DesktopKeyboardInput, HomeIcon, Input, RadioGroup, RadioInput, SearchIcon, Spinner };
469
+ export { Button, CallIcon, CloseIcon, DesktopKeyboardInput, HomeIcon, Input, Modal, RadioGroup, RadioInput, SearchIcon, Spinner };
429
470
  //# sourceMappingURL=index.esm.js.map
@@ -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
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var React = require('react');
4
+ var reactDom = require('react-dom');
4
5
 
5
6
  /******************************************************************************
6
7
  Copyright (c) Microsoft Corporation.
@@ -377,6 +378,46 @@ const RadioGroupItem = (_a) => {
377
378
  };
378
379
  RadioGroup.Item = RadioGroupItem;
379
380
 
381
+ const ModalContext = React.createContext({
382
+ isShow: false,
383
+ setIsShow: (value) => { },
384
+ });
385
+
386
+ const Modal = ({ opener, children, targetSelector = 'root', }) => {
387
+ const [isShow, setIsShow] = React.useState(false);
388
+ const onHandleShow = () => {
389
+ setIsShow(true);
390
+ };
391
+ return (React.createElement(ModalContext, { value: { isShow, setIsShow } },
392
+ React.cloneElement(opener, {
393
+ onClick: onHandleShow,
394
+ }),
395
+ isShow &&
396
+ document.querySelector(targetSelector) &&
397
+ reactDom.createPortal(children, document.querySelector(targetSelector))));
398
+ };
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));
412
+ };
413
+ const ModalCloseButton = (_a) => {
414
+ var props = __rest(_a, []);
415
+ const { setIsShow } = React.useContext(ModalContext);
416
+ return React.createElement(Button, Object.assign({}, props, { onClick: () => setIsShow(false) }));
417
+ };
418
+ Modal.Overlay = ModalOverlay;
419
+ Modal.Closer = ModalCloseButton;
420
+
380
421
  const CloseIcon = ({ color = '#000', size = '1em', bgColor = 'transparent', }) => {
381
422
  return (React.createElement("svg", { viewBox: "0 0 24 24", width: size, height: size, fill: "none", style: { backgroundColor: bgColor }, xmlns: "http://www.w3.org/2000/svg" },
382
423
  React.createElement("g", { id: "SVGRepo_bgCarrier", strokeWidth: "0" }),
@@ -433,6 +474,7 @@ exports.CloseIcon = CloseIcon;
433
474
  exports.DesktopKeyboardInput = DesktopKeyboardInput;
434
475
  exports.HomeIcon = HomeIcon;
435
476
  exports.Input = Input;
477
+ exports.Modal = Modal;
436
478
  exports.RadioGroup = RadioGroup;
437
479
  exports.RadioInput = RadioInput;
438
480
  exports.SearchIcon = SearchIcon;
package/dist/index.js.map C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;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jy-headless",
3
- "version": "0.0.20",
3
+ "version": "0.0.22",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs",
6
6
  "typings": "dist/index.d.ts",