@mirai/ui 1.0.151 → 1.0.153
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
|
@@ -113,6 +113,7 @@ This primitive returns an element that displays with relative position to other
|
|
|
113
113
|
- `timestamp:number` if you want to force render to recalculate the position of content, assign this property with a number (`Date.now()`).
|
|
114
114
|
- `top:bool` if you want open the content above the reference component.
|
|
115
115
|
- `visible:boolean` showing or hiding the layer
|
|
116
|
+
- `onPosition:boolean` called when the position of the layer is calculated or updated. It receives `orientation` argument, which is an object containing information about the layer's position with `top` and `left` properties
|
|
116
117
|
|
|
117
118
|
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
|
|
118
119
|
|
|
@@ -219,7 +220,7 @@ This primitive is used to make vertically scrollable views and receives the foll
|
|
|
219
220
|
- `snap:bool` if you want use the CSS feature `scroll-snap`
|
|
220
221
|
- `tag:string` html tag of resulting element
|
|
221
222
|
- `width:number` width value
|
|
222
|
-
- `
|
|
223
|
+
- `onScroll:function` executed when user scrolls over the element
|
|
223
224
|
|
|
224
225
|
```jsx
|
|
225
226
|
import { ScrollView, View } from '@mirai/ui';
|
|
@@ -234,7 +235,35 @@ const MyComponent = ({ isDesktop }) => (
|
|
|
234
235
|
|
|
235
236
|
### Select
|
|
236
237
|
|
|
237
|
-
|
|
238
|
+
This primitive returns a select element and receives the following props:
|
|
239
|
+
- `disabled:boolean` applying 'disabled' attribute
|
|
240
|
+
- `emptyOption:string` label for the empty default value (e.g. 'Select an option')
|
|
241
|
+
- `options:string[]` select options text and values
|
|
242
|
+
- `value:string` current value
|
|
243
|
+
- `onChange:function` executed when input value changes
|
|
244
|
+
- `onEnter` executed when select is focused
|
|
245
|
+
- `onError` executed when an error occurs
|
|
246
|
+
- `onLeave` executed when select loses
|
|
247
|
+
|
|
248
|
+
```jsx
|
|
249
|
+
import { Select } from '@mirai/ui';
|
|
250
|
+
|
|
251
|
+
const Example = (props) => {
|
|
252
|
+
const [value, setValue] = useState('');
|
|
253
|
+
|
|
254
|
+
const handleChange = (next, ...others) => {
|
|
255
|
+
setValue(next);
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
return <Select
|
|
259
|
+
emptyOption='Select one option...'
|
|
260
|
+
name='Select'
|
|
261
|
+
options={['foo', 'bar']}
|
|
262
|
+
value={value}
|
|
263
|
+
onChange={handleChange}
|
|
264
|
+
/>;
|
|
265
|
+
};
|
|
266
|
+
```
|
|
238
267
|
|
|
239
268
|
### Switch
|
|
240
269
|
|
|
@@ -283,6 +312,7 @@ A primitive for displaying text. It receives the following props:
|
|
|
283
312
|
- `tag:string` html tag of resulting element
|
|
284
313
|
- `underline:boolean` use an underline text decoration
|
|
285
314
|
- `upperCase:boolean` switching text to upper case
|
|
315
|
+
- `wide:boolean` specifies whether the component should have more width or not
|
|
286
316
|
|
|
287
317
|
```jsx
|
|
288
318
|
import { Text, View } from '@mirai/ui';
|
|
@@ -422,6 +452,7 @@ const MyComponent = (props) => {
|
|
|
422
452
|
|
|
423
453
|
A calendar component that receives the following props:
|
|
424
454
|
|
|
455
|
+
- `autoScroll:boolean` specifies whether the calendar should automatically scroll to the selected date or the focused month
|
|
425
456
|
- `captions:object` captions to be placed into calendar cells
|
|
426
457
|
- `disabledDates:[string]` dates to be shown as unavailable and can't be selected
|
|
427
458
|
- `disabledPast:boolean` past dates to be shown as unavailable and can't be selected
|
|
@@ -489,11 +520,119 @@ const MyComponent = props => {
|
|
|
489
520
|
|
|
490
521
|
### Form
|
|
491
522
|
|
|
492
|
-
|
|
523
|
+
Component that unites various inputs of different types into a single form. It receives the following props:
|
|
524
|
+
|
|
525
|
+
- `children:node` elements to be rendered within the form
|
|
526
|
+
- `debounce:number` the delay before triggering the onChange callback after the form values have changed (0 by default)
|
|
527
|
+
- `schema:object` defines validation schema for the form fields. Maps field names to their respective validation rules
|
|
528
|
+
- `showErrors:boolean` indicates whether to display the validation errors for the form fields
|
|
529
|
+
- `tag:string` HTML tag name to be used for rendering the form element ('form' by default)
|
|
530
|
+
- `validateOnMount:boolean` indicates whether to perform validation on form mount
|
|
531
|
+
- `onBlur:function` executed when a form field loses focus
|
|
532
|
+
- `onChange:function` executed when any field value changes
|
|
533
|
+
- `onError:function` executed when one or more fields have errors
|
|
534
|
+
- `onFocus:function` when a form field gets focus
|
|
535
|
+
- `onSubmit:function` executed when the form is submitted
|
|
536
|
+
|
|
537
|
+
```jsx
|
|
538
|
+
import { Button, Form, InputDate, InputText } from '@mirai/ui';
|
|
539
|
+
|
|
540
|
+
const Example = (props) => {
|
|
541
|
+
const [condition, setCondition] = useState(false);
|
|
542
|
+
const [form, setForm] = useState({
|
|
543
|
+
email: 'javi@mirai.com',
|
|
544
|
+
dateOfBirth: '04/10/1980',
|
|
545
|
+
});
|
|
546
|
+
const [error, setError] = useState({});
|
|
547
|
+
|
|
548
|
+
const handleBlur = (...others) => console.log('<Form>::onBlur', ...others);
|
|
549
|
+
|
|
550
|
+
const handleChange = (next, ...others) => {
|
|
551
|
+
setForm(next);
|
|
552
|
+
};
|
|
553
|
+
|
|
554
|
+
const handleError = (next, ...others) => {
|
|
555
|
+
setError(next);
|
|
556
|
+
};
|
|
557
|
+
|
|
558
|
+
const handleFocus = (...others) => console.log('<Form>::onFocus', ...others);
|
|
559
|
+
|
|
560
|
+
const handleSubmit = (...others) => console.log('<Form>::onSubmit', ...others);
|
|
561
|
+
|
|
562
|
+
return (
|
|
563
|
+
<Form
|
|
564
|
+
{...props}
|
|
565
|
+
onBlur={handleBlur}
|
|
566
|
+
onChange={handleChange}
|
|
567
|
+
onError={handleError}
|
|
568
|
+
onFocus={handleFocus}
|
|
569
|
+
onSubmit={handleSubmit}
|
|
570
|
+
>
|
|
571
|
+
<InputText
|
|
572
|
+
name="email"
|
|
573
|
+
error={!!error.email}
|
|
574
|
+
test={(value) => value.includes('@mirai.com')}
|
|
575
|
+
label="Email"
|
|
576
|
+
hint="Should contains @mirai.com"
|
|
577
|
+
required
|
|
578
|
+
type="email"
|
|
579
|
+
value={form.email}
|
|
580
|
+
/>
|
|
581
|
+
<InputDate
|
|
582
|
+
name="dateOfBirth"
|
|
583
|
+
error={!!error.dateOfBirth}
|
|
584
|
+
label="Your birthdate"
|
|
585
|
+
max="31/12/2022"
|
|
586
|
+
min="10/04/1980"
|
|
587
|
+
required
|
|
588
|
+
type="inputDate"
|
|
589
|
+
value={form.dateOfBirth}
|
|
590
|
+
/>
|
|
591
|
+
|
|
592
|
+
<Button disabled={Object.keys(error).length !== 0} type="submit" wide>
|
|
593
|
+
Submit
|
|
594
|
+
</Button>
|
|
595
|
+
</Form>
|
|
596
|
+
);
|
|
597
|
+
};
|
|
598
|
+
```
|
|
493
599
|
|
|
494
600
|
### InputDate
|
|
495
601
|
|
|
496
|
-
|
|
602
|
+
Input date component that receives the following props:
|
|
603
|
+
|
|
604
|
+
- `format:string` date format to be applied ('DD/MM/YYYY' by default)
|
|
605
|
+
- `max:string` maximum date value allowed
|
|
606
|
+
- `min:string` minimum date value allowed
|
|
607
|
+
- `placeholder:bool` indicated whether to show placeholder with format or not
|
|
608
|
+
- `value:string` current value
|
|
609
|
+
- `onChange:function` executed when the value is changed
|
|
610
|
+
- `onError:function` executed when there's an error
|
|
611
|
+
|
|
612
|
+
```jsx
|
|
613
|
+
import { InputDate } from '@mirai/ui';
|
|
614
|
+
|
|
615
|
+
const Example = ({ value: propValue, ...props }) => {
|
|
616
|
+
const [value, setValue] = useState(propValue);
|
|
617
|
+
|
|
618
|
+
const handleChange = (next, ...others) => {
|
|
619
|
+
setValue(next);
|
|
620
|
+
};
|
|
621
|
+
|
|
622
|
+
const handleError = (...others) => console.log('<InputDate>::onError', ...others);
|
|
623
|
+
|
|
624
|
+
return (
|
|
625
|
+
<InputDate
|
|
626
|
+
format='MM/DD/YYYY'
|
|
627
|
+
min='03/20/2023'
|
|
628
|
+
max='03/20/2028'
|
|
629
|
+
value={value}
|
|
630
|
+
onChange={handleChange}
|
|
631
|
+
onError={handleError}
|
|
632
|
+
/>
|
|
633
|
+
);
|
|
634
|
+
};
|
|
635
|
+
```
|
|
497
636
|
|
|
498
637
|
### InputNumber
|
|
499
638
|
|
|
@@ -593,11 +732,97 @@ const MyComponent = () => {
|
|
|
593
732
|
|
|
594
733
|
### InputPhone
|
|
595
734
|
|
|
596
|
-
|
|
735
|
+
Input element for phone numbers that receives the following props:
|
|
736
|
+
|
|
737
|
+
- `disabled:boolean` applying 'disabled' attribute
|
|
738
|
+
- `error:boolean` indicating whether there is an error in the input
|
|
739
|
+
- `hint:string` text with additional info to be displayed below the input
|
|
740
|
+
- `icon:function` icon component to be displayed before the input
|
|
741
|
+
- `label:string` label text for the phone number part
|
|
742
|
+
- `labelPrefix:string` label text for the country code part
|
|
743
|
+
- `name:string` - required prop, input name
|
|
744
|
+
- `prefixes:string[]` available country codes
|
|
745
|
+
- `showRequired:boolean` indicating whether the "required" indicator should be shown
|
|
746
|
+
- `showState:boolean` indicating whether to show the state icons for errors, success, and warning
|
|
747
|
+
- `success:boolean` indicating whether the input has a success state
|
|
748
|
+
- `value:string` current value
|
|
749
|
+
- `warning:boolean` indicating whether the input has a warning state
|
|
750
|
+
- `onChange:function` executed when input value changes
|
|
751
|
+
- `onEnter:function` executed when input gets focus
|
|
752
|
+
- `onError:function` executed when there are validation errors in the input
|
|
753
|
+
- `onLeave:function` executed when input loses focus
|
|
754
|
+
|
|
755
|
+
```jsx
|
|
756
|
+
import { InputPhone } from '@mirai/ui';
|
|
757
|
+
|
|
758
|
+
export const Story = (props) => {
|
|
759
|
+
const [value, setValue] = useState('+34 123456789');
|
|
760
|
+
|
|
761
|
+
const handleChange = (next, ...others) => {
|
|
762
|
+
setValue(next);
|
|
763
|
+
};
|
|
764
|
+
|
|
765
|
+
const handleError = (...others) => console.log('<InputSelect>::onError', ...others);
|
|
766
|
+
|
|
767
|
+
return (
|
|
768
|
+
<InputPhone
|
|
769
|
+
hint='hint'
|
|
770
|
+
label='Phone Number'
|
|
771
|
+
labelPrefix='Code'
|
|
772
|
+
name='name'
|
|
773
|
+
prefixes={['+34', '+44', '+001', '+999', '+39', '+56']}
|
|
774
|
+
required
|
|
775
|
+
value={value}
|
|
776
|
+
onChange={handleChange}
|
|
777
|
+
onError={handleError}
|
|
778
|
+
/>
|
|
779
|
+
);
|
|
780
|
+
};
|
|
781
|
+
```
|
|
597
782
|
|
|
598
783
|
### InputSelect
|
|
599
784
|
|
|
600
|
-
|
|
785
|
+
A select input component that receives the following props:
|
|
786
|
+
|
|
787
|
+
- `disabled:boolean` applying 'disabled' attribute
|
|
788
|
+
- `error:boolean` indicating whether there is an error in the input
|
|
789
|
+
- `hint:string` text with additional info to be displayed below the input
|
|
790
|
+
- `label:string` label text
|
|
791
|
+
- `name:string` - required prop, input name
|
|
792
|
+
- `showRequired:boolean` indicating whether the "required" indicator should be shown
|
|
793
|
+
- `showState:boolean` indicating whether to show the state icons for errors, success, and warning
|
|
794
|
+
- `success:boolean` indicating whether the input has a success state
|
|
795
|
+
- `warning:boolean` indicating whether the input has a warning state
|
|
796
|
+
- `onChange:function` executed when input value changes
|
|
797
|
+
- `onEnter:function` executed when input gets focus
|
|
798
|
+
- `onError:function` executed when there are validation errors in the input
|
|
799
|
+
- `onLeave:function` executed when input loses focus
|
|
800
|
+
|
|
801
|
+
```jsx
|
|
802
|
+
import { InputSelect } from '@mirai/ui';
|
|
803
|
+
|
|
804
|
+
const Example = (props) => {
|
|
805
|
+
const [value, setValue] = useState('two');
|
|
806
|
+
|
|
807
|
+
const handleChange = (next, ...others) => {
|
|
808
|
+
setValue(next);
|
|
809
|
+
};
|
|
810
|
+
|
|
811
|
+
const handleEnter = (...others) => console.log('<InputSelect>::onEnter', ...others);
|
|
812
|
+
const handleLeave = (...others) => console.log('<InputSelect>::onLeave', ...others);
|
|
813
|
+
|
|
814
|
+
return (<InputSelect
|
|
815
|
+
hint='hint'
|
|
816
|
+
label='label'
|
|
817
|
+
name='name'
|
|
818
|
+
options={['one', 'two', 'three', 'four', 'five']}
|
|
819
|
+
value={value}
|
|
820
|
+
onChange={handleChange}
|
|
821
|
+
onEnter={handleEnter}
|
|
822
|
+
onLeave={handleLeave}
|
|
823
|
+
/>);
|
|
824
|
+
};
|
|
825
|
+
```
|
|
601
826
|
|
|
602
827
|
### InputText
|
|
603
828
|
|
|
@@ -751,7 +976,34 @@ const MyComponent = (props) => {
|
|
|
751
976
|
|
|
752
977
|
### Notification
|
|
753
978
|
|
|
754
|
-
|
|
979
|
+
A component that displays a notification message with optional icons and close button and receives the following props:
|
|
980
|
+
|
|
981
|
+
- `children: node` required prop, the content of the notification (any valid React node)
|
|
982
|
+
- `error:bool` indicating whether the notification represents an error message with corresponding styles
|
|
983
|
+
- `info:bool` indicating whether the notification represents an informational message
|
|
984
|
+
- `inline:bool` indicating whether the notification should be displayed inline
|
|
985
|
+
- `large:bool` indicating whether the notification should be displayed in a large size
|
|
986
|
+
- `small:bool` indicating whether the notification should be displayed in a small size
|
|
987
|
+
- `success:bool` indicating whether the notification represents a success message with corresponding styles
|
|
988
|
+
- `warning:bool` indicating whether the notification represents a warning message with corresponding styles
|
|
989
|
+
- `wide:bool` indicating whether the notification should be displayed in a wide format
|
|
990
|
+
- `onClose:function` executed when the close button is clicked
|
|
991
|
+
|
|
992
|
+
```jsx
|
|
993
|
+
import { Notification } from '@mirai/ui';
|
|
994
|
+
|
|
995
|
+
const Example = (props) => (
|
|
996
|
+
<Notification
|
|
997
|
+
error
|
|
998
|
+
large
|
|
999
|
+
wide
|
|
1000
|
+
onClose={() => console.log('Closing...')}
|
|
1001
|
+
>
|
|
1002
|
+
Something went wrong...
|
|
1003
|
+
</Notification>
|
|
1004
|
+
)
|
|
1005
|
+
;
|
|
1006
|
+
```
|
|
755
1007
|
|
|
756
1008
|
### Progress
|
|
757
1009
|
|
|
@@ -784,7 +1036,9 @@ const MyComponent = (props) => {
|
|
|
784
1036
|
|
|
785
1037
|
This component helps you to create a pure html table receiving the following props:
|
|
786
1038
|
|
|
787
|
-
- `dataSource:arrayOf(shape)`
|
|
1039
|
+
- `dataSource:arrayOf(shape)` datasource of your model data schema
|
|
1040
|
+
- `filter:object[]` array of filter items that are applied to the table data. Each filter item represents a specific filter configuration.
|
|
1041
|
+
- `inline:shape` specifies whether the table should be displayed inline
|
|
788
1042
|
- `schema:shape` the model data schema
|
|
789
1043
|
- `search:string` the query string you want use for filter the datasource
|
|
790
1044
|
- `selected:arrayOf(dataSource.row)` if you want pre-select some rows in 1st render
|
|
@@ -859,9 +1113,12 @@ const MyComponent = () => {
|
|
|
859
1113
|
This component helps you to create a tooltip over a determinate component receiving the following props:
|
|
860
1114
|
|
|
861
1115
|
- `children:node` The element which we will use as reference for display the menu.
|
|
1116
|
+
- `left:bool` positioning of the tooltip relative to its parent element
|
|
862
1117
|
- `pressable:bool` Change event dispatcher to `onPress` instead of ` onEnter`.
|
|
1118
|
+
- `right:bool` positioning of the tooltip relative to its parent element
|
|
863
1119
|
- `Template:node` if you don't want use the default scaffold.
|
|
864
1120
|
- `text:string` text it will appears when hover on `children`.
|
|
1121
|
+
- `timestamp:number` value used to force render to recalculate the position of the tooltip
|
|
865
1122
|
- `top:bool` Change the position to the top of reference element.
|
|
866
1123
|
- `visible:boolean` the default state of visibility of the instance.
|
|
867
1124
|
|
|
@@ -167,7 +167,7 @@ var Calendar = function Calendar(_ref) {
|
|
|
167
167
|
onChange: handleChange,
|
|
168
168
|
onFocus: isDesktop ? setFocus : undefined
|
|
169
169
|
});
|
|
170
|
-
if (isMobile && to) months = (0, _locale.dateDiff)(today, (0, _locale.parseDate)(to, format)).months;
|
|
170
|
+
if (isMobile && to) months = (0, _locale.dateDiff)(today, (0, _locale.parseDate)(to, format)).months + 1;
|
|
171
171
|
return /*#__PURE__*/_react.default.createElement(_primitives.View, {
|
|
172
172
|
className: (0, _helpers.styles)(_CalendarModule.default.container, className),
|
|
173
173
|
"data-testid": testID
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Calendar.js","names":["Calendar","autoScroll","disabledPast","format","from","locale","range","rangeMaxDays","to","value","onChange","onFocus","onNavigation","onScroll","others","useDevice","isDesktop","isMobile","useState","focus","setFocus","getFirstDateOfMonth","getToday","instance","setInstance","scrollTo","setScrollTo","scrolling","setScrolling","undefined","selected","setSelected","timestamp","setTimestamp","useEffect","date","length","dateFrom","parseDate","dateDiff","days","next","diffMonths","months","getScrollTo","UTC","handleChange","getTime","handleMonth","month","addMonths","Date","getFullYear","getMonth","handleScroll","event","now","testID","scrollEventThrottle","className","props","today","instanceTS","todayMonthTS","disabledPrevious","disabledNext","dateCalc","tooltips","styles","style","container","scrollview","Array","empty","index","displayName","propTypes","PropTypes","bool","captions","shape","disabledDates","arrayOf","string","highlights","number","rangeMinDays","oneOfType","func"],"sources":["../../../src/components/Calendar/Calendar.jsx"],"sourcesContent":["import { dateCalc, dateDiff, parseDate, UTC } from '@mirai/locale';\nimport PropTypes from 'prop-types';\nimport React, { useEffect, useState } from 'react';\n\nimport { styles } from '../../helpers';\nimport { useDevice } from '../../hooks';\nimport { ScrollView, View } from '../../primitives';\nimport style from './Calendar.module.css';\nimport { Month } from './Calendar.Month';\nimport { Weekdays } from './Calendar.Weekdays';\nimport { getFirstDateOfMonth, getScrollTo, getToday } from './helpers';\n\nexport const Calendar = ({\n autoScroll = false,\n disabledPast = true,\n format = 'YYYY/MM/DD',\n from,\n locale,\n range = false,\n rangeMaxDays,\n to,\n value,\n onChange = () => {},\n onFocus = () => {},\n onNavigation = () => {},\n onScroll = () => {},\n ...others\n}) => {\n const { isDesktop, isMobile } = useDevice();\n\n const [focus, setFocus] = useState();\n const [instance, setInstance] = useState(getFirstDateOfMonth(getToday()));\n const [scrollTo, setScrollTo] = useState();\n const [scrolling, setScrolling] = useState();\n const [selected, setSelected] = useState(range ? [] : undefined);\n const [timestamp, setTimestamp] = useState();\n\n useEffect(() => {\n let date = range ? (value?.length > 0 ? value[0] : undefined) : value;\n\n if (from && date) {\n const dateFrom = parseDate(from, format);\n const { days } = dateDiff(dateFrom, parseDate(date, format));\n\n if (days < 0) date = undefined;\n }\n if (!date) return setSelected(range ? [] : undefined);\n\n date = parseDate(date, format);\n if ((range && (selected.length === 0 || value.length === 2)) || !range) {\n const next = getFirstDateOfMonth(date);\n const { months: diffMonths } = dateDiff(instance, date);\n\n if (isDesktop && (diffMonths >= months || diffMonths < 0)) setInstance(next);\n else if (isMobile) {\n autoScroll && setScrollTo(getScrollTo(diffMonths));\n setScrolling(false);\n }\n }\n\n setSelected(range ? [UTC(date), value[1] ? UTC(parseDate(value[1], format)) : undefined] : UTC(date));\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [format, from, range, value]);\n\n useEffect(() => {\n from && (!value || value.length === 0 || !value[0]) && setInstance(getFirstDateOfMonth(parseDate(from, format)));\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [from]);\n\n useEffect(() => {\n onFocus(focus);\n }, [focus, onFocus]);\n\n const handleChange = (date) => {\n setSelected(() => {\n let next;\n\n if (!range) {\n next = date;\n } else if (selected[1] === undefined && date > selected[0]) {\n next = [selected[0], date];\n } else {\n next = [selected[0]?.getTime() === date.getTime() ? undefined : date];\n setFocus(undefined);\n }\n onChange(next);\n\n return next;\n });\n };\n\n const handleMonth = (month) => {\n setInstance(() => {\n const addMonths = range && value[0] && !value[1] ? (month > 0 ? 1 : -1) : month;\n const next = getFirstDateOfMonth(new Date(instance.getFullYear(), instance.getMonth() + addMonths));\n\n onNavigation(next);\n return next;\n });\n };\n\n const handleScroll = (event) => {\n if (isMobile) setScrolling(true);\n\n onScroll(event);\n setTimestamp(Date.now());\n };\n\n const { ['data-testid']: testID, scrollEventThrottle } = others;\n let { className, months = 2, ...props } = others;\n\n const today = getToday();\n const instanceTS = instance.getTime();\n const todayMonthTS = getFirstDateOfMonth(today).getTime();\n const disabledPrevious =\n (disabledPast && instanceTS <= todayMonthTS) ||\n (from && instanceTS <= getFirstDateOfMonth(parseDate(from, format)).getTime());\n\n const disabledNext =\n to && parseDate(to, format).getTime() <= getFirstDateOfMonth(dateCalc(instance, months, 'months')).getTime();\n\n props = {\n ...props,\n disabledPast,\n focus,\n format,\n from: from ? parseDate(from, format) : undefined,\n locale,\n range,\n selected,\n timestamp,\n to:\n range &&\n rangeMaxDays &&\n selected[0] &&\n !selected[1] &&\n (!to || dateCalc(selected[0], rangeMaxDays, 'days') < parseDate(to, format))\n ? dateCalc(selected[0], rangeMaxDays, 'days')\n : to\n ? parseDate(to, format)\n : undefined,\n tooltips: !isMobile || !scrolling ? props.tooltips : {},\n onChange: handleChange,\n onFocus: isDesktop ? setFocus : undefined,\n };\n\n if (isMobile && to) months = dateDiff(today, parseDate(to, format)).months;\n\n return (\n <View className={styles(style.container, className)} data-testid={testID}>\n {isMobile && <Weekdays locale={locale} />}\n <ScrollView\n horizontal={isDesktop}\n scrollTo={scrollTo}\n className={style.scrollview}\n scrollEventThrottle={scrollEventThrottle}\n onScroll={handleScroll}\n >\n {Array.from({ length: months }, (empty, index) => (\n <Month\n data-testid={testID}\n key={index}\n onNext={isDesktop && index === months - 1 && !disabledNext ? () => handleMonth(months) : undefined}\n onPrevious={isDesktop && index === 0 && !disabledPrevious ? () => handleMonth(-months) : undefined}\n instance={new Date(instance.getFullYear(), instance.getMonth() + index, 1)} // ! TODO: calc with mirai/locale\n {...props}\n />\n ))}\n </ScrollView>\n </View>\n );\n};\n\nCalendar.displayName = 'Component:Calendar';\n\nCalendar.propTypes = {\n autoScroll: PropTypes.bool,\n captions: PropTypes.shape({}),\n disabledDates: PropTypes.arrayOf(PropTypes.string),\n disabledPast: PropTypes.bool,\n format: PropTypes.string,\n from: PropTypes.string,\n highlights: PropTypes.arrayOf(PropTypes.string),\n locale: PropTypes.string,\n months: PropTypes.number,\n range: PropTypes.bool,\n rangeMaxDays: PropTypes.number,\n rangeMinDays: PropTypes.number,\n to: PropTypes.string,\n tooltips: PropTypes.shape({}),\n value: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),\n onChange: PropTypes.func,\n onFocus: PropTypes.func,\n onNavigation: PropTypes.func,\n onScroll: PropTypes.func,\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAAuE;EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEhE,IAAMA,QAAQ,GAAG,SAAXA,QAAQ,OAef;EAAA,2BAdJC,UAAU;IAAVA,UAAU,gCAAG,KAAK;IAAA,yBAClBC,YAAY;IAAZA,YAAY,kCAAG,IAAI;IAAA,mBACnBC,MAAM;IAANA,MAAM,4BAAG,YAAY;IACrBC,IAAI,QAAJA,IAAI;IACJC,MAAM,QAANA,MAAM;IAAA,kBACNC,KAAK;IAALA,KAAK,2BAAG,KAAK;IACbC,YAAY,QAAZA,YAAY;IACZC,EAAE,QAAFA,EAAE;IACFC,KAAK,QAALA,KAAK;IAAA,qBACLC,QAAQ;IAARA,QAAQ,8BAAG,YAAM,CAAC,CAAC;IAAA,oBACnBC,OAAO;IAAPA,OAAO,6BAAG,YAAM,CAAC,CAAC;IAAA,yBAClBC,YAAY;IAAZA,YAAY,kCAAG,YAAM,CAAC,CAAC;IAAA,qBACvBC,QAAQ;IAARA,QAAQ,8BAAG,YAAM,CAAC,CAAC;IAChBC,MAAM;EAET,iBAAgC,IAAAC,gBAAS,GAAE;IAAnCC,SAAS,cAATA,SAAS;IAAEC,QAAQ,cAARA,QAAQ;EAE3B,gBAA0B,IAAAC,eAAQ,GAAE;IAAA;IAA7BC,KAAK;IAAEC,QAAQ;EACtB,iBAAgC,IAAAF,eAAQ,EAAC,IAAAG,6BAAmB,EAAC,IAAAC,kBAAQ,GAAE,CAAC,CAAC;IAAA;IAAlEC,QAAQ;IAAEC,WAAW;EAC5B,iBAAgC,IAAAN,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,CAAC,CAAC,CAAC;EAC7BvE,KAAK,EAAEoE,kBAAS,CAACU,SAAS,CAAC,CAACV,kBAAS,CAACM,MAAM,EAAEN,kBAAS,CAACK,OAAO,CAACL,kBAAS,CAACM,MAAM,CAAC,CAAC,CAAC;EACnFzE,QAAQ,EAAEmE,kBAAS,CAACW,IAAI;EACxB7E,OAAO,EAAEkE,kBAAS,CAACW,IAAI;EACvB5E,YAAY,EAAEiE,kBAAS,CAACW,IAAI;EAC5B3E,QAAQ,EAAEgE,kBAAS,CAACW;AACtB,CAAC"}
|
|
1
|
+
{"version":3,"file":"Calendar.js","names":["Calendar","autoScroll","disabledPast","format","from","locale","range","rangeMaxDays","to","value","onChange","onFocus","onNavigation","onScroll","others","useDevice","isDesktop","isMobile","useState","focus","setFocus","getFirstDateOfMonth","getToday","instance","setInstance","scrollTo","setScrollTo","scrolling","setScrolling","undefined","selected","setSelected","timestamp","setTimestamp","useEffect","date","length","dateFrom","parseDate","dateDiff","days","next","diffMonths","months","getScrollTo","UTC","handleChange","getTime","handleMonth","month","addMonths","Date","getFullYear","getMonth","handleScroll","event","now","testID","scrollEventThrottle","className","props","today","instanceTS","todayMonthTS","disabledPrevious","disabledNext","dateCalc","tooltips","styles","style","container","scrollview","Array","empty","index","displayName","propTypes","PropTypes","bool","captions","shape","disabledDates","arrayOf","string","highlights","number","rangeMinDays","oneOfType","func"],"sources":["../../../src/components/Calendar/Calendar.jsx"],"sourcesContent":["import { dateCalc, dateDiff, parseDate, UTC } from '@mirai/locale';\nimport PropTypes from 'prop-types';\nimport React, { useEffect, useState } from 'react';\n\nimport { styles } from '../../helpers';\nimport { useDevice } from '../../hooks';\nimport { ScrollView, View } from '../../primitives';\nimport style from './Calendar.module.css';\nimport { Month } from './Calendar.Month';\nimport { Weekdays } from './Calendar.Weekdays';\nimport { getFirstDateOfMonth, getScrollTo, getToday } from './helpers';\n\nexport const Calendar = ({\n autoScroll = false,\n disabledPast = true,\n format = 'YYYY/MM/DD',\n from,\n locale,\n range = false,\n rangeMaxDays,\n to,\n value,\n onChange = () => {},\n onFocus = () => {},\n onNavigation = () => {},\n onScroll = () => {},\n ...others\n}) => {\n const { isDesktop, isMobile } = useDevice();\n\n const [focus, setFocus] = useState();\n const [instance, setInstance] = useState(getFirstDateOfMonth(getToday()));\n const [scrollTo, setScrollTo] = useState();\n const [scrolling, setScrolling] = useState();\n const [selected, setSelected] = useState(range ? [] : undefined);\n const [timestamp, setTimestamp] = useState();\n\n useEffect(() => {\n let date = range ? (value?.length > 0 ? value[0] : undefined) : value;\n\n if (from && date) {\n const dateFrom = parseDate(from, format);\n const { days } = dateDiff(dateFrom, parseDate(date, format));\n\n if (days < 0) date = undefined;\n }\n if (!date) return setSelected(range ? [] : undefined);\n\n date = parseDate(date, format);\n if ((range && (selected.length === 0 || value.length === 2)) || !range) {\n const next = getFirstDateOfMonth(date);\n const { months: diffMonths } = dateDiff(instance, date);\n\n if (isDesktop && (diffMonths >= months || diffMonths < 0)) setInstance(next);\n else if (isMobile) {\n autoScroll && setScrollTo(getScrollTo(diffMonths));\n setScrolling(false);\n }\n }\n\n setSelected(range ? [UTC(date), value[1] ? UTC(parseDate(value[1], format)) : undefined] : UTC(date));\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [format, from, range, value]);\n\n useEffect(() => {\n from && (!value || value.length === 0 || !value[0]) && setInstance(getFirstDateOfMonth(parseDate(from, format)));\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [from]);\n\n useEffect(() => {\n onFocus(focus);\n }, [focus, onFocus]);\n\n const handleChange = (date) => {\n setSelected(() => {\n let next;\n\n if (!range) {\n next = date;\n } else if (selected[1] === undefined && date > selected[0]) {\n next = [selected[0], date];\n } else {\n next = [selected[0]?.getTime() === date.getTime() ? undefined : date];\n setFocus(undefined);\n }\n onChange(next);\n\n return next;\n });\n };\n\n const handleMonth = (month) => {\n setInstance(() => {\n const addMonths = range && value[0] && !value[1] ? (month > 0 ? 1 : -1) : month;\n const next = getFirstDateOfMonth(new Date(instance.getFullYear(), instance.getMonth() + addMonths));\n\n onNavigation(next);\n return next;\n });\n };\n\n const handleScroll = (event) => {\n if (isMobile) setScrolling(true);\n\n onScroll(event);\n setTimestamp(Date.now());\n };\n\n const { ['data-testid']: testID, scrollEventThrottle } = others;\n let { className, months = 2, ...props } = others;\n\n const today = getToday();\n const instanceTS = instance.getTime();\n const todayMonthTS = getFirstDateOfMonth(today).getTime();\n const disabledPrevious =\n (disabledPast && instanceTS <= todayMonthTS) ||\n (from && instanceTS <= getFirstDateOfMonth(parseDate(from, format)).getTime());\n\n const disabledNext =\n to && parseDate(to, format).getTime() <= getFirstDateOfMonth(dateCalc(instance, months, 'months')).getTime();\n\n props = {\n ...props,\n disabledPast,\n focus,\n format,\n from: from ? parseDate(from, format) : undefined,\n locale,\n range,\n selected,\n timestamp,\n to:\n range &&\n rangeMaxDays &&\n selected[0] &&\n !selected[1] &&\n (!to || dateCalc(selected[0], rangeMaxDays, 'days') < parseDate(to, format))\n ? dateCalc(selected[0], rangeMaxDays, 'days')\n : to\n ? parseDate(to, format)\n : undefined,\n tooltips: !isMobile || !scrolling ? props.tooltips : {},\n onChange: handleChange,\n onFocus: isDesktop ? setFocus : undefined,\n };\n\n if (isMobile && to) months = dateDiff(today, parseDate(to, format)).months + 1;\n\n return (\n <View className={styles(style.container, className)} data-testid={testID}>\n {isMobile && <Weekdays locale={locale} />}\n <ScrollView\n horizontal={isDesktop}\n scrollTo={scrollTo}\n className={style.scrollview}\n scrollEventThrottle={scrollEventThrottle}\n onScroll={handleScroll}\n >\n {Array.from({ length: months }, (empty, index) => (\n <Month\n data-testid={testID}\n key={index}\n onNext={isDesktop && index === months - 1 && !disabledNext ? () => handleMonth(months) : undefined}\n onPrevious={isDesktop && index === 0 && !disabledPrevious ? () => handleMonth(-months) : undefined}\n instance={new Date(instance.getFullYear(), instance.getMonth() + index, 1)} // ! TODO: calc with mirai/locale\n {...props}\n />\n ))}\n </ScrollView>\n </View>\n );\n};\n\nCalendar.displayName = 'Component:Calendar';\n\nCalendar.propTypes = {\n autoScroll: PropTypes.bool,\n captions: PropTypes.shape({}),\n disabledDates: PropTypes.arrayOf(PropTypes.string),\n disabledPast: PropTypes.bool,\n format: PropTypes.string,\n from: PropTypes.string,\n highlights: PropTypes.arrayOf(PropTypes.string),\n locale: PropTypes.string,\n months: PropTypes.number,\n range: PropTypes.bool,\n rangeMaxDays: PropTypes.number,\n rangeMinDays: PropTypes.number,\n to: PropTypes.string,\n tooltips: PropTypes.shape({}),\n value: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),\n onChange: PropTypes.func,\n onFocus: PropTypes.func,\n onNavigation: PropTypes.func,\n onScroll: PropTypes.func,\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAAuE;EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEhE,IAAMA,QAAQ,GAAG,SAAXA,QAAQ,OAef;EAAA,2BAdJC,UAAU;IAAVA,UAAU,gCAAG,KAAK;IAAA,yBAClBC,YAAY;IAAZA,YAAY,kCAAG,IAAI;IAAA,mBACnBC,MAAM;IAANA,MAAM,4BAAG,YAAY;IACrBC,IAAI,QAAJA,IAAI;IACJC,MAAM,QAANA,MAAM;IAAA,kBACNC,KAAK;IAALA,KAAK,2BAAG,KAAK;IACbC,YAAY,QAAZA,YAAY;IACZC,EAAE,QAAFA,EAAE;IACFC,KAAK,QAALA,KAAK;IAAA,qBACLC,QAAQ;IAARA,QAAQ,8BAAG,YAAM,CAAC,CAAC;IAAA,oBACnBC,OAAO;IAAPA,OAAO,6BAAG,YAAM,CAAC,CAAC;IAAA,yBAClBC,YAAY;IAAZA,YAAY,kCAAG,YAAM,CAAC,CAAC;IAAA,qBACvBC,QAAQ;IAARA,QAAQ,8BAAG,YAAM,CAAC,CAAC;IACh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