jy-headless 0.0.20 → 0.0.21

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.
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,45 @@ const RadioGroupItem = (_a) => {
375
376
  };
376
377
  RadioGroup.Item = RadioGroupItem;
377
378
 
379
+ const ModalContext = createContext({
380
+ isShow: false,
381
+ setIsShow: (value) => { },
382
+ });
383
+ const Modal = ({ opener, children, targetSelector = 'root', }) => {
384
+ const [isShow, setIsShow] = useState(false);
385
+ const onHandleShow = () => {
386
+ setIsShow(true);
387
+ };
388
+ return (React.createElement(ModalContext, { value: { isShow, setIsShow } },
389
+ React.cloneElement(opener, {
390
+ onClick: onHandleShow,
391
+ }),
392
+ isShow &&
393
+ document.querySelector(targetSelector) &&
394
+ createPortal(children, document.querySelector(targetSelector))));
395
+ };
396
+ const ModalOverlay = ({ backgroundColor = 'rgba(0,0,0,0.5)', children, zIndex = 999, }) => {
397
+ return (React.createElement("div", { style: {
398
+ position: 'fixed',
399
+ display: 'flex',
400
+ justifyContent: 'center',
401
+ alignItems: 'center',
402
+ top: 0,
403
+ right: 0,
404
+ bottom: 0,
405
+ left: 0,
406
+ zIndex,
407
+ backgroundColor,
408
+ } }, children));
409
+ };
410
+ const ModalCloseButton = (_a) => {
411
+ var props = __rest(_a, []);
412
+ const { setIsShow } = useContext(ModalContext);
413
+ return React.createElement(Button, Object.assign({}, props, { onClick: () => setIsShow(false) }));
414
+ };
415
+ Modal.Overlay = ModalOverlay;
416
+ Modal.Closer = ModalCloseButton;
417
+
378
418
  const CloseIcon = ({ color = '#000', size = '1em', bgColor = 'transparent', }) => {
379
419
  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
420
  React.createElement("g", { id: "SVGRepo_bgCarrier", strokeWidth: "0" }),
@@ -425,5 +465,5 @@ const SearchIcon = ({ color = '#000', size = '1em', bgColor = 'transparent', fil
425
465
  // AUTHOR: Ankush Syal
426
466
  // https://www.svgrepo.com/svg/520583/call
427
467
 
428
- export { Button, CallIcon, CloseIcon, DesktopKeyboardInput, HomeIcon, Input, RadioGroup, RadioInput, SearchIcon, Spinner };
468
+ export { Button, CallIcon, CloseIcon, DesktopKeyboardInput, HomeIcon, Input, Modal, RadioGroup, RadioInput, SearchIcon, Spinner };
429
469
  //# 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,45 @@ 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
+ const Modal = ({ opener, children, targetSelector = 'root', }) => {
386
+ const [isShow, setIsShow] = React.useState(false);
387
+ const onHandleShow = () => {
388
+ setIsShow(true);
389
+ };
390
+ return (React.createElement(ModalContext, { value: { isShow, setIsShow } },
391
+ React.cloneElement(opener, {
392
+ onClick: onHandleShow,
393
+ }),
394
+ isShow &&
395
+ document.querySelector(targetSelector) &&
396
+ reactDom.createPortal(children, document.querySelector(targetSelector))));
397
+ };
398
+ const ModalOverlay = ({ backgroundColor = 'rgba(0,0,0,0.5)', children, zIndex = 999, }) => {
399
+ return (React.createElement("div", { style: {
400
+ position: 'fixed',
401
+ display: 'flex',
402
+ justifyContent: 'center',
403
+ alignItems: 'center',
404
+ top: 0,
405
+ right: 0,
406
+ bottom: 0,
407
+ left: 0,
408
+ zIndex,
409
+ backgroundColor,
410
+ } }, children));
411
+ };
412
+ const ModalCloseButton = (_a) => {
413
+ var props = __rest(_a, []);
414
+ const { setIsShow } = React.useContext(ModalContext);
415
+ return React.createElement(Button, Object.assign({}, props, { onClick: () => setIsShow(false) }));
416
+ };
417
+ Modal.Overlay = ModalOverlay;
418
+ Modal.Closer = ModalCloseButton;
419
+
380
420
  const CloseIcon = ({ color = '#000', size = '1em', bgColor = 'transparent', }) => {
381
421
  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
422
  React.createElement("g", { id: "SVGRepo_bgCarrier", strokeWidth: "0" }),
@@ -433,6 +473,7 @@ exports.CloseIcon = CloseIcon;
433
473
  exports.DesktopKeyboardInput = DesktopKeyboardInput;
434
474
  exports.HomeIcon = HomeIcon;
435
475
  exports.Input = Input;
476
+ exports.Modal = Modal;
436
477
  exports.RadioGroup = RadioGroup;
437
478
  exports.RadioInput = RadioInput;
438
479
  exports.SearchIcon = SearchIcon;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jy-headless",
3
- "version": "0.0.20",
3
+ "version": "0.0.21",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs",
6
6
  "typings": "dist/index.d.ts",