@navikt/ds-react 4.4.2 → 4.6.0
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/_docs.json +325 -0
- package/cjs/alert/Alert.js +9 -3
- package/cjs/date/DateInput.js +9 -4
- package/cjs/date/hooks/useDatepicker.js +3 -0
- package/cjs/date/hooks/useMonthPicker.js +3 -0
- package/cjs/date/hooks/useRangeDatepicker.js +3 -0
- package/cjs/form/Fieldset/Fieldset.js +11 -4
- package/cjs/form/ReadOnlyIcon.js +15 -0
- package/cjs/form/Select.js +23 -3
- package/cjs/form/Switch.js +21 -8
- package/cjs/form/TextField.js +7 -3
- package/cjs/form/Textarea.js +7 -3
- package/cjs/form/checkbox/Checkbox.js +7 -2
- package/cjs/form/checkbox/CheckboxGroup.js +1 -1
- package/cjs/form/checkbox/useCheckbox.js +12 -2
- package/cjs/form/radio/Radio.js +3 -2
- package/cjs/form/radio/RadioGroup.js +2 -2
- package/cjs/form/radio/useRadio.js +12 -2
- package/cjs/form/search/Search.js +1 -1
- package/cjs/form/useFormField.js +11 -9
- package/esm/alert/Alert.d.ts +11 -0
- package/esm/alert/Alert.js +10 -4
- package/esm/alert/Alert.js.map +1 -1
- package/esm/date/DateInput.js +9 -4
- package/esm/date/DateInput.js.map +1 -1
- package/esm/date/hooks/useDatepicker.js +3 -0
- package/esm/date/hooks/useDatepicker.js.map +1 -1
- package/esm/date/hooks/useMonthPicker.js +3 -0
- package/esm/date/hooks/useMonthPicker.js.map +1 -1
- package/esm/date/hooks/useRangeDatepicker.js +3 -0
- package/esm/date/hooks/useRangeDatepicker.js.map +1 -1
- package/esm/form/ConfirmationPanel.d.ts +1 -1
- package/esm/form/Fieldset/Fieldset.d.ts +5 -0
- package/esm/form/Fieldset/Fieldset.js +11 -4
- package/esm/form/Fieldset/Fieldset.js.map +1 -1
- package/esm/form/Fieldset/useFieldset.d.ts +2 -1
- package/esm/form/ReadOnlyIcon.d.ts +5 -0
- package/esm/form/ReadOnlyIcon.js +9 -0
- package/esm/form/ReadOnlyIcon.js.map +1 -0
- package/esm/form/Select.js +23 -3
- package/esm/form/Select.js.map +1 -1
- package/esm/form/Switch.d.ts +1 -1
- package/esm/form/Switch.js +21 -8
- package/esm/form/Switch.js.map +1 -1
- package/esm/form/TextField.js +7 -3
- package/esm/form/TextField.js.map +1 -1
- package/esm/form/Textarea.js +7 -3
- package/esm/form/Textarea.js.map +1 -1
- package/esm/form/checkbox/Checkbox.js +7 -2
- package/esm/form/checkbox/Checkbox.js.map +1 -1
- package/esm/form/checkbox/CheckboxGroup.js +1 -1
- package/esm/form/checkbox/CheckboxGroup.js.map +1 -1
- package/esm/form/checkbox/useCheckbox.d.ts +5 -2
- package/esm/form/checkbox/useCheckbox.js +12 -2
- package/esm/form/checkbox/useCheckbox.js.map +1 -1
- package/esm/form/radio/Radio.d.ts +1 -1
- package/esm/form/radio/Radio.js +3 -2
- package/esm/form/radio/Radio.js.map +1 -1
- package/esm/form/radio/RadioGroup.js +2 -2
- package/esm/form/radio/RadioGroup.js.map +1 -1
- package/esm/form/radio/useRadio.d.ts +4 -2
- package/esm/form/radio/useRadio.js +12 -2
- package/esm/form/radio/useRadio.js.map +1 -1
- package/esm/form/search/Search.d.ts +1 -1
- package/esm/form/search/Search.js +1 -1
- package/esm/form/search/Search.js.map +1 -1
- package/esm/form/useFormField.d.ts +7 -2
- package/esm/form/useFormField.js +11 -9
- package/esm/form/useFormField.js.map +1 -1
- package/package.json +2 -2
- package/src/alert/Alert.tsx +49 -18
- package/src/alert/alert.stories.tsx +75 -22
- package/src/date/DateInput.tsx +8 -2
- package/src/date/datepicker/datepicker.stories.tsx +22 -0
- package/src/date/hooks/useDatepicker.tsx +3 -0
- package/src/date/hooks/useMonthPicker.tsx +3 -0
- package/src/date/hooks/useRangeDatepicker.tsx +3 -0
- package/src/form/ConfirmationPanel.tsx +1 -1
- package/src/form/Fieldset/Fieldset.tsx +15 -2
- package/src/form/ReadOnlyIcon.tsx +20 -0
- package/src/form/Select.tsx +28 -2
- package/src/form/Switch.tsx +20 -9
- package/src/form/TextField.tsx +5 -0
- package/src/form/Textarea.tsx +5 -0
- package/src/form/checkbox/Checkbox.tsx +7 -1
- package/src/form/checkbox/CheckboxGroup.tsx +1 -0
- package/src/form/checkbox/checkbox.stories.tsx +35 -1
- package/src/form/checkbox/useCheckbox.ts +13 -1
- package/src/form/radio/Radio.tsx +4 -3
- package/src/form/radio/RadioGroup.tsx +3 -0
- package/src/form/radio/radio.stories.tsx +27 -0
- package/src/form/radio/useRadio.ts +12 -1
- package/src/form/search/Search.tsx +2 -2
- package/src/form/stories/select.stories.tsx +17 -0
- package/src/form/stories/switch.stories.tsx +14 -0
- package/src/form/stories/text-field.stories.tsx +14 -0
- package/src/form/stories/textarea.stories.tsx +19 -0
- package/src/form/useFormField.ts +25 -3
package/_docs.json
CHANGED
|
@@ -480,6 +480,46 @@
|
|
|
480
480
|
"name": "boolean"
|
|
481
481
|
}
|
|
482
482
|
},
|
|
483
|
+
"closeButton": {
|
|
484
|
+
"defaultValue": {
|
|
485
|
+
"value": "false"
|
|
486
|
+
},
|
|
487
|
+
"description": "Removes close-button(X) when false\nRequires onClose to be set",
|
|
488
|
+
"name": "closeButton",
|
|
489
|
+
"parent": {
|
|
490
|
+
"fileName": "src/alert/Alert.tsx",
|
|
491
|
+
"name": "AlertProps"
|
|
492
|
+
},
|
|
493
|
+
"declarations": [
|
|
494
|
+
{
|
|
495
|
+
"fileName": "src/alert/Alert.tsx",
|
|
496
|
+
"name": "AlertProps"
|
|
497
|
+
}
|
|
498
|
+
],
|
|
499
|
+
"required": false,
|
|
500
|
+
"type": {
|
|
501
|
+
"name": "boolean"
|
|
502
|
+
}
|
|
503
|
+
},
|
|
504
|
+
"onClose": {
|
|
505
|
+
"defaultValue": null,
|
|
506
|
+
"description": "Callback for alert wanting to close\nrequires closeButton to be true",
|
|
507
|
+
"name": "onClose",
|
|
508
|
+
"parent": {
|
|
509
|
+
"fileName": "src/alert/Alert.tsx",
|
|
510
|
+
"name": "AlertProps"
|
|
511
|
+
},
|
|
512
|
+
"declarations": [
|
|
513
|
+
{
|
|
514
|
+
"fileName": "src/alert/Alert.tsx",
|
|
515
|
+
"name": "AlertProps"
|
|
516
|
+
}
|
|
517
|
+
],
|
|
518
|
+
"required": false,
|
|
519
|
+
"type": {
|
|
520
|
+
"name": "(() => void)"
|
|
521
|
+
}
|
|
522
|
+
},
|
|
483
523
|
"className": {
|
|
484
524
|
"defaultValue": null,
|
|
485
525
|
"description": "",
|
|
@@ -1809,6 +1849,25 @@
|
|
|
1809
1849
|
"name": "string"
|
|
1810
1850
|
}
|
|
1811
1851
|
},
|
|
1852
|
+
"readOnly": {
|
|
1853
|
+
"defaultValue": null,
|
|
1854
|
+
"description": "Read only-state",
|
|
1855
|
+
"name": "readOnly",
|
|
1856
|
+
"parent": {
|
|
1857
|
+
"fileName": "react/src/form/useFormField.ts",
|
|
1858
|
+
"name": "FormFieldProps"
|
|
1859
|
+
},
|
|
1860
|
+
"declarations": [
|
|
1861
|
+
{
|
|
1862
|
+
"fileName": "react/src/form/useFormField.ts",
|
|
1863
|
+
"name": "FormFieldProps"
|
|
1864
|
+
}
|
|
1865
|
+
],
|
|
1866
|
+
"required": false,
|
|
1867
|
+
"type": {
|
|
1868
|
+
"name": "boolean"
|
|
1869
|
+
}
|
|
1870
|
+
},
|
|
1812
1871
|
"className": {
|
|
1813
1872
|
"defaultValue": null,
|
|
1814
1873
|
"description": "",
|
|
@@ -2028,6 +2087,25 @@
|
|
|
2028
2087
|
"name": "string"
|
|
2029
2088
|
}
|
|
2030
2089
|
},
|
|
2090
|
+
"readOnly": {
|
|
2091
|
+
"defaultValue": null,
|
|
2092
|
+
"description": "Read only-state",
|
|
2093
|
+
"name": "readOnly",
|
|
2094
|
+
"parent": {
|
|
2095
|
+
"fileName": "react/src/form/useFormField.ts",
|
|
2096
|
+
"name": "FormFieldProps"
|
|
2097
|
+
},
|
|
2098
|
+
"declarations": [
|
|
2099
|
+
{
|
|
2100
|
+
"fileName": "react/src/form/useFormField.ts",
|
|
2101
|
+
"name": "FormFieldProps"
|
|
2102
|
+
}
|
|
2103
|
+
],
|
|
2104
|
+
"required": false,
|
|
2105
|
+
"type": {
|
|
2106
|
+
"name": "boolean"
|
|
2107
|
+
}
|
|
2108
|
+
},
|
|
2031
2109
|
"className": {
|
|
2032
2110
|
"defaultValue": null,
|
|
2033
2111
|
"description": "",
|
|
@@ -2807,6 +2885,44 @@
|
|
|
2807
2885
|
}
|
|
2808
2886
|
}
|
|
2809
2887
|
},
|
|
2888
|
+
{
|
|
2889
|
+
"filePath": "src/form/ReadOnlyIcon.tsx",
|
|
2890
|
+
"displayName": "ReadOnlyIcon",
|
|
2891
|
+
"props": {
|
|
2892
|
+
"readOnly": {
|
|
2893
|
+
"defaultValue": null,
|
|
2894
|
+
"description": "",
|
|
2895
|
+
"name": "readOnly",
|
|
2896
|
+
"declarations": [
|
|
2897
|
+
{
|
|
2898
|
+
"fileName": "src/form/ReadOnlyIcon.tsx",
|
|
2899
|
+
"name": "TypeLiteral"
|
|
2900
|
+
}
|
|
2901
|
+
],
|
|
2902
|
+
"required": false,
|
|
2903
|
+
"type": {
|
|
2904
|
+
"name": "boolean"
|
|
2905
|
+
}
|
|
2906
|
+
},
|
|
2907
|
+
"nativeReadOnly": {
|
|
2908
|
+
"defaultValue": {
|
|
2909
|
+
"value": "true"
|
|
2910
|
+
},
|
|
2911
|
+
"description": "",
|
|
2912
|
+
"name": "nativeReadOnly",
|
|
2913
|
+
"declarations": [
|
|
2914
|
+
{
|
|
2915
|
+
"fileName": "src/form/ReadOnlyIcon.tsx",
|
|
2916
|
+
"name": "TypeLiteral"
|
|
2917
|
+
}
|
|
2918
|
+
],
|
|
2919
|
+
"required": false,
|
|
2920
|
+
"type": {
|
|
2921
|
+
"name": "boolean"
|
|
2922
|
+
}
|
|
2923
|
+
}
|
|
2924
|
+
}
|
|
2925
|
+
},
|
|
2810
2926
|
{
|
|
2811
2927
|
"filePath": "src/form/Select.tsx",
|
|
2812
2928
|
"displayName": "Select",
|
|
@@ -3020,6 +3136,25 @@
|
|
|
3020
3136
|
"name": "string"
|
|
3021
3137
|
}
|
|
3022
3138
|
},
|
|
3139
|
+
"readOnly": {
|
|
3140
|
+
"defaultValue": null,
|
|
3141
|
+
"description": "Read only-state",
|
|
3142
|
+
"name": "readOnly",
|
|
3143
|
+
"parent": {
|
|
3144
|
+
"fileName": "react/src/form/useFormField.ts",
|
|
3145
|
+
"name": "FormFieldProps"
|
|
3146
|
+
},
|
|
3147
|
+
"declarations": [
|
|
3148
|
+
{
|
|
3149
|
+
"fileName": "react/src/form/useFormField.ts",
|
|
3150
|
+
"name": "FormFieldProps"
|
|
3151
|
+
}
|
|
3152
|
+
],
|
|
3153
|
+
"required": false,
|
|
3154
|
+
"type": {
|
|
3155
|
+
"name": "boolean"
|
|
3156
|
+
}
|
|
3157
|
+
},
|
|
3023
3158
|
"className": {
|
|
3024
3159
|
"defaultValue": null,
|
|
3025
3160
|
"description": "",
|
|
@@ -3218,6 +3353,25 @@
|
|
|
3218
3353
|
"name": "string"
|
|
3219
3354
|
}
|
|
3220
3355
|
},
|
|
3356
|
+
"readOnly": {
|
|
3357
|
+
"defaultValue": null,
|
|
3358
|
+
"description": "Read only-state",
|
|
3359
|
+
"name": "readOnly",
|
|
3360
|
+
"parent": {
|
|
3361
|
+
"fileName": "react/src/form/useFormField.ts",
|
|
3362
|
+
"name": "FormFieldProps"
|
|
3363
|
+
},
|
|
3364
|
+
"declarations": [
|
|
3365
|
+
{
|
|
3366
|
+
"fileName": "react/src/form/useFormField.ts",
|
|
3367
|
+
"name": "FormFieldProps"
|
|
3368
|
+
}
|
|
3369
|
+
],
|
|
3370
|
+
"required": false,
|
|
3371
|
+
"type": {
|
|
3372
|
+
"name": "boolean"
|
|
3373
|
+
}
|
|
3374
|
+
},
|
|
3221
3375
|
"className": {
|
|
3222
3376
|
"defaultValue": null,
|
|
3223
3377
|
"description": "",
|
|
@@ -3492,6 +3646,25 @@
|
|
|
3492
3646
|
"name": "string"
|
|
3493
3647
|
}
|
|
3494
3648
|
},
|
|
3649
|
+
"readOnly": {
|
|
3650
|
+
"defaultValue": null,
|
|
3651
|
+
"description": "Read only-state",
|
|
3652
|
+
"name": "readOnly",
|
|
3653
|
+
"parent": {
|
|
3654
|
+
"fileName": "react/src/form/useFormField.ts",
|
|
3655
|
+
"name": "FormFieldProps"
|
|
3656
|
+
},
|
|
3657
|
+
"declarations": [
|
|
3658
|
+
{
|
|
3659
|
+
"fileName": "react/src/form/useFormField.ts",
|
|
3660
|
+
"name": "FormFieldProps"
|
|
3661
|
+
}
|
|
3662
|
+
],
|
|
3663
|
+
"required": false,
|
|
3664
|
+
"type": {
|
|
3665
|
+
"name": "boolean"
|
|
3666
|
+
}
|
|
3667
|
+
},
|
|
3495
3668
|
"className": {
|
|
3496
3669
|
"defaultValue": null,
|
|
3497
3670
|
"description": "",
|
|
@@ -3821,6 +3994,25 @@
|
|
|
3821
3994
|
"name": "string"
|
|
3822
3995
|
}
|
|
3823
3996
|
},
|
|
3997
|
+
"readOnly": {
|
|
3998
|
+
"defaultValue": null,
|
|
3999
|
+
"description": "Read only-state",
|
|
4000
|
+
"name": "readOnly",
|
|
4001
|
+
"parent": {
|
|
4002
|
+
"fileName": "react/src/form/useFormField.ts",
|
|
4003
|
+
"name": "FormFieldProps"
|
|
4004
|
+
},
|
|
4005
|
+
"declarations": [
|
|
4006
|
+
{
|
|
4007
|
+
"fileName": "react/src/form/useFormField.ts",
|
|
4008
|
+
"name": "FormFieldProps"
|
|
4009
|
+
}
|
|
4010
|
+
],
|
|
4011
|
+
"required": false,
|
|
4012
|
+
"type": {
|
|
4013
|
+
"name": "boolean"
|
|
4014
|
+
}
|
|
4015
|
+
},
|
|
3824
4016
|
"className": {
|
|
3825
4017
|
"defaultValue": null,
|
|
3826
4018
|
"description": "",
|
|
@@ -12851,6 +13043,25 @@
|
|
|
12851
13043
|
"name": "boolean"
|
|
12852
13044
|
}
|
|
12853
13045
|
},
|
|
13046
|
+
"nativeReadOnly": {
|
|
13047
|
+
"defaultValue": null,
|
|
13048
|
+
"description": "",
|
|
13049
|
+
"name": "nativeReadOnly",
|
|
13050
|
+
"parent": {
|
|
13051
|
+
"fileName": "src/form/Fieldset/Fieldset.tsx",
|
|
13052
|
+
"name": "FieldsetProps"
|
|
13053
|
+
},
|
|
13054
|
+
"declarations": [
|
|
13055
|
+
{
|
|
13056
|
+
"fileName": "src/form/Fieldset/Fieldset.tsx",
|
|
13057
|
+
"name": "FieldsetProps"
|
|
13058
|
+
}
|
|
13059
|
+
],
|
|
13060
|
+
"required": false,
|
|
13061
|
+
"type": {
|
|
13062
|
+
"name": "boolean"
|
|
13063
|
+
}
|
|
13064
|
+
},
|
|
12854
13065
|
"error": {
|
|
12855
13066
|
"defaultValue": null,
|
|
12856
13067
|
"description": "Error message for element",
|
|
@@ -12965,6 +13176,25 @@
|
|
|
12965
13176
|
"name": "string"
|
|
12966
13177
|
}
|
|
12967
13178
|
},
|
|
13179
|
+
"readOnly": {
|
|
13180
|
+
"defaultValue": null,
|
|
13181
|
+
"description": "Read only-state",
|
|
13182
|
+
"name": "readOnly",
|
|
13183
|
+
"parent": {
|
|
13184
|
+
"fileName": "react/src/form/useFormField.ts",
|
|
13185
|
+
"name": "FormFieldProps"
|
|
13186
|
+
},
|
|
13187
|
+
"declarations": [
|
|
13188
|
+
{
|
|
13189
|
+
"fileName": "react/src/form/useFormField.ts",
|
|
13190
|
+
"name": "FormFieldProps"
|
|
13191
|
+
}
|
|
13192
|
+
],
|
|
13193
|
+
"required": false,
|
|
13194
|
+
"type": {
|
|
13195
|
+
"name": "boolean"
|
|
13196
|
+
}
|
|
13197
|
+
},
|
|
12968
13198
|
"className": {
|
|
12969
13199
|
"defaultValue": null,
|
|
12970
13200
|
"description": "",
|
|
@@ -13203,6 +13433,25 @@
|
|
|
13203
13433
|
"name": "string"
|
|
13204
13434
|
}
|
|
13205
13435
|
},
|
|
13436
|
+
"readOnly": {
|
|
13437
|
+
"defaultValue": null,
|
|
13438
|
+
"description": "Read only-state",
|
|
13439
|
+
"name": "readOnly",
|
|
13440
|
+
"parent": {
|
|
13441
|
+
"fileName": "react/src/form/useFormField.ts",
|
|
13442
|
+
"name": "FormFieldProps"
|
|
13443
|
+
},
|
|
13444
|
+
"declarations": [
|
|
13445
|
+
{
|
|
13446
|
+
"fileName": "react/src/form/useFormField.ts",
|
|
13447
|
+
"name": "FormFieldProps"
|
|
13448
|
+
}
|
|
13449
|
+
],
|
|
13450
|
+
"required": false,
|
|
13451
|
+
"type": {
|
|
13452
|
+
"name": "boolean"
|
|
13453
|
+
}
|
|
13454
|
+
},
|
|
13206
13455
|
"className": {
|
|
13207
13456
|
"defaultValue": null,
|
|
13208
13457
|
"description": "",
|
|
@@ -13363,6 +13612,25 @@
|
|
|
13363
13612
|
"name": "boolean"
|
|
13364
13613
|
}
|
|
13365
13614
|
},
|
|
13615
|
+
"nativeReadOnly": {
|
|
13616
|
+
"defaultValue": null,
|
|
13617
|
+
"description": "",
|
|
13618
|
+
"name": "nativeReadOnly",
|
|
13619
|
+
"parent": {
|
|
13620
|
+
"fileName": "react/src/form/Fieldset/Fieldset.tsx",
|
|
13621
|
+
"name": "FieldsetProps"
|
|
13622
|
+
},
|
|
13623
|
+
"declarations": [
|
|
13624
|
+
{
|
|
13625
|
+
"fileName": "react/src/form/Fieldset/Fieldset.tsx",
|
|
13626
|
+
"name": "FieldsetProps"
|
|
13627
|
+
}
|
|
13628
|
+
],
|
|
13629
|
+
"required": false,
|
|
13630
|
+
"type": {
|
|
13631
|
+
"name": "boolean"
|
|
13632
|
+
}
|
|
13633
|
+
},
|
|
13366
13634
|
"error": {
|
|
13367
13635
|
"defaultValue": null,
|
|
13368
13636
|
"description": "Error message for element",
|
|
@@ -13477,6 +13745,25 @@
|
|
|
13477
13745
|
"name": "string"
|
|
13478
13746
|
}
|
|
13479
13747
|
},
|
|
13748
|
+
"readOnly": {
|
|
13749
|
+
"defaultValue": null,
|
|
13750
|
+
"description": "Read only-state",
|
|
13751
|
+
"name": "readOnly",
|
|
13752
|
+
"parent": {
|
|
13753
|
+
"fileName": "react/src/form/useFormField.ts",
|
|
13754
|
+
"name": "FormFieldProps"
|
|
13755
|
+
},
|
|
13756
|
+
"declarations": [
|
|
13757
|
+
{
|
|
13758
|
+
"fileName": "react/src/form/useFormField.ts",
|
|
13759
|
+
"name": "FormFieldProps"
|
|
13760
|
+
}
|
|
13761
|
+
],
|
|
13762
|
+
"required": false,
|
|
13763
|
+
"type": {
|
|
13764
|
+
"name": "boolean"
|
|
13765
|
+
}
|
|
13766
|
+
},
|
|
13480
13767
|
"className": {
|
|
13481
13768
|
"defaultValue": null,
|
|
13482
13769
|
"description": "",
|
|
@@ -14039,6 +14326,25 @@
|
|
|
14039
14326
|
"name": "boolean"
|
|
14040
14327
|
}
|
|
14041
14328
|
},
|
|
14329
|
+
"nativeReadOnly": {
|
|
14330
|
+
"defaultValue": null,
|
|
14331
|
+
"description": "",
|
|
14332
|
+
"name": "nativeReadOnly",
|
|
14333
|
+
"parent": {
|
|
14334
|
+
"fileName": "react/src/form/Fieldset/Fieldset.tsx",
|
|
14335
|
+
"name": "FieldsetProps"
|
|
14336
|
+
},
|
|
14337
|
+
"declarations": [
|
|
14338
|
+
{
|
|
14339
|
+
"fileName": "react/src/form/Fieldset/Fieldset.tsx",
|
|
14340
|
+
"name": "FieldsetProps"
|
|
14341
|
+
}
|
|
14342
|
+
],
|
|
14343
|
+
"required": false,
|
|
14344
|
+
"type": {
|
|
14345
|
+
"name": "boolean"
|
|
14346
|
+
}
|
|
14347
|
+
},
|
|
14042
14348
|
"error": {
|
|
14043
14349
|
"defaultValue": null,
|
|
14044
14350
|
"description": "Error message for element",
|
|
@@ -14153,6 +14459,25 @@
|
|
|
14153
14459
|
"name": "string"
|
|
14154
14460
|
}
|
|
14155
14461
|
},
|
|
14462
|
+
"readOnly": {
|
|
14463
|
+
"defaultValue": null,
|
|
14464
|
+
"description": "Read only-state",
|
|
14465
|
+
"name": "readOnly",
|
|
14466
|
+
"parent": {
|
|
14467
|
+
"fileName": "react/src/form/useFormField.ts",
|
|
14468
|
+
"name": "FormFieldProps"
|
|
14469
|
+
},
|
|
14470
|
+
"declarations": [
|
|
14471
|
+
{
|
|
14472
|
+
"fileName": "react/src/form/useFormField.ts",
|
|
14473
|
+
"name": "FormFieldProps"
|
|
14474
|
+
}
|
|
14475
|
+
],
|
|
14476
|
+
"required": false,
|
|
14477
|
+
"type": {
|
|
14478
|
+
"name": "boolean"
|
|
14479
|
+
}
|
|
14480
|
+
},
|
|
14156
14481
|
"className": {
|
|
14157
14482
|
"defaultValue": null,
|
|
14158
14483
|
"description": "",
|
package/cjs/alert/Alert.js
CHANGED
|
@@ -42,6 +42,7 @@ const aksel_icons_1 = require("@navikt/aksel-icons");
|
|
|
42
42
|
const clsx_1 = __importDefault(require("clsx"));
|
|
43
43
|
const react_1 = __importStar(require("react"));
|
|
44
44
|
const BodyLong_1 = require("../typography/BodyLong");
|
|
45
|
+
const button_1 = require("../button");
|
|
45
46
|
const Icon = (_a) => {
|
|
46
47
|
var { variant } = _a, props = __rest(_a, ["variant"]);
|
|
47
48
|
switch (variant) {
|
|
@@ -67,9 +68,14 @@ const Icon = (_a) => {
|
|
|
67
68
|
* ```
|
|
68
69
|
*/
|
|
69
70
|
exports.Alert = (0, react_1.forwardRef)((_a, ref) => {
|
|
70
|
-
var { children, className, variant, size = "medium", fullWidth = false, inline = false } = _a, rest = __rest(_a, ["children", "className", "variant", "size", "fullWidth", "inline"]);
|
|
71
|
-
return (react_1.default.createElement("div", Object.assign({}, rest, { ref: ref, className: (0, clsx_1.default)(className, "navds-alert", `navds-alert--${variant}`, `navds-alert--${size}`, {
|
|
71
|
+
var { children, className, variant, size = "medium", fullWidth = false, inline = false, closeButton = false, onClose } = _a, rest = __rest(_a, ["children", "className", "variant", "size", "fullWidth", "inline", "closeButton", "onClose"]);
|
|
72
|
+
return (react_1.default.createElement("div", Object.assign({}, rest, { ref: ref, className: (0, clsx_1.default)(className, "navds-alert", `navds-alert--${variant}`, `navds-alert--${size}`, {
|
|
73
|
+
"navds-alert--full-width": fullWidth,
|
|
74
|
+
"navds-alert--inline": inline,
|
|
75
|
+
}) }),
|
|
72
76
|
react_1.default.createElement(Icon, { variant: variant, className: "navds-alert__icon" }),
|
|
73
|
-
react_1.default.createElement(BodyLong_1.BodyLong, { as: "div", size: size, className: "navds-alert__wrapper" }, children)
|
|
77
|
+
react_1.default.createElement(BodyLong_1.BodyLong, { as: "div", size: size, className: "navds-alert__wrapper" }, children),
|
|
78
|
+
closeButton && !inline && (react_1.default.createElement("div", { className: "navds-alert__button-wrapper" },
|
|
79
|
+
react_1.default.createElement(button_1.Button, { className: "navds-alert__button", size: "small", variant: "tertiary-neutral", onClick: onClose, icon: react_1.default.createElement(aksel_icons_1.XMarkIcon, { title: "Lukk Alert" }) })))));
|
|
74
80
|
});
|
|
75
81
|
exports.default = exports.Alert;
|
package/cjs/date/DateInput.js
CHANGED
|
@@ -44,6 +44,7 @@ const react_1 = __importStar(require("react"));
|
|
|
44
44
|
const __1 = require("..");
|
|
45
45
|
const useFormField_1 = require("../form/useFormField");
|
|
46
46
|
const context_1 = require("./context");
|
|
47
|
+
const ReadOnlyIcon_1 = require("../form/ReadOnlyIcon");
|
|
47
48
|
const DateInput = (0, react_1.forwardRef)((props, ref) => {
|
|
48
49
|
const { className, hideLabel = false, label, description, variant = "datepicker" } = props, rest = __rest(props, ["className", "hideLabel", "label", "description", "variant"]);
|
|
49
50
|
const isDatepickerVariant = variant === "datepicker";
|
|
@@ -55,22 +56,26 @@ const DateInput = (0, react_1.forwardRef)((props, ref) => {
|
|
|
55
56
|
},
|
|
56
57
|
};
|
|
57
58
|
const { onOpen, ariaId, open } = (0, context_1.useDateInputContext)();
|
|
58
|
-
const { inputProps, size = "medium", inputDescriptionId, errorId, showErrorMsg, hasError, } = (0, useFormField_1.useFormField)(props, conditionalVariables.prefix);
|
|
59
|
+
const { inputProps, size = "medium", inputDescriptionId, errorId, showErrorMsg, hasError, readOnly, } = (0, useFormField_1.useFormField)(props, conditionalVariables.prefix);
|
|
59
60
|
return (react_1.default.createElement("div", { className: (0, clsx_1.default)(className, "navds-form-field", `navds-form-field--${size}`, "navds-date__field", {
|
|
60
61
|
"navds-text-field--error": hasError,
|
|
61
62
|
"navds-date__field--error": hasError,
|
|
62
63
|
"navds-form-field--disabled": !!inputProps.disabled,
|
|
63
64
|
"navds-text-field--disabled": !!inputProps.disabled,
|
|
65
|
+
"navds-text-field--readonly": readOnly,
|
|
66
|
+
"navds-date__field--readonly": readOnly,
|
|
64
67
|
}) },
|
|
65
68
|
react_1.default.createElement(__1.Label, { htmlFor: inputProps.id, size: size, className: (0, clsx_1.default)("navds-form-field__label", {
|
|
66
69
|
"navds-sr-only": hideLabel,
|
|
67
|
-
}) },
|
|
70
|
+
}) },
|
|
71
|
+
react_1.default.createElement(ReadOnlyIcon_1.ReadOnlyIcon, { readOnly: readOnly }),
|
|
72
|
+
label),
|
|
68
73
|
!!description && (react_1.default.createElement(__1.BodyShort, { as: "div", className: (0, clsx_1.default)("navds-form-field__description", {
|
|
69
74
|
"navds-sr-only": hideLabel,
|
|
70
75
|
}), id: inputDescriptionId, size: size }, description)),
|
|
71
76
|
react_1.default.createElement("div", { className: "navds-date__field-wrapper" },
|
|
72
|
-
react_1.default.createElement("input", Object.assign({ ref: ref }, (0, __1.omit)(rest, ["error", "errorId", "size"]), inputProps, { autoComplete: "off", "aria-controls": ariaId, className: (0, clsx_1.default)("navds-date__field-input", "navds-text-field__input", "navds-body-short", `navds-body-${size}`), size: 14 })),
|
|
73
|
-
react_1.default.createElement("button", { disabled: inputProps.disabled, tabIndex: open ? -1 : 0, onClick: () => onOpen(), type: "button", className: "navds-date__field-button" },
|
|
77
|
+
react_1.default.createElement("input", Object.assign({ ref: ref }, (0, __1.omit)(rest, ["error", "errorId", "size"]), inputProps, { autoComplete: "off", "aria-controls": ariaId, readOnly: readOnly, className: (0, clsx_1.default)("navds-date__field-input", "navds-text-field__input", "navds-body-short", `navds-body-${size}`), size: 14 })),
|
|
78
|
+
react_1.default.createElement("button", { disabled: inputProps.disabled || readOnly, tabIndex: readOnly ? -1 : open ? -1 : 0, onClick: () => onOpen(), type: "button", className: "navds-date__field-button" },
|
|
74
79
|
react_1.default.createElement(aksel_icons_1.CalendarIcon, { pointerEvents: "none", title: open
|
|
75
80
|
? conditionalVariables.iconTitle.close
|
|
76
81
|
: conditionalVariables.iconTitle.open }))),
|
|
@@ -71,6 +71,9 @@ const useDatepicker = (opt = {}) => {
|
|
|
71
71
|
setInputValue(date ? (0, utils_1.formatDateForInput)(date, locale, "date", inputFormat) : "");
|
|
72
72
|
};
|
|
73
73
|
const handleFocus = (e) => {
|
|
74
|
+
if (e.target.readOnly) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
74
77
|
!open && openOnFocus && handleOpen(true);
|
|
75
78
|
let day = (0, utils_1.parseDate)(e.target.value, today, locale, "date", allowTwoDigitYear);
|
|
76
79
|
if ((0, utils_1.isValidDate)(day)) {
|
|
@@ -77,6 +77,9 @@ const useMonthpicker = (opt = {}) => {
|
|
|
77
77
|
};
|
|
78
78
|
const handleFocus = (e) => {
|
|
79
79
|
var _a;
|
|
80
|
+
if (e.target.readOnly) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
80
83
|
!open && openOnFocus && handleOpen(true);
|
|
81
84
|
let day = (0, utils_1.parseDate)(e.target.value, today, locale, "month", allowTwoDigitYear);
|
|
82
85
|
const isBefore = getIsBefore({ fromDate, date: day });
|
|
@@ -151,6 +151,9 @@ const useRangeDatepicker = (opt = {}) => {
|
|
|
151
151
|
setValidation(initialValidation(range, opt));
|
|
152
152
|
};
|
|
153
153
|
const handleFocus = (e, src) => {
|
|
154
|
+
if (e.target.readOnly) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
154
157
|
!open && openOnFocus && setOpen(true);
|
|
155
158
|
let day = (0, utils_1.parseDate)(e.target.value, today, locale, "date", allowTwoDigitYear);
|
|
156
159
|
if ((0, utils_1.isValidDate)(day)) {
|
|
@@ -42,12 +42,13 @@ const clsx_1 = __importDefault(require("clsx"));
|
|
|
42
42
|
const react_1 = __importStar(require("react"));
|
|
43
43
|
const __1 = require("../..");
|
|
44
44
|
const useFieldset_1 = require("./useFieldset");
|
|
45
|
+
const ReadOnlyIcon_1 = require("../ReadOnlyIcon");
|
|
45
46
|
exports.FieldsetContext = react_1.default.createContext(null);
|
|
46
47
|
exports.Fieldset = (0, react_1.forwardRef)((props, ref) => {
|
|
47
48
|
var _a, _b, _c;
|
|
48
|
-
const { inputProps, errorId, showErrorMsg, hasError, size, inputDescriptionId, } = (0, useFieldset_1.useFieldset)(props);
|
|
49
|
+
const { inputProps, errorId, showErrorMsg, hasError, size, readOnly, inputDescriptionId, } = (0, useFieldset_1.useFieldset)(props);
|
|
49
50
|
const fieldset = (0, react_1.useContext)(exports.FieldsetContext);
|
|
50
|
-
const { children, className, errorPropagation = true, legend, description, hideLegend } = props, rest = __rest(props, ["children", "className", "errorPropagation", "legend", "description", "hideLegend"]);
|
|
51
|
+
const { children, className, errorPropagation = true, legend, description, hideLegend, nativeReadOnly = true } = props, rest = __rest(props, ["children", "className", "errorPropagation", "legend", "description", "hideLegend", "nativeReadOnly"]);
|
|
51
52
|
return (react_1.default.createElement(exports.FieldsetContext.Provider, { value: {
|
|
52
53
|
error: errorPropagation ? (_a = props.error) !== null && _a !== void 0 ? _a : fieldset === null || fieldset === void 0 ? void 0 : fieldset.error : undefined,
|
|
53
54
|
errorId: (0, clsx_1.default)({
|
|
@@ -56,11 +57,17 @@ exports.Fieldset = (0, react_1.forwardRef)((props, ref) => {
|
|
|
56
57
|
}),
|
|
57
58
|
size,
|
|
58
59
|
disabled: (_c = props.disabled) !== null && _c !== void 0 ? _c : false,
|
|
60
|
+
readOnly,
|
|
59
61
|
} },
|
|
60
|
-
react_1.default.createElement("fieldset", Object.assign({}, (0, __1.omit)(rest, ["errorId", "error", "size"]), inputProps, { ref: ref, className: (0, clsx_1.default)(className, "navds-fieldset", `navds-fieldset--${size}`, {
|
|
62
|
+
react_1.default.createElement("fieldset", Object.assign({}, (0, __1.omit)(rest, ["errorId", "error", "size", "readOnly"]), inputProps, { ref: ref, className: (0, clsx_1.default)(className, "navds-fieldset", `navds-fieldset--${size}`, {
|
|
63
|
+
"navds-fieldset--error": hasError,
|
|
64
|
+
"navds-fieldset--readonly": readOnly,
|
|
65
|
+
}) }),
|
|
61
66
|
react_1.default.createElement(__1.Label, { size: size, as: "legend", className: (0, clsx_1.default)("navds-fieldset__legend", {
|
|
62
67
|
"navds-sr-only": !!hideLegend,
|
|
63
|
-
}) },
|
|
68
|
+
}) },
|
|
69
|
+
react_1.default.createElement(ReadOnlyIcon_1.ReadOnlyIcon, { readOnly: readOnly, nativeReadOnly: nativeReadOnly }),
|
|
70
|
+
legend),
|
|
64
71
|
!!description && (react_1.default.createElement(__1.BodyShort, { className: (0, clsx_1.default)("navds-fieldset__description", {
|
|
65
72
|
"navds-sr-only": !!hideLegend,
|
|
66
73
|
}), id: inputDescriptionId, size: size !== null && size !== void 0 ? size : "medium", as: "div" }, props.description)),
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ReadOnlyIcon = void 0;
|
|
7
|
+
const aksel_icons_1 = require("@navikt/aksel-icons");
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const ReadOnlyIcon = ({ readOnly, nativeReadOnly = true, }) => {
|
|
10
|
+
if (readOnly) {
|
|
11
|
+
return (react_1.default.createElement(aksel_icons_1.PadlockLockedFillIcon, Object.assign({}, (nativeReadOnly ? { "aria-hidden": true } : { title: "readonly" }), { className: "navds-form-field__readonly-icon" })));
|
|
12
|
+
}
|
|
13
|
+
return null;
|
|
14
|
+
};
|
|
15
|
+
exports.ReadOnlyIcon = ReadOnlyIcon;
|
package/cjs/form/Select.js
CHANGED
|
@@ -43,6 +43,7 @@ const react_1 = __importStar(require("react"));
|
|
|
43
43
|
const aksel_icons_1 = require("@navikt/aksel-icons");
|
|
44
44
|
const __1 = require("..");
|
|
45
45
|
const useFormField_1 = require("./useFormField");
|
|
46
|
+
const ReadOnlyIcon_1 = require("./ReadOnlyIcon");
|
|
46
47
|
/**
|
|
47
48
|
* A component that displays a select input field.
|
|
48
49
|
*
|
|
@@ -60,20 +61,39 @@ const useFormField_1 = require("./useFormField");
|
|
|
60
61
|
* ```
|
|
61
62
|
*/
|
|
62
63
|
exports.Select = (0, react_1.forwardRef)((props, ref) => {
|
|
63
|
-
const { inputProps, errorId, showErrorMsg, hasError, size, inputDescriptionId, } = (0, useFormField_1.useFormField)(props, "
|
|
64
|
+
const { inputProps, errorId, showErrorMsg, hasError, size, inputDescriptionId, readOnly, } = (0, useFormField_1.useFormField)(props, "select");
|
|
64
65
|
const { children, label, className, description, htmlSize, hideLabel = false, style } = props, rest = __rest(props, ["children", "label", "className", "description", "htmlSize", "hideLabel", "style"]);
|
|
66
|
+
const readOnlyEventHandlers = {
|
|
67
|
+
onMouseDown: (evt) => {
|
|
68
|
+
// NOTE: does not prevent click
|
|
69
|
+
if (readOnly) {
|
|
70
|
+
evt.preventDefault();
|
|
71
|
+
// focus on the element as per readonly input behavior
|
|
72
|
+
evt.target.focus();
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
onKeyDown: (evt) => {
|
|
76
|
+
if (readOnly &&
|
|
77
|
+
["ArrowDown", "ArrowUp", "ArrowRight", "ArrowLeft", " "].includes(evt.key)) {
|
|
78
|
+
evt.preventDefault();
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
};
|
|
65
82
|
return (react_1.default.createElement("div", { className: (0, clsx_1.default)(className, "navds-form-field", `navds-form-field--${size}`, {
|
|
66
83
|
"navds-form-field--disabled": !!inputProps.disabled,
|
|
67
84
|
"navds-select--error": hasError,
|
|
85
|
+
"navds-select--readonly": readOnly,
|
|
68
86
|
}) },
|
|
69
87
|
react_1.default.createElement(__1.Label, { htmlFor: inputProps.id, size: size, className: (0, clsx_1.default)("navds-form-field__label", {
|
|
70
88
|
"navds-sr-only": hideLabel,
|
|
71
|
-
}) },
|
|
89
|
+
}) },
|
|
90
|
+
react_1.default.createElement(ReadOnlyIcon_1.ReadOnlyIcon, { readOnly: readOnly, nativeReadOnly: false }),
|
|
91
|
+
label),
|
|
72
92
|
!!description && (react_1.default.createElement(__1.BodyShort, { className: (0, clsx_1.default)("navds-form-field__description", {
|
|
73
93
|
"navds-sr-only": hideLabel,
|
|
74
94
|
}), id: inputDescriptionId, size: size, as: "div" }, description)),
|
|
75
95
|
react_1.default.createElement("div", { className: "navds-select__container", style: style },
|
|
76
|
-
react_1.default.createElement("select", Object.assign({}, (0, __1.omit)(rest, ["error", "errorId", "size"]), inputProps, { ref: ref, className: (0, clsx_1.default)("navds-select__input", "navds-body-short", `navds-body--${size !== null && size !== void 0 ? size : "medium"}`), size: props.htmlSize }), children),
|
|
96
|
+
react_1.default.createElement("select", Object.assign({}, (0, __1.omit)(rest, ["error", "errorId", "size", "readOnly"]), inputProps, readOnlyEventHandlers, { ref: ref, className: (0, clsx_1.default)("navds-select__input", "navds-body-short", `navds-body--${size !== null && size !== void 0 ? size : "medium"}`), size: props.htmlSize }), children),
|
|
77
97
|
react_1.default.createElement(aksel_icons_1.ChevronDownIcon, { className: "navds-select__chevron", "aria-hidden": true })),
|
|
78
98
|
react_1.default.createElement("div", { className: "navds-form-field__error", id: errorId, "aria-relevant": "additions removals", "aria-live": "polite" }, showErrorMsg && (react_1.default.createElement(__1.ErrorMessage, { size: size }, props.error)))));
|
|
79
99
|
});
|