carbon-components-angular 5.14.7 → 5.14.9
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/datepicker/datepicker.component.d.ts +2 -3
- package/docs/documentation/components/DatePicker.html +116 -153
- package/docs/documentation/components/FileComponent.html +3 -3
- package/docs/documentation/components/FileUploader.html +3 -3
- package/docs/documentation/coverage.html +1 -1
- package/docs/documentation/js/search/search_index.js +2 -2
- package/docs/documentation/modules/ThemeModule/dependencies.svg +13 -13
- package/docs/documentation/modules/ThemeModule.html +13 -13
- package/docs/documentation/modules/TimePickerModule/dependencies.svg +4 -4
- package/docs/documentation/modules/TimePickerModule.html +4 -4
- package/docs/documentation/modules/TimePickerSelectModule/dependencies.svg +50 -46
- package/docs/documentation/modules/TimePickerSelectModule.html +50 -46
- package/docs/documentation/modules/ToggleModule/dependencies.svg +4 -4
- package/docs/documentation/modules/ToggleModule.html +4 -4
- package/docs/documentation/modules/TooltipModule/dependencies.svg +4 -4
- package/docs/documentation/modules/TooltipModule.html +4 -4
- package/docs/documentation/modules/UIShellModule/dependencies.svg +4 -4
- package/docs/documentation/modules/UIShellModule.html +4 -4
- package/docs/documentation.json +73 -74
- package/docs/storybook/datepicker-datepicker-stories.6255884c.iframe.bundle.js +1 -0
- package/docs/storybook/file-uploader-file-uploader-stories.47d6a66e.iframe.bundle.js +1 -0
- package/docs/storybook/iframe.html +2 -2
- package/docs/storybook/main.a9743d36.iframe.bundle.js +1 -0
- package/docs/storybook/project.json +1 -1
- package/docs/storybook/{runtime~main.86d3bd20.iframe.bundle.js → runtime~main.b0ccd54d.iframe.bundle.js} +1 -1
- package/esm2020/datepicker/datepicker.component.mjs +18 -11
- package/esm2020/file-uploader/file-uploader.component.mjs +3 -3
- package/esm2020/file-uploader/file.component.mjs +3 -3
- package/fesm2015/carbon-components-angular-datepicker.mjs +19 -10
- package/fesm2015/carbon-components-angular-datepicker.mjs.map +1 -1
- package/fesm2015/carbon-components-angular-file-uploader.mjs +4 -4
- package/fesm2015/carbon-components-angular-file-uploader.mjs.map +1 -1
- package/fesm2020/carbon-components-angular-datepicker.mjs +17 -10
- package/fesm2020/carbon-components-angular-datepicker.mjs.map +1 -1
- package/fesm2020/carbon-components-angular-file-uploader.mjs +4 -4
- package/fesm2020/carbon-components-angular-file-uploader.mjs.map +1 -1
- package/package.json +1 -1
- package/docs/storybook/datepicker-datepicker-stories.178ad9bd.iframe.bundle.js +0 -1
- package/docs/storybook/file-uploader-file-uploader-stories.ac7b5f6b.iframe.bundle.js +0 -1
- package/docs/storybook/main.1a927f43.iframe.bundle.js +0 -1
package/docs/documentation.json
CHANGED
|
@@ -24652,7 +24652,7 @@
|
|
|
24652
24652
|
},
|
|
24653
24653
|
{
|
|
24654
24654
|
"name": "DatePicker",
|
|
24655
|
-
"id": "component-DatePicker-
|
|
24655
|
+
"id": "component-DatePicker-af094372b29a0decf44cbd4db243a0226be86025c7a2899740b14aae1a4a85b7aafbbb8e3cddd8b3bd514820460a892bf64573455e13dada2d9f941f3ab4dd25",
|
|
24656
24656
|
"file": "src/datepicker/datepicker.component.ts",
|
|
24657
24657
|
"encapsulation": [
|
|
24658
24658
|
"ViewEncapsulation.None"
|
|
@@ -24680,7 +24680,7 @@
|
|
|
24680
24680
|
"deprecationMessage": "",
|
|
24681
24681
|
"rawdescription": "\n\nAria label added to datepicker's calendar container.\n",
|
|
24682
24682
|
"description": "<p>Aria label added to datepicker's calendar container.</p>\n",
|
|
24683
|
-
"line":
|
|
24683
|
+
"line": 152,
|
|
24684
24684
|
"type": "string",
|
|
24685
24685
|
"decorators": []
|
|
24686
24686
|
},
|
|
@@ -24691,7 +24691,7 @@
|
|
|
24691
24691
|
"deprecationMessage": "",
|
|
24692
24692
|
"rawdescription": "\n\nFormat of date\n\nFor reference: https://flatpickr.js.org/formatting/\n",
|
|
24693
24693
|
"description": "<p>Format of date</p>\n<p>For reference: <a href=\"https://flatpickr.js.org/formatting/\">https://flatpickr.js.org/formatting/</a></p>\n",
|
|
24694
|
-
"line":
|
|
24694
|
+
"line": 132,
|
|
24695
24695
|
"type": "string",
|
|
24696
24696
|
"decorators": []
|
|
24697
24697
|
},
|
|
@@ -24700,7 +24700,7 @@
|
|
|
24700
24700
|
"defaultValue": "false",
|
|
24701
24701
|
"deprecated": false,
|
|
24702
24702
|
"deprecationMessage": "",
|
|
24703
|
-
"line":
|
|
24703
|
+
"line": 178,
|
|
24704
24704
|
"type": "boolean",
|
|
24705
24705
|
"decorators": []
|
|
24706
24706
|
},
|
|
@@ -24708,7 +24708,7 @@
|
|
|
24708
24708
|
"name": "flatpickrOptions",
|
|
24709
24709
|
"deprecated": false,
|
|
24710
24710
|
"deprecationMessage": "",
|
|
24711
|
-
"line":
|
|
24711
|
+
"line": 219,
|
|
24712
24712
|
"type": "any",
|
|
24713
24713
|
"decorators": []
|
|
24714
24714
|
},
|
|
@@ -24716,7 +24716,7 @@
|
|
|
24716
24716
|
"name": "helperText",
|
|
24717
24717
|
"deprecated": false,
|
|
24718
24718
|
"deprecationMessage": "",
|
|
24719
|
-
"line":
|
|
24719
|
+
"line": 143,
|
|
24720
24720
|
"type": "string | TemplateRef<any>",
|
|
24721
24721
|
"decorators": []
|
|
24722
24722
|
},
|
|
@@ -24725,7 +24725,7 @@
|
|
|
24725
24725
|
"defaultValue": "`datepicker-${DatePicker.datePickerCount++}`",
|
|
24726
24726
|
"deprecated": false,
|
|
24727
24727
|
"deprecationMessage": "",
|
|
24728
|
-
"line":
|
|
24728
|
+
"line": 159,
|
|
24729
24729
|
"type": "string",
|
|
24730
24730
|
"decorators": []
|
|
24731
24731
|
},
|
|
@@ -24736,7 +24736,7 @@
|
|
|
24736
24736
|
"deprecationMessage": "",
|
|
24737
24737
|
"rawdescription": "\n\nThe pattern for the underlying input element\n",
|
|
24738
24738
|
"description": "<p>The pattern for the underlying input element</p>\n",
|
|
24739
|
-
"line":
|
|
24739
|
+
"line": 157,
|
|
24740
24740
|
"type": "string",
|
|
24741
24741
|
"decorators": []
|
|
24742
24742
|
},
|
|
@@ -24747,7 +24747,7 @@
|
|
|
24747
24747
|
"deprecationMessage": "",
|
|
24748
24748
|
"rawdescription": "\n\nSet to `true` to display the invalid state.\n",
|
|
24749
24749
|
"description": "<p>Set to <code>true</code> to display the invalid state.</p>\n",
|
|
24750
|
-
"line":
|
|
24750
|
+
"line": 182,
|
|
24751
24751
|
"type": "boolean",
|
|
24752
24752
|
"decorators": []
|
|
24753
24753
|
},
|
|
@@ -24757,7 +24757,7 @@
|
|
|
24757
24757
|
"deprecationMessage": "",
|
|
24758
24758
|
"rawdescription": "\n\nValue displayed if datepicker is in an invalid state.\n",
|
|
24759
24759
|
"description": "<p>Value displayed if datepicker is in an invalid state.</p>\n",
|
|
24760
|
-
"line":
|
|
24760
|
+
"line": 186,
|
|
24761
24761
|
"type": "string | TemplateRef<any>",
|
|
24762
24762
|
"decorators": []
|
|
24763
24763
|
},
|
|
@@ -24765,7 +24765,7 @@
|
|
|
24765
24765
|
"name": "label",
|
|
24766
24766
|
"deprecated": false,
|
|
24767
24767
|
"deprecationMessage": "",
|
|
24768
|
-
"line":
|
|
24768
|
+
"line": 142,
|
|
24769
24769
|
"type": "string | TemplateRef<any>",
|
|
24770
24770
|
"decorators": []
|
|
24771
24771
|
},
|
|
@@ -24776,7 +24776,7 @@
|
|
|
24776
24776
|
"deprecationMessage": "",
|
|
24777
24777
|
"rawdescription": "\n\nLanguage of the flatpickr calendar.\n\nFor reference of the possible locales:\nhttps://github.com/flatpickr/flatpickr/blob/master/src/l10n/index.ts\n",
|
|
24778
24778
|
"description": "<p>Language of the flatpickr calendar.</p>\n<p>For reference of the possible locales:\n<a href=\"https://github.com/flatpickr/flatpickr/blob/master/src/l10n/index.ts\">https://github.com/flatpickr/flatpickr/blob/master/src/l10n/index.ts</a></p>\n",
|
|
24779
|
-
"line":
|
|
24779
|
+
"line": 140,
|
|
24780
24780
|
"type": "string",
|
|
24781
24781
|
"decorators": []
|
|
24782
24782
|
},
|
|
@@ -24785,7 +24785,7 @@
|
|
|
24785
24785
|
"defaultValue": "\"mm/dd/yyyy\"",
|
|
24786
24786
|
"deprecated": false,
|
|
24787
24787
|
"deprecationMessage": "",
|
|
24788
|
-
"line":
|
|
24788
|
+
"line": 147,
|
|
24789
24789
|
"type": "string",
|
|
24790
24790
|
"decorators": []
|
|
24791
24791
|
},
|
|
@@ -24794,7 +24794,7 @@
|
|
|
24794
24794
|
"defaultValue": "[]",
|
|
24795
24795
|
"deprecated": false,
|
|
24796
24796
|
"deprecationMessage": "",
|
|
24797
|
-
"line":
|
|
24797
|
+
"line": 216,
|
|
24798
24798
|
"type": "{}",
|
|
24799
24799
|
"decorators": []
|
|
24800
24800
|
},
|
|
@@ -24805,7 +24805,7 @@
|
|
|
24805
24805
|
"deprecationMessage": "",
|
|
24806
24806
|
"rawdescription": "\n\nSelect calendar range mode\n",
|
|
24807
24807
|
"description": "<p>Select calendar range mode</p>\n",
|
|
24808
|
-
"line":
|
|
24808
|
+
"line": 125,
|
|
24809
24809
|
"type": "boolean",
|
|
24810
24810
|
"decorators": []
|
|
24811
24811
|
},
|
|
@@ -24813,7 +24813,7 @@
|
|
|
24813
24813
|
"name": "rangeHelperText",
|
|
24814
24814
|
"deprecated": false,
|
|
24815
24815
|
"deprecationMessage": "",
|
|
24816
|
-
"line":
|
|
24816
|
+
"line": 144,
|
|
24817
24817
|
"type": "string | TemplateRef<any>",
|
|
24818
24818
|
"decorators": []
|
|
24819
24819
|
},
|
|
@@ -24824,7 +24824,7 @@
|
|
|
24824
24824
|
"deprecationMessage": "",
|
|
24825
24825
|
"rawdescription": "\n\nSet to `true` to display the invalid state for the second datepicker input.\n",
|
|
24826
24826
|
"description": "<p>Set to <code>true</code> to display the invalid state for the second datepicker input.</p>\n",
|
|
24827
|
-
"line":
|
|
24827
|
+
"line": 200,
|
|
24828
24828
|
"type": "boolean",
|
|
24829
24829
|
"decorators": []
|
|
24830
24830
|
},
|
|
@@ -24834,7 +24834,7 @@
|
|
|
24834
24834
|
"deprecationMessage": "",
|
|
24835
24835
|
"rawdescription": "\n\nValue displayed if the second datepicker input is in an invalid state.\n",
|
|
24836
24836
|
"description": "<p>Value displayed if the second datepicker input is in an invalid state.</p>\n",
|
|
24837
|
-
"line":
|
|
24837
|
+
"line": 204,
|
|
24838
24838
|
"type": "string | TemplateRef<any>",
|
|
24839
24839
|
"decorators": []
|
|
24840
24840
|
},
|
|
@@ -24842,7 +24842,7 @@
|
|
|
24842
24842
|
"name": "rangeLabel",
|
|
24843
24843
|
"deprecated": false,
|
|
24844
24844
|
"deprecationMessage": "",
|
|
24845
|
-
"line":
|
|
24845
|
+
"line": 145,
|
|
24846
24846
|
"type": "string",
|
|
24847
24847
|
"decorators": []
|
|
24848
24848
|
},
|
|
@@ -24853,7 +24853,7 @@
|
|
|
24853
24853
|
"deprecationMessage": "",
|
|
24854
24854
|
"rawdescription": "\n\nSet to `true` to show a warning in the second datepicker input (contents set by rangeWarningText)\n",
|
|
24855
24855
|
"description": "<p>Set to <code>true</code> to show a warning in the second datepicker input (contents set by rangeWarningText)</p>\n",
|
|
24856
|
-
"line":
|
|
24856
|
+
"line": 208,
|
|
24857
24857
|
"type": "boolean",
|
|
24858
24858
|
"decorators": []
|
|
24859
24859
|
},
|
|
@@ -24863,7 +24863,7 @@
|
|
|
24863
24863
|
"deprecationMessage": "",
|
|
24864
24864
|
"rawdescription": "\n\nSets the warning text for the second datepicker input\n",
|
|
24865
24865
|
"description": "<p>Sets the warning text for the second datepicker input</p>\n",
|
|
24866
|
-
"line":
|
|
24866
|
+
"line": 212,
|
|
24867
24867
|
"type": "string | TemplateRef<any>",
|
|
24868
24868
|
"decorators": []
|
|
24869
24869
|
},
|
|
@@ -24872,7 +24872,7 @@
|
|
|
24872
24872
|
"defaultValue": "\"md\"",
|
|
24873
24873
|
"deprecated": false,
|
|
24874
24874
|
"deprecationMessage": "",
|
|
24875
|
-
"line":
|
|
24875
|
+
"line": 196,
|
|
24876
24876
|
"type": "\"sm\" | \"md\" | \"lg\"",
|
|
24877
24877
|
"decorators": []
|
|
24878
24878
|
},
|
|
@@ -24881,7 +24881,7 @@
|
|
|
24881
24881
|
"defaultValue": "false",
|
|
24882
24882
|
"deprecated": false,
|
|
24883
24883
|
"deprecationMessage": "",
|
|
24884
|
-
"line":
|
|
24884
|
+
"line": 214,
|
|
24885
24885
|
"type": "boolean",
|
|
24886
24886
|
"decorators": []
|
|
24887
24887
|
},
|
|
@@ -24892,15 +24892,15 @@
|
|
|
24892
24892
|
"deprecationMessage": "since v5 - Use `cdsLayer` directive instead\nSet to `\"light\"` to apply the light style",
|
|
24893
24893
|
"jsdoctags": [
|
|
24894
24894
|
{
|
|
24895
|
-
"pos":
|
|
24896
|
-
"end":
|
|
24895
|
+
"pos": 4390,
|
|
24896
|
+
"end": 4494,
|
|
24897
24897
|
"flags": 8421376,
|
|
24898
24898
|
"modifierFlagsCache": 0,
|
|
24899
24899
|
"transformFlags": 0,
|
|
24900
24900
|
"kind": 334,
|
|
24901
24901
|
"tagName": {
|
|
24902
|
-
"pos":
|
|
24903
|
-
"end":
|
|
24902
|
+
"pos": 4391,
|
|
24903
|
+
"end": 4401,
|
|
24904
24904
|
"flags": 8421376,
|
|
24905
24905
|
"modifierFlagsCache": 0,
|
|
24906
24906
|
"transformFlags": 0,
|
|
@@ -24910,7 +24910,7 @@
|
|
|
24910
24910
|
"comment": "<p>since v5 - Use <code>cdsLayer</code> directive instead\nSet to <code>"light"</code> to apply the light style</p>\n"
|
|
24911
24911
|
}
|
|
24912
24912
|
],
|
|
24913
|
-
"line":
|
|
24913
|
+
"line": 176,
|
|
24914
24914
|
"type": "\"light\" | \"dark\"",
|
|
24915
24915
|
"decorators": []
|
|
24916
24916
|
},
|
|
@@ -24918,7 +24918,7 @@
|
|
|
24918
24918
|
"name": "value",
|
|
24919
24919
|
"deprecated": false,
|
|
24920
24920
|
"deprecationMessage": "",
|
|
24921
|
-
"line":
|
|
24921
|
+
"line": 161,
|
|
24922
24922
|
"type": "[]",
|
|
24923
24923
|
"decorators": []
|
|
24924
24924
|
},
|
|
@@ -24929,7 +24929,7 @@
|
|
|
24929
24929
|
"deprecationMessage": "",
|
|
24930
24930
|
"rawdescription": "\n\nSet to `true` to show a warning (contents set by warningText)\n",
|
|
24931
24931
|
"description": "<p>Set to <code>true</code> to show a warning (contents set by warningText)</p>\n",
|
|
24932
|
-
"line":
|
|
24932
|
+
"line": 190,
|
|
24933
24933
|
"type": "boolean",
|
|
24934
24934
|
"decorators": []
|
|
24935
24935
|
},
|
|
@@ -24939,7 +24939,7 @@
|
|
|
24939
24939
|
"deprecationMessage": "",
|
|
24940
24940
|
"rawdescription": "\n\nSets the warning text\n",
|
|
24941
24941
|
"description": "<p>Sets the warning text</p>\n",
|
|
24942
|
-
"line":
|
|
24942
|
+
"line": 194,
|
|
24943
24943
|
"type": "string | TemplateRef<any>",
|
|
24944
24944
|
"decorators": []
|
|
24945
24945
|
}
|
|
@@ -24952,7 +24952,7 @@
|
|
|
24952
24952
|
"deprecationMessage": "",
|
|
24953
24953
|
"rawdescription": "\n\nWe are overriding onClose event even if users pass it via flatpickr options\nEmits an event when date picker closes\n",
|
|
24954
24954
|
"description": "<p>We are overriding onClose event even if users pass it via flatpickr options\nEmits an event when date picker closes</p>\n",
|
|
24955
|
-
"line":
|
|
24955
|
+
"line": 244,
|
|
24956
24956
|
"type": "EventEmitter<any>"
|
|
24957
24957
|
},
|
|
24958
24958
|
{
|
|
@@ -24960,7 +24960,7 @@
|
|
|
24960
24960
|
"defaultValue": "new EventEmitter()",
|
|
24961
24961
|
"deprecated": false,
|
|
24962
24962
|
"deprecationMessage": "",
|
|
24963
|
-
"line":
|
|
24963
|
+
"line": 238,
|
|
24964
24964
|
"type": "EventEmitter<any>"
|
|
24965
24965
|
}
|
|
24966
24966
|
],
|
|
@@ -24972,7 +24972,7 @@
|
|
|
24972
24972
|
"type": "DatePickerInput",
|
|
24973
24973
|
"optional": false,
|
|
24974
24974
|
"description": "",
|
|
24975
|
-
"line":
|
|
24975
|
+
"line": 235,
|
|
24976
24976
|
"decorators": [
|
|
24977
24977
|
{
|
|
24978
24978
|
"name": "ViewChild",
|
|
@@ -24991,7 +24991,7 @@
|
|
|
24991
24991
|
"type": "function",
|
|
24992
24992
|
"optional": false,
|
|
24993
24993
|
"description": "",
|
|
24994
|
-
"line":
|
|
24994
|
+
"line": 399
|
|
24995
24995
|
},
|
|
24996
24996
|
{
|
|
24997
24997
|
"name": "propagateChange",
|
|
@@ -25001,7 +25001,7 @@
|
|
|
25001
25001
|
"type": "",
|
|
25002
25002
|
"optional": false,
|
|
25003
25003
|
"description": "",
|
|
25004
|
-
"line":
|
|
25004
|
+
"line": 401
|
|
25005
25005
|
},
|
|
25006
25006
|
{
|
|
25007
25007
|
"name": "rangeInput",
|
|
@@ -25010,7 +25010,7 @@
|
|
|
25010
25010
|
"type": "DatePickerInput",
|
|
25011
25011
|
"optional": false,
|
|
25012
25012
|
"description": "",
|
|
25013
|
-
"line":
|
|
25013
|
+
"line": 236,
|
|
25014
25014
|
"decorators": [
|
|
25015
25015
|
{
|
|
25016
25016
|
"name": "ViewChild",
|
|
@@ -25029,7 +25029,7 @@
|
|
|
25029
25029
|
"optional": false,
|
|
25030
25030
|
"returnType": "void",
|
|
25031
25031
|
"typeParameters": [],
|
|
25032
|
-
"line":
|
|
25032
|
+
"line": 348,
|
|
25033
25033
|
"deprecated": false,
|
|
25034
25034
|
"deprecationMessage": "",
|
|
25035
25035
|
"decorators": [
|
|
@@ -25048,7 +25048,7 @@
|
|
|
25048
25048
|
"optional": false,
|
|
25049
25049
|
"returnType": "void",
|
|
25050
25050
|
"typeParameters": [],
|
|
25051
|
-
"line":
|
|
25051
|
+
"line": 363,
|
|
25052
25052
|
"deprecated": false,
|
|
25053
25053
|
"deprecationMessage": "",
|
|
25054
25054
|
"decorators": [
|
|
@@ -25074,7 +25074,7 @@
|
|
|
25074
25074
|
"optional": false,
|
|
25075
25075
|
"returnType": "void",
|
|
25076
25076
|
"typeParameters": [],
|
|
25077
|
-
"line":
|
|
25077
|
+
"line": 429,
|
|
25078
25078
|
"deprecated": false,
|
|
25079
25079
|
"deprecationMessage": "",
|
|
25080
25080
|
"rawdescription": "\n\nHandles the `valueChange` event from the range input\n",
|
|
@@ -25104,7 +25104,7 @@
|
|
|
25104
25104
|
"optional": false,
|
|
25105
25105
|
"returnType": "void",
|
|
25106
25106
|
"typeParameters": [],
|
|
25107
|
-
"line":
|
|
25107
|
+
"line": 414,
|
|
25108
25108
|
"deprecated": false,
|
|
25109
25109
|
"deprecationMessage": "",
|
|
25110
25110
|
"rawdescription": "\n\nHandles the `valueChange` event from the primary/single input\n",
|
|
@@ -25134,7 +25134,7 @@
|
|
|
25134
25134
|
"optional": false,
|
|
25135
25135
|
"returnType": "void",
|
|
25136
25136
|
"typeParameters": [],
|
|
25137
|
-
"line":
|
|
25137
|
+
"line": 440,
|
|
25138
25138
|
"deprecated": false,
|
|
25139
25139
|
"deprecationMessage": "",
|
|
25140
25140
|
"rawdescription": "\n\nHandles opening the calendar \"properly\" when the calendar icon is clicked.\n",
|
|
@@ -25164,7 +25164,7 @@
|
|
|
25164
25164
|
"optional": false,
|
|
25165
25165
|
"returnType": "void",
|
|
25166
25166
|
"typeParameters": [],
|
|
25167
|
-
"line":
|
|
25167
|
+
"line": 391,
|
|
25168
25168
|
"deprecated": false,
|
|
25169
25169
|
"deprecationMessage": "",
|
|
25170
25170
|
"jsdoctags": [
|
|
@@ -25192,7 +25192,7 @@
|
|
|
25192
25192
|
"optional": false,
|
|
25193
25193
|
"returnType": "void",
|
|
25194
25194
|
"typeParameters": [],
|
|
25195
|
-
"line":
|
|
25195
|
+
"line": 395,
|
|
25196
25196
|
"deprecated": false,
|
|
25197
25197
|
"deprecationMessage": "",
|
|
25198
25198
|
"jsdoctags": [
|
|
@@ -25220,7 +25220,7 @@
|
|
|
25220
25220
|
"optional": false,
|
|
25221
25221
|
"returnType": "void",
|
|
25222
25222
|
"typeParameters": [],
|
|
25223
|
-
"line":
|
|
25223
|
+
"line": 387,
|
|
25224
25224
|
"deprecated": false,
|
|
25225
25225
|
"deprecationMessage": "",
|
|
25226
25226
|
"rawdescription": "\n\n`ControlValueAccessor` method to programmatically disable the DatePicker.\n\nex: `this.formGroup.get(\"myDatePicker\").disable();`\n\n",
|
|
@@ -25228,8 +25228,8 @@
|
|
|
25228
25228
|
"jsdoctags": [
|
|
25229
25229
|
{
|
|
25230
25230
|
"name": {
|
|
25231
|
-
"pos":
|
|
25232
|
-
"end":
|
|
25231
|
+
"pos": 10918,
|
|
25232
|
+
"end": 10928,
|
|
25233
25233
|
"flags": 8421376,
|
|
25234
25234
|
"modifierFlagsCache": 0,
|
|
25235
25235
|
"transformFlags": 0,
|
|
@@ -25240,8 +25240,8 @@
|
|
|
25240
25240
|
"deprecated": false,
|
|
25241
25241
|
"deprecationMessage": "",
|
|
25242
25242
|
"tagName": {
|
|
25243
|
-
"pos":
|
|
25244
|
-
"end":
|
|
25243
|
+
"pos": 10912,
|
|
25244
|
+
"end": 10917,
|
|
25245
25245
|
"flags": 8421376,
|
|
25246
25246
|
"modifierFlagsCache": 0,
|
|
25247
25247
|
"transformFlags": 0,
|
|
@@ -25265,7 +25265,7 @@
|
|
|
25265
25265
|
"optional": false,
|
|
25266
25266
|
"returnType": "void",
|
|
25267
25267
|
"typeParameters": [],
|
|
25268
|
-
"line":
|
|
25268
|
+
"line": 371,
|
|
25269
25269
|
"deprecated": false,
|
|
25270
25270
|
"deprecationMessage": "",
|
|
25271
25271
|
"rawdescription": "\n\nWrites a value from the model to the component. Expects the value to be `null` or `(Date | string)[]`\n",
|
|
@@ -25273,8 +25273,8 @@
|
|
|
25273
25273
|
"jsdoctags": [
|
|
25274
25274
|
{
|
|
25275
25275
|
"name": {
|
|
25276
|
-
"pos":
|
|
25277
|
-
"end":
|
|
25276
|
+
"pos": 10517,
|
|
25277
|
+
"end": 10522,
|
|
25278
25278
|
"flags": 8421376,
|
|
25279
25279
|
"modifierFlagsCache": 0,
|
|
25280
25280
|
"transformFlags": 0,
|
|
@@ -25285,8 +25285,8 @@
|
|
|
25285
25285
|
"deprecated": false,
|
|
25286
25286
|
"deprecationMessage": "",
|
|
25287
25287
|
"tagName": {
|
|
25288
|
-
"pos":
|
|
25289
|
-
"end":
|
|
25288
|
+
"pos": 10511,
|
|
25289
|
+
"end": 10516,
|
|
25290
25290
|
"flags": 8421376,
|
|
25291
25291
|
"modifierFlagsCache": 0,
|
|
25292
25292
|
"transformFlags": 0,
|
|
@@ -25308,7 +25308,7 @@
|
|
|
25308
25308
|
"argsDecorator": [],
|
|
25309
25309
|
"deprecated": false,
|
|
25310
25310
|
"deprecationMessage": "",
|
|
25311
|
-
"line":
|
|
25311
|
+
"line": 348
|
|
25312
25312
|
},
|
|
25313
25313
|
{
|
|
25314
25314
|
"name": "focusout",
|
|
@@ -25316,7 +25316,7 @@
|
|
|
25316
25316
|
"argsDecorator": [],
|
|
25317
25317
|
"deprecated": false,
|
|
25318
25318
|
"deprecationMessage": "",
|
|
25319
|
-
"line":
|
|
25319
|
+
"line": 363
|
|
25320
25320
|
}
|
|
25321
25321
|
],
|
|
25322
25322
|
"standalone": false,
|
|
@@ -25324,7 +25324,7 @@
|
|
|
25324
25324
|
"description": "<p><a href=\"../../?path=/story/components-date-picker--single\">See demo</a></p>\n",
|
|
25325
25325
|
"rawdescription": "\n\n[See demo](../../?path=/story/components-date-picker--single)\n",
|
|
25326
25326
|
"type": "component",
|
|
25327
|
-
"sourceCode": "import {\n\tComponent,\n\tInput,\n\tOutput,\n\tEventEmitter,\n\tViewEncapsulation,\n\tElementRef,\n\tOnDestroy,\n\tHostListener,\n\tTemplateRef,\n\tOnChanges,\n\tSimpleChanges,\n\tAfterViewChecked,\n\tAfterViewInit,\n\tViewChild,\n\tAfterContentInit,\n\tOnInit,\n\tSimpleChange\n} from \"@angular/core\";\nimport rangePlugin from \"flatpickr/dist/plugins/rangePlugin\";\nimport flatpickr from \"flatpickr\";\nimport { NG_VALUE_ACCESSOR } from \"@angular/forms\";\nimport { carbonFlatpickrMonthSelectPlugin } from \"./carbon-flatpickr-month-select\";\nimport * as languages from \"flatpickr/dist/l10n/index\";\nimport { DatePickerInput } from \"carbon-components-angular/datepicker-input\";\nimport { ElementService } from \"carbon-components-angular/utils\";\nimport { I18n } from \"carbon-components-angular/i18n\";\n\n/**\n * [See demo](../../?path=/story/components-date-picker--single)\n */\n@Component({\n\tselector: \"cds-date-picker, ibm-date-picker\",\n\ttemplate: `\n\t<div class=\"cds--form-item\">\n\t\t<div\n\t\t\tclass=\"cds--date-picker\"\n\t\t\t[ngClass]=\"{\n\t\t\t\t'cds--date-picker--range' : range,\n\t\t\t\t'cds--date-picker--single' : !range,\n\t\t\t\t'cds--date-picker--light' : theme === 'light',\n\t\t\t\t'cds--skeleton' : skeleton\n\t\t\t}\">\n\t\t\t<div class=\"cds--date-picker-container\">\n\t\t\t\t<cds-date-picker-input\n\t\t\t\t\t#input\n\t\t\t\t\t[label]=\"label\"\n\t\t\t\t\t[placeholder]=\"placeholder\"\n\t\t\t\t\t[pattern]=\"inputPattern\"\n\t\t\t\t\t[id]=\"id + '-input'\"\n\t\t\t\t\t[size]=\"size\"\n\t\t\t\t\t[type]=\"(range ? 'range' : 'single')\"\n\t\t\t\t\t[hasIcon]=\"(range ? false : true)\"\n\t\t\t\t\t[disabled]=\"disabled\"\n\t\t\t\t\t[invalid]=\"invalid\"\n\t\t\t\t\t[invalidText]=\"invalidText\"\n\t\t\t\t\t[warn]=\"warn\"\n\t\t\t\t\t[warnText]=\"warnText\"\n\t\t\t\t\t[skeleton]=\"skeleton\"\n\t\t\t\t\t[helperText]=\"helperText\"\n\t\t\t\t\t(valueChange)=\"onValueChange($event)\"\n\t\t\t\t\t(click)=\"openCalendar(input)\">\n\t\t\t\t</cds-date-picker-input>\n\t\t\t</div>\n\n\t\t\t<div *ngIf=\"range\" class=\"cds--date-picker-container\">\n\t\t\t\t<cds-date-picker-input\n\t\t\t\t\t#rangeInput\n\t\t\t\t\t[label]=\"rangeLabel\"\n\t\t\t\t\t[placeholder]=\"placeholder\"\n\t\t\t\t\t[pattern]=\"inputPattern\"\n\t\t\t\t\t[id]=\"id + '-rangeInput'\"\n\t\t\t\t\t[size]=\"size\"\n\t\t\t\t\t[type]=\"(range ? 'range' : 'single')\"\n\t\t\t\t\t[hasIcon]=\"(range ? true : null)\"\n\t\t\t\t\t[disabled]=\"disabled\"\n\t\t\t\t\t[invalid]=\"rangeInvalid\"\n\t\t\t\t\t[invalidText]=\"rangeInvalidText\"\n\t\t\t\t\t[warn]=\"rangeWarn\"\n\t\t\t\t\t[warnText]=\"rangeWarnText\"\n\t\t\t\t\t[skeleton]=\"skeleton\"\n\t\t\t\t\t[helperText]=\"rangeHelperText\"\n\t\t\t\t\t(valueChange)=\"onRangeValueChange($event)\"\n\t\t\t\t\t(click)=\"openCalendar(rangeInput)\">\n\t\t\t\t</cds-date-picker-input>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n\t`,\n\tproviders: [\n\t\t{\n\t\t\tprovide: NG_VALUE_ACCESSOR,\n\t\t\tuseExisting: DatePicker,\n\t\t\tmulti: true\n\t\t}\n\t],\n\tencapsulation: ViewEncapsulation.None\n})\nexport class DatePicker implements\n\tOnInit,\n\tOnDestroy,\n\tOnChanges,\n\tAfterViewChecked,\n\tAfterViewInit,\n\tAfterContentInit {\n\tprivate static datePickerCount = 0;\n\n\t/**\n\t * Select calendar range mode\n\t */\n\t@Input() range = false;\n\n\t/**\n\t * Format of date\n\t *\n\t * For reference: https://flatpickr.js.org/formatting/\n\t */\n\t@Input() dateFormat = \"m/d/Y\";\n\n\t/**\n\t * Language of the flatpickr calendar.\n\t *\n\t * For reference of the possible locales:\n\t * https://github.com/flatpickr/flatpickr/blob/master/src/l10n/index.ts\n\t */\n\t@Input() language = \"en\";\n\n\t@Input() label: string | TemplateRef<any>;\n\t@Input() helperText: string | TemplateRef<any>;\n\t@Input() rangeHelperText: string | TemplateRef<any>;\n\t@Input() rangeLabel: string;\n\n\t@Input() placeholder = \"mm/dd/yyyy\";\n\n\t/**\n\t * Aria label added to datepicker's calendar container.\n\t */\n\t@Input() ariaLabel = \"calendar container\";\n\n\t/**\n\t * The pattern for the underlying input element\n\t */\n\t@Input() inputPattern = \"^\\\\d{1,2}/\\\\d{1,2}/\\\\d{4}$\";\n\n\t@Input() id = `datepicker-${DatePicker.datePickerCount++}`;\n\n\t@Input() set value(v: (Date | string)[]) {\n\t\tif (!v) {\n\t\t\tv = [];\n\t\t}\n\t\tthis._value = v;\n\t}\n\n\tget value() {\n\t\treturn this._value;\n\t}\n\n\t/**\n\t * @deprecated since v5 - Use `cdsLayer` directive instead\n\t * Set to `\"light\"` to apply the light style\n\t */\n\t@Input() theme: \"light\" | \"dark\" = \"dark\";\n\n\t@Input() disabled = false;\n\t/**\n\t * Set to `true` to display the invalid state.\n\t */\n\t@Input() invalid = false;\n\t/**\n\t * Value displayed if datepicker is in an invalid state.\n\t */\n\t@Input() invalidText: string | TemplateRef<any>;\n\t/**\n\t * Set to `true` to show a warning (contents set by warningText)\n\t */\n\t@Input() warn = false;\n\t/**\n\t * Sets the warning text\n\t */\n\t@Input() warnText: string | TemplateRef<any>;\n\n\t@Input() size: \"sm\" | \"md\" | \"lg\" = \"md\";\n\t/**\n\t * Set to `true` to display the invalid state for the second datepicker input.\n\t */\n\t@Input() rangeInvalid = false;\n\t/**\n\t * Value displayed if the second datepicker input is in an invalid state.\n\t */\n\t@Input() rangeInvalidText: string | TemplateRef<any>;\n\t/**\n\t * Set to `true` to show a warning in the second datepicker input (contents set by rangeWarningText)\n\t */\n\t@Input() rangeWarn = false;\n\t/**\n\t * Sets the warning text for the second datepicker input\n\t */\n\t@Input() rangeWarnText: string | TemplateRef<any>;\n\n\t@Input() skeleton = false;\n\n\t@Input() plugins = [];\n\n\t@Input()\n\tset flatpickrOptions(options) {\n\t\tthis._flatpickrOptions = Object.assign({}, this._flatpickrOptions, options);\n\t}\n\tget flatpickrOptions() {\n\t\tconst plugins = [...this.plugins, carbonFlatpickrMonthSelectPlugin];\n\t\tif (this.range) {\n\t\t\tplugins.push(rangePlugin({ input: `#${this.id}-rangeInput`, position: \"left\" }));\n\t\t}\n\t\treturn Object.assign({}, this._flatpickrOptions, this.flatpickrBaseOptions, {\n\t\t\tmode: this.range ? \"range\" : \"single\",\n\t\t\tplugins,\n\t\t\tdateFormat: this.dateFormat,\n\t\t\tlocale: languages.default[this.language]\n\t\t});\n\t}\n\n\t@ViewChild(\"input\", { static: true }) input: DatePickerInput;\n\t@ViewChild(\"rangeInput\") rangeInput: DatePickerInput;\n\n\t@Output() valueChange: EventEmitter<any> = new EventEmitter();\n\n\t/**\n\t * We are overriding onClose event even if users pass it via flatpickr options\n\t * Emits an event when date picker closes\n\t */\n\t@Output() onClose: EventEmitter<any> = new EventEmitter();\n\n\tprotected _value = [];\n\n\tprotected _flatpickrOptions = {\n\t\tallowInput: true\n\t};\n\n\tprotected flatpickrBaseOptions = {\n\t\tmode: \"single\",\n\t\tdateFormat: \"m/d/Y\",\n\t\tplugins: this.plugins,\n\t\tonOpen: () => {\n\t\t\tthis.updateClassNames();\n\t\t\tthis.updateAttributes();\n\t\t\tthis.updateCalendarListeners();\n\t\t},\n\t\tonClose: (date) => {\n\t\t\t// This makes sure that the `flatpickrInstance selectedDates` are in sync with the values of\n\t\t\t// the inputs when the calendar closes.\n\t\t\tif (this.range && this.flatpickrInstance) {\n\t\t\t\tif (this.flatpickrInstance.selectedDates.length !== 2) {\n\t\t\t\t\t// we could `this.flatpickrInstance.clear()` but it insists on opening the second picker\n\t\t\t\t\t// in some cases, so instead we do this\n\t\t\t\t\tthis.setDateValues([]);\n\t\t\t\t\tthis.doSelect([]);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst inputValue = this.input.input.nativeElement.value;\n\t\t\t\tconst rangeInputValue = this.rangeInput.input.nativeElement.value;\n\t\t\t\tif (inputValue || rangeInputValue) {\n\t\t\t\t\tconst parseDate = (date: string) => this.flatpickrInstance.parseDate(date, this.dateFormat);\n\t\t\t\t\tthis.setDateValues([parseDate(inputValue), parseDate(rangeInputValue)]);\n\t\t\t\t\tthis.doSelect(this.flatpickrInstance.selectedDates);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.onClose.emit(date);\n\t\t},\n\t\tonDayCreate: (_dObj, _dStr, _fp, dayElem) => {\n\t\t\tdayElem.classList.add(\"cds--date-picker__day\");\n\t\t},\n\t\tnextArrow: this.rightArrowHTML(),\n\t\tprevArrow: this.leftArrowHTML(),\n\t\tvalue: this.value\n\t};\n\n\tprotected flatpickrInstance = null;\n\n\tconstructor(\n\t\tprotected elementRef: ElementRef,\n\t\tprotected i18n: I18n\n\t) { }\n\n\tngOnInit() {\n\t\t// if i18n is set to anything other than en we'll want to change the language\n\t\t// otherwise we'll just use the local setting\n\t\tif (this.i18n.getLocale() !== \"en\") {\n\t\t\tthis.i18n.getLocaleObservable().subscribe(locale => {\n\t\t\t\tthis.language = locale;\n\t\t\t\tthis.resetFlatpickrInstance();\n\t\t\t});\n\t\t}\n\t}\n\n\tngOnChanges(changes: SimpleChanges) {\n\t\t// Reset the flatpickr instance on input changes that affect flatpickr.\n\t\tconst flatpickrChangeKeys = [\n\t\t\t\"range\",\n\t\t\t\"dateFormat\",\n\t\t\t\"language\",\n\t\t\t\"id\",\n\t\t\t\"value\",\n\t\t\t\"plugins\",\n\t\t\t\"flatpickrOptions\"\n\t\t];\n\t\tconst changeKeys = Object.keys(changes);\n\t\tif (changeKeys.some(key => flatpickrChangeKeys.includes(key))) {\n\t\t\tthis.resetFlatpickrInstance(changes.value);\n\t\t}\n\t}\n\n\tngAfterViewInit() {\n\t\tsetTimeout(() => {\n\t\t\tthis.addInputListeners();\n\t\t}, 0);\n\t}\n\n\t// because the actual view may be delayed in loading (think projection into a tab pane)\n\t// and because we rely on a library that operates outside the Angular view of the world\n\t// we need to keep trying to load the library, until the relevant DOM is actually live\n\tngAfterViewChecked() {\n\t\tif (!this.isFlatpickrLoaded()) {\n\t\t\t// @ts-ignore ts is unhappy with the below call to `flatpickr`\n\t\t\tthis.flatpickrInstance = flatpickr(`#${this.id}-input`, this.flatpickrOptions);\n\t\t\t// if (and only if) the initialization succeeded, we can set the date values\n\t\t\tif (this.isFlatpickrLoaded()) {\n\t\t\t\tif (this.value.length > 0) {\n\t\t\t\t\tthis.setDateValues(this.value);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tngAfterContentInit() {\n\t\t(languages.default.en.weekdays.shorthand as string[])\n\t\t\t= languages.default.en.weekdays.longhand.map(day => {\n\t\t\t\tif (day === \"Thursday\") {\n\t\t\t\t\treturn \"Th\";\n\t\t\t\t}\n\t\t\t\treturn day.charAt(0);\n\t\t\t});\n\t}\n\n\t@HostListener(\"focusin\")\n\tonFocus() {\n\t\t// Updates the month manually when calendar mode is range because month\n\t\t// will not update properly without manually updating them on focus.\n\t\tif (this.range) {\n\t\t\tif (this.rangeInput.input.nativeElement === document.activeElement && this.flatpickrInstance.selectedDates[1]) {\n\t\t\t\tconst currentMonth = this.flatpickrInstance.selectedDates[1].getMonth();\n\t\t\t\tthis.flatpickrInstance.changeMonth(currentMonth, false);\n\t\t\t} else if (this.input.input.nativeElement === document.activeElement && this.flatpickrInstance.selectedDates[0]) {\n\t\t\t\tconst currentMonth = this.flatpickrInstance.selectedDates[0].getMonth();\n\t\t\t\tthis.flatpickrInstance.changeMonth(currentMonth, false);\n\t\t\t}\n\t\t}\n\t}\n\n\t@HostListener(\"focusout\")\n\tonFocusOut() {\n\t\tthis.onTouched();\n\t}\n\n\t/**\n\t * Writes a value from the model to the component. Expects the value to be `null` or `(Date | string)[]`\n\t * @param value value received from the model\n\t */\n\twriteValue(value: (Date | string)[]) {\n\t\tthis.value = value;\n\t\tsetTimeout(() => {\n\t\t\tif (this.isFlatpickrLoaded() && this.flatpickrInstance.config) {\n\t\t\t\tthis.setDateValues(this.value);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * `ControlValueAccessor` method to programmatically disable the DatePicker.\n\t *\n\t * ex: `this.formGroup.get(\"myDatePicker\").disable();`\n\t *\n\t * @param isDisabled `true` to disable the DatePicker\n\t */\n\tsetDisabledState(isDisabled: boolean) {\n\t\tthis.disabled = isDisabled;\n\t}\n\n\tregisterOnChange(fn: any) {\n\t\tthis.propagateChange = fn;\n\t}\n\n\tregisterOnTouched(fn: any) {\n\t\tthis.onTouched = fn;\n\t}\n\n\tonTouched: () => any = () => { };\n\n\tpropagateChange = (_: any) => { };\n\n\t/**\n\t * Cleans up our flatpickr instance\n\t */\n\tngOnDestroy() {\n\t\tif (!this.isFlatpickrLoaded()) { return; }\n\t\tthis.flatpickrInstance.destroy();\n\t}\n\n\t/**\n\t * Handles the `valueChange` event from the primary/single input\n\t */\n\tonValueChange(event: string) {\n\t\tif (this.isFlatpickrLoaded()) {\n\t\t\tconst date = this.flatpickrInstance.parseDate(event, this.dateFormat);\n\t\t\tif (this.range) {\n\t\t\t\tthis.setDateValues([date, this.flatpickrInstance.selectedDates[1]]);\n\t\t\t} else {\n\t\t\t\tthis.setDateValues([date]);\n\t\t\t}\n\t\t\tthis.doSelect(this.flatpickrInstance.selectedDates);\n\t\t}\n\t}\n\n\t/**\n\t * Handles the `valueChange` event from the range input\n\t */\n\tonRangeValueChange(event: string) {\n\t\tif (this.isFlatpickrLoaded() && this.flatpickrInstance.isOpen) {\n\t\t\tconst date = this.flatpickrInstance.parseDate(event, this.dateFormat);\n\t\t\tthis.setDateValues([this.flatpickrInstance.selectedDates[0], date]);\n\t\t\tthis.doSelect(this.flatpickrInstance.selectedDates);\n\t\t}\n\t}\n\n\t/**\n\t * Handles opening the calendar \"properly\" when the calendar icon is clicked.\n\t */\n\topenCalendar(datepickerInput: DatePickerInput) {\n\t\tif (this.range) {\n\t\t\tdatepickerInput.input.nativeElement.click();\n\n\t\t\t// If the first input's calendar icon is clicked when calendar is in range mode, then\n\t\t\t// the month and year needs to be manually changed to the current selected month and\n\t\t\t// year otherwise the calendar view will not be updated upon opening.\n\t\t\tif (datepickerInput === this.input && this.flatpickrInstance.selectedDates[0]) {\n\t\t\t\tconst currentMonth = this.flatpickrInstance.selectedDates[0].getMonth();\n\n\t\t\t\tthis.flatpickrInstance.currentYear = this.flatpickrInstance.selectedDates[0].getFullYear();\n\t\t\t\tthis.flatpickrInstance.changeMonth(currentMonth, false);\n\t\t\t}\n\t\t} else {\n\t\t\t// Single-mode flatpickr handles mousedown but not click, so nativeElement.click() won't\n\t\t\t// work when the calendar icon is clicked. In this case we simply use flatpickr.open().\n\t\t\tthis.flatpickrInstance.open();\n\t\t}\n\t}\n\n\tprotected updateCalendarListeners() {\n\t\tconst calendarContainer = document.querySelectorAll(\".flatpickr-calendar\");\n\t\tArray.from(calendarContainer).forEach(calendar => {\n\t\t\tcalendar.removeEventListener(\"click\", this.preventCalendarClose);\n\t\t\tcalendar.addEventListener(\"click\", this.preventCalendarClose);\n\t\t});\n\t}\n\n\t/**\n\t * Handles the initialization of event listeners for the datepicker input and range input fields.\n\t */\n\tprotected addInputListeners() {\n\t\tif (!this.isFlatpickrLoaded()) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Allows focus transition from the datepicker input or range input field to\n\t\t// flatpickr calendar using a keyboard.\n\t\tconst addFocusCalendarListener = (element: HTMLInputElement) => {\n\t\t\telement.addEventListener(\"keydown\", (event: KeyboardEvent) => {\n\t\t\t\tif (event.key === \"ArrowDown\") {\n\t\t\t\t\tif (!this.flatpickrInstance.isOpen) {\n\t\t\t\t\t\tthis.flatpickrInstance.open();\n\t\t\t\t\t}\n\n\t\t\t\t\tconst calendarContainer = this.flatpickrInstance.calendarContainer;\n\t\t\t\t\tconst dayElement = calendarContainer && calendarContainer.querySelector(\".flatpickr-day[tabindex]\");\n\n\t\t\t\t\tif (dayElement) {\n\t\t\t\t\t\tdayElement.focus();\n\n\t\t\t\t\t\t// If the user manually inputs a value into the date field and presses arrow down,\n\t\t\t\t\t\t// datepicker input onchange will be triggered when focus is removed from it and\n\t\t\t\t\t\t// `flatpickrInstance.setDate` and `flatpickrInstance.changeMonth` will be invoked\n\t\t\t\t\t\t// which will automatically change focus to the beginning of the document.\n\t\t\t\t\t\tif (document.activeElement !== dayElement && this.flatpickrInstance.selectedDateElem) {\n\t\t\t\t\t\t\tthis.flatpickrInstance.selectedDateElem.focus();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t};\n\n\t\tif (this.input && this.input.input) {\n\t\t\taddFocusCalendarListener(this.input.input.nativeElement);\n\t\t}\n\n\t\tif (this.rangeInput && this.rangeInput.input) {\n\t\t\taddFocusCalendarListener(this.rangeInput.input.nativeElement);\n\t\t}\n\t}\n\n\t/**\n\t * Resets the flatpickr instance while keeping the date values (or updating them if newDates is provided)\n\t *\n\t * Used to pick up input changes or locale changes.\n\t *\n\t * @param newDates An optional SimpleChange of date values\n\t */\n\tprotected resetFlatpickrInstance(newDates?: SimpleChange) {\n\t\tif (this.isFlatpickrLoaded()) {\n\t\t\tlet dates = this.flatpickrInstance.selectedDates;\n\t\t\tif (newDates && this.didDateValueChange(newDates.currentValue, newDates.previousValue)) {\n\t\t\t\tdates = newDates.currentValue;\n\t\t\t}\n\t\t\t// only reset the flatpickr instance on Input changes\n\t\t\t// @ts-ignore ts is unhappy with the below call to `flatpickr`\n\t\t\tthis.flatpickrInstance = flatpickr(`#${this.id}-input`, this.flatpickrOptions);\n\t\t\tthis.setDateValues(dates);\n\t\t}\n\t}\n\n\t/**\n\t * Carbon uses a number of specific classnames for parts of the flatpickr - this idempotent method applies them if needed.\n\t */\n\tprotected updateClassNames() {\n\t\tif (!this.elementRef) { return; }\n\t\t// get all the possible flatpickrs in the document - we need to add classes to (potentially) all of them\n\t\tconst calendarContainer = document.querySelectorAll(\".flatpickr-calendar\");\n\t\tconst monthContainer = document.querySelectorAll(\".flatpickr-month\");\n\t\tconst weekdaysContainer = document.querySelectorAll(\".flatpickr-weekdays\");\n\t\tconst weekdayContainer = document.querySelectorAll(\".flatpickr-weekday\");\n\t\tconst daysContainer = document.querySelectorAll(\".flatpickr-days\");\n\t\tconst dayContainer = document.querySelectorAll(\".flatpickr-day\");\n\n\t\t// add classes to lists of elements\n\t\tconst addClassIfNotExists = (classname: string, elementList: NodeListOf<Element>) => {\n\t\t\tArray.from(elementList).forEach(element => {\n\t\t\t\tif (!element.classList.contains(classname)) {\n\t\t\t\t\telement.classList.add(classname);\n\t\t\t\t}\n\t\t\t});\n\t\t};\n\n\t\t// add classes (but only if they don't exist, small perf win)\n\t\taddClassIfNotExists(\"cds--date-picker__calendar\", calendarContainer);\n\t\taddClassIfNotExists(\"cds--date-picker__month\", monthContainer);\n\t\taddClassIfNotExists(\"cds--date-picker__weekdays\", weekdaysContainer);\n\t\taddClassIfNotExists(\"cds--date-picker__days\", daysContainer);\n\n\t\t// add weekday classes and format the text\n\t\tArray.from(weekdayContainer).forEach(element => {\n\t\t\telement.innerHTML = element.innerHTML.replace(/\\s+/g, \"\");\n\t\t\telement.classList.add(\"cds--date-picker__weekday\");\n\t\t});\n\n\t\t// add day classes and special case the \"today\" element based on `this.value`\n\t\tArray.from(dayContainer).forEach(element => {\n\t\t\telement.classList.add(\"cds--date-picker__day\");\n\t\t\tif (!this.value) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (element.classList.contains(\"today\") && this.value.length > 0) {\n\t\t\t\telement.classList.add(\"no-border\");\n\t\t\t} else if (element.classList.contains(\"today\") && this.value.length === 0) {\n\t\t\t\telement.classList.remove(\"no-border\");\n\t\t\t}\n\t\t});\n\t}\n\n\tprotected updateAttributes() {\n\t\tconst calendarContainer = document.querySelectorAll(\".flatpickr-calendar\");\n\t\tArray.from(calendarContainer).forEach(calendar => {\n\t\t\tcalendar.setAttribute(\"role\", \"region\");\n\t\t\tcalendar.setAttribute(\"aria-label\", this.ariaLabel);\n\t\t});\n\t}\n\n\t/**\n\t * Applies the given date value array to both the flatpickr instance and the `input`(s)\n\t * @param dates the date values to apply\n\t */\n\tprotected setDateValues(dates: (Date | string)[]) {\n\t\tif (this.isFlatpickrLoaded()) {\n\t\t\tconst singleInput = this.elementRef.nativeElement.querySelector(`#${this.id}-input`);\n\t\t\tconst rangeInput = this.elementRef.nativeElement.querySelector(`#${this.id}-rangeInput`);\n\n\t\t\t// `flatpickrInstance.setDate` removes the focus on the selected date element and will\n\t\t\t// automatically change focus to the beginning of the document. If a selected date is\n\t\t\t// focused before `flatpickrInstance.setDate` is invoked then it should remain focused.\n\t\t\tlet shouldRefocusDateElement = this.flatpickrInstance.selectedDateElem === document.activeElement;\n\n\t\t\t// set the date on the instance\n\t\t\tthis.flatpickrInstance.setDate(dates);\n\n\t\t\tif (shouldRefocusDateElement) {\n\t\t\t\tthis.flatpickrInstance.selectedDateElem.focus();\n\t\t\t}\n\n\t\t\t// we can either set a date value or an empty string, so we start with an empty string\n\t\t\tlet singleDate = \"\";\n\t\t\t// if date is a string, parse and format\n\t\t\tif (typeof this.flatpickrInstance.selectedDates[0] === \"string\") {\n\t\t\t\tsingleDate = this.flatpickrInstance.parseDate(this.flatpickrInstance.selectedDates[0], this.dateFormat);\n\t\t\t\tsingleDate = this.flatpickrInstance.formatDate(singleDate, this.dateFormat);\n\t\t\t// if date is not a string we can assume it's a Date and we should format\n\t\t\t} else if (!!this.flatpickrInstance.selectedDates[0]) {\n\t\t\t\tsingleDate = this.flatpickrInstance.formatDate(this.flatpickrInstance.selectedDates[0], this.dateFormat);\n\t\t\t}\n\n\t\t\tif (rangeInput) {\n\t\t\t\t// we can either set a date value or an empty string, so we start with an empty string\n\t\t\t\tlet rangeDate = \"\";\n\t\t\t\t// if date is a string, parse and format\n\t\t\t\tif (typeof this.flatpickrInstance.selectedDates[1] === \"string\") {\n\t\t\t\t\trangeDate = this.flatpickrInstance.parseDate(this.flatpickrInstance.selectedDates[1].toString(), this.dateFormat);\n\t\t\t\t\trangeDate = this.flatpickrInstance.formatDate(rangeDate, this.dateFormat);\n\t\t\t\t// if date is not a string we can assume it's a Date and we should format\n\t\t\t\t} else if (!!this.flatpickrInstance.selectedDates[1]) {\n\t\t\t\t\trangeDate = this.flatpickrInstance.formatDate(this.flatpickrInstance.selectedDates[1], this.dateFormat);\n\t\t\t\t}\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t// apply the values\n\t\t\t\t\trangeInput.value = rangeDate;\n\t\t\t\t\tsingleInput.value = singleDate;\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected preventCalendarClose = event => event.stopPropagation();\n\n\tprotected doSelect(selectedValue: (Date | string)[]) {\n\t\t// In range mode, if a date is selected from the first calendar that is from the previous month,\n\t\t// the month will not be updated on the calendar until the calendar is re-opened.\n\t\t// This will make sure the calendar is updated with the correct month.\n\t\tif (this.range && this.flatpickrInstance.selectedDates[0]) {\n\t\t\tconst currentMonth = this.flatpickrInstance.selectedDates[0].getMonth();\n\n\t\t\t// `flatpickrInstance.changeMonth` removes the focus on the selected date element and will\n\t\t\t// automatically change focus to the beginning of the document. If a selected date is\n\t\t\t// focused before `flatpickrInstance.changeMonth` is invoked then it should remain focused.\n\t\t\tlet shouldRefocusDateElement = this.flatpickrInstance.selectedDateElem === document.activeElement;\n\n\t\t\tthis.flatpickrInstance.changeMonth(currentMonth, false);\n\n\t\t\tif (shouldRefocusDateElement) {\n\t\t\t\tthis.flatpickrInstance.selectedDateElem.focus();\n\t\t\t}\n\n\t\t}\n\t\tthis.valueChange.emit(selectedValue);\n\t\tthis.propagateChange(selectedValue);\n\t}\n\n\tprotected didDateValueChange(currentValue, previousValue) {\n\t\treturn currentValue[0] !== previousValue[0] || currentValue[1] !== previousValue[1];\n\t}\n\n\t/**\n\t * More advanced checking of the loaded state of flatpickr\n\t */\n\tprotected isFlatpickrLoaded() {\n\t\t// cast the instance to a boolean, and some method that has to exist for the library to be loaded in this case `setDate`\n\t\treturn !!this.flatpickrInstance && !!this.flatpickrInstance.setDate;\n\t}\n\n\t/**\n\t * Right arrow HTML passed to flatpickr\n\t */\n\tprotected rightArrowHTML() {\n\t\treturn `\n\t\t\t<svg width=\"16px\" height=\"16px\" viewBox=\"0 0 16 16\">\n\t\t\t\t<polygon points=\"11,8 6,13 5.3,12.3 9.6,8 5.3,3.7 6,3 \"/>\n\t\t\t\t<rect width=\"16\" height=\"16\" style=\"fill:none\" />\n\t\t\t</svg>`;\n\t}\n\n\t/**\n\t * Left arrow HTML passed to flatpickr\n\t */\n\tprotected leftArrowHTML() {\n\t\treturn `\n\t\t\t<svg width=\"16px\" height=\"16px\" viewBox=\"0 0 16 16\">\n\t\t\t\t<polygon points=\"5,8 10,3 10.7,3.7 6.4,8 10.7,12.3 10,13 \"/>\n\t\t\t\t<rect width=\"16\" height=\"16\" style=\"fill:none\" />\n\t\t\t</svg>`;\n\t}\n}\n",
|
|
25327
|
+
"sourceCode": "import {\n\tComponent,\n\tInput,\n\tOutput,\n\tEventEmitter,\n\tViewEncapsulation,\n\tElementRef,\n\tOnDestroy,\n\tHostListener,\n\tTemplateRef,\n\tOnChanges,\n\tSimpleChanges,\n\tAfterViewChecked,\n\tAfterViewInit,\n\tViewChild,\n\tOnInit,\n\tSimpleChange\n} from \"@angular/core\";\nimport rangePlugin from \"flatpickr/dist/plugins/rangePlugin\";\nimport flatpickr from \"flatpickr\";\nimport { NG_VALUE_ACCESSOR } from \"@angular/forms\";\nimport { carbonFlatpickrMonthSelectPlugin } from \"./carbon-flatpickr-month-select\";\nimport * as languages from \"flatpickr/dist/l10n/index\";\nimport { DatePickerInput } from \"carbon-components-angular/datepicker-input\";\nimport { I18n } from \"carbon-components-angular/i18n\";\n\n/**\n * Due to type error, we have to use square brackets property accessor\n * There is a webpack issue when attempting to access exported languages from flatpickr l10n Angular 14+ apps\n * languages.default[locale] fails in app consuming CCA library but passes in test\n * languages.default.default[locale] fails in test but works in app consuming CCA library.\n *\n * To please both scenarios, we are adding a condition to prevent tests from failing\n */\nif (languages.default?.default[\"en\"]?.weekdays) {\n\t(languages.default.default[\"en\"].weekdays.shorthand as string[]) = languages.default.default[\"en\"].weekdays.longhand.map(day => {\n\t\tif (day === \"Thursday\") {\n\t\t\treturn \"Th\";\n\t\t}\n\t\treturn day.charAt(0);\n\t});\n}\n\n/**\n * [See demo](../../?path=/story/components-date-picker--single)\n */\n@Component({\n\tselector: \"cds-date-picker, ibm-date-picker\",\n\ttemplate: `\n\t<div class=\"cds--form-item\">\n\t\t<div\n\t\t\tclass=\"cds--date-picker\"\n\t\t\t[ngClass]=\"{\n\t\t\t\t'cds--date-picker--range' : range,\n\t\t\t\t'cds--date-picker--single' : !range,\n\t\t\t\t'cds--date-picker--light' : theme === 'light',\n\t\t\t\t'cds--skeleton' : skeleton\n\t\t\t}\">\n\t\t\t<div class=\"cds--date-picker-container\">\n\t\t\t\t<cds-date-picker-input\n\t\t\t\t\t#input\n\t\t\t\t\t[label]=\"label\"\n\t\t\t\t\t[placeholder]=\"placeholder\"\n\t\t\t\t\t[pattern]=\"inputPattern\"\n\t\t\t\t\t[id]=\"id + '-input'\"\n\t\t\t\t\t[size]=\"size\"\n\t\t\t\t\t[type]=\"(range ? 'range' : 'single')\"\n\t\t\t\t\t[hasIcon]=\"(range ? false : true)\"\n\t\t\t\t\t[disabled]=\"disabled\"\n\t\t\t\t\t[invalid]=\"invalid\"\n\t\t\t\t\t[invalidText]=\"invalidText\"\n\t\t\t\t\t[warn]=\"warn\"\n\t\t\t\t\t[warnText]=\"warnText\"\n\t\t\t\t\t[skeleton]=\"skeleton\"\n\t\t\t\t\t[helperText]=\"helperText\"\n\t\t\t\t\t(valueChange)=\"onValueChange($event)\"\n\t\t\t\t\t(click)=\"openCalendar(input)\">\n\t\t\t\t</cds-date-picker-input>\n\t\t\t</div>\n\n\t\t\t<div *ngIf=\"range\" class=\"cds--date-picker-container\">\n\t\t\t\t<cds-date-picker-input\n\t\t\t\t\t#rangeInput\n\t\t\t\t\t[label]=\"rangeLabel\"\n\t\t\t\t\t[placeholder]=\"placeholder\"\n\t\t\t\t\t[pattern]=\"inputPattern\"\n\t\t\t\t\t[id]=\"id + '-rangeInput'\"\n\t\t\t\t\t[size]=\"size\"\n\t\t\t\t\t[type]=\"(range ? 'range' : 'single')\"\n\t\t\t\t\t[hasIcon]=\"(range ? true : null)\"\n\t\t\t\t\t[disabled]=\"disabled\"\n\t\t\t\t\t[invalid]=\"rangeInvalid\"\n\t\t\t\t\t[invalidText]=\"rangeInvalidText\"\n\t\t\t\t\t[warn]=\"rangeWarn\"\n\t\t\t\t\t[warnText]=\"rangeWarnText\"\n\t\t\t\t\t[skeleton]=\"skeleton\"\n\t\t\t\t\t[helperText]=\"rangeHelperText\"\n\t\t\t\t\t(valueChange)=\"onRangeValueChange($event)\"\n\t\t\t\t\t(click)=\"openCalendar(rangeInput)\">\n\t\t\t\t</cds-date-picker-input>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n\t`,\n\tproviders: [\n\t\t{\n\t\t\tprovide: NG_VALUE_ACCESSOR,\n\t\t\tuseExisting: DatePicker,\n\t\t\tmulti: true\n\t\t}\n\t],\n\tencapsulation: ViewEncapsulation.None\n})\nexport class DatePicker implements\n\tOnInit,\n\tOnDestroy,\n\tOnChanges,\n\tAfterViewChecked,\n\tAfterViewInit {\n\tprivate static datePickerCount = 0;\n\n\t/**\n\t * Select calendar range mode\n\t */\n\t@Input() range = false;\n\n\t/**\n\t * Format of date\n\t *\n\t * For reference: https://flatpickr.js.org/formatting/\n\t */\n\t@Input() dateFormat = \"m/d/Y\";\n\n\t/**\n\t * Language of the flatpickr calendar.\n\t *\n\t * For reference of the possible locales:\n\t * https://github.com/flatpickr/flatpickr/blob/master/src/l10n/index.ts\n\t */\n\t@Input() language = \"en\";\n\n\t@Input() label: string | TemplateRef<any>;\n\t@Input() helperText: string | TemplateRef<any>;\n\t@Input() rangeHelperText: string | TemplateRef<any>;\n\t@Input() rangeLabel: string;\n\n\t@Input() placeholder = \"mm/dd/yyyy\";\n\n\t/**\n\t * Aria label added to datepicker's calendar container.\n\t */\n\t@Input() ariaLabel = \"calendar container\";\n\n\t/**\n\t * The pattern for the underlying input element\n\t */\n\t@Input() inputPattern = \"^\\\\d{1,2}/\\\\d{1,2}/\\\\d{4}$\";\n\n\t@Input() id = `datepicker-${DatePicker.datePickerCount++}`;\n\n\t@Input() set value(v: (Date | string)[]) {\n\t\tif (!v) {\n\t\t\tv = [];\n\t\t}\n\t\tthis._value = v;\n\t}\n\n\tget value() {\n\t\treturn this._value;\n\t}\n\n\t/**\n\t * @deprecated since v5 - Use `cdsLayer` directive instead\n\t * Set to `\"light\"` to apply the light style\n\t */\n\t@Input() theme: \"light\" | \"dark\" = \"dark\";\n\n\t@Input() disabled = false;\n\t/**\n\t * Set to `true` to display the invalid state.\n\t */\n\t@Input() invalid = false;\n\t/**\n\t * Value displayed if datepicker is in an invalid state.\n\t */\n\t@Input() invalidText: string | TemplateRef<any>;\n\t/**\n\t * Set to `true` to show a warning (contents set by warningText)\n\t */\n\t@Input() warn = false;\n\t/**\n\t * Sets the warning text\n\t */\n\t@Input() warnText: string | TemplateRef<any>;\n\n\t@Input() size: \"sm\" | \"md\" | \"lg\" = \"md\";\n\t/**\n\t * Set to `true` to display the invalid state for the second datepicker input.\n\t */\n\t@Input() rangeInvalid = false;\n\t/**\n\t * Value displayed if the second datepicker input is in an invalid state.\n\t */\n\t@Input() rangeInvalidText: string | TemplateRef<any>;\n\t/**\n\t * Set to `true` to show a warning in the second datepicker input (contents set by rangeWarningText)\n\t */\n\t@Input() rangeWarn = false;\n\t/**\n\t * Sets the warning text for the second datepicker input\n\t */\n\t@Input() rangeWarnText: string | TemplateRef<any>;\n\n\t@Input() skeleton = false;\n\n\t@Input() plugins = [];\n\n\t@Input()\n\tset flatpickrOptions(options) {\n\t\tthis._flatpickrOptions = Object.assign({}, this._flatpickrOptions, options);\n\t}\n\tget flatpickrOptions() {\n\t\tconst plugins = [...this.plugins, carbonFlatpickrMonthSelectPlugin];\n\t\tif (this.range) {\n\t\t\tplugins.push(rangePlugin({ input: `#${this.id}-rangeInput`, position: \"left\" }));\n\t\t}\n\t\treturn Object.assign({}, this._flatpickrOptions, this.flatpickrBaseOptions, {\n\t\t\tmode: this.range ? \"range\" : \"single\",\n\t\t\tplugins,\n\t\t\tdateFormat: this.dateFormat,\n\t\t\tlocale: languages.default?.default[this.language] || languages.default[this.language]\n\t\t});\n\t}\n\n\t@ViewChild(\"input\", { static: true }) input: DatePickerInput;\n\t@ViewChild(\"rangeInput\") rangeInput: DatePickerInput;\n\n\t@Output() valueChange: EventEmitter<any> = new EventEmitter();\n\n\t/**\n\t * We are overriding onClose event even if users pass it via flatpickr options\n\t * Emits an event when date picker closes\n\t */\n\t@Output() onClose: EventEmitter<any> = new EventEmitter();\n\n\tprotected _value = [];\n\n\tprotected _flatpickrOptions = {\n\t\tallowInput: true\n\t};\n\n\tprotected flatpickrBaseOptions = {\n\t\tmode: \"single\",\n\t\tdateFormat: \"m/d/Y\",\n\t\tplugins: this.plugins,\n\t\tonOpen: () => {\n\t\t\tthis.updateClassNames();\n\t\t\tthis.updateAttributes();\n\t\t\tthis.updateCalendarListeners();\n\t\t},\n\t\tonClose: (date) => {\n\t\t\t// This makes sure that the `flatpickrInstance selectedDates` are in sync with the values of\n\t\t\t// the inputs when the calendar closes.\n\t\t\tif (this.range && this.flatpickrInstance) {\n\t\t\t\tif (this.flatpickrInstance.selectedDates.length !== 2) {\n\t\t\t\t\t// we could `this.flatpickrInstance.clear()` but it insists on opening the second picker\n\t\t\t\t\t// in some cases, so instead we do this\n\t\t\t\t\tthis.setDateValues([]);\n\t\t\t\t\tthis.doSelect([]);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst inputValue = this.input.input.nativeElement.value;\n\t\t\t\tconst rangeInputValue = this.rangeInput.input.nativeElement.value;\n\t\t\t\tif (inputValue || rangeInputValue) {\n\t\t\t\t\tconst parseDate = (date: string) => this.flatpickrInstance.parseDate(date, this.dateFormat);\n\t\t\t\t\tthis.setDateValues([parseDate(inputValue), parseDate(rangeInputValue)]);\n\t\t\t\t\tthis.doSelect(this.flatpickrInstance.selectedDates);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.onClose.emit(date);\n\t\t},\n\t\tonDayCreate: (_dObj, _dStr, _fp, dayElem) => {\n\t\t\tdayElem.classList.add(\"cds--date-picker__day\");\n\t\t},\n\t\tnextArrow: this.rightArrowHTML(),\n\t\tprevArrow: this.leftArrowHTML(),\n\t\tvalue: this.value\n\t};\n\n\tprotected flatpickrInstance = null;\n\n\tconstructor(\n\t\tprotected elementRef: ElementRef,\n\t\tprotected i18n: I18n\n\t) { }\n\n\tngOnInit() {\n\t\t// if i18n is set to anything other than en we'll want to change the language\n\t\t// otherwise we'll just use the local setting\n\t\tif (this.i18n.getLocale() !== \"en\") {\n\t\t\tthis.i18n.getLocaleObservable().subscribe(locale => {\n\t\t\t\tthis.language = locale;\n\t\t\t\tthis.resetFlatpickrInstance();\n\t\t\t});\n\t\t}\n\t}\n\n\tngOnChanges(changes: SimpleChanges) {\n\t\t// Reset the flatpickr instance on input changes that affect flatpickr.\n\t\tconst flatpickrChangeKeys = [\n\t\t\t\"range\",\n\t\t\t\"dateFormat\",\n\t\t\t\"language\",\n\t\t\t\"id\",\n\t\t\t\"value\",\n\t\t\t\"plugins\",\n\t\t\t\"flatpickrOptions\"\n\t\t];\n\t\tconst changeKeys = Object.keys(changes);\n\t\tif (changeKeys.some(key => flatpickrChangeKeys.includes(key))) {\n\t\t\tthis.resetFlatpickrInstance(changes.value);\n\t\t}\n\t}\n\n\tngAfterViewInit() {\n\t\tsetTimeout(() => {\n\t\t\tthis.addInputListeners();\n\t\t}, 0);\n\t}\n\n\t// because the actual view may be delayed in loading (think projection into a tab pane)\n\t// and because we rely on a library that operates outside the Angular view of the world\n\t// we need to keep trying to load the library, until the relevant DOM is actually live\n\tngAfterViewChecked() {\n\t\tif (!this.isFlatpickrLoaded()) {\n\t\t\t// @ts-ignore ts is unhappy with the below call to `flatpickr`\n\t\t\tthis.flatpickrInstance = flatpickr(`#${this.id}-input`, this.flatpickrOptions);\n\t\t\t// if (and only if) the initialization succeeded, we can set the date values\n\t\t\tif (this.isFlatpickrLoaded()) {\n\t\t\t\tif (this.value.length > 0) {\n\t\t\t\t\tthis.setDateValues(this.value);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t@HostListener(\"focusin\")\n\tonFocus() {\n\t\t// Updates the month manually when calendar mode is range because month\n\t\t// will not update properly without manually updating them on focus.\n\t\tif (this.range) {\n\t\t\tif (this.rangeInput.input.nativeElement === document.activeElement && this.flatpickrInstance.selectedDates[1]) {\n\t\t\t\tconst currentMonth = this.flatpickrInstance.selectedDates[1].getMonth();\n\t\t\t\tthis.flatpickrInstance.changeMonth(currentMonth, false);\n\t\t\t} else if (this.input.input.nativeElement === document.activeElement && this.flatpickrInstance.selectedDates[0]) {\n\t\t\t\tconst currentMonth = this.flatpickrInstance.selectedDates[0].getMonth();\n\t\t\t\tthis.flatpickrInstance.changeMonth(currentMonth, false);\n\t\t\t}\n\t\t}\n\t}\n\n\t@HostListener(\"focusout\")\n\tonFocusOut() {\n\t\tthis.onTouched();\n\t}\n\n\t/**\n\t * Writes a value from the model to the component. Expects the value to be `null` or `(Date | string)[]`\n\t * @param value value received from the model\n\t */\n\twriteValue(value: (Date | string)[]) {\n\t\tthis.value = value;\n\t\tsetTimeout(() => {\n\t\t\tif (this.isFlatpickrLoaded() && this.flatpickrInstance.config) {\n\t\t\t\tthis.setDateValues(this.value);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * `ControlValueAccessor` method to programmatically disable the DatePicker.\n\t *\n\t * ex: `this.formGroup.get(\"myDatePicker\").disable();`\n\t *\n\t * @param isDisabled `true` to disable the DatePicker\n\t */\n\tsetDisabledState(isDisabled: boolean) {\n\t\tthis.disabled = isDisabled;\n\t}\n\n\tregisterOnChange(fn: any) {\n\t\tthis.propagateChange = fn;\n\t}\n\n\tregisterOnTouched(fn: any) {\n\t\tthis.onTouched = fn;\n\t}\n\n\tonTouched: () => any = () => { };\n\n\tpropagateChange = (_: any) => { };\n\n\t/**\n\t * Cleans up our flatpickr instance\n\t */\n\tngOnDestroy() {\n\t\tif (!this.isFlatpickrLoaded()) { return; }\n\t\tthis.flatpickrInstance.destroy();\n\t}\n\n\t/**\n\t * Handles the `valueChange` event from the primary/single input\n\t */\n\tonValueChange(event: string) {\n\t\tif (this.isFlatpickrLoaded()) {\n\t\t\tconst date = this.flatpickrInstance.parseDate(event, this.dateFormat);\n\t\t\tif (this.range) {\n\t\t\t\tthis.setDateValues([date, this.flatpickrInstance.selectedDates[1]]);\n\t\t\t} else {\n\t\t\t\tthis.setDateValues([date]);\n\t\t\t}\n\t\t\tthis.doSelect(this.flatpickrInstance.selectedDates);\n\t\t}\n\t}\n\n\t/**\n\t * Handles the `valueChange` event from the range input\n\t */\n\tonRangeValueChange(event: string) {\n\t\tif (this.isFlatpickrLoaded() && this.flatpickrInstance.isOpen) {\n\t\t\tconst date = this.flatpickrInstance.parseDate(event, this.dateFormat);\n\t\t\tthis.setDateValues([this.flatpickrInstance.selectedDates[0], date]);\n\t\t\tthis.doSelect(this.flatpickrInstance.selectedDates);\n\t\t}\n\t}\n\n\t/**\n\t * Handles opening the calendar \"properly\" when the calendar icon is clicked.\n\t */\n\topenCalendar(datepickerInput: DatePickerInput) {\n\t\tif (this.range) {\n\t\t\tdatepickerInput.input.nativeElement.click();\n\n\t\t\t// If the first input's calendar icon is clicked when calendar is in range mode, then\n\t\t\t// the month and year needs to be manually changed to the current selected month and\n\t\t\t// year otherwise the calendar view will not be updated upon opening.\n\t\t\tif (datepickerInput === this.input && this.flatpickrInstance.selectedDates[0]) {\n\t\t\t\tconst currentMonth = this.flatpickrInstance.selectedDates[0].getMonth();\n\n\t\t\t\tthis.flatpickrInstance.currentYear = this.flatpickrInstance.selectedDates[0].getFullYear();\n\t\t\t\tthis.flatpickrInstance.changeMonth(currentMonth, false);\n\t\t\t}\n\t\t} else {\n\t\t\t// Single-mode flatpickr handles mousedown but not click, so nativeElement.click() won't\n\t\t\t// work when the calendar icon is clicked. In this case we simply use flatpickr.open().\n\t\t\tthis.flatpickrInstance.open();\n\t\t}\n\t}\n\n\tprotected updateCalendarListeners() {\n\t\tconst calendarContainer = document.querySelectorAll(\".flatpickr-calendar\");\n\t\tArray.from(calendarContainer).forEach(calendar => {\n\t\t\tcalendar.removeEventListener(\"click\", this.preventCalendarClose);\n\t\t\tcalendar.addEventListener(\"click\", this.preventCalendarClose);\n\t\t});\n\t}\n\n\t/**\n\t * Handles the initialization of event listeners for the datepicker input and range input fields.\n\t */\n\tprotected addInputListeners() {\n\t\tif (!this.isFlatpickrLoaded()) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Allows focus transition from the datepicker input or range input field to\n\t\t// flatpickr calendar using a keyboard.\n\t\tconst addFocusCalendarListener = (element: HTMLInputElement) => {\n\t\t\telement.addEventListener(\"keydown\", (event: KeyboardEvent) => {\n\t\t\t\tif (event.key === \"ArrowDown\") {\n\t\t\t\t\tif (!this.flatpickrInstance.isOpen) {\n\t\t\t\t\t\tthis.flatpickrInstance.open();\n\t\t\t\t\t}\n\n\t\t\t\t\tconst calendarContainer = this.flatpickrInstance.calendarContainer;\n\t\t\t\t\tconst dayElement = calendarContainer && calendarContainer.querySelector(\".flatpickr-day[tabindex]\");\n\n\t\t\t\t\tif (dayElement) {\n\t\t\t\t\t\tdayElement.focus();\n\n\t\t\t\t\t\t// If the user manually inputs a value into the date field and presses arrow down,\n\t\t\t\t\t\t// datepicker input onchange will be triggered when focus is removed from it and\n\t\t\t\t\t\t// `flatpickrInstance.setDate` and `flatpickrInstance.changeMonth` will be invoked\n\t\t\t\t\t\t// which will automatically change focus to the beginning of the document.\n\t\t\t\t\t\tif (document.activeElement !== dayElement && this.flatpickrInstance.selectedDateElem) {\n\t\t\t\t\t\t\tthis.flatpickrInstance.selectedDateElem.focus();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t};\n\n\t\tif (this.input && this.input.input) {\n\t\t\taddFocusCalendarListener(this.input.input.nativeElement);\n\t\t}\n\n\t\tif (this.rangeInput && this.rangeInput.input) {\n\t\t\taddFocusCalendarListener(this.rangeInput.input.nativeElement);\n\t\t}\n\t}\n\n\t/**\n\t * Resets the flatpickr instance while keeping the date values (or updating them if newDates is provided)\n\t *\n\t * Used to pick up input changes or locale changes.\n\t *\n\t * @param newDates An optional SimpleChange of date values\n\t */\n\tprotected resetFlatpickrInstance(newDates?: SimpleChange) {\n\t\tif (this.isFlatpickrLoaded()) {\n\t\t\tlet dates = this.flatpickrInstance.selectedDates;\n\t\t\tif (newDates && this.didDateValueChange(newDates.currentValue, newDates.previousValue)) {\n\t\t\t\tdates = newDates.currentValue;\n\t\t\t}\n\t\t\t// only reset the flatpickr instance on Input changes\n\t\t\t// @ts-ignore ts is unhappy with the below call to `flatpickr`\n\t\t\tthis.flatpickrInstance = flatpickr(`#${this.id}-input`, this.flatpickrOptions);\n\t\t\tthis.setDateValues(dates);\n\t\t}\n\t}\n\n\t/**\n\t * Carbon uses a number of specific classnames for parts of the flatpickr - this idempotent method applies them if needed.\n\t */\n\tprotected updateClassNames() {\n\t\tif (!this.elementRef) { return; }\n\t\t// get all the possible flatpickrs in the document - we need to add classes to (potentially) all of them\n\t\tconst calendarContainer = document.querySelectorAll(\".flatpickr-calendar\");\n\t\tconst monthContainer = document.querySelectorAll(\".flatpickr-month\");\n\t\tconst weekdaysContainer = document.querySelectorAll(\".flatpickr-weekdays\");\n\t\tconst weekdayContainer = document.querySelectorAll(\".flatpickr-weekday\");\n\t\tconst daysContainer = document.querySelectorAll(\".flatpickr-days\");\n\t\tconst dayContainer = document.querySelectorAll(\".flatpickr-day\");\n\n\t\t// add classes to lists of elements\n\t\tconst addClassIfNotExists = (classname: string, elementList: NodeListOf<Element>) => {\n\t\t\tArray.from(elementList).forEach(element => {\n\t\t\t\tif (!element.classList.contains(classname)) {\n\t\t\t\t\telement.classList.add(classname);\n\t\t\t\t}\n\t\t\t});\n\t\t};\n\n\t\t// add classes (but only if they don't exist, small perf win)\n\t\taddClassIfNotExists(\"cds--date-picker__calendar\", calendarContainer);\n\t\taddClassIfNotExists(\"cds--date-picker__month\", monthContainer);\n\t\taddClassIfNotExists(\"cds--date-picker__weekdays\", weekdaysContainer);\n\t\taddClassIfNotExists(\"cds--date-picker__days\", daysContainer);\n\n\t\t// add weekday classes and format the text\n\t\tArray.from(weekdayContainer).forEach(element => {\n\t\t\telement.innerHTML = element.innerHTML.replace(/\\s+/g, \"\");\n\t\t\telement.classList.add(\"cds--date-picker__weekday\");\n\t\t});\n\n\t\t// add day classes and special case the \"today\" element based on `this.value`\n\t\tArray.from(dayContainer).forEach(element => {\n\t\t\telement.classList.add(\"cds--date-picker__day\");\n\t\t\tif (!this.value) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (element.classList.contains(\"today\") && this.value.length > 0) {\n\t\t\t\telement.classList.add(\"no-border\");\n\t\t\t} else if (element.classList.contains(\"today\") && this.value.length === 0) {\n\t\t\t\telement.classList.remove(\"no-border\");\n\t\t\t}\n\t\t});\n\t}\n\n\tprotected updateAttributes() {\n\t\tconst calendarContainer = document.querySelectorAll(\".flatpickr-calendar\");\n\t\tArray.from(calendarContainer).forEach(calendar => {\n\t\t\tcalendar.setAttribute(\"role\", \"region\");\n\t\t\tcalendar.setAttribute(\"aria-label\", this.ariaLabel);\n\t\t});\n\t}\n\n\t/**\n\t * Applies the given date value array to both the flatpickr instance and the `input`(s)\n\t * @param dates the date values to apply\n\t */\n\tprotected setDateValues(dates: (Date | string)[]) {\n\t\tif (this.isFlatpickrLoaded()) {\n\t\t\tconst singleInput = this.elementRef.nativeElement.querySelector(`#${this.id}-input`);\n\t\t\tconst rangeInput = this.elementRef.nativeElement.querySelector(`#${this.id}-rangeInput`);\n\n\t\t\t// `flatpickrInstance.setDate` removes the focus on the selected date element and will\n\t\t\t// automatically change focus to the beginning of the document. If a selected date is\n\t\t\t// focused before `flatpickrInstance.setDate` is invoked then it should remain focused.\n\t\t\tlet shouldRefocusDateElement = this.flatpickrInstance.selectedDateElem === document.activeElement;\n\n\t\t\t// set the date on the instance\n\t\t\tthis.flatpickrInstance.setDate(dates);\n\n\t\t\tif (shouldRefocusDateElement) {\n\t\t\t\tthis.flatpickrInstance.selectedDateElem.focus();\n\t\t\t}\n\n\t\t\t// we can either set a date value or an empty string, so we start with an empty string\n\t\t\tlet singleDate = \"\";\n\t\t\t// if date is a string, parse and format\n\t\t\tif (typeof this.flatpickrInstance.selectedDates[0] === \"string\") {\n\t\t\t\tsingleDate = this.flatpickrInstance.parseDate(this.flatpickrInstance.selectedDates[0], this.dateFormat);\n\t\t\t\tsingleDate = this.flatpickrInstance.formatDate(singleDate, this.dateFormat);\n\t\t\t// if date is not a string we can assume it's a Date and we should format\n\t\t\t} else if (!!this.flatpickrInstance.selectedDates[0]) {\n\t\t\t\tsingleDate = this.flatpickrInstance.formatDate(this.flatpickrInstance.selectedDates[0], this.dateFormat);\n\t\t\t}\n\n\t\t\tif (rangeInput) {\n\t\t\t\t// we can either set a date value or an empty string, so we start with an empty string\n\t\t\t\tlet rangeDate = \"\";\n\t\t\t\t// if date is a string, parse and format\n\t\t\t\tif (typeof this.flatpickrInstance.selectedDates[1] === \"string\") {\n\t\t\t\t\trangeDate = this.flatpickrInstance.parseDate(this.flatpickrInstance.selectedDates[1].toString(), this.dateFormat);\n\t\t\t\t\trangeDate = this.flatpickrInstance.formatDate(rangeDate, this.dateFormat);\n\t\t\t\t// if date is not a string we can assume it's a Date and we should format\n\t\t\t\t} else if (!!this.flatpickrInstance.selectedDates[1]) {\n\t\t\t\t\trangeDate = this.flatpickrInstance.formatDate(this.flatpickrInstance.selectedDates[1], this.dateFormat);\n\t\t\t\t}\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t// apply the values\n\t\t\t\t\trangeInput.value = rangeDate;\n\t\t\t\t\tsingleInput.value = singleDate;\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected preventCalendarClose = event => event.stopPropagation();\n\n\tprotected doSelect(selectedValue: (Date | string)[]) {\n\t\t// In range mode, if a date is selected from the first calendar that is from the previous month,\n\t\t// the month will not be updated on the calendar until the calendar is re-opened.\n\t\t// This will make sure the calendar is updated with the correct month.\n\t\tif (this.range && this.flatpickrInstance.selectedDates[0]) {\n\t\t\tconst currentMonth = this.flatpickrInstance.selectedDates[0].getMonth();\n\n\t\t\t// `flatpickrInstance.changeMonth` removes the focus on the selected date element and will\n\t\t\t// automatically change focus to the beginning of the document. If a selected date is\n\t\t\t// focused before `flatpickrInstance.changeMonth` is invoked then it should remain focused.\n\t\t\tlet shouldRefocusDateElement = this.flatpickrInstance.selectedDateElem === document.activeElement;\n\n\t\t\tthis.flatpickrInstance.changeMonth(currentMonth, false);\n\n\t\t\tif (shouldRefocusDateElement) {\n\t\t\t\tthis.flatpickrInstance.selectedDateElem.focus();\n\t\t\t}\n\n\t\t}\n\t\tthis.valueChange.emit(selectedValue);\n\t\tthis.propagateChange(selectedValue);\n\t}\n\n\tprotected didDateValueChange(currentValue, previousValue) {\n\t\treturn currentValue[0] !== previousValue[0] || currentValue[1] !== previousValue[1];\n\t}\n\n\t/**\n\t * More advanced checking of the loaded state of flatpickr\n\t */\n\tprotected isFlatpickrLoaded() {\n\t\t// cast the instance to a boolean, and some method that has to exist for the library to be loaded in this case `setDate`\n\t\treturn !!this.flatpickrInstance && !!this.flatpickrInstance.setDate;\n\t}\n\n\t/**\n\t * Right arrow HTML passed to flatpickr\n\t */\n\tprotected rightArrowHTML() {\n\t\treturn `\n\t\t\t<svg width=\"16px\" height=\"16px\" viewBox=\"0 0 16 16\">\n\t\t\t\t<polygon points=\"11,8 6,13 5.3,12.3 9.6,8 5.3,3.7 6,3 \"/>\n\t\t\t\t<rect width=\"16\" height=\"16\" style=\"fill:none\" />\n\t\t\t</svg>`;\n\t}\n\n\t/**\n\t * Left arrow HTML passed to flatpickr\n\t */\n\tprotected leftArrowHTML() {\n\t\treturn `\n\t\t\t<svg width=\"16px\" height=\"16px\" viewBox=\"0 0 16 16\">\n\t\t\t\t<polygon points=\"5,8 10,3 10.7,3.7 6.4,8 10.7,12.3 10,13 \"/>\n\t\t\t\t<rect width=\"16\" height=\"16\" style=\"fill:none\" />\n\t\t\t</svg>`;\n\t}\n}\n",
|
|
25328
25328
|
"assetsDirs": [],
|
|
25329
25329
|
"styleUrlsData": "",
|
|
25330
25330
|
"stylesData": "",
|
|
@@ -25347,7 +25347,7 @@
|
|
|
25347
25347
|
"deprecationMessage": ""
|
|
25348
25348
|
}
|
|
25349
25349
|
],
|
|
25350
|
-
"line":
|
|
25350
|
+
"line": 290,
|
|
25351
25351
|
"jsdoctags": [
|
|
25352
25352
|
{
|
|
25353
25353
|
"name": "elementRef",
|
|
@@ -25374,8 +25374,7 @@
|
|
|
25374
25374
|
"OnDestroy",
|
|
25375
25375
|
"OnChanges",
|
|
25376
25376
|
"AfterViewChecked",
|
|
25377
|
-
"AfterViewInit"
|
|
25378
|
-
"AfterContentInit"
|
|
25377
|
+
"AfterViewInit"
|
|
25379
25378
|
],
|
|
25380
25379
|
"accessors": {
|
|
25381
25380
|
"value": {
|
|
@@ -25394,7 +25393,7 @@
|
|
|
25394
25393
|
}
|
|
25395
25394
|
],
|
|
25396
25395
|
"returnType": "void",
|
|
25397
|
-
"line":
|
|
25396
|
+
"line": 161,
|
|
25398
25397
|
"jsdoctags": [
|
|
25399
25398
|
{
|
|
25400
25399
|
"name": "v",
|
|
@@ -25411,7 +25410,7 @@
|
|
|
25411
25410
|
"name": "value",
|
|
25412
25411
|
"type": "",
|
|
25413
25412
|
"returnType": "",
|
|
25414
|
-
"line":
|
|
25413
|
+
"line": 168
|
|
25415
25414
|
}
|
|
25416
25415
|
},
|
|
25417
25416
|
"flatpickrOptions": {
|
|
@@ -25430,7 +25429,7 @@
|
|
|
25430
25429
|
}
|
|
25431
25430
|
],
|
|
25432
25431
|
"returnType": "void",
|
|
25433
|
-
"line":
|
|
25432
|
+
"line": 219,
|
|
25434
25433
|
"jsdoctags": [
|
|
25435
25434
|
{
|
|
25436
25435
|
"name": "options",
|
|
@@ -25447,7 +25446,7 @@
|
|
|
25447
25446
|
"name": "flatpickrOptions",
|
|
25448
25447
|
"type": "",
|
|
25449
25448
|
"returnType": "",
|
|
25450
|
-
"line":
|
|
25449
|
+
"line": 222
|
|
25451
25450
|
}
|
|
25452
25451
|
}
|
|
25453
25452
|
}
|
|
@@ -29459,7 +29458,7 @@
|
|
|
29459
29458
|
},
|
|
29460
29459
|
{
|
|
29461
29460
|
"name": "FileComponent",
|
|
29462
|
-
"id": "component-FileComponent-
|
|
29461
|
+
"id": "component-FileComponent-5dd02c14d1b5b94175eb2f5541aef2631a5238d8a357cc189f01382f7b55c5556a39fd590b189d01110ab2519bcb6cfb8bc62537a01e32920509e9fea450d407",
|
|
29463
29462
|
"file": "src/file-uploader/file.component.ts",
|
|
29464
29463
|
"encapsulation": [],
|
|
29465
29464
|
"entryComponents": [],
|
|
@@ -29469,7 +29468,7 @@
|
|
|
29469
29468
|
"selector": "cds-file, ibm-file",
|
|
29470
29469
|
"styleUrls": [],
|
|
29471
29470
|
"styles": [],
|
|
29472
|
-
"template": "<p class=\"cds--file-filename\" [title]=\"fileItem.file.name\">{{fileItem.file.name}}</p>\n<span\n\t*ngIf=\"fileItem.state === 'edit'\"\n\tclass=\"cds--file__state-container\">\n\t<svg\n\t\t*ngIf=\"isInvalidText\"\n\t\tcdsIcon=\"warning--filled\"\n\t\tclass=\"cds--file--invalid\"\n\t\tsize=\"16\">\n\t</svg>\n\t<button\n\t\ttype=\"button\"\n\t\tclass=\"cds--file-close\"\n\t\t[attr.aria-label]=\"translations.REMOVE_BUTTON\"\n\t\ttabindex=\"0\"\n\t\t(click)=\"remove.emit()\"\n\t\t(keyup.enter)=\"remove.emit()\"\n\t\t(keyup.space)=\"remove.emit()\">\n\t\t<svg cdsIcon=\"close\" size=\"16\"></svg>\n\t</button>\n</span>\n<span *ngIf=\"fileItem.state === 'upload'\">\n\t<div class=\"cds--inline-loading__animation\">\n\t\t<cds-loading size=\"sm\"></cds-loading>\n\t</div>\n</span>\n<span *ngIf=\"fileItem.state === 'complete'\" class=\"cds--file__state-container\">\n\t<svg\n\t\tcdsIcon=\"checkmark--filled\"\n\t\tsize=\"16\"\n\t\tclass=\"cds--file-complete\"\n\t\t[ariaLabel]=\"translations.CHECKMARK\">\n\t</svg>\n</span>\n<div class=\"cds--form-requirement\" *ngIf=\"fileItem.invalid\">\n\t<div class=\"cds--form-requirement__title\">{{fileItem.invalidTitle}}</div>\n\t<p class=\"cds--form-requirement__supplement\">{{fileItem.invalidText}}</p>\n</div>\n\t",
|
|
29471
|
+
"template": "<p class=\"cds--file-filename\" [title]=\"fileItem.file.name\">{{fileItem.file.name}}</p>\n<span\n\t*ngIf=\"fileItem.state === 'edit'\"\n\tclass=\"cds--file__state-container\">\n\t<svg\n\t\t*ngIf=\"isInvalidText\"\n\t\tcdsIcon=\"warning--filled\"\n\t\tclass=\"cds--file--invalid\"\n\t\tsize=\"16\">\n\t</svg>\n\t<button\n\t\ttype=\"button\"\n\t\tclass=\"cds--file-close\"\n\t\t[attr.aria-label]=\"translations.REMOVE_BUTTON\"\n\t\ttabindex=\"0\"\n\t\t(click)=\"remove.emit()\"\n\t\t(keyup.enter)=\"remove.emit()\"\n\t\t(keyup.space)=\"remove.emit()\">\n\t\t<svg cdsIcon=\"close\" size=\"16\"></svg>\n\t</button>\n</span>\n<span *ngIf=\"fileItem.state === 'upload'\">\n\t<div class=\"cds--inline-loading__animation\">\n\t\t<cds-loading size=\"sm\"></cds-loading>\n\t</div>\n</span>\n<span *ngIf=\"fileItem.state === 'complete'\" class=\"cds--file__state-container\">\n\t<svg\n\t\tcdsIcon=\"checkmark--filled\"\n\t\tsize=\"16\"\n\t\tclass=\"cds--file-complete\"\n\t\t[ariaLabel]=\"translations.CHECKMARK\">\n\t</svg>\n</span>\n<div class=\"cds--form-requirement\" role=\"alert\" *ngIf=\"fileItem.invalid\">\n\t<div class=\"cds--form-requirement__title\">{{fileItem.invalidTitle}}</div>\n\t<p class=\"cds--form-requirement__supplement\">{{fileItem.invalidText}}</p>\n</div>\n\t",
|
|
29473
29472
|
"templateUrl": [],
|
|
29474
29473
|
"viewProviders": [],
|
|
29475
29474
|
"hostDirectives": [],
|
|
@@ -29588,7 +29587,7 @@
|
|
|
29588
29587
|
"description": "",
|
|
29589
29588
|
"rawdescription": "\n",
|
|
29590
29589
|
"type": "component",
|
|
29591
|
-
"sourceCode": "import {\n\tComponent,\n\tInput,\n\tOutput,\n\tEventEmitter,\n\tHostBinding,\n\tOnDestroy\n} from \"@angular/core\";\n\nimport { I18n } from \"carbon-components-angular/i18n\";\nimport { FileItem } from \"./file-item.interface\";\n\n@Component({\n\tselector: \"cds-file, ibm-file\",\n\ttemplate: `\n\t\t<p class=\"cds--file-filename\" [title]=\"fileItem.file.name\">{{fileItem.file.name}}</p>\n\t\t<span\n\t\t\t*ngIf=\"fileItem.state === 'edit'\"\n\t\t\tclass=\"cds--file__state-container\">\n\t\t\t<svg\n\t\t\t\t*ngIf=\"isInvalidText\"\n\t\t\t\tcdsIcon=\"warning--filled\"\n\t\t\t\tclass=\"cds--file--invalid\"\n\t\t\t\tsize=\"16\">\n\t\t\t</svg>\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\tclass=\"cds--file-close\"\n\t\t\t\t[attr.aria-label]=\"translations.REMOVE_BUTTON\"\n\t\t\t\ttabindex=\"0\"\n\t\t\t\t(click)=\"remove.emit()\"\n\t\t\t\t(keyup.enter)=\"remove.emit()\"\n\t\t\t\t(keyup.space)=\"remove.emit()\">\n\t\t\t\t<svg cdsIcon=\"close\" size=\"16\"></svg>\n\t\t\t</button>\n\t\t</span>\n\t\t<span *ngIf=\"fileItem.state === 'upload'\">\n\t\t\t<div class=\"cds--inline-loading__animation\">\n\t\t\t\t<cds-loading size=\"sm\"></cds-loading>\n\t\t\t</div>\n\t\t</span>\n\t\t<span *ngIf=\"fileItem.state === 'complete'\" class=\"cds--file__state-container\">\n\t\t\t<svg\n\t\t\t\tcdsIcon=\"checkmark--filled\"\n\t\t\t\tsize=\"16\"\n\t\t\t\tclass=\"cds--file-complete\"\n\t\t\t\t[ariaLabel]=\"translations.CHECKMARK\">\n\t\t\t</svg>\n\t\t</span>\n\t\t<div class=\"cds--form-requirement\" *ngIf=\"fileItem.invalid\">\n\t\t\t<div class=\"cds--form-requirement__title\">{{fileItem.invalidTitle}}</div>\n\t\t\t<p class=\"cds--form-requirement__supplement\">{{fileItem.invalidText}}</p>\n\t\t</div>\n\t`\n})\nexport class FileComponent implements OnDestroy {\n\t/**\n\t * Accessible translations for the close and complete icons\n\t */\n\t@Input() translations = this.i18n.get().FILE_UPLOADER;\n\t/**\n\t * A single `FileItem` from the set of `FileItem`s\n\t */\n\t@Input() fileItem: FileItem;\n\n\t@Input() size: \"sm\" | \"md\" | \"lg\" = \"lg\";\n\n\t@Output() remove = new EventEmitter();\n\n\t@HostBinding(\"class.cds--file__selected-file\") selectedFile = true;\n\n\t@HostBinding(\"class.cds--file__selected-file--invalid\") get isInvalidText() {\n\t\treturn this.fileItem.invalidText;\n\t}\n\n\t@HostBinding(\"class.cds--file__selected-file--sm\") get fileSizeSmall() {\n\t\treturn this.size === \"sm\";\n\t}\n\n\t@HostBinding(\"class.cds--file__selected-file--md\") get fileSizeMedium() {\n\t\treturn this.size === \"md\";\n\t}\n\n\t@HostBinding(\"class.cds--file__selected-file--lg\") get fileSizeLarge() {\n\t\treturn this.size === \"lg\";\n\t}\n\tconstructor(protected i18n: I18n) {}\n\n\tngOnDestroy() {\n\t\tthis.remove.emit();\n\t}\n}\n",
|
|
29590
|
+
"sourceCode": "import {\n\tComponent,\n\tInput,\n\tOutput,\n\tEventEmitter,\n\tHostBinding,\n\tOnDestroy\n} from \"@angular/core\";\n\nimport { I18n } from \"carbon-components-angular/i18n\";\nimport { FileItem } from \"./file-item.interface\";\n\n@Component({\n\tselector: \"cds-file, ibm-file\",\n\ttemplate: `\n\t\t<p class=\"cds--file-filename\" [title]=\"fileItem.file.name\">{{fileItem.file.name}}</p>\n\t\t<span\n\t\t\t*ngIf=\"fileItem.state === 'edit'\"\n\t\t\tclass=\"cds--file__state-container\">\n\t\t\t<svg\n\t\t\t\t*ngIf=\"isInvalidText\"\n\t\t\t\tcdsIcon=\"warning--filled\"\n\t\t\t\tclass=\"cds--file--invalid\"\n\t\t\t\tsize=\"16\">\n\t\t\t</svg>\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\tclass=\"cds--file-close\"\n\t\t\t\t[attr.aria-label]=\"translations.REMOVE_BUTTON\"\n\t\t\t\ttabindex=\"0\"\n\t\t\t\t(click)=\"remove.emit()\"\n\t\t\t\t(keyup.enter)=\"remove.emit()\"\n\t\t\t\t(keyup.space)=\"remove.emit()\">\n\t\t\t\t<svg cdsIcon=\"close\" size=\"16\"></svg>\n\t\t\t</button>\n\t\t</span>\n\t\t<span *ngIf=\"fileItem.state === 'upload'\">\n\t\t\t<div class=\"cds--inline-loading__animation\">\n\t\t\t\t<cds-loading size=\"sm\"></cds-loading>\n\t\t\t</div>\n\t\t</span>\n\t\t<span *ngIf=\"fileItem.state === 'complete'\" class=\"cds--file__state-container\">\n\t\t\t<svg\n\t\t\t\tcdsIcon=\"checkmark--filled\"\n\t\t\t\tsize=\"16\"\n\t\t\t\tclass=\"cds--file-complete\"\n\t\t\t\t[ariaLabel]=\"translations.CHECKMARK\">\n\t\t\t</svg>\n\t\t</span>\n\t\t<div class=\"cds--form-requirement\" role=\"alert\" *ngIf=\"fileItem.invalid\">\n\t\t\t<div class=\"cds--form-requirement__title\">{{fileItem.invalidTitle}}</div>\n\t\t\t<p class=\"cds--form-requirement__supplement\">{{fileItem.invalidText}}</p>\n\t\t</div>\n\t`\n})\nexport class FileComponent implements OnDestroy {\n\t/**\n\t * Accessible translations for the close and complete icons\n\t */\n\t@Input() translations = this.i18n.get().FILE_UPLOADER;\n\t/**\n\t * A single `FileItem` from the set of `FileItem`s\n\t */\n\t@Input() fileItem: FileItem;\n\n\t@Input() size: \"sm\" | \"md\" | \"lg\" = \"lg\";\n\n\t@Output() remove = new EventEmitter();\n\n\t@HostBinding(\"class.cds--file__selected-file\") selectedFile = true;\n\n\t@HostBinding(\"class.cds--file__selected-file--invalid\") get isInvalidText() {\n\t\treturn this.fileItem.invalidText;\n\t}\n\n\t@HostBinding(\"class.cds--file__selected-file--sm\") get fileSizeSmall() {\n\t\treturn this.size === \"sm\";\n\t}\n\n\t@HostBinding(\"class.cds--file__selected-file--md\") get fileSizeMedium() {\n\t\treturn this.size === \"md\";\n\t}\n\n\t@HostBinding(\"class.cds--file__selected-file--lg\") get fileSizeLarge() {\n\t\treturn this.size === \"lg\";\n\t}\n\tconstructor(protected i18n: I18n) {}\n\n\tngOnDestroy() {\n\t\tthis.remove.emit();\n\t}\n}\n",
|
|
29592
29591
|
"assetsDirs": [],
|
|
29593
29592
|
"styleUrlsData": "",
|
|
29594
29593
|
"stylesData": "",
|
|
@@ -29662,7 +29661,7 @@
|
|
|
29662
29661
|
},
|
|
29663
29662
|
{
|
|
29664
29663
|
"name": "FileUploader",
|
|
29665
|
-
"id": "component-FileUploader-
|
|
29664
|
+
"id": "component-FileUploader-16618b5809363fea59d72357ffa4b07e95929d21f9b6f877e0e1e0cc77571170d13a9b73a0a9c332b8e0dd05a18d728283373b0b3f7031ad19fade02045a499f",
|
|
29666
29665
|
"file": "src/file-uploader/file-uploader.component.ts",
|
|
29667
29666
|
"encapsulation": [],
|
|
29668
29667
|
"entryComponents": [],
|
|
@@ -29676,7 +29675,7 @@
|
|
|
29676
29675
|
"selector": "cds-file-uploader, ibm-file-uploader",
|
|
29677
29676
|
"styleUrls": [],
|
|
29678
29677
|
"styles": [],
|
|
29679
|
-
"template": "<ng-container *ngIf=\"!skeleton; else skeletonTemplate\">\n\t<label [for]=\"fileUploaderId\" class=\"cds--file--label\">{{title}}</label>\n\t<p class=\"cds--label-description\">{{description}}</p>\n\t<div class=\"cds--file\">\n\t\t<label\n\t\t\t*ngIf=\"drop\"\n\t\t\tclass=\"cds--file-browse-btn\"\n\t\t\t(keyup.enter)=\"fileInput.click()\"\n\t\t\t(keyup.space)=\"fileInput.click()\"\n\t\t\t[ngClass]=\"{'cds--file-browse-btn--disabled': disabled}\"\n\t\t\ttabindex=\"0\">\n\t\t\t<div\n\t\t\t\tclass=\"cds--file__drop-container\"\n\t\t\t\t[ngClass]=\"{'cds--file__drop-container--drag-over': dragOver}\"\n\t\t\t\trole=\"button\"\n\t\t\t\t(click)=\"fileInput.click()\"\n\t\t\t\t[attr.for]=\"fileUploaderId\"\n\t\t\t\t(dragover)=\"onDragOver($event)\"\n\t\t\t\t(dragleave)=\"onDragLeave($event)\"\n\t\t\t\t(drop)=\"onDrop($event)\">\n\t\t\t\t<ng-container *ngIf=\"!isTemplate(dropText)\">{{dropText}}</ng-container>\n\t\t\t\t<ng-template *ngIf=\"isTemplate(dropText)\" [ngTemplateOutlet]=\"dropText\"></ng-template>\n\t\t\t</div>\n\t\t</label>\n\t\t<button\n\t\t\t*ngIf=\"!drop\"\n\t\t\ttype=\"button\"\n\t\t\t[cdsButton]=\"buttonType\"\n\t\t\t(click)=\"fileInput.click()\"\n\t\t\t[attr.for]=\"fileUploaderId\"\n\t\t\t[size]=\"size\"\n\t\t\t[disabled]=\"disabled\">\n\t\t\t{{buttonText}}\n\t\t</button>\n\t\t<input\n\t\t\t#fileInput\n\t\t\ttype=\"file\"\n\t\t\tclass=\"cds--file-input\"\n\t\t\t[accept]=\"accept\"\n\t\t\t[id]=\"fileUploaderId\"\n\t\t\t[multiple]=\"multiple\"\n\t\t\ttabindex=\"-1\"\n\t\t\t(change)=\"onFilesAdded()\"\n\t\t\t[disabled]=\"disabled\"/>\n\t\t<div class=\"cds--file-container\">\n\t\t\t<ng-container *ngFor=\"let fileItem of files\">\n\t\t\t\t<cds-file\n\t\t\t\t\t[fileItem]=\"fileItem\"\n\t\t\t\t\t(remove)=\"removeFile(fileItem)\"\n\t\t\t\t\t[size]=\"fileItemSize\">\n\t\t\t\t</cds-file>\n\t\t\t</ng-container>\n\t\t</div>\n\t</div>\n</ng-container>\n\n<ng-template #skeletonTemplate>\n\t<div class=\"cds--skeleton__text\" style=\"width: 100px\"></div>\n\t<div class=\"cds--skeleton__text\" style=\"width: 225px\"></div>\n\t<button cdsButton skeleton=\"true\"></button>\n</ng-template>\n\t",
|
|
29678
|
+
"template": "<ng-container *ngIf=\"!skeleton; else skeletonTemplate\">\n\t<label [for]=\"fileUploaderId\" class=\"cds--file--label\">{{title}}</label>\n\t<p class=\"cds--label-description\" role=\"alert\">{{description}}</p>\n\t<div class=\"cds--file\">\n\t\t<label\n\t\t\t*ngIf=\"drop\"\n\t\t\tclass=\"cds--file-browse-btn\"\n\t\t\t(keyup.enter)=\"fileInput.click()\"\n\t\t\t(keyup.space)=\"fileInput.click()\"\n\t\t\t[ngClass]=\"{'cds--file-browse-btn--disabled': disabled}\"\n\t\t\ttabindex=\"0\">\n\t\t\t<div\n\t\t\t\tclass=\"cds--file__drop-container\"\n\t\t\t\t[ngClass]=\"{'cds--file__drop-container--drag-over': dragOver}\"\n\t\t\t\trole=\"button\"\n\t\t\t\t(click)=\"fileInput.click()\"\n\t\t\t\t[attr.for]=\"fileUploaderId\"\n\t\t\t\t(dragover)=\"onDragOver($event)\"\n\t\t\t\t(dragleave)=\"onDragLeave($event)\"\n\t\t\t\t(drop)=\"onDrop($event)\">\n\t\t\t\t<ng-container *ngIf=\"!isTemplate(dropText)\">{{dropText}}</ng-container>\n\t\t\t\t<ng-template *ngIf=\"isTemplate(dropText)\" [ngTemplateOutlet]=\"dropText\"></ng-template>\n\t\t\t</div>\n\t\t</label>\n\t\t<button\n\t\t\t*ngIf=\"!drop\"\n\t\t\ttype=\"button\"\n\t\t\t[cdsButton]=\"buttonType\"\n\t\t\t(click)=\"fileInput.click()\"\n\t\t\t[attr.for]=\"fileUploaderId\"\n\t\t\t[size]=\"size\"\n\t\t\t[disabled]=\"disabled\">\n\t\t\t{{buttonText}}\n\t\t</button>\n\t\t<input\n\t\t\t#fileInput\n\t\t\ttype=\"file\"\n\t\t\tclass=\"cds--file-input\"\n\t\t\t[accept]=\"accept\"\n\t\t\t[id]=\"fileUploaderId\"\n\t\t\t[multiple]=\"multiple\"\n\t\t\ttabindex=\"-1\"\n\t\t\t(change)=\"onFilesAdded()\"\n\t\t\t[disabled]=\"disabled\"/>\n\t\t<div class=\"cds--file-container\">\n\t\t\t<ng-container *ngFor=\"let fileItem of files\">\n\t\t\t\t<cds-file\n\t\t\t\t\t[fileItem]=\"fileItem\"\n\t\t\t\t\t(remove)=\"removeFile(fileItem)\"\n\t\t\t\t\t[size]=\"fileItemSize\">\n\t\t\t\t</cds-file>\n\t\t\t</ng-container>\n\t\t</div>\n\t</div>\n</ng-container>\n\n<ng-template #skeletonTemplate>\n\t<div class=\"cds--skeleton__text\" style=\"width: 100px\"></div>\n\t<div class=\"cds--skeleton__text\" style=\"width: 225px\"></div>\n\t<button cdsButton skeleton=\"true\"></button>\n</ng-template>\n\t",
|
|
29680
29679
|
"templateUrl": [],
|
|
29681
29680
|
"viewProviders": [],
|
|
29682
29681
|
"hostDirectives": [],
|
|
@@ -30164,8 +30163,8 @@
|
|
|
30164
30163
|
"jsdoctags": [
|
|
30165
30164
|
{
|
|
30166
30165
|
"name": {
|
|
30167
|
-
"pos":
|
|
30168
|
-
"end":
|
|
30166
|
+
"pos": 7741,
|
|
30167
|
+
"end": 7751,
|
|
30169
30168
|
"flags": 8421376,
|
|
30170
30169
|
"modifierFlagsCache": 0,
|
|
30171
30170
|
"transformFlags": 0,
|
|
@@ -30176,8 +30175,8 @@
|
|
|
30176
30175
|
"deprecated": false,
|
|
30177
30176
|
"deprecationMessage": "",
|
|
30178
30177
|
"tagName": {
|
|
30179
|
-
"pos":
|
|
30180
|
-
"end":
|
|
30178
|
+
"pos": 7735,
|
|
30179
|
+
"end": 7740,
|
|
30181
30180
|
"flags": 8421376,
|
|
30182
30181
|
"modifierFlagsCache": 0,
|
|
30183
30182
|
"transformFlags": 0,
|
|
@@ -30228,7 +30227,7 @@
|
|
|
30228
30227
|
"description": "<p><a href=\"../../?path=/story/components-file-uploader--basic\">See demo</a></p>\n",
|
|
30229
30228
|
"rawdescription": "\n\n[See demo](../../?path=/story/components-file-uploader--basic)\n",
|
|
30230
30229
|
"type": "component",
|
|
30231
|
-
"sourceCode": "import {\n\tComponent,\n\tInput,\n\tOutput,\n\tViewChild,\n\tEventEmitter,\n\tTemplateRef\n} from \"@angular/core\";\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from \"@angular/forms\";\n\nimport { I18n } from \"carbon-components-angular/i18n\";\nimport { FileItem } from \"./file-item.interface\";\n\nconst noop = () => { };\n\n/**\n * [See demo](../../?path=/story/components-file-uploader--basic)\n */\n@Component({\n\tselector: \"cds-file-uploader, ibm-file-uploader\",\n\ttemplate: `\n\t\t<ng-container *ngIf=\"!skeleton; else skeletonTemplate\">\n\t\t\t<label [for]=\"fileUploaderId\" class=\"cds--file--label\">{{title}}</label>\n\t\t\t<p class=\"cds--label-description\">{{description}}</p>\n\t\t\t<div class=\"cds--file\">\n\t\t\t\t<label\n\t\t\t\t\t*ngIf=\"drop\"\n\t\t\t\t\tclass=\"cds--file-browse-btn\"\n\t\t\t\t\t(keyup.enter)=\"fileInput.click()\"\n\t\t\t\t\t(keyup.space)=\"fileInput.click()\"\n\t\t\t\t\t[ngClass]=\"{'cds--file-browse-btn--disabled': disabled}\"\n\t\t\t\t\ttabindex=\"0\">\n\t\t\t\t\t<div\n\t\t\t\t\t\tclass=\"cds--file__drop-container\"\n\t\t\t\t\t\t[ngClass]=\"{'cds--file__drop-container--drag-over': dragOver}\"\n\t\t\t\t\t\trole=\"button\"\n\t\t\t\t\t\t(click)=\"fileInput.click()\"\n\t\t\t\t\t\t[attr.for]=\"fileUploaderId\"\n\t\t\t\t\t\t(dragover)=\"onDragOver($event)\"\n\t\t\t\t\t\t(dragleave)=\"onDragLeave($event)\"\n\t\t\t\t\t\t(drop)=\"onDrop($event)\">\n\t\t\t\t\t\t<ng-container *ngIf=\"!isTemplate(dropText)\">{{dropText}}</ng-container>\n\t\t\t\t\t\t<ng-template *ngIf=\"isTemplate(dropText)\" [ngTemplateOutlet]=\"dropText\"></ng-template>\n\t\t\t\t\t</div>\n\t\t\t\t</label>\n\t\t\t\t<button\n\t\t\t\t\t*ngIf=\"!drop\"\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t[cdsButton]=\"buttonType\"\n\t\t\t\t\t(click)=\"fileInput.click()\"\n\t\t\t\t\t[attr.for]=\"fileUploaderId\"\n\t\t\t\t\t[size]=\"size\"\n\t\t\t\t\t[disabled]=\"disabled\">\n\t\t\t\t\t{{buttonText}}\n\t\t\t\t</button>\n\t\t\t\t<input\n\t\t\t\t\t#fileInput\n\t\t\t\t\ttype=\"file\"\n\t\t\t\t\tclass=\"cds--file-input\"\n\t\t\t\t\t[accept]=\"accept\"\n\t\t\t\t\t[id]=\"fileUploaderId\"\n\t\t\t\t\t[multiple]=\"multiple\"\n\t\t\t\t\ttabindex=\"-1\"\n\t\t\t\t\t(change)=\"onFilesAdded()\"\n\t\t\t\t\t[disabled]=\"disabled\"/>\n\t\t\t\t<div class=\"cds--file-container\">\n\t\t\t\t\t<ng-container *ngFor=\"let fileItem of files\">\n\t\t\t\t\t\t<cds-file\n\t\t\t\t\t\t\t[fileItem]=\"fileItem\"\n\t\t\t\t\t\t\t(remove)=\"removeFile(fileItem)\"\n\t\t\t\t\t\t\t[size]=\"fileItemSize\">\n\t\t\t\t\t\t</cds-file>\n\t\t\t\t\t</ng-container>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</ng-container>\n\n\t\t<ng-template #skeletonTemplate>\n\t\t\t<div class=\"cds--skeleton__text\" style=\"width: 100px\"></div>\n\t\t\t<div class=\"cds--skeleton__text\" style=\"width: 225px\"></div>\n\t\t\t<button cdsButton skeleton=\"true\"></button>\n\t\t</ng-template>\n\t`,\n\tproviders: [\n\t\t{\n\t\t\tprovide: NG_VALUE_ACCESSOR,\n\t\t\tuseExisting: FileUploader,\n\t\t\tmulti: true\n\t\t}\n\t]\n})\nexport class FileUploader implements ControlValueAccessor {\n\t/**\n\t * Counter used to create unique ids for file-uploader components\n\t */\n\tstatic fileUploaderCount = 0;\n\t/**\n\t * Accessible text for the button that opens the upload window.\n\t *\n\t * Defaults to the `FILE_UPLOADER.OPEN` value from the i18n service\n\t */\n\t@Input() buttonText = this.i18n.get().FILE_UPLOADER.OPEN;\n\t/**\n\t * Type set for button\n\t */\n\t@Input() buttonType: \"primary\" | \"secondary\" | \"tertiary\" | \"ghost\" | \"danger\" = \"primary\";\n\t/**\n\t * Text set to the title\n\t */\n\t@Input() title: string;\n\t/**\n\t * Text set to the description\n\t */\n\t@Input() description: string;\n\t/**\n\t * Specify the types of files that the input should be able to receive\n\t */\n\t@Input() accept = [];\n\t/**\n\t * Set to `false` to tell the component to only accept a single file on upload.\n\t *\n\t * Defaults to `true`. Accepts multiple files.\n\t */\n\t@Input() multiple = true;\n\t/**\n\t * Set to `true` for a loading file uploader.\n\t */\n\t@Input() skeleton = false;\n\t/**\n\t * Sets the size of the button.\n\t */\n\t@Input() size: \"sm\" | \"md\" | \"lg\";\n\t/**\n\t * Sets the size of the file items\n\t */\n\t@Input() fileItemSize: \"sm\" | \"md\" | \"lg\" = \"lg\";\n\t/**\n\t * Set to `true` to enable drag and drop.\n\t */\n\t@Input() drop = false;\n\t/**\n\t * Sets the text shown in drag and drop box.\n\t */\n\t@Input() dropText: string | TemplateRef<any>;\n\t/**\n\t * Provides a unique id for the underlying `<input>` node\n\t */\n\t@Input() fileUploaderId = `file-uploader-${FileUploader.fileUploaderCount}`;\n\t/**\n\t * Maintains a reference to the view DOM element of the underlying <input> node\n\t */\n\t@ViewChild(\"fileInput\") fileInput;\n\t/**\n\t * The list of files that have been submitted to be uploaded\n\t */\n\t@Input() files = new Set<FileItem>();\n\t/**\n\t * Set to `true` to disable upload button\n\t */\n\t@Input() disabled = false;\n\n\t@Output() filesChange = new EventEmitter<any>();\n\n\t/**\n\t * Controls the state of the drag and drop file container\n\t */\n\tpublic dragOver = false;\n\n\tprotected onTouchedCallback: () => void = noop;\n\tprotected onChangeCallback: (_: Set<FileItem>) => void = noop;\n\n\tconstructor(protected i18n: I18n) {\n\t\tFileUploader.fileUploaderCount++;\n\t}\n\n\t/**\n\t * Specifies the property to be used as the return value to `ngModel` and reactive forms.\n\t * Updates `this.files`.\n\t */\n\tget value(): Set<FileItem> {\n\t\treturn this.files;\n\t}\n\tset value(v: Set<FileItem>) {\n\t\tif (v !== this.files) {\n\t\t\tthis.files = v;\n\t\t\tthis.onChangeCallback(v);\n\t\t}\n\t}\n\n\tonBlur() {\n\t\tthis.onTouchedCallback();\n\t}\n\n\tget fileList() {\n\t\treturn Array.from(this.fileInput.nativeElement.files);\n\t}\n\n\t/**\n\t * Propagates the injected `value`.\n\t */\n\twriteValue(value: Set<FileItem>) {\n\t\tif (value !== this.value) {\n\t\t\tthis.files = value;\n\t\t}\n\t}\n\n\tcreateFileItem(file): FileItem {\n\t\treturn {\n\t\t\tuploaded: false,\n\t\t\tstate: \"edit\",\n\t\t\tinvalid: false,\n\t\t\tinvalidText: \"\",\n\t\t\tfile: file\n\t\t};\n\t}\n\n\tonFilesAdded() {\n\t\tconst newFiles = new Set<FileItem>(this.files);\n\t\tif (!this.multiple) {\n\t\t\tnewFiles.clear();\n\t\t}\n\t\tfor (let file of this.fileList) {\n\t\t\tconst fileItem = this.createFileItem(file);\n\t\t\tnewFiles.add(fileItem);\n\t\t}\n\n\t\tthis.value = newFiles;\n\t\tthis.filesChange.emit(newFiles);\n\t}\n\n\tonDragOver(event) {\n\t\tevent.stopPropagation();\n\t\tevent.preventDefault();\n\t\tif (this.disabled) {\n\t\t\treturn;\n\t\t}\n\t\tthis.dragOver = true;\n\t}\n\n\tonDragLeave(event) {\n\t\tevent.stopPropagation();\n\t\tevent.preventDefault();\n\t\tthis.dragOver = false;\n\t}\n\n\tonDrop(event) {\n\t\tevent.stopPropagation();\n\t\tevent.preventDefault();\n\t\tif (this.disabled) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst transferredFiles: Array<File> = Array.from(event.dataTransfer.files);\n\t\tconst newFiles = new Set<FileItem>(this.files);\n\n\t\ttransferredFiles.filter(({ name, type }) => {\n\t\t\t// Get the file extension and add a \".\" to the beginning.\n\t\t\tconst fileExtension = name.split(\".\").pop().replace(/^/, \".\");\n\t\t\t// Check if the accept array contains the mime type or extension of the file.\n\t\t\treturn this.accept.includes(type) || this.accept.includes(fileExtension) || !this.accept.length;\n\t\t}).forEach(file => {\n\t\t\tif (!newFiles.size || this.multiple) {\n\t\t\t\tconst fileItem = this.createFileItem(file);\n\t\t\t\tnewFiles.add(fileItem);\n\t\t\t}\n\t\t});\n\n\t\tthis.value = newFiles;\n\t\tthis.filesChange.emit(newFiles);\n\t\tthis.dragOver = false;\n\t}\n\n\tremoveFile(fileItem) {\n\t\t// Deleting an item from this.files removes the <ibm-file> component,\n\t\t// which triggers its ngOnDestroy(), which fires the (remove) event again.\n\t\t// So, (remove) may double-fire and we need to handle it here.\n\t\tif (this.files && this.files.has(fileItem)) {\n\t\t\tconst newFiles = new Set<FileItem>(this.files);\n\t\t\tnewFiles.delete(fileItem);\n\t\t\tthis.filesChange.emit(newFiles);\n\t\t\tthis.value = newFiles;\n\t\t}\n\t\tthis.fileInput.nativeElement.value = \"\";\n\t}\n\n\tpublic isTemplate(value) {\n\t\treturn value instanceof TemplateRef;\n\t}\n\n\t/**\n\t * Registers the injected function to control the touch use of the `FileUploader`.\n\t */\n\tregisterOnTouched(fn: any) {\n\t\tthis.onTouchedCallback = fn;\n\t}\n\t/**\n\t * Sets a method in order to propagate changes back to the form.\n\t */\n\tregisterOnChange(fn: any) {\n\t\tthis.onChangeCallback = fn;\n\t}\n\n\t/**\n\t * `ControlValueAccessor` method to programmatically disable the checkbox.\n\t *\n\t * ex: `this.formGroup.get(\"myFileUploader\").disable();`\n\t *\n\t * @param isDisabled `true` to disable the file uploader\n\t */\n\tsetDisabledState(isDisabled: boolean) {\n\t\tthis.disabled = isDisabled;\n\t}\n}\n",
|
|
30230
|
+
"sourceCode": "import {\n\tComponent,\n\tInput,\n\tOutput,\n\tViewChild,\n\tEventEmitter,\n\tTemplateRef\n} from \"@angular/core\";\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from \"@angular/forms\";\n\nimport { I18n } from \"carbon-components-angular/i18n\";\nimport { FileItem } from \"./file-item.interface\";\n\nconst noop = () => { };\n\n/**\n * [See demo](../../?path=/story/components-file-uploader--basic)\n */\n@Component({\n\tselector: \"cds-file-uploader, ibm-file-uploader\",\n\ttemplate: `\n\t\t<ng-container *ngIf=\"!skeleton; else skeletonTemplate\">\n\t\t\t<label [for]=\"fileUploaderId\" class=\"cds--file--label\">{{title}}</label>\n\t\t\t<p class=\"cds--label-description\" role=\"alert\">{{description}}</p>\n\t\t\t<div class=\"cds--file\">\n\t\t\t\t<label\n\t\t\t\t\t*ngIf=\"drop\"\n\t\t\t\t\tclass=\"cds--file-browse-btn\"\n\t\t\t\t\t(keyup.enter)=\"fileInput.click()\"\n\t\t\t\t\t(keyup.space)=\"fileInput.click()\"\n\t\t\t\t\t[ngClass]=\"{'cds--file-browse-btn--disabled': disabled}\"\n\t\t\t\t\ttabindex=\"0\">\n\t\t\t\t\t<div\n\t\t\t\t\t\tclass=\"cds--file__drop-container\"\n\t\t\t\t\t\t[ngClass]=\"{'cds--file__drop-container--drag-over': dragOver}\"\n\t\t\t\t\t\trole=\"button\"\n\t\t\t\t\t\t(click)=\"fileInput.click()\"\n\t\t\t\t\t\t[attr.for]=\"fileUploaderId\"\n\t\t\t\t\t\t(dragover)=\"onDragOver($event)\"\n\t\t\t\t\t\t(dragleave)=\"onDragLeave($event)\"\n\t\t\t\t\t\t(drop)=\"onDrop($event)\">\n\t\t\t\t\t\t<ng-container *ngIf=\"!isTemplate(dropText)\">{{dropText}}</ng-container>\n\t\t\t\t\t\t<ng-template *ngIf=\"isTemplate(dropText)\" [ngTemplateOutlet]=\"dropText\"></ng-template>\n\t\t\t\t\t</div>\n\t\t\t\t</label>\n\t\t\t\t<button\n\t\t\t\t\t*ngIf=\"!drop\"\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t[cdsButton]=\"buttonType\"\n\t\t\t\t\t(click)=\"fileInput.click()\"\n\t\t\t\t\t[attr.for]=\"fileUploaderId\"\n\t\t\t\t\t[size]=\"size\"\n\t\t\t\t\t[disabled]=\"disabled\">\n\t\t\t\t\t{{buttonText}}\n\t\t\t\t</button>\n\t\t\t\t<input\n\t\t\t\t\t#fileInput\n\t\t\t\t\ttype=\"file\"\n\t\t\t\t\tclass=\"cds--file-input\"\n\t\t\t\t\t[accept]=\"accept\"\n\t\t\t\t\t[id]=\"fileUploaderId\"\n\t\t\t\t\t[multiple]=\"multiple\"\n\t\t\t\t\ttabindex=\"-1\"\n\t\t\t\t\t(change)=\"onFilesAdded()\"\n\t\t\t\t\t[disabled]=\"disabled\"/>\n\t\t\t\t<div class=\"cds--file-container\">\n\t\t\t\t\t<ng-container *ngFor=\"let fileItem of files\">\n\t\t\t\t\t\t<cds-file\n\t\t\t\t\t\t\t[fileItem]=\"fileItem\"\n\t\t\t\t\t\t\t(remove)=\"removeFile(fileItem)\"\n\t\t\t\t\t\t\t[size]=\"fileItemSize\">\n\t\t\t\t\t\t</cds-file>\n\t\t\t\t\t</ng-container>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</ng-container>\n\n\t\t<ng-template #skeletonTemplate>\n\t\t\t<div class=\"cds--skeleton__text\" style=\"width: 100px\"></div>\n\t\t\t<div class=\"cds--skeleton__text\" style=\"width: 225px\"></div>\n\t\t\t<button cdsButton skeleton=\"true\"></button>\n\t\t</ng-template>\n\t`,\n\tproviders: [\n\t\t{\n\t\t\tprovide: NG_VALUE_ACCESSOR,\n\t\t\tuseExisting: FileUploader,\n\t\t\tmulti: true\n\t\t}\n\t]\n})\nexport class FileUploader implements ControlValueAccessor {\n\t/**\n\t * Counter used to create unique ids for file-uploader components\n\t */\n\tstatic fileUploaderCount = 0;\n\t/**\n\t * Accessible text for the button that opens the upload window.\n\t *\n\t * Defaults to the `FILE_UPLOADER.OPEN` value from the i18n service\n\t */\n\t@Input() buttonText = this.i18n.get().FILE_UPLOADER.OPEN;\n\t/**\n\t * Type set for button\n\t */\n\t@Input() buttonType: \"primary\" | \"secondary\" | \"tertiary\" | \"ghost\" | \"danger\" = \"primary\";\n\t/**\n\t * Text set to the title\n\t */\n\t@Input() title: string;\n\t/**\n\t * Text set to the description\n\t */\n\t@Input() description: string;\n\t/**\n\t * Specify the types of files that the input should be able to receive\n\t */\n\t@Input() accept = [];\n\t/**\n\t * Set to `false` to tell the component to only accept a single file on upload.\n\t *\n\t * Defaults to `true`. Accepts multiple files.\n\t */\n\t@Input() multiple = true;\n\t/**\n\t * Set to `true` for a loading file uploader.\n\t */\n\t@Input() skeleton = false;\n\t/**\n\t * Sets the size of the button.\n\t */\n\t@Input() size: \"sm\" | \"md\" | \"lg\";\n\t/**\n\t * Sets the size of the file items\n\t */\n\t@Input() fileItemSize: \"sm\" | \"md\" | \"lg\" = \"lg\";\n\t/**\n\t * Set to `true` to enable drag and drop.\n\t */\n\t@Input() drop = false;\n\t/**\n\t * Sets the text shown in drag and drop box.\n\t */\n\t@Input() dropText: string | TemplateRef<any>;\n\t/**\n\t * Provides a unique id for the underlying `<input>` node\n\t */\n\t@Input() fileUploaderId = `file-uploader-${FileUploader.fileUploaderCount}`;\n\t/**\n\t * Maintains a reference to the view DOM element of the underlying <input> node\n\t */\n\t@ViewChild(\"fileInput\") fileInput;\n\t/**\n\t * The list of files that have been submitted to be uploaded\n\t */\n\t@Input() files = new Set<FileItem>();\n\t/**\n\t * Set to `true` to disable upload button\n\t */\n\t@Input() disabled = false;\n\n\t@Output() filesChange = new EventEmitter<any>();\n\n\t/**\n\t * Controls the state of the drag and drop file container\n\t */\n\tpublic dragOver = false;\n\n\tprotected onTouchedCallback: () => void = noop;\n\tprotected onChangeCallback: (_: Set<FileItem>) => void = noop;\n\n\tconstructor(protected i18n: I18n) {\n\t\tFileUploader.fileUploaderCount++;\n\t}\n\n\t/**\n\t * Specifies the property to be used as the return value to `ngModel` and reactive forms.\n\t * Updates `this.files`.\n\t */\n\tget value(): Set<FileItem> {\n\t\treturn this.files;\n\t}\n\tset value(v: Set<FileItem>) {\n\t\tif (v !== this.files) {\n\t\t\tthis.files = v;\n\t\t\tthis.onChangeCallback(v);\n\t\t}\n\t}\n\n\tonBlur() {\n\t\tthis.onTouchedCallback();\n\t}\n\n\tget fileList() {\n\t\treturn Array.from(this.fileInput.nativeElement.files);\n\t}\n\n\t/**\n\t * Propagates the injected `value`.\n\t */\n\twriteValue(value: Set<FileItem>) {\n\t\tif (value !== this.value) {\n\t\t\tthis.files = value;\n\t\t}\n\t}\n\n\tcreateFileItem(file): FileItem {\n\t\treturn {\n\t\t\tuploaded: false,\n\t\t\tstate: \"edit\",\n\t\t\tinvalid: false,\n\t\t\tinvalidText: \"\",\n\t\t\tfile: file\n\t\t};\n\t}\n\n\tonFilesAdded() {\n\t\tconst newFiles = new Set<FileItem>(this.files);\n\t\tif (!this.multiple) {\n\t\t\tnewFiles.clear();\n\t\t}\n\t\tfor (let file of this.fileList) {\n\t\t\tconst fileItem = this.createFileItem(file);\n\t\t\tnewFiles.add(fileItem);\n\t\t}\n\n\t\tthis.value = newFiles;\n\t\tthis.filesChange.emit(newFiles);\n\t}\n\n\tonDragOver(event) {\n\t\tevent.stopPropagation();\n\t\tevent.preventDefault();\n\t\tif (this.disabled) {\n\t\t\treturn;\n\t\t}\n\t\tthis.dragOver = true;\n\t}\n\n\tonDragLeave(event) {\n\t\tevent.stopPropagation();\n\t\tevent.preventDefault();\n\t\tthis.dragOver = false;\n\t}\n\n\tonDrop(event) {\n\t\tevent.stopPropagation();\n\t\tevent.preventDefault();\n\t\tif (this.disabled) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst transferredFiles: Array<File> = Array.from(event.dataTransfer.files);\n\t\tconst newFiles = new Set<FileItem>(this.files);\n\n\t\ttransferredFiles.filter(({ name, type }) => {\n\t\t\t// Get the file extension and add a \".\" to the beginning.\n\t\t\tconst fileExtension = name.split(\".\").pop().replace(/^/, \".\");\n\t\t\t// Check if the accept array contains the mime type or extension of the file.\n\t\t\treturn this.accept.includes(type) || this.accept.includes(fileExtension) || !this.accept.length;\n\t\t}).forEach(file => {\n\t\t\tif (!newFiles.size || this.multiple) {\n\t\t\t\tconst fileItem = this.createFileItem(file);\n\t\t\t\tnewFiles.add(fileItem);\n\t\t\t}\n\t\t});\n\n\t\tthis.value = newFiles;\n\t\tthis.filesChange.emit(newFiles);\n\t\tthis.dragOver = false;\n\t}\n\n\tremoveFile(fileItem) {\n\t\t// Deleting an item from this.files removes the <ibm-file> component,\n\t\t// which triggers its ngOnDestroy(), which fires the (remove) event again.\n\t\t// So, (remove) may double-fire and we need to handle it here.\n\t\tif (this.files && this.files.has(fileItem)) {\n\t\t\tconst newFiles = new Set<FileItem>(this.files);\n\t\t\tnewFiles.delete(fileItem);\n\t\t\tthis.filesChange.emit(newFiles);\n\t\t\tthis.value = newFiles;\n\t\t}\n\t\tthis.fileInput.nativeElement.value = \"\";\n\t}\n\n\tpublic isTemplate(value) {\n\t\treturn value instanceof TemplateRef;\n\t}\n\n\t/**\n\t * Registers the injected function to control the touch use of the `FileUploader`.\n\t */\n\tregisterOnTouched(fn: any) {\n\t\tthis.onTouchedCallback = fn;\n\t}\n\t/**\n\t * Sets a method in order to propagate changes back to the form.\n\t */\n\tregisterOnChange(fn: any) {\n\t\tthis.onChangeCallback = fn;\n\t}\n\n\t/**\n\t * `ControlValueAccessor` method to programmatically disable the checkbox.\n\t *\n\t * ex: `this.formGroup.get(\"myFileUploader\").disable();`\n\t *\n\t * @param isDisabled `true` to disable the file uploader\n\t */\n\tsetDisabledState(isDisabled: boolean) {\n\t\tthis.disabled = isDisabled;\n\t}\n}\n",
|
|
30232
30231
|
"assetsDirs": [],
|
|
30233
30232
|
"styleUrlsData": "",
|
|
30234
30233
|
"stylesData": "",
|