@ukic/canary-web-components 2.0.0-canary.37 → 2.0.0-canary.39
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/dist/cjs/core.cjs.js +1 -1
- package/dist/cjs/ic-data-table.cjs.entry.js +6 -2
- package/dist/cjs/ic-data-table.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-date-picker.cjs.entry.js +110 -57
- package/dist/cjs/ic-date-picker.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-navigation-group.cjs.entry.js +9 -0
- package/dist/cjs/ic-navigation-group.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-radio-option.cjs.entry.js +1 -1
- package/dist/cjs/ic-radio-option.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-tree-item.cjs.entry.js +1 -1
- package/dist/cjs/ic-tree-item.cjs.entry.js.map +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/ic-card-horizontal/ic-card-horizontal.stories.js +605 -0
- package/dist/collection/components/ic-card-horizontal/ic-card-horizontal.stories.js.map +1 -0
- package/dist/collection/components/ic-data-table/ic-data-table.js +6 -2
- package/dist/collection/components/ic-data-table/ic-data-table.js.map +1 -1
- package/dist/collection/components/ic-data-table/ic-data-table.stories.js +414 -0
- package/dist/collection/components/ic-data-table/ic-data-table.stories.js.map +1 -0
- package/dist/collection/components/ic-data-table/story-data.js +155 -0
- package/dist/collection/components/ic-data-table/story-data.js.map +1 -1
- package/dist/collection/components/ic-data-table-title-bar/ic-data-table-title-bar.stories.js +98 -0
- package/dist/collection/components/ic-data-table-title-bar/ic-data-table-title-bar.stories.js.map +1 -0
- package/dist/collection/components/ic-date-input/ic-date-input.stories.js +341 -0
- package/dist/collection/components/ic-date-input/ic-date-input.stories.js.map +1 -0
- package/dist/collection/components/ic-date-picker/ic-date-picker.css +10 -3
- package/dist/collection/components/ic-date-picker/ic-date-picker.js +152 -57
- package/dist/collection/components/ic-date-picker/ic-date-picker.js.map +1 -1
- package/dist/collection/components/ic-date-picker/ic-date-picker.stories.js +167 -0
- package/dist/collection/components/ic-date-picker/ic-date-picker.stories.js.map +1 -0
- package/dist/collection/components/ic-date-picker/story-data.js +34 -3
- package/dist/collection/components/ic-date-picker/story-data.js.map +1 -1
- package/dist/collection/components/ic-pagination-bar/ic-pagination-bar.stories.js +260 -0
- package/dist/collection/components/ic-pagination-bar/ic-pagination-bar.stories.js.map +1 -0
- package/dist/collection/components/ic-select-with-multi/ic-select-multi.stories.js +144 -0
- package/dist/collection/components/ic-select-with-multi/ic-select-multi.stories.js.map +1 -0
- package/dist/collection/components/ic-tree-item/ic-tree-item.css +22 -3
- package/dist/collection/components/ic-tree-view/ic-tree-view.stories.js +456 -0
- package/dist/collection/components/ic-tree-view/ic-tree-view.stories.js.map +1 -0
- package/dist/components/ic-data-table.js +6 -2
- package/dist/components/ic-data-table.js.map +1 -1
- package/dist/components/ic-date-picker.js +112 -57
- package/dist/components/ic-date-picker.js.map +1 -1
- package/dist/components/ic-navigation-group.js +11 -2
- package/dist/components/ic-navigation-group.js.map +1 -1
- package/dist/components/ic-radio-option.js +1 -1
- package/dist/components/ic-radio-option.js.map +1 -1
- package/dist/components/ic-tree-item.js +1 -1
- package/dist/components/ic-tree-item.js.map +1 -1
- package/dist/core/core.esm.js +1 -1
- package/dist/core/core.esm.js.map +1 -1
- package/dist/core/p-04fe848d.entry.js +2 -0
- package/dist/core/p-04fe848d.entry.js.map +1 -0
- package/dist/core/{p-b4f824a6.entry.js → p-3ebd4703.entry.js} +2 -2
- package/dist/core/p-3ebd4703.entry.js.map +1 -0
- package/dist/core/p-bd0328f3.entry.js +2 -0
- package/dist/core/p-bd0328f3.entry.js.map +1 -0
- package/dist/core/p-cc0e0b46.entry.js +2 -0
- package/dist/core/p-cc0e0b46.entry.js.map +1 -0
- package/dist/core/p-fac387e8.entry.js +2 -0
- package/dist/core/p-fac387e8.entry.js.map +1 -0
- package/dist/esm/core.js +1 -1
- package/dist/esm/ic-data-table.entry.js +6 -2
- package/dist/esm/ic-data-table.entry.js.map +1 -1
- package/dist/esm/ic-date-picker.entry.js +110 -57
- package/dist/esm/ic-date-picker.entry.js.map +1 -1
- package/dist/esm/ic-navigation-group.entry.js +10 -1
- package/dist/esm/ic-navigation-group.entry.js.map +1 -1
- package/dist/esm/ic-radio-option.entry.js +1 -1
- package/dist/esm/ic-radio-option.entry.js.map +1 -1
- package/dist/esm/ic-tree-item.entry.js +1 -1
- package/dist/esm/ic-tree-item.entry.js.map +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/types/components/ic-card-horizontal/ic-card-horizontal.stories.d.ts +82 -0
- package/dist/types/components/ic-data-table/ic-data-table.stories.d.ts +239 -0
- package/dist/types/components/ic-data-table/story-data.d.ts +57 -0
- package/dist/types/components/ic-data-table-title-bar/ic-data-table-title-bar.stories.d.ts +47 -0
- package/dist/types/components/ic-date-input/ic-date-input.stories.d.ts +124 -0
- package/dist/types/components/ic-date-picker/ic-date-picker.d.ts +18 -1
- package/dist/types/components/ic-date-picker/ic-date-picker.stories.d.ts +153 -0
- package/dist/types/components/ic-date-picker/story-data.d.ts +2 -0
- package/dist/types/components/ic-pagination-bar/ic-pagination-bar.stories.d.ts +106 -0
- package/dist/types/components/ic-select-with-multi/ic-select-multi.stories.d.ts +106 -0
- package/dist/types/components/ic-tree-view/ic-tree-view.stories.d.ts +99 -0
- package/dist/types/components.d.ts +13 -0
- package/hydrate/index.js +129 -62
- package/package.json +12 -12
- package/dist/core/p-4084bce2.entry.js +0 -2
- package/dist/core/p-4084bce2.entry.js.map +0 -1
- package/dist/core/p-71bbb583.entry.js +0 -2
- package/dist/core/p-71bbb583.entry.js.map +0 -1
- package/dist/core/p-89112e37.entry.js +0 -2
- package/dist/core/p-89112e37.entry.js.map +0 -1
- package/dist/core/p-b4f824a6.entry.js.map +0 -1
- package/dist/core/p-fe105ed0.entry.js +0 -2
- package/dist/core/p-fe105ed0.entry.js.map +0 -1
@@ -0,0 +1,98 @@
|
|
1
|
+
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
2
|
+
import { html } from "lit-html";
|
3
|
+
import readme from "./readme.md";
|
4
|
+
export default {
|
5
|
+
title: "Web Components/Data Table Title Bar",
|
6
|
+
component: "ic-data-table-title-bar",
|
7
|
+
parameters: {
|
8
|
+
componentAPI: {
|
9
|
+
data: readme,
|
10
|
+
},
|
11
|
+
},
|
12
|
+
};
|
13
|
+
/**
|
14
|
+
* Use the data table title bar component to provide titling, description, metadata and also global table functionality.
|
15
|
+
*
|
16
|
+
* By default, the density selector appears within the data table title bar. The three density options are:
|
17
|
+
* - Default
|
18
|
+
* - Dense
|
19
|
+
* - Spacious
|
20
|
+
*/
|
21
|
+
export const Basic = {
|
22
|
+
render: () => html `<ic-data-table-title-bar
|
23
|
+
heading="Title Bar"
|
24
|
+
></ic-data-table-title-bar>`,
|
25
|
+
name: "Basic",
|
26
|
+
height: "220px",
|
27
|
+
};
|
28
|
+
/**
|
29
|
+
* Custom elements can be passed into the areas which contain the title bar heading and description. This flexibility allows the heading tag to be updated if the default heading level (i.e. `h3`) is not semantically correct.
|
30
|
+
*/
|
31
|
+
export const Slots = {
|
32
|
+
render: () => html `
|
33
|
+
<ic-data-table-title-bar>
|
34
|
+
<ic-typography slot="heading" variant="h1"
|
35
|
+
><h3>Title Bar</h3></ic-typography
|
36
|
+
>
|
37
|
+
<div slot="description">
|
38
|
+
<ic-chip label="Chip"></ic-chip>
|
39
|
+
<ic-chip label="Chip"></ic-chip>
|
40
|
+
</div>
|
41
|
+
</ic-data-table-title-bar>
|
42
|
+
`,
|
43
|
+
name: "Slots",
|
44
|
+
height: "220px",
|
45
|
+
};
|
46
|
+
/**
|
47
|
+
* Data table metadata and description can be added to the data table title bar via the `metadata` and `description` props.
|
48
|
+
*/
|
49
|
+
export const WithMetadataAndDescription = {
|
50
|
+
render: () => html `<ic-data-table-title-bar
|
51
|
+
heading="Title Bar"
|
52
|
+
metadata="128 items | 32gb | Updated: 01/02/03"
|
53
|
+
description="Data table description that describes the purpose of the table."
|
54
|
+
></ic-data-table-title-bar>`,
|
55
|
+
name: "With metadata and description",
|
56
|
+
height: "220px",
|
57
|
+
};
|
58
|
+
/**
|
59
|
+
* By default, the density selector is displayed on the data table title bar. To hide it, set `hide-density-select` to `true`.
|
60
|
+
*/
|
61
|
+
export const HideDensitySelector = {
|
62
|
+
render: () => html `<ic-data-table-title-bar
|
63
|
+
hide-density-select="true"
|
64
|
+
heading="Title Bar"
|
65
|
+
metadata="128 items | 32gb | Updated: 01/02/03"
|
66
|
+
description="Data table description that describes the purpose of the table."
|
67
|
+
></ic-data-table-title-bar>`,
|
68
|
+
name: "Hide density selector",
|
69
|
+
};
|
70
|
+
/**
|
71
|
+
* Custom actions can be added to the data table title bar via slots. There are two slots available:
|
72
|
+
* - `primary-action` is suitable for a primary button. The custom element will appear to the right of the data table title bar.
|
73
|
+
* - `custom-actions` can be used for secondary actions. The custom element will appear to the left of the density selector if displayed.
|
74
|
+
*/
|
75
|
+
export const CustomActions = {
|
76
|
+
render: () => html `<ic-data-table-title-bar
|
77
|
+
heading="Title Bar"
|
78
|
+
metadata="128 items | 32gb | Updated: 01/02/03"
|
79
|
+
description="Data table description that describes the purpose of the table."
|
80
|
+
>
|
81
|
+
<ic-button slot="primary-action" size="small">Primary</ic-button>
|
82
|
+
<ic-button slot="custom-actions" variant="icon" aria-label="Icon Button">
|
83
|
+
<svg
|
84
|
+
xmlns="http://www.w3.org/2000/svg"
|
85
|
+
height="24"
|
86
|
+
viewBox="0 -960 960 960"
|
87
|
+
width="24"
|
88
|
+
>
|
89
|
+
<path
|
90
|
+
d="M180-120q-24 0-42-18t-18-42v-600q0-24 18-42t42-18h600q24 0 42 18t18 42v600q0 24-18 42t-42 18H180Zm0-60h600v-600H180v600Zm56-97h489L578-473 446-302l-93-127-117 152Zm-56 97v-600 600Z"
|
91
|
+
/>
|
92
|
+
</svg>
|
93
|
+
</ic-button>
|
94
|
+
</ic-data-table-title-bar>`,
|
95
|
+
name: "Custom actions",
|
96
|
+
height: "220px",
|
97
|
+
};
|
98
|
+
//# sourceMappingURL=ic-data-table-title-bar.stories.js.map
|
package/dist/collection/components/ic-data-table-title-bar/ic-data-table-title-bar.stories.js.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ic-data-table-title-bar.stories.js","sourceRoot":"","sources":["../../../src/components/ic-data-table-title-bar/ic-data-table-title-bar.stories.js"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,eAAe;IACb,KAAK,EAAE,qCAAqC;IAC5C,SAAS,EAAE,yBAAyB;IAEpC,UAAU,EAAE;QACV,YAAY,EAAE;YACZ,IAAI,EAAE,MAAM;SACb;KACF;CACF,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,MAAM,EAAE,GAAG,EAAE,CACX,IAAI,CAAA;;gCAEwB;IAE9B,IAAI,EAAE,OAAO;IACb,MAAM,EAAE,OAAO;CAChB,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAA;;;;;;;;;;GAUjB;IAED,IAAI,EAAE,OAAO;IACb,MAAM,EAAE,OAAO;CAChB,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,MAAM,EAAE,GAAG,EAAE,CACX,IAAI,CAAA;;;;gCAIwB;IAE9B,IAAI,EAAE,+BAA+B;IACrC,MAAM,EAAE,OAAO;CAChB,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,MAAM,EAAE,GAAG,EAAE,CACX,IAAI,CAAA;;;;;gCAKwB;IAE9B,IAAI,EAAE,uBAAuB;CAC9B,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,MAAM,EAAE,GAAG,EAAE,CACX,IAAI,CAAA;;;;;;;;;;;;;;;;;;+BAkBuB;IAE7B,IAAI,EAAE,gBAAgB;IACtB,MAAM,EAAE,OAAO;CAChB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/explicit-module-boundary-types */\nimport { html } from \"lit-html\";\nimport readme from \"./readme.md\";\n\nexport default {\n title: \"Web Components/Data Table Title Bar\",\n component: \"ic-data-table-title-bar\",\n\n parameters: {\n componentAPI: {\n data: readme,\n },\n },\n};\n\n/**\n * Use the data table title bar component to provide titling, description, metadata and also global table functionality.\n *\n * By default, the density selector appears within the data table title bar. The three density options are:\n * - Default\n * - Dense\n * - Spacious\n */\nexport const Basic = {\n render: () =>\n html`<ic-data-table-title-bar\n heading=\"Title Bar\"\n ></ic-data-table-title-bar>`,\n\n name: \"Basic\",\n height: \"220px\",\n};\n\n/**\n * Custom elements can be passed into the areas which contain the title bar heading and description. This flexibility allows the heading tag to be updated if the default heading level (i.e. `h3`) is not semantically correct.\n */\nexport const Slots = {\n render: () => html`\n <ic-data-table-title-bar>\n <ic-typography slot=\"heading\" variant=\"h1\"\n ><h3>Title Bar</h3></ic-typography\n >\n <div slot=\"description\">\n <ic-chip label=\"Chip\"></ic-chip>\n <ic-chip label=\"Chip\"></ic-chip>\n </div>\n </ic-data-table-title-bar>\n `,\n\n name: \"Slots\",\n height: \"220px\",\n};\n\n/**\n * Data table metadata and description can be added to the data table title bar via the `metadata` and `description` props.\n */\nexport const WithMetadataAndDescription = {\n render: () =>\n html`<ic-data-table-title-bar\n heading=\"Title Bar\"\n metadata=\"128 items | 32gb | Updated: 01/02/03\"\n description=\"Data table description that describes the purpose of the table.\"\n ></ic-data-table-title-bar>`,\n\n name: \"With metadata and description\",\n height: \"220px\",\n};\n\n/**\n * By default, the density selector is displayed on the data table title bar. To hide it, set `hide-density-select` to `true`.\n */\nexport const HideDensitySelector = {\n render: () =>\n html`<ic-data-table-title-bar\n hide-density-select=\"true\"\n heading=\"Title Bar\"\n metadata=\"128 items | 32gb | Updated: 01/02/03\"\n description=\"Data table description that describes the purpose of the table.\"\n ></ic-data-table-title-bar>`,\n\n name: \"Hide density selector\",\n};\n\n/**\n * Custom actions can be added to the data table title bar via slots. There are two slots available:\n * - `primary-action` is suitable for a primary button. The custom element will appear to the right of the data table title bar.\n * - `custom-actions` can be used for secondary actions. The custom element will appear to the left of the density selector if displayed.\n */\nexport const CustomActions = {\n render: () =>\n html`<ic-data-table-title-bar\n heading=\"Title Bar\"\n metadata=\"128 items | 32gb | Updated: 01/02/03\"\n description=\"Data table description that describes the purpose of the table.\"\n >\n <ic-button slot=\"primary-action\" size=\"small\">Primary</ic-button>\n <ic-button slot=\"custom-actions\" variant=\"icon\" aria-label=\"Icon Button\">\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n height=\"24\"\n viewBox=\"0 -960 960 960\"\n width=\"24\"\n >\n <path\n d=\"M180-120q-24 0-42-18t-18-42v-600q0-24 18-42t42-18h600q24 0 42 18t18 42v600q0 24-18 42t-42 18H180Zm0-60h600v-600H180v600Zm56-97h489L578-473 446-302l-93-127-117 152Zm-56 97v-600 600Z\"\n />\n </svg>\n </ic-button>\n </ic-data-table-title-bar>`,\n\n name: \"Custom actions\",\n height: \"220px\",\n};\n"]}
|
@@ -0,0 +1,341 @@
|
|
1
|
+
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
2
|
+
import { createDateInputForm } from "./story-data";
|
3
|
+
import { html } from "lit-html";
|
4
|
+
import readme from "./readme.md";
|
5
|
+
export default {
|
6
|
+
title: "Web Components/Date Input",
|
7
|
+
component: "ic-date-input",
|
8
|
+
parameters: {
|
9
|
+
componentAPI: {
|
10
|
+
data: readme,
|
11
|
+
},
|
12
|
+
},
|
13
|
+
};
|
14
|
+
/**
|
15
|
+
* Use the date input component to manually type in a date in different formats.
|
16
|
+
* The input `label` is the only required attribute for date input.
|
17
|
+
*
|
18
|
+
* Click the 'Component API' tab to view all the available attributes, events and slots for date input.
|
19
|
+
* To use the date input component, import `@ukic/canary-web-components` into your application.
|
20
|
+
*
|
21
|
+
* Each example below demonstrates the date input in three different date formats:
|
22
|
+
* - DD/MM/YYYY (Default date format)
|
23
|
+
* - MM/DD/YYYY
|
24
|
+
* - YYYY/MM/DD
|
25
|
+
*
|
26
|
+
* Dates can be added by manually typing into the input or using the up and down arrow keys.
|
27
|
+
* To move between day, month and year using the keyboard, provide the required values based on the placeholders or use `/` or `-`.
|
28
|
+
*
|
29
|
+
* By default, the helper text displays the date format.
|
30
|
+
*/
|
31
|
+
export const Default = {
|
32
|
+
render: () => html `<ic-date-input
|
33
|
+
label="When would you like to collect your coffee?"
|
34
|
+
></ic-date-input>
|
35
|
+
<script>
|
36
|
+
var dateInput = document.querySelector("ic-date-input");
|
37
|
+
{
|
38
|
+
dateInput.addEventListener("icChange", function (event) {
|
39
|
+
console.log("icChange", event.detail.value);
|
40
|
+
});
|
41
|
+
}
|
42
|
+
</script>
|
43
|
+
<br />
|
44
|
+
<br />
|
45
|
+
<ic-date-input
|
46
|
+
label="When would you like to collect your coffee?"
|
47
|
+
date-format="MM/DD/YYYY"
|
48
|
+
></ic-date-input>
|
49
|
+
<br />
|
50
|
+
<br />
|
51
|
+
<ic-date-input
|
52
|
+
label="When would you like to collect your coffee?"
|
53
|
+
date-format="YYYY/MM/DD"
|
54
|
+
></ic-date-input> `,
|
55
|
+
name: "Default",
|
56
|
+
};
|
57
|
+
/**
|
58
|
+
* Retrieving the date input value via `icChange` returns the date as a Date object. The event returns the Date object once day, month and year have been entered.
|
59
|
+
*/
|
60
|
+
export const IcChangeEvent = {
|
61
|
+
render: () => html `<ic-date-input
|
62
|
+
label="When would you like to collect your coffee?"
|
63
|
+
></ic-date-input>
|
64
|
+
<script>
|
65
|
+
var dateInput = document.querySelector("ic-date-input");
|
66
|
+
dateInput.addEventListener("icChange", function (event) {
|
67
|
+
console.log(event.detail.value);
|
68
|
+
});
|
69
|
+
</script>`,
|
70
|
+
name: "icChange event",
|
71
|
+
};
|
72
|
+
/**
|
73
|
+
* To set a value to the date input, pass the date value in the relevant date format.
|
74
|
+
*/
|
75
|
+
export const WithValue = {
|
76
|
+
render: () => html `<ic-date-input
|
77
|
+
id="date-input-default-date-with-value"
|
78
|
+
label="When would you like to collect your coffee?"
|
79
|
+
date-format="DD/MM/YYYY"
|
80
|
+
value="21/01/2001"
|
81
|
+
></ic-date-input>`,
|
82
|
+
name: "With value",
|
83
|
+
};
|
84
|
+
/**
|
85
|
+
* The date input also accepts a number of different date formats within the value attribute:
|
86
|
+
* - [Date object](#date-object)
|
87
|
+
* - [Zulu datetime](#zulu-time)
|
88
|
+
* - [With hyphens (DD-MM-YYYY)](#with-hyphens)
|
89
|
+
* - [Epoch time](#epoch-time)
|
90
|
+
*/
|
91
|
+
export const DateObject = {
|
92
|
+
render: () => html `<ic-date-input
|
93
|
+
id="date-input-default-date-date"
|
94
|
+
label="When would you like to collect your coffee?"
|
95
|
+
></ic-date-input>
|
96
|
+
<script>
|
97
|
+
var dateInputDate = document.querySelector(
|
98
|
+
"#date-input-default-date-date"
|
99
|
+
);
|
100
|
+
dateInputDate.value = new Date("28 November 2021");
|
101
|
+
</script>`,
|
102
|
+
name: "Date object",
|
103
|
+
};
|
104
|
+
export const ZuluTime = {
|
105
|
+
render: () => html `<div>
|
106
|
+
<ic-date-input
|
107
|
+
id="date-input-default-zulu-date"
|
108
|
+
label="When would you like to collect your coffee?"
|
109
|
+
></ic-date-input>
|
110
|
+
</div>
|
111
|
+
<script>
|
112
|
+
var dateInputDate = document.querySelector(
|
113
|
+
"#date-input-default-zulu-date"
|
114
|
+
);
|
115
|
+
dateInputDate.value = new Date("1 May 1990").toISOString();
|
116
|
+
</script>`,
|
117
|
+
name: "Zulu time",
|
118
|
+
};
|
119
|
+
export const WithHyphens = {
|
120
|
+
render: () => html `<ic-date-input
|
121
|
+
id="date-input-default-date-string"
|
122
|
+
label="When would you like to collect your coffee?"
|
123
|
+
></ic-date-input>
|
124
|
+
<script>
|
125
|
+
var dateInputString = document.querySelector(
|
126
|
+
"#date-input-default-date-string"
|
127
|
+
);
|
128
|
+
dateInputString.value = "25-05-2005";
|
129
|
+
</script>`,
|
130
|
+
name: "With hyphens",
|
131
|
+
};
|
132
|
+
export const EpochTime = {
|
133
|
+
render: () => html `<ic-date-input
|
134
|
+
id="date-input-default-date-epoch"
|
135
|
+
label="When would you like to collect your coffee?"
|
136
|
+
></ic-date-input>
|
137
|
+
<script>
|
138
|
+
var dateInputString = document.querySelector(
|
139
|
+
"#date-input-default-date-epoch"
|
140
|
+
);
|
141
|
+
dateInputString.value = Date.now();
|
142
|
+
</script>`,
|
143
|
+
name: "Epoch time",
|
144
|
+
};
|
145
|
+
/**
|
146
|
+
* To set the date input as a required field, set the `required` attribute to `true`. This will add an asterisk at the end of the date input label.
|
147
|
+
*/
|
148
|
+
export const Required = {
|
149
|
+
render: () => html `<ic-date-input
|
150
|
+
label="When would you like to collect your coffee?"
|
151
|
+
required
|
152
|
+
></ic-date-input>`,
|
153
|
+
name: "Required",
|
154
|
+
};
|
155
|
+
/**
|
156
|
+
* To hide the label, set the `hide-label` attribute to `true`. The required `label` will still be read out by screen readers.
|
157
|
+
*/
|
158
|
+
export const HideLabel = {
|
159
|
+
render: () => html `<ic-date-input
|
160
|
+
label="When would you like to collect your coffee?"
|
161
|
+
hide-label="true"
|
162
|
+
></ic-date-input> `,
|
163
|
+
name: "Hide label",
|
164
|
+
};
|
165
|
+
/**
|
166
|
+
* Set the `disabled` attribute to `true` to prevent interaction with the date input.
|
167
|
+
*/
|
168
|
+
export const Disabled = {
|
169
|
+
render: () => html `<ic-date-input
|
170
|
+
label="When would you like to collect your coffee?"
|
171
|
+
disabled
|
172
|
+
></ic-date-input>`,
|
173
|
+
name: "Disabled",
|
174
|
+
};
|
175
|
+
/**
|
176
|
+
* The date input is available in three different sizes:
|
177
|
+
* - small
|
178
|
+
* - default
|
179
|
+
* - large
|
180
|
+
*/
|
181
|
+
export const Sizes = {
|
182
|
+
render: () => html `<ic-date-input
|
183
|
+
label="When would you like to collect your coffee?"
|
184
|
+
size="small"
|
185
|
+
></ic-date-input>
|
186
|
+
<br />
|
187
|
+
<br />
|
188
|
+
<ic-date-input
|
189
|
+
label="When would you like to collect your coffee?"
|
190
|
+
></ic-date-input>
|
191
|
+
<br />
|
192
|
+
<br />
|
193
|
+
<ic-date-input
|
194
|
+
label="When would you like to collect your coffee?"
|
195
|
+
size="large"
|
196
|
+
></ic-date-input> `,
|
197
|
+
name: "Sizes",
|
198
|
+
};
|
199
|
+
/**
|
200
|
+
* Use the `helper-text` attribute to add additional detail for the date input.
|
201
|
+
*/
|
202
|
+
export const CustomHelperText = {
|
203
|
+
render: () => html `<ic-date-input
|
204
|
+
label="When would you like to collect your coffee?"
|
205
|
+
helper-text="We will have your order ready for you on this date"
|
206
|
+
></ic-date-input>`,
|
207
|
+
name: "Custom helper text",
|
208
|
+
};
|
209
|
+
/**
|
210
|
+
* Hide visible helper text by setting `hide-helper-text` to `true`.
|
211
|
+
*/
|
212
|
+
export const HideHelperText = {
|
213
|
+
render: () => html `<ic-date-input
|
214
|
+
label="When would you like to collect your coffee?"
|
215
|
+
helper-text="You cannot see me, but you can hear me"
|
216
|
+
hide-helper-text="true"
|
217
|
+
></ic-date-input>`,
|
218
|
+
name: "Hide helper text",
|
219
|
+
};
|
220
|
+
/**
|
221
|
+
* Validation on date input is set via `validation-status` and `validation-text`.
|
222
|
+
* `validation-status` will set the style of the validation message. `validation-status` accepts:
|
223
|
+
* - `error`
|
224
|
+
* - `warning`
|
225
|
+
* - `success`
|
226
|
+
*
|
227
|
+
* `validation-status` is required for the `validation-text` to appear.
|
228
|
+
*/
|
229
|
+
export const CustomValidation = {
|
230
|
+
render: () => html `<ic-date-input
|
231
|
+
label="When would you like to collect your coffee?"
|
232
|
+
validation-status="error"
|
233
|
+
validation-text="There is a coffee shortage forecast for that day. Please choose a different date."
|
234
|
+
></ic-date-input>
|
235
|
+
<br />
|
236
|
+
<br />
|
237
|
+
<ic-date-input
|
238
|
+
label="When would you like to collect your coffee?"
|
239
|
+
validation-status="warning"
|
240
|
+
validation-text="Please be aware that there may be a coffee shortage on that day."
|
241
|
+
></ic-date-input>
|
242
|
+
<br />
|
243
|
+
<br />
|
244
|
+
<ic-date-input
|
245
|
+
label="When would you like to collect your coffee?"
|
246
|
+
validation-status="success"
|
247
|
+
validation-text="Your coffee will be available for you to collect on this day."
|
248
|
+
></ic-date-input> `,
|
249
|
+
name: "Custom validation",
|
250
|
+
};
|
251
|
+
/**
|
252
|
+
* Validation can be set on the date input if a date in the past has been set by setting the `disable-past` attribute to `true`.
|
253
|
+
*
|
254
|
+
* Enter a date in the past to view the validation message.
|
255
|
+
*/
|
256
|
+
export const DisabledPastDates = {
|
257
|
+
render: () => html `<ic-date-input
|
258
|
+
label="When would you like to collect your coffee?"
|
259
|
+
disable-past
|
260
|
+
></ic-date-input>`,
|
261
|
+
name: "Disabled past dates",
|
262
|
+
};
|
263
|
+
/**
|
264
|
+
* Validation can be set on the date input if a date in the future has been set by setting the `disable-future` attribute to `true`.
|
265
|
+
*
|
266
|
+
* Enter a date in the future to view the validation message.
|
267
|
+
*/
|
268
|
+
export const DisabledFutureDates = {
|
269
|
+
render: () => html `<ic-date-input
|
270
|
+
label="When would you like to collect your coffee?"
|
271
|
+
disable-future
|
272
|
+
></ic-date-input>`,
|
273
|
+
name: "Disabled future dates",
|
274
|
+
};
|
275
|
+
/**
|
276
|
+
* It is possible to set a min and max date range. If a date is set and it is before the min or after the max date, a validation error will appear.
|
277
|
+
* The min or max dates accept the following date formats:
|
278
|
+
* - [Date string](#with-value) (with slashes i.e. DD/MM/YYYY)
|
279
|
+
* - [Date string](#with-hyphens) (with hyphens i.e. DD-MM-YYYY)
|
280
|
+
* - [Date object](#date-object)
|
281
|
+
* - [Zulu time](#zulu-time)
|
282
|
+
*
|
283
|
+
* Enter a date after 2nd Jan 2023 and before 20th July to view the validation message.
|
284
|
+
*
|
285
|
+
* In this code snippet, the min and max have been set using two different date formats to demonstrate its flexibility.
|
286
|
+
*/
|
287
|
+
export const MinAndMax = {
|
288
|
+
render: () => html `<ic-date-input
|
289
|
+
label="When would you like to collect your coffee?"
|
290
|
+
min="02/01/2023"
|
291
|
+
max="20-07-2023"
|
292
|
+
></ic-date-input>`,
|
293
|
+
name: "Min and max",
|
294
|
+
};
|
295
|
+
/**
|
296
|
+
* When the date input component is used within a form, the date value is returned as an ISO string. The value is console logged to the browser dev tools.
|
297
|
+
*/
|
298
|
+
export const Form = {
|
299
|
+
render: () => createDateInputForm(),
|
300
|
+
name: "Form",
|
301
|
+
};
|
302
|
+
/**
|
303
|
+
* The date input can be cleared by setting the the value attribute to one of the following:
|
304
|
+
* - empty string
|
305
|
+
* - `null`
|
306
|
+
* - `undefined`
|
307
|
+
*/
|
308
|
+
export const WithClearingValue = {
|
309
|
+
render: () => html `<ic-date-input
|
310
|
+
id="date-input-clear-value"
|
311
|
+
label="When would you like to collect your coffee?"
|
312
|
+
date-format="DD/MM/YYYY"
|
313
|
+
value="21/01/2001"
|
314
|
+
></ic-date-input>
|
315
|
+
<br />
|
316
|
+
<ic-button id="update">Update date</ic-button>
|
317
|
+
<ic-button id="null-btn">set null</ic-button>
|
318
|
+
<ic-button id="empty-btn">set empty string</ic-button>
|
319
|
+
<ic-button id="undef-btn">set undefined</ic-button>
|
320
|
+
<script>
|
321
|
+
var input = document.querySelector("#date-input-clear-value");
|
322
|
+
var btn = document.querySelector("#update");
|
323
|
+
btn.addEventListener("click", () => {
|
324
|
+
input.value = new Date("05 May 2005");
|
325
|
+
});
|
326
|
+
var btn2 = document.querySelector("#null-btn");
|
327
|
+
btn2.addEventListener("click", () => {
|
328
|
+
input.value = null;
|
329
|
+
});
|
330
|
+
var btn3 = document.querySelector("#empty-btn");
|
331
|
+
btn3.addEventListener("click", () => {
|
332
|
+
input.value = "";
|
333
|
+
});
|
334
|
+
var btn4 = document.querySelector("#undef-btn");
|
335
|
+
btn4.addEventListener("click", () => {
|
336
|
+
input.value = undefined;
|
337
|
+
});
|
338
|
+
</script>`,
|
339
|
+
name: "With clearing value",
|
340
|
+
};
|
341
|
+
//# sourceMappingURL=ic-date-input.stories.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ic-date-input.stories.js","sourceRoot":"","sources":["../../../src/components/ic-date-input/ic-date-input.stories.js"],"names":[],"mappings":"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","sourcesContent":["/* eslint-disable @typescript-eslint/explicit-module-boundary-types */\nimport { createDateInputForm } from \"./story-data\";\nimport { html } from \"lit-html\";\nimport readme from \"./readme.md\";\n\nexport default {\n title: \"Web Components/Date Input\",\n component: \"ic-date-input\",\n\n parameters: {\n componentAPI: {\n data: readme,\n },\n },\n};\n\n/**\n * Use the date input component to manually type in a date in different formats.\n * The input `label` is the only required attribute for date input.\n *\n * Click the 'Component API' tab to view all the available attributes, events and slots for date input.\n * To use the date input component, import `@ukic/canary-web-components` into your application.\n *\n * Each example below demonstrates the date input in three different date formats:\n * - DD/MM/YYYY (Default date format)\n * - MM/DD/YYYY\n * - YYYY/MM/DD\n *\n * Dates can be added by manually typing into the input or using the up and down arrow keys.\n * To move between day, month and year using the keyboard, provide the required values based on the placeholders or use `/` or `-`.\n *\n * By default, the helper text displays the date format.\n */\nexport const Default = {\n render: () =>\n html`<ic-date-input\n label=\"When would you like to collect your coffee?\"\n ></ic-date-input>\n <script>\n var dateInput = document.querySelector(\"ic-date-input\");\n {\n dateInput.addEventListener(\"icChange\", function (event) {\n console.log(\"icChange\", event.detail.value);\n });\n }\n </script>\n <br />\n <br />\n <ic-date-input\n label=\"When would you like to collect your coffee?\"\n date-format=\"MM/DD/YYYY\"\n ></ic-date-input>\n <br />\n <br />\n <ic-date-input\n label=\"When would you like to collect your coffee?\"\n date-format=\"YYYY/MM/DD\"\n ></ic-date-input> `,\n\n name: \"Default\",\n};\n\n/**\n * Retrieving the date input value via `icChange` returns the date as a Date object. The event returns the Date object once day, month and year have been entered.\n */\nexport const IcChangeEvent = {\n render: () =>\n html`<ic-date-input\n label=\"When would you like to collect your coffee?\"\n ></ic-date-input>\n <script>\n var dateInput = document.querySelector(\"ic-date-input\");\n dateInput.addEventListener(\"icChange\", function (event) {\n console.log(event.detail.value);\n });\n </script>`,\n\n name: \"icChange event\",\n};\n\n/**\n * To set a value to the date input, pass the date value in the relevant date format.\n */\nexport const WithValue = {\n render: () =>\n html`<ic-date-input\n id=\"date-input-default-date-with-value\"\n label=\"When would you like to collect your coffee?\"\n date-format=\"DD/MM/YYYY\"\n value=\"21/01/2001\"\n ></ic-date-input>`,\n\n name: \"With value\",\n};\n\n/**\n * The date input also accepts a number of different date formats within the value attribute:\n * - [Date object](#date-object)\n * - [Zulu datetime](#zulu-time)\n * - [With hyphens (DD-MM-YYYY)](#with-hyphens)\n * - [Epoch time](#epoch-time)\n */\nexport const DateObject = {\n render: () =>\n html`<ic-date-input\n id=\"date-input-default-date-date\"\n label=\"When would you like to collect your coffee?\"\n ></ic-date-input>\n <script>\n var dateInputDate = document.querySelector(\n \"#date-input-default-date-date\"\n );\n dateInputDate.value = new Date(\"28 November 2021\");\n </script>`,\n\n name: \"Date object\",\n};\n\nexport const ZuluTime = {\n render: () =>\n html`<div>\n <ic-date-input\n id=\"date-input-default-zulu-date\"\n label=\"When would you like to collect your coffee?\"\n ></ic-date-input>\n </div>\n <script>\n var dateInputDate = document.querySelector(\n \"#date-input-default-zulu-date\"\n );\n dateInputDate.value = new Date(\"1 May 1990\").toISOString();\n </script>`,\n\n name: \"Zulu time\",\n};\n\nexport const WithHyphens = {\n render: () =>\n html`<ic-date-input\n id=\"date-input-default-date-string\"\n label=\"When would you like to collect your coffee?\"\n ></ic-date-input>\n <script>\n var dateInputString = document.querySelector(\n \"#date-input-default-date-string\"\n );\n dateInputString.value = \"25-05-2005\";\n </script>`,\n\n name: \"With hyphens\",\n};\n\nexport const EpochTime = {\n render: () =>\n html`<ic-date-input\n id=\"date-input-default-date-epoch\"\n label=\"When would you like to collect your coffee?\"\n ></ic-date-input>\n <script>\n var dateInputString = document.querySelector(\n \"#date-input-default-date-epoch\"\n );\n dateInputString.value = Date.now();\n </script>`,\n\n name: \"Epoch time\",\n};\n\n/**\n * To set the date input as a required field, set the `required` attribute to `true`. This will add an asterisk at the end of the date input label.\n */\nexport const Required = {\n render: () =>\n html`<ic-date-input\n label=\"When would you like to collect your coffee?\"\n required\n ></ic-date-input>`,\n\n name: \"Required\",\n};\n\n/**\n * To hide the label, set the `hide-label` attribute to `true`. The required `label` will still be read out by screen readers.\n */\nexport const HideLabel = {\n render: () =>\n html`<ic-date-input\n label=\"When would you like to collect your coffee?\"\n hide-label=\"true\"\n ></ic-date-input> `,\n\n name: \"Hide label\",\n};\n\n/**\n * Set the `disabled` attribute to `true` to prevent interaction with the date input.\n */\nexport const Disabled = {\n render: () =>\n html`<ic-date-input\n label=\"When would you like to collect your coffee?\"\n disabled\n ></ic-date-input>`,\n\n name: \"Disabled\",\n};\n\n/**\n * The date input is available in three different sizes:\n * - small\n * - default\n * - large\n */\nexport const Sizes = {\n render: () =>\n html`<ic-date-input\n label=\"When would you like to collect your coffee?\"\n size=\"small\"\n ></ic-date-input>\n <br />\n <br />\n <ic-date-input\n label=\"When would you like to collect your coffee?\"\n ></ic-date-input>\n <br />\n <br />\n <ic-date-input\n label=\"When would you like to collect your coffee?\"\n size=\"large\"\n ></ic-date-input> `,\n\n name: \"Sizes\",\n};\n\n/**\n * Use the `helper-text` attribute to add additional detail for the date input.\n */\nexport const CustomHelperText = {\n render: () =>\n html`<ic-date-input\n label=\"When would you like to collect your coffee?\"\n helper-text=\"We will have your order ready for you on this date\"\n ></ic-date-input>`,\n\n name: \"Custom helper text\",\n};\n\n/**\n * Hide visible helper text by setting `hide-helper-text` to `true`.\n */\nexport const HideHelperText = {\n render: () =>\n html`<ic-date-input\n label=\"When would you like to collect your coffee?\"\n helper-text=\"You cannot see me, but you can hear me\"\n hide-helper-text=\"true\"\n ></ic-date-input>`,\n\n name: \"Hide helper text\",\n};\n\n/**\n * Validation on date input is set via `validation-status` and `validation-text`.\n * `validation-status` will set the style of the validation message. `validation-status` accepts:\n * - `error`\n * - `warning`\n * - `success`\n *\n * `validation-status` is required for the `validation-text` to appear.\n */\nexport const CustomValidation = {\n render: () =>\n html`<ic-date-input\n label=\"When would you like to collect your coffee?\"\n validation-status=\"error\"\n validation-text=\"There is a coffee shortage forecast for that day. Please choose a different date.\"\n ></ic-date-input>\n <br />\n <br />\n <ic-date-input\n label=\"When would you like to collect your coffee?\"\n validation-status=\"warning\"\n validation-text=\"Please be aware that there may be a coffee shortage on that day.\"\n ></ic-date-input>\n <br />\n <br />\n <ic-date-input\n label=\"When would you like to collect your coffee?\"\n validation-status=\"success\"\n validation-text=\"Your coffee will be available for you to collect on this day.\"\n ></ic-date-input> `,\n\n name: \"Custom validation\",\n};\n\n/**\n * Validation can be set on the date input if a date in the past has been set by setting the `disable-past` attribute to `true`.\n *\n * Enter a date in the past to view the validation message.\n */\nexport const DisabledPastDates = {\n render: () =>\n html`<ic-date-input\n label=\"When would you like to collect your coffee?\"\n disable-past\n ></ic-date-input>`,\n\n name: \"Disabled past dates\",\n};\n\n/**\n * Validation can be set on the date input if a date in the future has been set by setting the `disable-future` attribute to `true`.\n *\n * Enter a date in the future to view the validation message.\n */\nexport const DisabledFutureDates = {\n render: () =>\n html`<ic-date-input\n label=\"When would you like to collect your coffee?\"\n disable-future\n ></ic-date-input>`,\n\n name: \"Disabled future dates\",\n};\n\n/**\n * It is possible to set a min and max date range. If a date is set and it is before the min or after the max date, a validation error will appear.\n * The min or max dates accept the following date formats:\n * - [Date string](#with-value) (with slashes i.e. DD/MM/YYYY)\n * - [Date string](#with-hyphens) (with hyphens i.e. DD-MM-YYYY)\n * - [Date object](#date-object)\n * - [Zulu time](#zulu-time)\n *\n * Enter a date after 2nd Jan 2023 and before 20th July to view the validation message.\n *\n * In this code snippet, the min and max have been set using two different date formats to demonstrate its flexibility.\n */\nexport const MinAndMax = {\n render: () =>\n html`<ic-date-input\n label=\"When would you like to collect your coffee?\"\n min=\"02/01/2023\"\n max=\"20-07-2023\"\n ></ic-date-input>`,\n\n name: \"Min and max\",\n};\n\n/**\n * When the date input component is used within a form, the date value is returned as an ISO string. The value is console logged to the browser dev tools.\n */\nexport const Form = {\n render: () => createDateInputForm(),\n name: \"Form\",\n};\n\n/**\n * The date input can be cleared by setting the the value attribute to one of the following:\n * - empty string\n * - `null`\n * - `undefined`\n */\nexport const WithClearingValue = {\n render: () =>\n html`<ic-date-input\n id=\"date-input-clear-value\"\n label=\"When would you like to collect your coffee?\"\n date-format=\"DD/MM/YYYY\"\n value=\"21/01/2001\"\n ></ic-date-input>\n <br />\n <ic-button id=\"update\">Update date</ic-button>\n <ic-button id=\"null-btn\">set null</ic-button>\n <ic-button id=\"empty-btn\">set empty string</ic-button>\n <ic-button id=\"undef-btn\">set undefined</ic-button>\n <script>\n var input = document.querySelector(\"#date-input-clear-value\");\n var btn = document.querySelector(\"#update\");\n btn.addEventListener(\"click\", () => {\n input.value = new Date(\"05 May 2005\");\n });\n var btn2 = document.querySelector(\"#null-btn\");\n btn2.addEventListener(\"click\", () => {\n input.value = null;\n });\n var btn3 = document.querySelector(\"#empty-btn\");\n btn3.addEventListener(\"click\", () => {\n input.value = \"\";\n });\n var btn4 = document.querySelector(\"#undef-btn\");\n btn4.addEventListener(\"click\", () => {\n input.value = undefined;\n });\n </script>`,\n\n name: \"With clearing value\",\n};\n"]}
|
@@ -481,18 +481,25 @@ ic-date-input {
|
|
481
481
|
flex-direction: column;
|
482
482
|
gap: var(--ic-space-xs);
|
483
483
|
position: absolute;
|
484
|
-
border: var(--ic-border-default);
|
485
|
-
border-radius: var(--ic-border-radius);
|
486
484
|
align-items: center;
|
487
485
|
background-color: var(--ic-architectural-white);
|
488
486
|
z-index: var(--ic-z-index-date-picker);
|
489
487
|
box-sizing: border-box;
|
490
|
-
box-shadow: var(--ic-elevation-overlay);
|
491
488
|
margin-top: var(--ic-space-xxxs);
|
492
489
|
padding: var(--ic-space-xs);
|
493
490
|
animation: fade-in-calendar var(--ic-transition-duration-slow);
|
494
491
|
}
|
495
492
|
|
493
|
+
:host .calendar-container.show-date-input {
|
494
|
+
border: var(--ic-border-default);
|
495
|
+
border-radius: var(--ic-border-radius);
|
496
|
+
box-shadow: var(--ic-elevation-overlay);
|
497
|
+
}
|
498
|
+
|
499
|
+
:host .calendar-container.hide-date-input {
|
500
|
+
position: static;
|
501
|
+
}
|
502
|
+
|
496
503
|
:host(.small) .calendar-container {
|
497
504
|
min-width: 17rem;
|
498
505
|
max-width: 21.5rem;
|