@mirai/ui 1.0.152 → 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.
Files changed (2) hide show
  1. package/README.md +265 -8
  2. package/package.json +1 -1
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
- - `onscroll:function` executed when user scrolls over the element
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
- > @TODO
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
- > @TODO
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
- > @TODO
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
- > @TODO
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
- > @TODO
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
- > @TODO
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)` The datasource of your model data schema
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mirai/ui",
3
- "version": "1.0.152",
3
+ "version": "1.0.153",
4
4
  "repository": "git@gitlab.com:miraicorp/dev/frontend/ui.git",
5
5
  "author": "JΛVI <hello@soyjavi.com>",
6
6
  "license": "MIT",