@mirai/ui 1.0.47 → 1.0.49

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/README.md CHANGED
@@ -17,8 +17,10 @@ yarn add @mirai/ui
17
17
  This primitive returns a checkbox button based on the following properties:
18
18
 
19
19
  - `checked:boolean` if true, the checkbox button is checked
20
+ - `children:node`
20
21
  - `disabled:boolean` applying 'disabled' attribute
21
- - `name:string` input name
22
+ - `name:string` input name (required)
23
+ - `value:string` input value
22
24
  - `onChange:function` executed when input value changes
23
25
 
24
26
  ```jsx
@@ -30,8 +32,8 @@ const MyComponent = () => (
30
32
  name="checkbox"
31
33
  checked={false}
32
34
  disabled={false}
33
- value={primitive}
34
- onChange={() => console.log('change')
35
+ value="primitive"
36
+ onChange={() => console.log('change')}
35
37
  />
36
38
  </View>
37
39
  ```
@@ -50,6 +52,8 @@ const MyComponent = () => (
50
52
  );
51
53
  ```
52
54
 
55
+ > ℹ️ Current available names: Empty, Account, Left, Right, Up, Down, Close, CloseArrow, Plus, Minus, EyeOpen, EyeClose, Check, Error, Info, Success, Warning, Bed, Calendar, List, Lock, Person
56
+
53
57
  ### Input
54
58
 
55
59
  This primitive returns an input or a textarea based on the following props:
@@ -85,7 +89,13 @@ const MyComponent = () => (
85
89
 
86
90
  This primitive returns an element that displays with relative position to other element based on the following props:
87
91
 
92
+ - `bottom:bool` if you want open the content below the reference component.
93
+ - `centered:bool` if you want center the content using screen as parent.
88
94
  - `children:node` two children elements are accepted, the first one is the element to be displayed and the second one is the LayerContent that wraps the element to be displayed if the visible prop is true
95
+ - `forceRender:bool` if you want render content children even if `visible` is _falsy_, by default is `true`.
96
+ - `left:bool` if you want open the content on the left of the reference component.
97
+ - `right:bool` if you want open the content on the right of the reference component.
98
+ - `top:bool` if you want open the content above the reference component.
89
99
  - `visible:boolean` showing or hiding the layer
90
100
 
91
101
  The position of the layer is based on the position of the element to be displayed. If the layer can show on right or left because have a gap in this direction, the layer will be shown on the right or left of the element to be displayed. If the layer can open on top or bottom because have a gap in this direction, the layer will be shown on the top or bottom of the element to be displayed
@@ -115,6 +125,7 @@ This primitive returns pressable elements based on the following properties:
115
125
 
116
126
  - `children:node`
117
127
  - `disabled:boolean` disable attribute
128
+ - `preventDefault:boolean` if you want stop the event tunneling.
118
129
  - `tag:string` html tag applied to a primitive
119
130
  - `onEnter:function` executed once the user hovers over the element
120
131
  - `onLeave:function` executed once the user hovers away
@@ -139,6 +150,7 @@ This primitive returns a radio button based on the following properties:
139
150
  - `checked:boolean` if true, the radio button is checked
140
151
  - `disabled:boolean` applying 'disabled' attribute
141
152
  - `name:string` input name
153
+ - `value:string` input value
142
154
  - `onChange:function` executed when input value changes
143
155
 
144
156
  ```jsx
@@ -167,6 +179,7 @@ This primitive is used to make vertically scrollable views and receives the foll
167
179
  - `scrollEventThrottle:number` scroll timeout value
168
180
  - `scrollIndicator:boolean` if true the scroll indicator is shown
169
181
  - `scrollTo:number` coordinate to scroll to
182
+ - `snap:bool` if you want use the CSS feature `scroll-snap`
170
183
  - `tag:string` html tag of resulting element
171
184
  - `width:number` width value
172
185
  - `onscroll:function` executed when user scrolls over the element
@@ -190,9 +203,10 @@ A primitive for displaying text. It receives the following props:
190
203
  - `bold:boolean` modifying font-weight
191
204
  - `children:string`
192
205
  - `headline:boolean` modifying font-size
193
- - `upperCase:boolean` switching text to upper case
194
206
  - `small:boolean` modifying font-size
207
+ - `subheadline:boolean` modifying font-size
195
208
  - `tag:string` html tag of resulting element
209
+ - `upperCase:boolean` switching text to upper case
196
210
 
197
211
  ```jsx
198
212
  import { Text, View } from '@mirai/ui';
@@ -236,9 +250,12 @@ React components assembled with primitives.
236
250
 
237
251
  A button component that receives the following props:
238
252
 
253
+ - `busy:bool` if `true` will disable button and give feedback as something is processing.
239
254
  - `children:node|string`
240
255
  - `disabled:boolean` applying 'disabled' attribute
241
256
  - `large:boolean` modifying the button size
257
+ - `outlined:boolean` modifying the button appearance using an outlined line
258
+ - `rounded:boolean` if true will use the theme border-radius variable for round the corners
242
259
  - `small:boolean` modifying the button size
243
260
  - `squared:boolean` if true gives rectangular shape to the button (false by default)
244
261
  - `tag:string` html tag of resulting element ('button' by default)
@@ -267,12 +284,11 @@ A calendar component that receives the following props:
267
284
  - `captions:object` captions to be placed into calendar cells
268
285
  - `disabledDates:[string]` dates to be shown as unavailable and can't be selected
269
286
  - `disabledPast:boolean` past dates to be shown as unavailable and can't be selected
270
- - `disabledWeekends` boolean: weekends to be shown as unavailable and can't be selected
271
287
  - `format:string` date display format (e.g. "DD/MM/YYYY")
272
288
  - `from:string` date in specific format (e.g. "31/03/2022")
273
289
  - `highlights:[string]` highlights a determinate group of dates
274
- - `months:number` number of months to be visible
275
290
  - `locale:string` locale value
291
+ - `months:number` number of months to be visible
276
292
  - `range:boolean` Enable range selection
277
293
  - `rangeMaxDays:number` Maximum days in a range
278
294
  - `rangeMinDays:number` Minimum days in a range
@@ -280,6 +296,8 @@ A calendar component that receives the following props:
280
296
  - `value:string|[string]`
281
297
  - `onChange:function` executed when input value changes
282
298
  - `onFocus:function` executed on calendar cell hover
299
+ - `onNavigation:function` executed when move to the next/previous months
300
+ - `onScroll:function` executed when user scrolls the calendars container (only available in mobile environments)
283
301
 
284
302
  ```jsx
285
303
  import { Calendar } from '@mirai/ui';
@@ -311,11 +329,13 @@ const MyComponent = props => {
311
329
 
312
330
  Input number component controlling the value with 2 buttons. Receives the following props:
313
331
 
332
+ - `disabled:bool` applying 'disabled' attribute
314
333
  - `hint:string` brief message
315
334
  - `label:string` input label
316
335
  - `max:number` maximum input value
317
336
  - `min:number` minimum input value
318
337
  - `name:string` input name attribute (required)
338
+ - `rounded:bool` if you want use the `rounded` property of `<Button>`
319
339
  - `step:number` to be added/subtracted from value on each button click
320
340
  - `value:number` input value
321
341
  - `onChange:function` executed when input value changes
@@ -334,11 +354,11 @@ const MyComponent = (props) => {
334
354
 
335
355
  This component is used to display a radio button or checkbox base on a mandatory string prop `type`. It receives the following props:
336
356
 
337
- - `reverse:boolean` if true the label is placed on the left side of the input element (false by default)
338
357
  - `checked:boolean` if true, the input is checked
339
358
  - `disabled:boolean` applying 'disabled' attribute
340
359
  - `label:string` input label
341
360
  - `name:string` input name
361
+ - `reverse:boolean` if true the label is placed on the left side of the input element (false by default)
342
362
  - `type:string` type of input (radio or checkbox)
343
363
  - `value:number` input value
344
364
  - `onChange:function` executed when input value changes
@@ -391,6 +411,7 @@ Text input component receiving the following props:
391
411
  - `disabled:boolean` applying 'disabled' attribute
392
412
  - `error:boolean` true if error event fired
393
413
  - `hint:string` brief message
414
+ - `icon:string` if you want use an `<Icon>` within the component
394
415
  - `label:string` input label
395
416
  - `multiline:boolean` : if true returning textarea
396
417
  - `name:string` : input name (required)
@@ -466,8 +487,12 @@ const MyComponent = () => {
466
487
  A modal component receiving the following props:
467
488
 
468
489
  - `children:node`
490
+ - `portal:bool` if you want use _portal feature_ of React API
491
+ - `overflow:bool` wraps all modal in a semi-transparent layer
492
+ - `title:string` shows a title for the modal
469
493
  - `visible:boolean` if true modal is shown
470
- - `onClose:function` executed once modal close button is clicked
494
+ - `onBack:function` executed once back button is clicked
495
+ - `onClose:function` executed once close button is clicked
471
496
 
472
497
  ```jsx
473
498
  import { Modal, View } from '@mirai/ui';
@@ -512,7 +537,7 @@ Styles can be customised by using Theme utility.
512
537
 
513
538
  This method returns current theme settings (variables with values). This method receives as an optional parameter a string with a prefix (domain) to specify the scope ('--mirai-ui-' by default);
514
539
 
515
- ### set(variable, value, domain)
540
+ ### setVariable(variable, value, domain)
516
541
 
517
542
  This method sets a value of the variable passed as a parameter.
518
543
 
@@ -541,3 +566,50 @@ export default () => {
541
566
  );
542
567
  };
543
568
  ```
569
+
570
+ ### shadeColors
571
+
572
+ This method helps you to create a color palette for the `accent` color of your theme. For example if in our theme we have `--mirai-ui-accent: #3978c5`:
573
+
574
+ ```js
575
+ Theme.shadeColors()
576
+ >> ACCENT:400 #61a0ed
577
+ ACCENT:300 #89c8ff
578
+ ACCENT:200 #edffff
579
+ ```
580
+
581
+ ## Hooks
582
+
583
+ a repository of hooks which will help you create simpler solutions.
584
+
585
+ ### useDevice
586
+
587
+ This _hook_ can help you know what type of device your application or component is running on. Lets see the properties that this _hook_ is going to expose for you:
588
+
589
+ <!-- screen -->
590
+ - `height:number` height resolution of device
591
+ - `width:number` width resolution of device
592
+ <!-- navigator -->
593
+ - `userAgent:string` type of browser's user agent
594
+ - `chrome:bool` using chrome browser
595
+ - `firefox:bool` using firefox browser
596
+ - `inApp:bool` using an application browser such as Facebook, Twitter..
597
+ - `mobile:bool` using a mobile browser
598
+ - `safari:bool` using safari browser
599
+ - `touch:bool` touch screen capability
600
+ <!-- orientation -->
601
+ - `isLandscape:bool` orientation is landscape
602
+ - `isPortrait:bool` orientation is portrait
603
+ <!-- type -->
604
+ - `isMobile:bool` is in the mobile breakpoint (<600px)
605
+ - `isDesktop:bool` in in the desktop breakpoint (>=600px)
606
+
607
+ Let's see a simple use of the hook:
608
+
609
+ ```jsx
610
+ const component = () => {
611
+ const { isPortrait, isDesktop } = useDevice();
612
+
613
+ return <div classname={styles(style.container, isPortrait && isDesktop && style.mobileApp)} />;
614
+ };
615
+ ```
@@ -121,3 +121,15 @@
121
121
  align-self: flex-end;
122
122
  }
123
123
  }
124
+
125
+ @media only screen and (min-width: 600px) and (orientation: landscape) {
126
+ .modal {
127
+ min-width: 25vw;
128
+ }
129
+ }
130
+
131
+ @media only screen and (min-width: 600px) and (orientation: portrait) {
132
+ .modal {
133
+ min-width: 40vw;
134
+ }
135
+ }
package/build/index.js CHANGED
@@ -17,19 +17,6 @@ Object.keys(_components).forEach(function (key) {
17
17
  });
18
18
  });
19
19
 
20
- var _helpers = require("./helpers");
21
-
22
- Object.keys(_helpers).forEach(function (key) {
23
- if (key === "default" || key === "__esModule") return;
24
- if (key in exports && exports[key] === _helpers[key]) return;
25
- Object.defineProperty(exports, key, {
26
- enumerable: true,
27
- get: function get() {
28
- return _helpers[key];
29
- }
30
- });
31
- });
32
-
33
20
  var _hooks = require("./hooks");
34
21
 
35
22
  Object.keys(_hooks).forEach(function (key) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.js"],"sourcesContent":["export * from './components';\nexport * from './helpers';\nexport * from './hooks';\nexport * from './primitives';\nexport * from './theme';\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.js"],"sourcesContent":["export * from './components';\nexport * from './hooks';\nexport * from './primitives';\nexport * from './theme';\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
@@ -11,6 +11,7 @@ var _md = require("react-icons/md");
11
11
 
12
12
  var ICONS = {
13
13
  Empty: undefined,
14
+ Account: _md.MdOutlineAccountCircle,
14
15
  // directions
15
16
  Left: _fi.FiArrowLeft,
16
17
  Right: _fi.FiArrowRight,
@@ -1 +1 @@
1
- {"version":3,"file":"Icon.constants.js","names":["ICONS","Empty","undefined","Left","Right","Up","Down","Close","CloseArrow","Plus","Minus","EyeOpen","EyeClose","Check","Error","Info","Success","Warning","Bed","Calendar","List","Lock","Person"],"sources":["../../../src/primitives/Icon/Icon.constants.js"],"sourcesContent":["import {\n // directions\n FiArrowUp as Up,\n FiArrowDown as Down,\n FiArrowLeft as Left,\n FiArrowRight as Right,\n // Close\n FiChevronDown as CloseArrow,\n FiX as Close,\n // Calc\n FiMinus as Minus,\n FiPlus as Plus,\n // Eye\n FiEye as EyeOpen,\n FiEyeOff as EyeClose,\n // Check\n FiCheck as Check,\n} from 'react-icons/fi';\nimport {\n MdBed as Bed,\n MdOutlineCalendarToday as Calendar,\n MdListAlt as List,\n MdLockOutline as Lock,\n MdOutlinePersonOutline as Person,\n\n // Notification\n MdError as Error,\n MdInfo as Info,\n MdCheckCircle as Success,\n MdWarning as Warning,\n} from 'react-icons/md';\n\nconst ICONS = {\n Empty: undefined,\n // directions\n Left,\n Right,\n Up,\n Down,\n // Close\n Close,\n CloseArrow,\n // Calc\n Plus,\n Minus,\n // Eye\n EyeOpen,\n EyeClose,\n // Check\n Check,\n // Notification,\n Error,\n Info,\n Success,\n Warning,\n // Finder\n Bed,\n Calendar,\n List,\n Lock,\n Person,\n};\n\nexport { ICONS };\n"],"mappings":";;;;;;;AAAA;;AAkBA;;AAcA,IAAMA,KAAK,GAAG;EACZC,KAAK,EAAEC,SADK;EAEZ;EACAC,IAAI,EAAJA,eAHY;EAIZC,KAAK,EAALA,gBAJY;EAKZC,EAAE,EAAFA,aALY;EAMZC,IAAI,EAAJA,eANY;EAOZ;EACAC,KAAK,EAALA,OARY;EASZC,UAAU,EAAVA,iBATY;EAUZ;EACAC,IAAI,EAAJA,UAXY;EAYZC,KAAK,EAALA,WAZY;EAaZ;EACAC,OAAO,EAAPA,SAdY;EAeZC,QAAQ,EAARA,YAfY;EAgBZ;EACAC,KAAK,EAALA,WAjBY;EAkBZ;EACAC,KAAK,EAALA,WAnBY;EAoBZC,IAAI,EAAJA,UApBY;EAqBZC,OAAO,EAAPA,iBArBY;EAsBZC,OAAO,EAAPA,aAtBY;EAuBZ;EACAC,GAAG,EAAHA,SAxBY;EAyBZC,QAAQ,EAARA,0BAzBY;EA0BZC,IAAI,EAAJA,aA1BY;EA2BZC,IAAI,EAAJA,iBA3BY;EA4BZC,MAAM,EAANA;AA5BY,CAAd"}
1
+ {"version":3,"file":"Icon.constants.js","names":["ICONS","Empty","undefined","Account","Left","Right","Up","Down","Close","CloseArrow","Plus","Minus","EyeOpen","EyeClose","Check","Error","Info","Success","Warning","Bed","Calendar","List","Lock","Person"],"sources":["../../../src/primitives/Icon/Icon.constants.js"],"sourcesContent":["import {\n // directions\n FiArrowUp as Up,\n FiArrowDown as Down,\n FiArrowLeft as Left,\n FiArrowRight as Right,\n // Close\n FiChevronDown as CloseArrow,\n FiX as Close,\n // Calc\n FiMinus as Minus,\n FiPlus as Plus,\n // Eye\n FiEye as EyeOpen,\n FiEyeOff as EyeClose,\n // Check\n FiCheck as Check,\n // User\n} from 'react-icons/fi';\nimport {\n MdOutlineAccountCircle as Account,\n MdBed as Bed,\n MdOutlineCalendarToday as Calendar,\n MdListAlt as List,\n MdLockOutline as Lock,\n MdOutlinePersonOutline as Person,\n\n // Notification\n MdError as Error,\n MdInfo as Info,\n MdCheckCircle as Success,\n MdWarning as Warning,\n} from 'react-icons/md';\n\nconst ICONS = {\n Empty: undefined,\n Account,\n // directions\n Left,\n Right,\n Up,\n Down,\n // Close\n Close,\n CloseArrow,\n // Calc\n Plus,\n Minus,\n // Eye\n EyeOpen,\n EyeClose,\n // Check\n Check,\n // Notification,\n Error,\n Info,\n Success,\n Warning,\n // Finder\n Bed,\n Calendar,\n List,\n Lock,\n Person,\n};\n\nexport { ICONS };\n"],"mappings":";;;;;;;AAAA;;AAmBA;;AAeA,IAAMA,KAAK,GAAG;EACZC,KAAK,EAAEC,SADK;EAEZC,OAAO,EAAPA,0BAFY;EAGZ;EACAC,IAAI,EAAJA,eAJY;EAKZC,KAAK,EAALA,gBALY;EAMZC,EAAE,EAAFA,aANY;EAOZC,IAAI,EAAJA,eAPY;EAQZ;EACAC,KAAK,EAALA,OATY;EAUZC,UAAU,EAAVA,iBAVY;EAWZ;EACAC,IAAI,EAAJA,UAZY;EAaZC,KAAK,EAALA,WAbY;EAcZ;EACAC,OAAO,EAAPA,SAfY;EAgBZC,QAAQ,EAARA,YAhBY;EAiBZ;EACAC,KAAK,EAALA,WAlBY;EAmBZ;EACAC,KAAK,EAALA,WApBY;EAqBZC,IAAI,EAAJA,UArBY;EAsBZC,OAAO,EAAPA,iBAtBY;EAuBZC,OAAO,EAAPA,aAvBY;EAwBZ;EACAC,GAAG,EAAHA,SAzBY;EA0BZC,QAAQ,EAARA,0BA1BY;EA2BZC,IAAI,EAAJA,aA3BY;EA4BZC,IAAI,EAAJA,iBA5BY;EA6BZC,MAAM,EAANA;AA7BY,CAAd"}
@@ -21,7 +21,7 @@ var _LayerModule = _interopRequireDefault(require("./Layer.module.css"));
21
21
 
22
22
  var _LayerContent = require("./LayerContent");
23
23
 
24
- var _excluded = ["centered", "forceRender", "bottom", "left", "right", "top", "visible"];
24
+ var _excluded = ["bottom", "centered", "forceRender", "left", "right", "top", "visible"];
25
25
 
26
26
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
27
27
 
@@ -52,10 +52,10 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
52
52
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
53
53
 
54
54
  var Layer = function Layer(_ref) {
55
- var centered = _ref.centered,
55
+ var forceBottom = _ref.bottom,
56
+ centered = _ref.centered,
56
57
  _ref$forceRender = _ref.forceRender,
57
58
  forceRender = _ref$forceRender === void 0 ? true : _ref$forceRender,
58
- forceBottom = _ref.bottom,
59
59
  forceLeft = _ref.left,
60
60
  forceRight = _ref.right,
61
61
  forceTop = _ref.top,
@@ -1 +1 @@
1
- {"version":3,"file":"Layer.js","names":["Layer","centered","forceRender","forceBottom","bottom","forceLeft","left","forceRight","right","forceTop","top","visible","others","device","componentRef","contentRef","position","setPosition","current","componentEl","firstChild","contentEl","componentLayout","contentLayout","children","React","Children","map","child","find","name","type","LayerContent","style","layer","hidden","className","propTypes","PropTypes","bool","node"],"sources":["../../../src/primitives/Layer/Layer.jsx"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React, { useLayoutEffect, useRef, useState } from 'react';\n\nimport { styles } from '../../helpers';\nimport { useDevice } from '../../hooks';\nimport { getElementLayout, getLayerPosition } from './helpers';\nimport style from './Layer.module.css';\nimport { LayerContent } from './LayerContent';\n\nconst Layer = ({\n centered,\n forceRender = true,\n bottom: forceBottom,\n left: forceLeft,\n right: forceRight,\n top: forceTop,\n visible,\n ...others\n}) => {\n const device = useDevice();\n const componentRef = useRef();\n const contentRef = useRef();\n\n const [position, setPosition] = useState();\n\n useLayoutEffect(() => {\n const { current: { firstChild: componentEl } = {} } = componentRef;\n const { current: contentEl } = contentRef;\n\n if (!componentEl || !contentEl) return setPosition();\n\n const componentLayout = getElementLayout(componentEl);\n const contentLayout = getElementLayout(contentEl);\n const { left = 0, top = 0 } = getLayerPosition(componentLayout, contentLayout, device, {\n centered,\n forceBottom,\n forceLeft,\n forceRight,\n forceTop,\n });\n\n setPosition({ left: `${left}px`, top: `${top}px` });\n }, [centered, device, forceBottom, forceLeft, forceRight, forceTop, visible]);\n\n const children = React.Children.map(others.children || [], (child) => child);\n\n return (\n <>\n <span data-testid={others['data-testid']} ref={componentRef}>\n {children.find(({ type: { name } }) => name !== LayerContent.name)}\n </span>\n\n {(forceRender || visible) && (\n <div\n ref={contentRef}\n className={styles(style.layer, !visible && style.hidden, others.className)}\n style={{ ...others.style, ...position }}\n >\n {children?.find(({ type: { name } }) => name === LayerContent.name)}\n </div>\n )}\n </>\n );\n};\n\nLayer.propTypes = {\n bottom: PropTypes.bool,\n centered: PropTypes.bool,\n children: PropTypes.node,\n forceRender: PropTypes.bool,\n left: PropTypes.bool,\n right: PropTypes.bool,\n top: PropTypes.bool,\n visible: PropTypes.bool,\n};\n\nexport { Layer };\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAMA,KAAK,GAAG,SAARA,KAAQ,OASR;EAAA,IARJC,QAQI,QARJA,QAQI;EAAA,4BAPJC,WAOI;EAAA,IAPJA,WAOI,iCAPU,IAOV;EAAA,IANIC,WAMJ,QANJC,MAMI;EAAA,IALEC,SAKF,QALJC,IAKI;EAAA,IAJGC,UAIH,QAJJC,KAII;EAAA,IAHCC,QAGD,QAHJC,GAGI;EAAA,IAFJC,OAEI,QAFJA,OAEI;EAAA,IADDC,MACC;;EACJ,IAAMC,MAAM,GAAG,uBAAf;EACA,IAAMC,YAAY,GAAG,oBAArB;EACA,IAAMC,UAAU,GAAG,oBAAnB;;EAEA,gBAAgC,sBAAhC;EAAA;EAAA,IAAOC,QAAP;EAAA,IAAiBC,WAAjB;;EAEA,4BAAgB,YAAM;IACpB,4BAAsDH,YAAtD,CAAQI,OAAR;IAAA,2DAA+C,EAA/C;IAAA,IAA+BC,WAA/B,yBAAmBC,UAAnB;IACA,IAAiBC,SAAjB,GAA+BN,UAA/B,CAAQG,OAAR;IAEA,IAAI,CAACC,WAAD,IAAgB,CAACE,SAArB,EAAgC,OAAOJ,WAAW,EAAlB;IAEhC,IAAMK,eAAe,GAAG,gCAAiBH,WAAjB,CAAxB;IACA,IAAMI,aAAa,GAAG,gCAAiBF,SAAjB,CAAtB;;IACA,wBAA8B,gCAAiBC,eAAjB,EAAkCC,aAAlC,EAAiDV,MAAjD,EAAyD;MACrFZ,QAAQ,EAARA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I,KAAKE,2BAAaF,IAA9C;EAAA,CAAf,CALH,CANJ,CADF;AAiBD,CAtDD;;;AAwDA9B,KAAK,CAACqC,SAAN,GAAkB;EAChBjC,MAAM,EAAEkC,mBAAUC,IADF;EAEhBtC,QAAQ,EAAEqC,mBAAUC,IAFJ;EAGhBf,QAAQ,EAAEc,mBAAUE,IAHJ;EAIhBtC,WAAW,EAAEoC,mBAAUC,IAJP;EAKhBjC,IAAI,EAAEgC,mBAAUC,IALA;EAMhB/B,KAAK,EAAE8B,mBAAUC,IAND;EAOhB7B,GAAG,EAAE4B,mBAAUC,IAPC;EAQhB5B,OAAO,EAAE2B,mBAAUC;AARH,CAAlB"}
1
+ {"version":3,"file":"Layer.js","names":["Layer","forceBottom","bottom","centered","forceRender","forceLeft","left","forceRight","right","forceTop","top","visible","others","device","componentRef","contentRef","position","setPosition","current","componentEl","firstChild","contentEl","componentLayout","contentLayout","children","React","Children","map","child","find","name","type","LayerContent","style","layer","hidden","className","propTypes","PropTypes","bool","node"],"sources":["../../../src/primitives/Layer/Layer.jsx"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React, { useLayoutEffect, useRef, useState } from 'react';\n\nimport { styles } from '../../helpers';\nimport { useDevice } from '../../hooks';\nimport { getElementLayout, getLayerPosition } from './helpers';\nimport style from './Layer.module.css';\nimport { LayerContent } from './LayerContent';\n\nconst Layer = ({\n bottom: forceBottom,\n centered,\n forceRender = true,\n left: forceLeft,\n right: forceRight,\n top: forceTop,\n visible,\n ...others\n}) => {\n const device = useDevice();\n const componentRef = useRef();\n const contentRef = useRef();\n\n const [position, setPosition] = useState();\n\n useLayoutEffect(() => {\n const { current: { firstChild: componentEl } = {} } = componentRef;\n const { current: contentEl } = contentRef;\n\n if (!componentEl || !contentEl) return setPosition();\n\n const componentLayout = getElementLayout(componentEl);\n const contentLayout = getElementLayout(contentEl);\n const { left = 0, top = 0 } = getLayerPosition(componentLayout, contentLayout, device, {\n centered,\n forceBottom,\n forceLeft,\n forceRight,\n forceTop,\n });\n\n setPosition({ left: `${left}px`, top: `${top}px` });\n }, [centered, device, forceBottom, forceLeft, forceRight, forceTop, visible]);\n\n const children = React.Children.map(others.children || [], (child) => child);\n\n return (\n <>\n <span data-testid={others['data-testid']} ref={componentRef}>\n {children.find(({ type: { name } }) => name !== LayerContent.name)}\n </span>\n\n {(forceRender || visible) && (\n <div\n ref={contentRef}\n className={styles(style.layer, !visible && style.hidden, others.className)}\n style={{ ...others.style, ...position }}\n >\n {children?.find(({ type: { name } }) => name === LayerContent.name)}\n </div>\n )}\n </>\n );\n};\n\nLayer.propTypes = {\n bottom: PropTypes.bool,\n centered: PropTypes.bool,\n children: PropTypes.node,\n forceRender: PropTypes.bool,\n left: PropTypes.bool,\n right: PropTypes.bool,\n top: PropTypes.bool,\n visible: PropTypes.bool,\n};\n\nexport { Layer };\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAMA,KAAK,GAAG,SAARA,KAAQ,OASR;EAAA,IARIC,WAQJ,QARJC,MAQI;EAAA,IAPJC,QAOI,QAPJA,QAOI;EAAA,4BANJC,WAMI;EAAA,IANJA,WAMI,iCANU,IAMV;EAAA,IALEC,SAKF,QALJC,IAKI;EAAA,IAJGC,UAIH,QAJJC,KAII;EAAA,IAHCC,QAGD,QAHJC,GAGI;EAAA,IAFJC,OAEI,QAFJA,OAEI;EAAA,IADDC,MACC;;EACJ,IAAMC,MAAM,GAAG,uBAAf;EACA,IAAMC,YAAY,GAAG,oBAArB;EACA,IAAMC,UAAU,GAAG,oBAAnB;;EAEA,gBAAgC,sBAAhC;EAAA;EAAA,IAAOC,QAAP;EAAA,IAAiBC,WAAjB;;EAEA,4BAAgB,YAAM;IACpB,4BAAsDH,YAAtD,CAAQI,OAAR;IAAA,2DAA+C,EAA/C;IAAA,IAA+BC,WAA/B,yBAAmBC,UAAnB;IACA,IAAiBC,SAAjB,GAA+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OkB,qBAAMC,KAAb,EAAoB,CAACvB,OAAD,IAAYsB,qBAAME,MAAtC,EAA8CvB,MAAM,CAACwB,SAArD,CAFb;IAGE,KAAK,kCAAOxB,MAAM,CAACqB,KAAd,GAAwBjB,QAAxB;EAHP,GAKGQ,QALH,aAKGA,QALH,uBAKGA,QAAQ,CAAEK,IAAV,CAAe;IAAA,IAAWC,IAAX,SAAGC,IAAH,CAAWD,IAAX;IAAA,OAAwBA,IAAI,KAAKE,2BAAaF,IAA9C;EAAA,CAAf,CALH,CANJ,CADF;AAiBD,CAtDD;;;AAwDA9B,KAAK,CAACqC,SAAN,GAAkB;EAChBnC,MAAM,EAAEoC,mBAAUC,IADF;EAEhBpC,QAAQ,EAAEmC,mBAAUC,IAFJ;EAGhBf,QAAQ,EAAEc,mBAAUE,IAHJ;EAIhBpC,WAAW,EAAEkC,mBAAUC,IAJP;EAKhBjC,IAAI,EAAEgC,mBAAUC,IALA;EAMhB/B,KAAK,EAAE8B,mBAAUC,IAND;EAOhB7B,GAAG,EAAE4B,mBAAUC,IAPC;EAQhB5B,OAAO,EAAE2B,mBAAUC;AARH,CAAlB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mirai/ui",
3
- "version": "1.0.47",
3
+ "version": "1.0.49",
4
4
  "repository": "git@gitlab.com:miraicorp/dev/frontend/ui.git",
5
5
  "author": "JΛVI <hello@soyjavi.com>",
6
6
  "license": "MIT",