@aurodesignsystem-dev/auro-datetime 0.0.0-pr110.0 → 0.0.0-pr112.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -41
- package/custom-elements.json +373 -0
- package/demo/api.md +198 -153
- package/demo/api.min.js +125 -136
- package/demo/index.md +14 -11
- package/demo/index.min.js +125 -136
- package/demo/readme.md +21 -20
- package/dist/auro-datetime-CRsYbYbt.js +6 -0
- package/dist/index.d.ts +75 -71
- package/dist/index.js +1 -1
- package/dist/registered.js +1 -1
- package/package.json +8 -6
- package/dist/auro-datetime-39FU0ZIU.js +0 -6
package/dist/index.d.ts
CHANGED
|
@@ -22,7 +22,9 @@ export type ScopedElements<
|
|
|
22
22
|
Prefix extends string = "",
|
|
23
23
|
Suffix extends string = "",
|
|
24
24
|
> = {
|
|
25
|
-
[
|
|
25
|
+
[
|
|
26
|
+
Key in keyof CustomElements as `${Prefix}${Key}${Suffix}`
|
|
27
|
+
]: CustomElements[Key];
|
|
26
28
|
};
|
|
27
29
|
|
|
28
30
|
type BaseProps<T extends HTMLElement> = {
|
|
@@ -48,6 +50,8 @@ type BaseProps<T extends HTMLElement> = {
|
|
|
48
50
|
key?: string | number;
|
|
49
51
|
/** Specifies the language of the element. */
|
|
50
52
|
lang?: string;
|
|
53
|
+
/** Defines the element's semantic role for accessibility APIs. */
|
|
54
|
+
role?: string;
|
|
51
55
|
/** Contains a space-separated list of the part names of the element. Part names allows CSS to select and style specific elements in a shadow tree via the ::part pseudo-element. */
|
|
52
56
|
part?: string;
|
|
53
57
|
/** Use the ref attribute with a variable to assign a DOM element to the variable once the element is rendered. */
|
|
@@ -73,50 +77,32 @@ type BaseProps<T extends HTMLElement> = {
|
|
|
73
77
|
type BaseEvents = {};
|
|
74
78
|
|
|
75
79
|
export type AuroDatetimeProps = {
|
|
76
|
-
/**
|
|
80
|
+
/** Sets the language and region used to format the date or time, such as `en-GB`, `de-DE`, or `ja-JP` (a BCP 47 language tag). It changes month and weekday names, separators, and whether times use a 12- or 24-hour clock, but not the time zone. A malformed tag logs a console warning and falls back to `en-US`; a well-formed tag the browser doesn't support, such as `zz-ZZ`, uses the browser's default language instead, with no warning. */
|
|
77
81
|
locale?: AuroDatetime["locale"];
|
|
78
|
-
/**
|
|
82
|
+
/** Sets how the month name is written: `short`, such as "Jul", or `long`, such as "July". It applies to the full date and to `type="month"`. */
|
|
79
83
|
month?: AuroDatetime["month"];
|
|
80
|
-
/**
|
|
81
|
-
When set, the moment described by `value` is converted into this IANA zone for display.
|
|
82
|
-
When unset, the wall-clock time from the input string is rendered as-is. */
|
|
84
|
+
/** Sets the time zone to show the date or time in, such as `America/Los_Angeles` or `UTC` (an IANA time zone name). When `value` has an offset or `Z`, the element converts that moment into this zone; when it has none, the element reads `value` as a time already in this zone. Without it, or with an invalid name, which logs a console warning, the element shows the date and time in `value` as written, or the current date and time in the viewer's own time zone when `value` isn't set. */
|
|
83
85
|
timezone?: AuroDatetime["timezone"];
|
|
84
|
-
/**
|
|
86
|
+
/** Sets which part of the date or time to show: `date` for the full date, such as "Thu, Jul 14, 2022", `numeric` for a numeric date, such as "7/14/2022", `time` for the hour and minute, such as "8:00 am", or `year`, `month`, `weekday`, or `day` for that part alone. Without it, or with any other value, the element shows the full date. */
|
|
85
87
|
type?: AuroDatetime["type"];
|
|
86
|
-
/** ISO 8601 date or date-time
|
|
87
|
-
- `2022-07-14T08:00:00-07:00` (with offset)
|
|
88
|
-
- `2022-07-14T08:00:00Z` (UTC)
|
|
89
|
-
- `2022-07-14T08:00:00` (no offset)
|
|
90
|
-
- `2022-07-14` (date only)
|
|
91
|
-
|
|
92
|
-
When omitted, the component renders today's date.
|
|
93
|
-
Invalid input is logged as a warning and renders nothing. */
|
|
88
|
+
/** Sets the date or time to show, as an ISO 8601 date or date-time, such as `2022-07-14`, `2022-07-14T08:00:00`, or `2022-07-14T08:00:00-07:00`. Without it, the element shows the current date and time from when it last rendered; it doesn't currently update as time passes. Invalid input, including an empty value, logs a console warning and shows nothing. */
|
|
94
89
|
value?: AuroDatetime["value"];
|
|
95
|
-
/**
|
|
90
|
+
/** Sets how the weekday name is written: `short`, such as "Thu", or `long`, such as "Thursday". It applies to the full date and to `type="weekday"`. */
|
|
96
91
|
weekday?: AuroDatetime["weekday"];
|
|
97
92
|
};
|
|
98
93
|
|
|
99
94
|
export type AuroDatetimeSolidJsProps = {
|
|
100
|
-
/**
|
|
95
|
+
/** Sets the language and region used to format the date or time, such as `en-GB`, `de-DE`, or `ja-JP` (a BCP 47 language tag). It changes month and weekday names, separators, and whether times use a 12- or 24-hour clock, but not the time zone. A malformed tag logs a console warning and falls back to `en-US`; a well-formed tag the browser doesn't support, such as `zz-ZZ`, uses the browser's default language instead, with no warning. */
|
|
101
96
|
"prop:locale"?: AuroDatetime["locale"];
|
|
102
|
-
/**
|
|
97
|
+
/** Sets how the month name is written: `short`, such as "Jul", or `long`, such as "July". It applies to the full date and to `type="month"`. */
|
|
103
98
|
"prop:month"?: AuroDatetime["month"];
|
|
104
|
-
/**
|
|
105
|
-
When set, the moment described by `value` is converted into this IANA zone for display.
|
|
106
|
-
When unset, the wall-clock time from the input string is rendered as-is. */
|
|
99
|
+
/** Sets the time zone to show the date or time in, such as `America/Los_Angeles` or `UTC` (an IANA time zone name). When `value` has an offset or `Z`, the element converts that moment into this zone; when it has none, the element reads `value` as a time already in this zone. Without it, or with an invalid name, which logs a console warning, the element shows the date and time in `value` as written, or the current date and time in the viewer's own time zone when `value` isn't set. */
|
|
107
100
|
"prop:timezone"?: AuroDatetime["timezone"];
|
|
108
|
-
/**
|
|
101
|
+
/** Sets which part of the date or time to show: `date` for the full date, such as "Thu, Jul 14, 2022", `numeric` for a numeric date, such as "7/14/2022", `time` for the hour and minute, such as "8:00 am", or `year`, `month`, `weekday`, or `day` for that part alone. Without it, or with any other value, the element shows the full date. */
|
|
109
102
|
"prop:type"?: AuroDatetime["type"];
|
|
110
|
-
/** ISO 8601 date or date-time
|
|
111
|
-
- `2022-07-14T08:00:00-07:00` (with offset)
|
|
112
|
-
- `2022-07-14T08:00:00Z` (UTC)
|
|
113
|
-
- `2022-07-14T08:00:00` (no offset)
|
|
114
|
-
- `2022-07-14` (date only)
|
|
115
|
-
|
|
116
|
-
When omitted, the component renders today's date.
|
|
117
|
-
Invalid input is logged as a warning and renders nothing. */
|
|
103
|
+
/** Sets the date or time to show, as an ISO 8601 date or date-time, such as `2022-07-14`, `2022-07-14T08:00:00`, or `2022-07-14T08:00:00-07:00`. Without it, the element shows the current date and time from when it last rendered; it doesn't currently update as time passes. Invalid input, including an empty value, logs a console warning and shows nothing. */
|
|
118
104
|
"prop:value"?: AuroDatetime["value"];
|
|
119
|
-
/**
|
|
105
|
+
/** Sets how the weekday name is written: `short`, such as "Thu", or `long`, such as "Thursday". It applies to the full date and to `type="weekday"`. */
|
|
120
106
|
"prop:weekday"?: AuroDatetime["weekday"];
|
|
121
107
|
|
|
122
108
|
/** Set the innerHTML of the element */
|
|
@@ -127,41 +113,44 @@ Invalid input is logged as a warning and renders nothing. */
|
|
|
127
113
|
|
|
128
114
|
export type CustomElements = {
|
|
129
115
|
/**
|
|
130
|
-
*
|
|
116
|
+
* Shows a date or time as text, formatted for a language and region you choose and, optionally, a specific time zone.
|
|
117
|
+
*
|
|
118
|
+
* **Key capabilities**
|
|
119
|
+
* - **What to show**: `type` picks the full date, the time, a numeric date, or a single part, such as the year or weekday.
|
|
120
|
+
* - **Date and time to show**: `value` takes an ISO 8601 date or date-time; without it, the element shows the current date and time.
|
|
121
|
+
* - **Language formatting**: `locale` formats month names, separators, and the 12- or 24-hour clock for a language, such as `de-DE`.
|
|
122
|
+
* - **Time zones**: `timezone` shows the moment in a time zone, such as `America/Los_Angeles`.
|
|
123
|
+
* - **Name length**: `month="long"` and `weekday="long"` spell out the month and weekday names.
|
|
124
|
+
*
|
|
125
|
+
* **Example**
|
|
126
|
+
* ```html
|
|
127
|
+
* <auro-datetime type="date" value="2022-07-14T08:00:00"></auro-datetime>
|
|
128
|
+
* ```
|
|
131
129
|
*
|
|
132
130
|
* ## Attributes & Properties
|
|
133
131
|
*
|
|
134
132
|
* Component attributes and properties that can be applied to the element or by using JavaScript.
|
|
135
133
|
*
|
|
136
|
-
* - `locale`:
|
|
137
|
-
* - `month`:
|
|
138
|
-
* - `timezone`:
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
* - `
|
|
142
|
-
* - `value`: ISO 8601 date or date-time string. Examples:
|
|
143
|
-
* - `2022-07-14T08:00:00-07:00` (with offset)
|
|
144
|
-
* - `2022-07-14T08:00:00Z` (UTC)
|
|
145
|
-
* - `2022-07-14T08:00:00` (no offset)
|
|
146
|
-
* - `2022-07-14` (date only)
|
|
147
|
-
*
|
|
148
|
-
* When omitted, the component renders today's date.
|
|
149
|
-
* Invalid input is logged as a warning and renders nothing.
|
|
150
|
-
* - `weekday`: Defines format of weekday
|
|
134
|
+
* - `locale`: Sets the language and region used to format the date or time, such as `en-GB`, `de-DE`, or `ja-JP` (a BCP 47 language tag). It changes month and weekday names, separators, and whether times use a 12- or 24-hour clock, but not the time zone. A malformed tag logs a console warning and falls back to `en-US`; a well-formed tag the browser doesn't support, such as `zz-ZZ`, uses the browser's default language instead, with no warning.
|
|
135
|
+
* - `month`: Sets how the month name is written: `short`, such as "Jul", or `long`, such as "July". It applies to the full date and to `type="month"`.
|
|
136
|
+
* - `timezone`: Sets the time zone to show the date or time in, such as `America/Los_Angeles` or `UTC` (an IANA time zone name). When `value` has an offset or `Z`, the element converts that moment into this zone; when it has none, the element reads `value` as a time already in this zone. Without it, or with an invalid name, which logs a console warning, the element shows the date and time in `value` as written, or the current date and time in the viewer's own time zone when `value` isn't set.
|
|
137
|
+
* - `type`: Sets which part of the date or time to show: `date` for the full date, such as "Thu, Jul 14, 2022", `numeric` for a numeric date, such as "7/14/2022", `time` for the hour and minute, such as "8:00 am", or `year`, `month`, `weekday`, or `day` for that part alone. Without it, or with any other value, the element shows the full date.
|
|
138
|
+
* - `value`: Sets the date or time to show, as an ISO 8601 date or date-time, such as `2022-07-14`, `2022-07-14T08:00:00`, or `2022-07-14T08:00:00-07:00`. Without it, the element shows the current date and time from when it last rendered; it doesn't currently update as time passes. Invalid input, including an empty value, logs a console warning and shows nothing.
|
|
139
|
+
* - `weekday`: Sets how the weekday name is written: `short`, such as "Thu", or `long`, such as "Thursday". It applies to the full date and to `type="weekday"`.
|
|
151
140
|
*
|
|
152
141
|
* ## Slots
|
|
153
142
|
*
|
|
154
143
|
* Areas where markup can be added to the component.
|
|
155
144
|
*
|
|
156
|
-
* - `
|
|
157
|
-
* - `
|
|
145
|
+
* - `(default)`: Content shown after the `post` slot's content, such as the end of a sentence that includes the date.
|
|
146
|
+
* - `post`: Content shown after the date or time, such as "local time". The element doesn't currently let content sit right against the date or time: this content, or text right after the element, always shows with a space between them, so a period or comma can't follow the date or time directly.
|
|
147
|
+
* - `pre`: Content shown before the date or time, such as "Departs". The element doesn't currently let content sit right against the date or time: this content, or text right before the element, always shows with a space between it and the date or time.
|
|
158
148
|
*
|
|
159
149
|
* ## Methods
|
|
160
150
|
*
|
|
161
151
|
* Methods that can be called to access component functionality.
|
|
162
152
|
*
|
|
163
|
-
* - `
|
|
164
|
-
* - `register(name?: string = "auro-datetime") => void`: This will register this element with the browser.
|
|
153
|
+
* - `register(name?: string = "auro-datetime") => void`: Registers the element with the browser under a tag name. Use a custom name to run more than one version of the element on the same page. If the tag name is already registered, it does nothing.
|
|
165
154
|
*/
|
|
166
155
|
"auro-datetime": Partial<
|
|
167
156
|
AuroDatetimeProps & BaseProps<AuroDatetime> & BaseEvents
|
|
@@ -170,41 +159,44 @@ export type CustomElements = {
|
|
|
170
159
|
|
|
171
160
|
export type CustomElementsSolidJs = {
|
|
172
161
|
/**
|
|
173
|
-
*
|
|
162
|
+
* Shows a date or time as text, formatted for a language and region you choose and, optionally, a specific time zone.
|
|
163
|
+
*
|
|
164
|
+
* **Key capabilities**
|
|
165
|
+
* - **What to show**: `type` picks the full date, the time, a numeric date, or a single part, such as the year or weekday.
|
|
166
|
+
* - **Date and time to show**: `value` takes an ISO 8601 date or date-time; without it, the element shows the current date and time.
|
|
167
|
+
* - **Language formatting**: `locale` formats month names, separators, and the 12- or 24-hour clock for a language, such as `de-DE`.
|
|
168
|
+
* - **Time zones**: `timezone` shows the moment in a time zone, such as `America/Los_Angeles`.
|
|
169
|
+
* - **Name length**: `month="long"` and `weekday="long"` spell out the month and weekday names.
|
|
170
|
+
*
|
|
171
|
+
* **Example**
|
|
172
|
+
* ```html
|
|
173
|
+
* <auro-datetime type="date" value="2022-07-14T08:00:00"></auro-datetime>
|
|
174
|
+
* ```
|
|
174
175
|
*
|
|
175
176
|
* ## Attributes & Properties
|
|
176
177
|
*
|
|
177
178
|
* Component attributes and properties that can be applied to the element or by using JavaScript.
|
|
178
179
|
*
|
|
179
|
-
* - `locale`:
|
|
180
|
-
* - `month`:
|
|
181
|
-
* - `timezone`:
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
* - `
|
|
185
|
-
* - `value`: ISO 8601 date or date-time string. Examples:
|
|
186
|
-
* - `2022-07-14T08:00:00-07:00` (with offset)
|
|
187
|
-
* - `2022-07-14T08:00:00Z` (UTC)
|
|
188
|
-
* - `2022-07-14T08:00:00` (no offset)
|
|
189
|
-
* - `2022-07-14` (date only)
|
|
190
|
-
*
|
|
191
|
-
* When omitted, the component renders today's date.
|
|
192
|
-
* Invalid input is logged as a warning and renders nothing.
|
|
193
|
-
* - `weekday`: Defines format of weekday
|
|
180
|
+
* - `locale`: Sets the language and region used to format the date or time, such as `en-GB`, `de-DE`, or `ja-JP` (a BCP 47 language tag). It changes month and weekday names, separators, and whether times use a 12- or 24-hour clock, but not the time zone. A malformed tag logs a console warning and falls back to `en-US`; a well-formed tag the browser doesn't support, such as `zz-ZZ`, uses the browser's default language instead, with no warning.
|
|
181
|
+
* - `month`: Sets how the month name is written: `short`, such as "Jul", or `long`, such as "July". It applies to the full date and to `type="month"`.
|
|
182
|
+
* - `timezone`: Sets the time zone to show the date or time in, such as `America/Los_Angeles` or `UTC` (an IANA time zone name). When `value` has an offset or `Z`, the element converts that moment into this zone; when it has none, the element reads `value` as a time already in this zone. Without it, or with an invalid name, which logs a console warning, the element shows the date and time in `value` as written, or the current date and time in the viewer's own time zone when `value` isn't set.
|
|
183
|
+
* - `type`: Sets which part of the date or time to show: `date` for the full date, such as "Thu, Jul 14, 2022", `numeric` for a numeric date, such as "7/14/2022", `time` for the hour and minute, such as "8:00 am", or `year`, `month`, `weekday`, or `day` for that part alone. Without it, or with any other value, the element shows the full date.
|
|
184
|
+
* - `value`: Sets the date or time to show, as an ISO 8601 date or date-time, such as `2022-07-14`, `2022-07-14T08:00:00`, or `2022-07-14T08:00:00-07:00`. Without it, the element shows the current date and time from when it last rendered; it doesn't currently update as time passes. Invalid input, including an empty value, logs a console warning and shows nothing.
|
|
185
|
+
* - `weekday`: Sets how the weekday name is written: `short`, such as "Thu", or `long`, such as "Thursday". It applies to the full date and to `type="weekday"`.
|
|
194
186
|
*
|
|
195
187
|
* ## Slots
|
|
196
188
|
*
|
|
197
189
|
* Areas where markup can be added to the component.
|
|
198
190
|
*
|
|
199
|
-
* - `
|
|
200
|
-
* - `
|
|
191
|
+
* - `(default)`: Content shown after the `post` slot's content, such as the end of a sentence that includes the date.
|
|
192
|
+
* - `post`: Content shown after the date or time, such as "local time". The element doesn't currently let content sit right against the date or time: this content, or text right after the element, always shows with a space between them, so a period or comma can't follow the date or time directly.
|
|
193
|
+
* - `pre`: Content shown before the date or time, such as "Departs". The element doesn't currently let content sit right against the date or time: this content, or text right before the element, always shows with a space between it and the date or time.
|
|
201
194
|
*
|
|
202
195
|
* ## Methods
|
|
203
196
|
*
|
|
204
197
|
* Methods that can be called to access component functionality.
|
|
205
198
|
*
|
|
206
|
-
* - `
|
|
207
|
-
* - `register(name?: string = "auro-datetime") => void`: This will register this element with the browser.
|
|
199
|
+
* - `register(name?: string = "auro-datetime") => void`: Registers the element with the browser under a tag name. Use a custom name to run more than one version of the element on the same page. If the tag name is already registered, it does nothing.
|
|
208
200
|
*/
|
|
209
201
|
"auro-datetime": Partial<
|
|
210
202
|
AuroDatetimeProps &
|
|
@@ -222,6 +214,18 @@ declare module "react" {
|
|
|
222
214
|
}
|
|
223
215
|
}
|
|
224
216
|
|
|
217
|
+
declare module "react/jsx-runtime" {
|
|
218
|
+
namespace JSX {
|
|
219
|
+
interface IntrinsicElements extends CustomElements {}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
declare module "react/jsx-dev-runtime" {
|
|
224
|
+
namespace JSX {
|
|
225
|
+
interface IntrinsicElements extends CustomElements {}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
225
229
|
declare module "preact" {
|
|
226
230
|
namespace JSX {
|
|
227
231
|
interface IntrinsicElements extends CustomElements {}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{A as AuroDatetime}from"./auro-datetime-
|
|
1
|
+
export{A as AuroDatetime}from"./auro-datetime-CRsYbYbt.js";import"lit";
|
package/dist/registered.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as r}from"./auro-datetime-
|
|
1
|
+
import{A as r}from"./auro-datetime-CRsYbYbt.js";import"lit";r.register();
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"================================================================================"
|
|
8
8
|
],
|
|
9
9
|
"name": "@aurodesignsystem-dev/auro-datetime",
|
|
10
|
-
"version": "0.0.0-
|
|
10
|
+
"version": "0.0.0-pr112.0",
|
|
11
11
|
"description": "auro-datetime HTML custom element",
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
"node": ">=20"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"lit": "^3.3.
|
|
24
|
+
"lit": "^3.3.3"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@aurodesignsystem/auro-cli": "^
|
|
28
|
-
"@aurodesignsystem/auro-config": "^1.3.
|
|
29
|
-
"@aurodesignsystem/auro-library": "^5.
|
|
27
|
+
"@aurodesignsystem/auro-cli": "^5.1.0",
|
|
28
|
+
"@aurodesignsystem/auro-config": "^1.3.2",
|
|
29
|
+
"@aurodesignsystem/auro-library": "^5.14.4",
|
|
30
30
|
"husky": "^9.1.7"
|
|
31
31
|
},
|
|
32
32
|
"browserslist": [
|
|
@@ -47,7 +47,8 @@
|
|
|
47
47
|
"web components"
|
|
48
48
|
],
|
|
49
49
|
"scripts": {
|
|
50
|
-
"build": "auro build",
|
|
50
|
+
"build": "auro build && npm run cem:check",
|
|
51
|
+
"cem:check": "auro cem-check --strict",
|
|
51
52
|
"dev": "auro dev -w -s",
|
|
52
53
|
"dev:open": "auro dev -w -s --open",
|
|
53
54
|
"lint": "biome check --no-errors-on-unmatched && stylelint \"./src/**/*.scss\"",
|
|
@@ -77,6 +78,7 @@
|
|
|
77
78
|
"files": [
|
|
78
79
|
"dist/**/*",
|
|
79
80
|
"demo/**/*",
|
|
81
|
+
"custom-elements.json",
|
|
80
82
|
"CHANGELOG.md",
|
|
81
83
|
"README.md",
|
|
82
84
|
"LICENSE",
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{LitElement as e,html as t}from"lit";class i{registerComponent(e,t){customElements.get(e)||customElements.define(e,class extends t{})}closestElement(e,t=this,i=(t,a=t&&t.closest(e))=>t&&t!==document&&t!==window?a||i(t.getRootNode().host):null){return i(t)}handleComponentTagRename(e,t){const i=t.toLowerCase();e.tagName.toLowerCase()!==i&&e.setAttribute(i,!0)}elementMatch(e,t){const i=t.toLowerCase();return e.tagName.toLowerCase()===i||e.hasAttribute(i)}getSlotText(e,t){const i=e.shadowRoot?.querySelector(`slot[name="${t}"]`);return(i?.assignedNodes({flatten:!0})||[]).map(e=>e.textContent?.trim()).join(" ").trim()||null}}const a=/^(\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?)?)(Z|[+-]\d{2}:\d{2})?$/u;class n extends e{constructor(){super(),this._initializeDefaults()}_initializeDefaults(){this.weekday="short",this.month="short",this.locale="en-US",this._warnedLocales=new Set,this._warnedTimeZones=new Set,this._warnedValues=new Set,this._effectiveLocale=this._resolveLocale(this.locale),this._effectiveTimeZone=this._resolveTimeZone(this.timezone),this.runtimeUtils=new i}_resolveLocale(e){if(!e)return"en-US";try{return Intl.getCanonicalLocales(e)[0]}catch{return this._warnedLocales&&!this._warnedLocales.has(e)&&(this._warnedLocales.add(e),console.warn(`auro-datetime: "${e}" is not a valid BCP 47 locale tag. Falling back to "en-US".`)),"en-US"}}_resolveTimeZone(e){if(e)try{return new Intl.DateTimeFormat(void 0,{timeZone:e}),e}catch{return void(this._warnedTimeZones&&!this._warnedTimeZones.has(e)&&(this._warnedTimeZones.add(e),console.warn(`auro-datetime: "${e}" is not a valid IANA timezone. Falling back to viewer-local.`)))}}connectedCallback(){super.connectedCallback(),this.dateTemplate={weekday:this.weekday,year:"numeric",month:this.month,day:"numeric"},this.timeTemplate={hour:"2-digit",minute:"2-digit"}}static get properties(){return{locale:{type:String},month:{type:String},timezone:{type:String},type:{type:String},value:{type:String},weekday:{type:String}}}static register(e="auro-datetime"){i.prototype.registerComponent(e,n)}willUpdate(e){e.has("locale")&&(this._effectiveLocale=this._resolveLocale(this.locale)),e.has("timezone")&&(this._effectiveTimeZone=this._resolveTimeZone(this.timezone))}firstUpdated(){this.runtimeUtils.handleComponentTagRename(this,"auro-datetime")}_zonedWallClockToUtc(e,t){const i=new Date(`${e}Z`),a=new Intl.DateTimeFormat("en-US",{timeZone:t,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).formatToParts(i),n=Object.fromEntries(a.filter(e=>"literal"!==e.type).map(e=>[e.type,e.value])),o=new Date(`${n.year}-${n.month}-${n.day}T${n.hour}:${n.minute}:${n.second}Z`),s=i.getTime()-o.getTime();return new Date(i.getTime()+s)}_resolveInputDate(){const e=this._effectiveTimeZone;if(null==this.value)return{date:new Date,timeZoneOption:e};const t=this.value.match(a);if(!t)return this._warnedValues.has(this.value)||(this._warnedValues.add(this.value),console.warn(`auro-datetime: "${this.value}" is not a valid ISO 8601 string.`)),{date:null,timeZoneOption:void 0};const i=t[1],n=Boolean(t[2]);if(n&&!i.includes("T"))return this._warnedValues.has(this.value)||(this._warnedValues.add(this.value),console.warn(`auro-datetime: "${this.value}" is not a valid ISO 8601 string (offset/Z requires a time component).`)),{date:null,timeZoneOption:void 0};const o=i.includes("T")?i:`${i}T00:00:00`,s=(()=>e&&!n?this._zonedWallClockToUtc(o,e):e&&n?new Date(this.value):new Date(o))();return Number.isNaN(s.getTime())?(this._warnedValues.has(this.value)||(this._warnedValues.add(this.value),console.warn(`auro-datetime: "${this.value}" is not a valid ISO 8601 date.`)),{date:null,timeZoneOption:void 0}):{date:s,timeZoneOption:e}}humanDate(){const{date:e,timeZoneOption:t}=this._resolveInputDate();if(!e)return"";const i={...this.dateTemplate};return t&&(i.timeZone=t),e.toLocaleString(this._effectiveLocale,i)}humanDateConversion(){const{date:e,timeZoneOption:t}=this._resolveInputDate();if(!e)return"";const i={};switch(t&&(i.timeZone=t),this.type){case"day":i.day="numeric";break;case"month":i.month=this.month;break;case"year":i.year="numeric";break;case"weekday":i.weekday=this.weekday}return e.toLocaleString(this._effectiveLocale,i)}numericDate(){const{date:e,timeZoneOption:t}=this._resolveInputDate();if(!e)return"";const i={...this.dateTemplate,month:"numeric"};return Reflect.deleteProperty(i,"weekday"),t&&(i.timeZone=t),e.toLocaleString(this._effectiveLocale,i)}humanTime(){const{date:e,timeZoneOption:t}=this._resolveInputDate();if(!e)return"";const i={...this.timeTemplate};t&&(i.timeZone=t);const a=e.toLocaleString(this._effectiveLocale,i);return/[ap]\.?m\.?/iu.test(a)?a.replace(/^0+/u,"").toLowerCase():a}whichDate(){switch(this.type){case"date":default:return this.humanDate();case"time":return this.humanTime();case"year":case"month":case"weekday":case"day":return this.humanDateConversion();case"numeric":return this.numericDate()}}render(){return t`
|
|
2
|
-
<slot name="pre"></slot>
|
|
3
|
-
<span class="yield">${this.whichDate()}</span>
|
|
4
|
-
<slot name="post"></slot>
|
|
5
|
-
<slot></slot>
|
|
6
|
-
`}}export{n as A};
|