@aurodesignsystem-dev/auro-datetime 0.0.0-pr83.0 → 0.0.0-pr89.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/demo/api.md +128 -55
- package/demo/auro-datetime.min.js +325 -122
- package/dist/auro-datetime-39FU0ZIU.js +6 -0
- package/dist/index.d.ts +145 -69
- package/dist/index.js +1 -1
- package/dist/registered.js +1 -1
- package/package.json +4 -4
- package/dist/auro-datetime-jIlTbbhr.js +0 -6
|
@@ -0,0 +1,6 @@
|
|
|
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};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
import type { AuroDatetime } from "src/auro-datetime.js";
|
|
3
2
|
|
|
4
3
|
/**
|
|
@@ -21,13 +20,12 @@ import type { AuroDatetime } from "src/auro-datetime.js";
|
|
|
21
20
|
*/
|
|
22
21
|
export type ScopedElements<
|
|
23
22
|
Prefix extends string = "",
|
|
24
|
-
Suffix extends string = ""
|
|
23
|
+
Suffix extends string = "",
|
|
25
24
|
> = {
|
|
26
25
|
[Key in keyof CustomElements as `${Prefix}${Key}${Suffix}`]: CustomElements[Key];
|
|
27
26
|
};
|
|
28
27
|
|
|
29
28
|
type BaseProps<T extends HTMLElement> = {
|
|
30
|
-
|
|
31
29
|
/** Content added between the opening and closing tags of the element */
|
|
32
30
|
children?: any;
|
|
33
31
|
/** Used for declaratively styling one or more elements using CSS (Cascading Stylesheets) */
|
|
@@ -70,122 +68,200 @@ type BaseProps<T extends HTMLElement> = {
|
|
|
70
68
|
popovertarget?: "top" | "bottom" | "left" | "right" | "auto";
|
|
71
69
|
/** Specifies the action to be performed on a popover element being controlled by a control element. */
|
|
72
70
|
popovertargetaction?: "show" | "hide" | "toggle";
|
|
73
|
-
|
|
74
|
-
} ;
|
|
75
|
-
|
|
76
|
-
type BaseEvents = {
|
|
77
|
-
|
|
78
|
-
|
|
79
71
|
};
|
|
80
72
|
|
|
81
|
-
|
|
73
|
+
type BaseEvents = {};
|
|
82
74
|
|
|
83
75
|
export type AuroDatetimeProps = {
|
|
84
|
-
/**
|
|
85
|
-
|
|
76
|
+
/** BCP 47 language tag for locale-aware date/time formatting (e.g. 'en-GB', 'de-DE', 'ja-JP'). */
|
|
77
|
+
locale?: AuroDatetime["locale"];
|
|
86
78
|
/** Defines format of month */
|
|
87
|
-
|
|
88
|
-
/** Pass in string to
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
79
|
+
month?: AuroDatetime["month"];
|
|
80
|
+
/** Pass in string to define [timezone](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
|
|
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. */
|
|
83
|
+
timezone?: AuroDatetime["timezone"];
|
|
92
84
|
/** Defines type of data to render */
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
|
|
85
|
+
type?: AuroDatetime["type"];
|
|
86
|
+
/** ISO 8601 date or date-time string. Examples:
|
|
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. */
|
|
94
|
+
value?: AuroDatetime["value"];
|
|
96
95
|
/** Defines format of weekday */
|
|
97
|
-
|
|
96
|
+
weekday?: AuroDatetime["weekday"];
|
|
97
|
+
};
|
|
98
98
|
|
|
99
|
+
export type AuroDatetimeSolidJsProps = {
|
|
100
|
+
/** BCP 47 language tag for locale-aware date/time formatting (e.g. 'en-GB', 'de-DE', 'ja-JP'). */
|
|
101
|
+
"prop:locale"?: AuroDatetime["locale"];
|
|
102
|
+
/** Defines format of month */
|
|
103
|
+
"prop:month"?: AuroDatetime["month"];
|
|
104
|
+
/** Pass in string to define [timezone](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
|
|
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. */
|
|
107
|
+
"prop:timezone"?: AuroDatetime["timezone"];
|
|
108
|
+
/** Defines type of data to render */
|
|
109
|
+
"prop:type"?: AuroDatetime["type"];
|
|
110
|
+
/** ISO 8601 date or date-time string. Examples:
|
|
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)
|
|
99
115
|
|
|
100
|
-
|
|
116
|
+
When omitted, the component renders today's date.
|
|
117
|
+
Invalid input is logged as a warning and renders nothing. */
|
|
118
|
+
"prop:value"?: AuroDatetime["value"];
|
|
119
|
+
/** Defines format of weekday */
|
|
120
|
+
"prop:weekday"?: AuroDatetime["weekday"];
|
|
101
121
|
|
|
102
|
-
|
|
122
|
+
/** Set the innerHTML of the element */
|
|
123
|
+
innerHTML?: string;
|
|
124
|
+
/** Set the textContent of the element */
|
|
125
|
+
textContent?: string | number;
|
|
126
|
+
};
|
|
103
127
|
|
|
128
|
+
export type CustomElements = {
|
|
129
|
+
/**
|
|
130
|
+
* The `auro-datetime` element is for the purposes of providing an easy to use date and time API.
|
|
131
|
+
*
|
|
132
|
+
* ## Attributes & Properties
|
|
133
|
+
*
|
|
134
|
+
* Component attributes and properties that can be applied to the element or by using JavaScript.
|
|
135
|
+
*
|
|
136
|
+
* - `locale`: BCP 47 language tag for locale-aware date/time formatting (e.g. 'en-GB', 'de-DE', 'ja-JP').
|
|
137
|
+
* - `month`: Defines format of month
|
|
138
|
+
* - `timezone`: Pass in string to define [timezone](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
|
|
139
|
+
* When set, the moment described by `value` is converted into this IANA zone for display.
|
|
140
|
+
* When unset, the wall-clock time from the input string is rendered as-is.
|
|
141
|
+
* - `type`: Defines type of data to render
|
|
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
|
|
151
|
+
*
|
|
152
|
+
* ## Slots
|
|
153
|
+
*
|
|
154
|
+
* Areas where markup can be added to the component.
|
|
155
|
+
*
|
|
156
|
+
* - `post`: Content that comes after the `pre` content
|
|
157
|
+
* - `pre`: Content that comes before the `post` content
|
|
158
|
+
*
|
|
159
|
+
* ## Methods
|
|
160
|
+
*
|
|
161
|
+
* Methods that can be called to access component functionality.
|
|
162
|
+
*
|
|
163
|
+
* - `_initializeDefaults() => void`: undefined
|
|
164
|
+
* - `register(name?: string = "auro-datetime") => void`: This will register this element with the browser.
|
|
165
|
+
*/
|
|
166
|
+
"auro-datetime": Partial<
|
|
167
|
+
AuroDatetimeProps & BaseProps<AuroDatetime> & BaseEvents
|
|
168
|
+
>;
|
|
169
|
+
};
|
|
104
170
|
|
|
171
|
+
export type CustomElementsSolidJs = {
|
|
105
172
|
/**
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
173
|
+
* The `auro-datetime` element is for the purposes of providing an easy to use date and time API.
|
|
174
|
+
*
|
|
175
|
+
* ## Attributes & Properties
|
|
176
|
+
*
|
|
177
|
+
* Component attributes and properties that can be applied to the element or by using JavaScript.
|
|
178
|
+
*
|
|
179
|
+
* - `locale`: BCP 47 language tag for locale-aware date/time formatting (e.g. 'en-GB', 'de-DE', 'ja-JP').
|
|
180
|
+
* - `month`: Defines format of month
|
|
181
|
+
* - `timezone`: Pass in string to define [timezone](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
|
|
182
|
+
* When set, the moment described by `value` is converted into this IANA zone for display.
|
|
183
|
+
* When unset, the wall-clock time from the input string is rendered as-is.
|
|
184
|
+
* - `type`: Defines type of data to render
|
|
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
|
|
194
|
+
*
|
|
195
|
+
* ## Slots
|
|
196
|
+
*
|
|
197
|
+
* Areas where markup can be added to the component.
|
|
198
|
+
*
|
|
199
|
+
* - `post`: Content that comes after the `pre` content
|
|
200
|
+
* - `pre`: Content that comes before the `post` content
|
|
201
|
+
*
|
|
202
|
+
* ## Methods
|
|
203
|
+
*
|
|
204
|
+
* Methods that can be called to access component functionality.
|
|
205
|
+
*
|
|
206
|
+
* - `_initializeDefaults() => void`: undefined
|
|
207
|
+
* - `register(name?: string = "auro-datetime") => void`: This will register this element with the browser.
|
|
208
|
+
*/
|
|
209
|
+
"auro-datetime": Partial<
|
|
210
|
+
AuroDatetimeProps &
|
|
211
|
+
AuroDatetimeSolidJsProps &
|
|
212
|
+
BaseProps<AuroDatetime> &
|
|
213
|
+
BaseEvents
|
|
214
|
+
>;
|
|
215
|
+
};
|
|
136
216
|
|
|
137
|
-
export type CustomCssProperties = {
|
|
217
|
+
export type CustomCssProperties = {};
|
|
138
218
|
|
|
219
|
+
declare module "react" {
|
|
220
|
+
namespace JSX {
|
|
221
|
+
interface IntrinsicElements extends CustomElements {}
|
|
222
|
+
}
|
|
139
223
|
}
|
|
140
224
|
|
|
141
|
-
|
|
142
|
-
declare module 'react' {
|
|
225
|
+
declare module "preact" {
|
|
143
226
|
namespace JSX {
|
|
144
227
|
interface IntrinsicElements extends CustomElements {}
|
|
145
228
|
}
|
|
146
|
-
|
|
147
229
|
}
|
|
148
230
|
|
|
149
|
-
declare module
|
|
231
|
+
declare module "@builder.io/qwik" {
|
|
150
232
|
namespace JSX {
|
|
151
233
|
interface IntrinsicElements extends CustomElements {}
|
|
152
234
|
}
|
|
153
|
-
|
|
154
235
|
}
|
|
155
236
|
|
|
156
|
-
declare module
|
|
237
|
+
declare module "@stencil/core" {
|
|
157
238
|
namespace JSX {
|
|
158
239
|
interface IntrinsicElements extends CustomElements {}
|
|
159
240
|
}
|
|
160
|
-
|
|
161
241
|
}
|
|
162
242
|
|
|
163
|
-
declare module
|
|
243
|
+
declare module "hono/jsx" {
|
|
164
244
|
namespace JSX {
|
|
165
245
|
interface IntrinsicElements extends CustomElements {}
|
|
166
246
|
}
|
|
167
|
-
|
|
168
247
|
}
|
|
169
248
|
|
|
170
|
-
declare module
|
|
249
|
+
declare module "react-native" {
|
|
171
250
|
namespace JSX {
|
|
172
251
|
interface IntrinsicElements extends CustomElements {}
|
|
173
252
|
}
|
|
174
|
-
|
|
175
253
|
}
|
|
176
254
|
|
|
177
|
-
declare module
|
|
255
|
+
declare module "solid-js" {
|
|
178
256
|
namespace JSX {
|
|
179
|
-
interface IntrinsicElements extends
|
|
257
|
+
interface IntrinsicElements extends CustomElementsSolidJs {}
|
|
180
258
|
}
|
|
181
|
-
|
|
182
259
|
}
|
|
183
260
|
|
|
184
261
|
declare global {
|
|
185
262
|
namespace JSX {
|
|
186
263
|
interface IntrinsicElements extends CustomElements {}
|
|
187
264
|
}
|
|
188
|
-
|
|
189
265
|
}
|
|
190
266
|
declare global {
|
|
191
267
|
namespace svelteHTML {
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{A as AuroDatetime}from"./auro-datetime-
|
|
1
|
+
export{A as AuroDatetime}from"./auro-datetime-39FU0ZIU.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-39FU0ZIU.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-pr89.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.2"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@aurodesignsystem/auro-cli": "^3.
|
|
27
|
+
"@aurodesignsystem/auro-cli": "^3.6.0",
|
|
28
28
|
"@aurodesignsystem/auro-config": "^1.3.1",
|
|
29
|
-
"@aurodesignsystem/auro-library": "^5.
|
|
29
|
+
"@aurodesignsystem/auro-library": "^5.12.2",
|
|
30
30
|
"husky": "^9.1.7"
|
|
31
31
|
},
|
|
32
32
|
"browserslist": [
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{LitElement as e,html as t}from"lit";class a{registerComponent(e,t){customElements.get(e)||customElements.define(e,class extends t{})}closestElement(e,t=this,a=(t,s=t&&t.closest(e))=>t&&t!==document&&t!==window?s||a(t.getRootNode().host):null){return a(t)}handleComponentTagRename(e,t){const a=t.toLowerCase();e.tagName.toLowerCase()!==a&&e.setAttribute(a,!0)}elementMatch(e,t){const a=t.toLowerCase();return e.tagName.toLowerCase()===a||e.hasAttribute(a)}getSlotText(e,t){const a=e.shadowRoot?.querySelector(`slot[name="${t}"]`);return(a?.assignedNodes({flatten:!0})||[]).map(e=>e.textContent?.trim()).join(" ").trim()||null}}class s extends e{constructor(){super(),this._initializeDefaults()}_initializeDefaults(){this.weekday="short",this.month="short",this.runtimeUtils=new a}connectedCallback(){super.connectedCallback(),this.dateTemplate={weekday:this.weekday,year:"numeric",month:this.month,day:"numeric"},this.timeTemplate={hour:"2-digit",minute:"2-digit",timeZone:this.timeZone},this.template={}}static get properties(){return{cap:{type:Boolean},month:{type:String},setDate:{type:String},timeZone:{type:String},type:{type:String},utc:{type:String},weekday:{type:String}}}static register(e="auro-datetime"){a.prototype.registerComponent(e,s)}firstUpdated(){this.runtimeUtils.handleComponentTagRename(this,"auro-datetime")}humanDate(){let e=new Date;return this.utc?(this.dateTemplate.timeZone="UTC",e=new Date(this.utc)):this.setDate&&(e=new Date(this.setDate)),e.toLocaleString("en-us",this.dateTemplate)}humanDateConversion(){let e=new Date;switch(this.utc?(this.template.timeZone="UTC",e=new Date(this.utc)):this.setDate&&(e=new Date(this.setDate)),this.type){case"day":this.template.day="numeric";break;case"month":this.template.month=this.month;break;case"year":this.template.year="numeric";break;case"weekday":this.template.weekday=this.weekday;break;default:this.template.weekday=this.template}return e.toLocaleString("en-us",this.template)}numericDate(){this.dateTemplate.month="numeric",Reflect.deleteProperty(this.dateTemplate,"weekday");let e=new Date;return this.utc?(this.dateTemplate.timeZone="UTC",e=new Date(this.utc)):this.setDate&&(e=new Date(this.setDate)),e.toLocaleString("en-us",this.dateTemplate)}humanTime(){let e=new Date;return this.utc?(this.timeTemplate.timeZone="UTC",e=new Date(this.utc)):this.setDate&&(e=new Date(this.setDate)),this.cap?e.toLocaleString("en-us",this.timeTemplate).replace(/^0+/u,""):e.toLocaleString("en-us",this.timeTemplate).replace(/^0+/u,"").toLowerCase()}tzTime(e){const t=this.setDate.slice(0,-6),a=new Date(t);return this.cap?a.toLocaleString("en-us",e).replace(/^0+/u,""):a.toLocaleString("en-us",e).replace(/^0+/u,"").replace("AM","am").replace("PM","pm")}whichDate(){let e="";switch(this.type){case"date":e=this.humanDate();break;case"tzDate":e=this.tzTime(this.dateTemplate);break;case"tzTime":e=this.tzTime(this.timeTemplate);break;case"time":e=this.humanTime();break;case"year":case"month":case"weekday":case"day":e=this.humanDateConversion();break;case"numeric":e=this.numericDate();break;default:this.humanDate()}return this.setDate&&!this.type||this.utc&&!this.type?this.humanDate():e}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{s as A};
|