@energinet/watt 4.5.2 → 4.5.4
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/fesm2022/energinet-watt-core-date.mjs +4 -0
- package/fesm2022/energinet-watt-core-date.mjs.map +1 -1
- package/fesm2022/energinet-watt-expandable-link.mjs +172 -0
- package/fesm2022/energinet-watt-expandable-link.mjs.map +1 -0
- package/package.json +5 -1
- package/types/energinet-watt-core-date.d.ts +3 -1
- package/types/energinet-watt-expandable-link.d.ts +57 -0
|
@@ -5,6 +5,8 @@ import timezone from 'dayjs/plugin/timezone';
|
|
|
5
5
|
import duration from 'dayjs/plugin/duration';
|
|
6
6
|
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
|
7
7
|
import updateLocale from 'dayjs/plugin/updateLocale';
|
|
8
|
+
import isBetween from 'dayjs/plugin/isBetween';
|
|
9
|
+
import isSameOrAfter from 'dayjs/plugin/isSameOrAfter';
|
|
8
10
|
import { NativeDateAdapter, MAT_DATE_LOCALE, DateAdapter, MAT_NATIVE_DATE_FORMATS, MAT_DATE_FORMATS } from '@angular/material/core';
|
|
9
11
|
import * as i0 from '@angular/core';
|
|
10
12
|
import { Injectable, makeEnvironmentProviders, Pipe, inject, signal, LOCALE_ID, computed } from '@angular/core';
|
|
@@ -32,6 +34,8 @@ dayjs.extend(timezone);
|
|
|
32
34
|
dayjs.extend(duration);
|
|
33
35
|
dayjs.extend(customParseFormat);
|
|
34
36
|
dayjs.extend(updateLocale);
|
|
37
|
+
dayjs.extend(isBetween);
|
|
38
|
+
dayjs.extend(isSameOrAfter);
|
|
35
39
|
|
|
36
40
|
//#region License
|
|
37
41
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"energinet-watt-core-date.mjs","sources":["../../../libs/watt/package/core/date/dayjs.ts","../../../libs/watt/package/core/date/watt-date-adapter.ts","../../../libs/watt/package/core/date/watt-danish-datetime.providers.ts","../../../libs/watt/package/core/date/watt-date-range.ts","../../../libs/watt/package/core/date/watt-format-date.ts","../../../libs/watt/package/core/date/watt-date.pipe.ts","../../../libs/watt/package/core/date/watt-locale.service.ts","../../../libs/watt/package/core/date/index.ts","../../../libs/watt/package/core/date/energinet-watt-core-date.ts"],"sourcesContent":["//#region License\n/**\n * @license\n * Copyright 2020 Energinet DataHub A/S\n *\n * Licensed under the Apache License, Version 2.0 (the \"License2\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n//#endregion\nimport dayjs from 'dayjs'; // eslint-disable-line no-restricted-imports\nimport utc from 'dayjs/plugin/utc';\nimport timezone from 'dayjs/plugin/timezone';\nimport duration from 'dayjs/plugin/duration';\nimport customParseFormat from 'dayjs/plugin/customParseFormat';\nimport updateLocale from 'dayjs/plugin/updateLocale';\n\n// Force import of plugins in generated .d.ts file by exporting their types\ntype __ngPackagrDayjsTypeScriptWorkaround =\n | typeof utc\n | typeof timezone\n | typeof duration\n | typeof customParseFormat\n | typeof updateLocale;\n\ndayjs.extend(utc);\ndayjs.extend(timezone);\ndayjs.extend(duration);\ndayjs.extend(customParseFormat);\ndayjs.extend(updateLocale);\n\nexport { dayjs, __ngPackagrDayjsTypeScriptWorkaround };\n","//#region License\n/**\n * @license\n * Copyright 2020 Energinet DataHub A/S\n *\n * Licensed under the Apache License, Version 2.0 (the \"License2\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n//#endregion\nimport { Injectable } from '@angular/core';\nimport { NativeDateAdapter } from '@angular/material/core';\n\nexport type WattSupportedLocales = 'da' | 'en';\nconst danishLocale = 'da';\n\n@Injectable()\nexport class WattDateAdapter extends NativeDateAdapter {\n setActiveLocale(language: WattSupportedLocales): void {\n this.setLocale(language === danishLocale ? danishLocale : 'en-GB');\n }\n\n /**\n * This is necessary to remove the dots from the date (ordinals) for danish locale in the calendar view.\n * due to `Intl.DateTimeFormat`\n */\n override getDateNames(): string[] {\n const dateNames = super.getDateNames();\n\n return this.locale === danishLocale\n ? dateNames.map((dateName) => dateName.replace(/\\./g, ''))\n : dateNames;\n }\n\n /**\n * Our week starts on Monday\n * @returns 0 for Sunday, 1 for Monday, etc.\n */\n override getFirstDayOfWeek(): number {\n return 1;\n }\n}\n","//#region License\n/**\n * @license\n * Copyright 2020 Energinet DataHub A/S\n *\n * Licensed under the Apache License, Version 2.0 (the \"License2\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n//#endregion\nimport {\n DateAdapter,\n MAT_DATE_FORMATS,\n MAT_DATE_LOCALE,\n MAT_NATIVE_DATE_FORMATS,\n} from '@angular/material/core';\nimport { makeEnvironmentProviders } from '@angular/core';\n\nimport { WattDateAdapter } from './watt-date-adapter';\n\nexport const danishDatetimeProviders = makeEnvironmentProviders([\n { provide: MAT_DATE_LOCALE, useValue: 'da' },\n {\n provide: DateAdapter,\n useClass: WattDateAdapter,\n deps: [MAT_DATE_LOCALE],\n },\n { provide: MAT_DATE_FORMATS, useValue: MAT_NATIVE_DATE_FORMATS },\n]);\n","//#region License\n/**\n * @license\n * Copyright 2020 Energinet DataHub A/S\n *\n * Licensed under the Apache License, Version 2.0 (the \"License2\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n//#endregion\nimport { dayjs } from './dayjs';\n\nexport interface WattRange<T> {\n start: T;\n end: T | null;\n}\n\n/**\n * This is included for legacy reasons, components should return Date objects instead of strings.\n * @deprecated Avoid using strings as dates, use Date objects instead.\n */\nexport type WattDateRange = WattRange<string>;\n\n/**\n * Checks if a given date is within a specified date range.\n */\nexport function contains(interval: WattRange<Date>, date: Date) {\n const day = dayjs(date);\n const isSameOrAfterStart = day.isSame(interval.start) || day.isAfter(interval.start);\n if (!interval.end) return isSameOrAfterStart;\n const isSameOrBeforeEnd = day.isSame(interval.end) || day.isBefore(interval.end);\n return isSameOrAfterStart && isSameOrBeforeEnd;\n}\n","//#region License\n/**\n * @license\n * Copyright 2020 Energinet DataHub A/S\n *\n * Licensed under the Apache License, Version 2.0 (the \"License2\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n//#endregion\nimport { dayjs } from './dayjs';\nimport { WattRange } from './watt-date-range';\n\nexport const formatStrings = {\n year: 'YYYY',\n monthYear: 'MMMM YYYY',\n short: 'DD-MM-YYYY',\n shortAbbr: 'DD. MMM YYYY',\n long: 'DD-MM-YYYY HH:mm',\n longAbbr: 'DD. MMM YYYY HH:mm',\n time: 'HH:mm',\n longAbbrWithSeconds: 'DD-MMM YYYY HH:mm:ss',\n};\n\nexport function wattFormatDate(\n input?: WattRange<Date> | WattRange<string> | Date | string | number | null,\n format: keyof typeof formatStrings = 'short',\n timeZone = 'Europe/Copenhagen'\n): string | null {\n if (!input) return null;\n\n if (input instanceof Date || typeof input === 'string') {\n return dayjs(input).tz(timeZone).format(formatStrings[format]);\n } else if (typeof input === 'number') {\n return dayjs(new Date(input)).tz(timeZone).format(formatStrings[format]);\n } else {\n return transformRange(input, format);\n }\n}\n\nfunction transformRange(\n input: WattRange<Date | string>,\n format: keyof typeof formatStrings\n): string | null {\n if (dayjs(input.start).isSame(dayjs(input.end), 'day') || input.end === null) {\n return wattFormatDate(input.start, format);\n } else {\n return `${wattFormatDate(input.start, format)} ― ${wattFormatDate(input.end, format)}`;\n }\n}\n","//#region License\n/**\n * @license\n * Copyright 2020 Energinet DataHub A/S\n *\n * Licensed under the Apache License, Version 2.0 (the \"License2\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n//#endregion\nimport { Pipe, PipeTransform } from '@angular/core';\n\nimport { WattRange } from './watt-date-range';\nimport { formatStrings, wattFormatDate } from './watt-format-date';\n\n@Pipe({\n name: 'wattDate',\n})\nexport class WattDatePipe implements PipeTransform {\n /**\n * @param input WattDateRange or string in ISO 8601 format or unix timestamp number\n */\n transform(\n input?: WattRange<Date> | WattRange<string> | Date | string | number | null,\n format: keyof typeof formatStrings = 'short',\n timeZone = 'Europe/Copenhagen'\n ): string | null {\n return wattFormatDate(input, format, timeZone);\n }\n}\n","//#region License\n/**\n * @license\n * Copyright 2020 Energinet DataHub A/S\n *\n * Licensed under the Apache License, Version 2.0 (the \"License2\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n//#endregion\nimport { computed, inject, Injectable, LOCALE_ID, signal } from '@angular/core';\nimport { DateAdapter } from '@angular/material/core';\n\nimport { WattDateAdapter, WattSupportedLocales } from './watt-date-adapter';\nimport { dayjs } from './dayjs';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class WattLocaleService {\n private readonly dateAdapter = inject<DateAdapter<unknown>>(DateAdapter);\n\n locale = signal(inject<WattSupportedLocales>(LOCALE_ID));\n isDanish = computed(() => this.locale() == 'da');\n isEnglish = computed(() => this.locale() == 'en');\n\n async setActiveLocale(locale: WattSupportedLocales): Promise<void> {\n if (locale === 'da') {\n await import('dayjs/locale/da');\n }\n\n if (locale === 'en') {\n await import('dayjs/locale/en');\n }\n\n dayjs.locale(locale);\n dayjs.updateLocale(locale, {\n weekStart: 1,\n });\n (this.dateAdapter as WattDateAdapter).setActiveLocale(locale);\n this.locale.set(locale);\n }\n}\n","//#region License\n/**\n * @license\n * Copyright 2020 Energinet DataHub A/S\n *\n * Licensed under the Apache License, Version 2.0 (the \"License2\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n//#endregion\nexport { dayjs, __ngPackagrDayjsTypeScriptWorkaround } from './dayjs';\nexport { danishDatetimeProviders } from './watt-danish-datetime.providers';\nexport { WattDateAdapter, WattSupportedLocales } from './watt-date-adapter';\nexport { type WattRange, type WattDateRange, contains } from './watt-date-range';\nexport { WattDatePipe } from './watt-date.pipe';\nexport { wattFormatDate } from './watt-format-date';\nexport { WattLocaleService } from './watt-locale.service';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;AACA;;;;;;;;;;;;;;;AAeG;AACH;AAgBA,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC;AACjB,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC;AACtB,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC;AACtB,KAAK,CAAC,MAAM,CAAC,iBAAiB,CAAC;AAC/B,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC;;ACrC1B;AACA;;;;;;;;;;;;;;;AAeG;AACH;AAKA,MAAM,YAAY,GAAG,IAAI;AAGnB,MAAO,eAAgB,SAAQ,iBAAiB,CAAA;AACpD,IAAA,eAAe,CAAC,QAA8B,EAAA;AAC5C,QAAA,IAAI,CAAC,SAAS,CAAC,QAAQ,KAAK,YAAY,GAAG,YAAY,GAAG,OAAO,CAAC;IACpE;AAEA;;;AAGG;IACM,YAAY,GAAA;AACnB,QAAA,MAAM,SAAS,GAAG,KAAK,CAAC,YAAY,EAAE;AAEtC,QAAA,OAAO,IAAI,CAAC,MAAM,KAAK;AACrB,cAAE,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;cACvD,SAAS;IACf;AAEA;;;AAGG;IACM,iBAAiB,GAAA;AACxB,QAAA,OAAO,CAAC;IACV;uGAvBW,eAAe,EAAA,IAAA,EAAA,IAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;2GAAf,eAAe,EAAA,CAAA;;2FAAf,eAAe,EAAA,UAAA,EAAA,CAAA;kBAD3B;;;ACxBD;AACA;;;;;;;;;;;;;;;AAeG;AACH;AAWO,MAAM,uBAAuB,GAAG,wBAAwB,CAAC;AAC9D,IAAA,EAAE,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE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,EAAA,EAAA,IAAA,EAAA,iBAAiB,cAFhB,MAAM,EAAA,CAAA;;2FAEP,iBAAiB,EAAA,UAAA,EAAA,CAAA;kBAH7B,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA;;;AC1BD;AACA;;;;;;;;;;;;;;;AAeG;AACH;;ACjBA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"energinet-watt-core-date.mjs","sources":["../../../libs/watt/package/core/date/dayjs.ts","../../../libs/watt/package/core/date/watt-date-adapter.ts","../../../libs/watt/package/core/date/watt-danish-datetime.providers.ts","../../../libs/watt/package/core/date/watt-date-range.ts","../../../libs/watt/package/core/date/watt-format-date.ts","../../../libs/watt/package/core/date/watt-date.pipe.ts","../../../libs/watt/package/core/date/watt-locale.service.ts","../../../libs/watt/package/core/date/index.ts","../../../libs/watt/package/core/date/energinet-watt-core-date.ts"],"sourcesContent":["//#region License\n/**\n * @license\n * Copyright 2020 Energinet DataHub A/S\n *\n * Licensed under the Apache License, Version 2.0 (the \"License2\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n//#endregion\nimport dayjs from 'dayjs'; // eslint-disable-line no-restricted-imports\nimport utc from 'dayjs/plugin/utc';\nimport timezone from 'dayjs/plugin/timezone';\nimport duration from 'dayjs/plugin/duration';\nimport customParseFormat from 'dayjs/plugin/customParseFormat';\nimport updateLocale from 'dayjs/plugin/updateLocale';\nimport isBetween from 'dayjs/plugin/isBetween';\nimport isSameOrAfter from 'dayjs/plugin/isSameOrAfter';\n\n// Force import of plugins in generated .d.ts file by exporting their types\ntype __ngPackagrDayjsTypeScriptWorkaround =\n | typeof utc\n | typeof timezone\n | typeof duration\n | typeof customParseFormat\n | typeof updateLocale\n | typeof isBetween\n | typeof isSameOrAfter;\n\ndayjs.extend(utc);\ndayjs.extend(timezone);\ndayjs.extend(duration);\ndayjs.extend(customParseFormat);\ndayjs.extend(updateLocale);\ndayjs.extend(isBetween);\ndayjs.extend(isSameOrAfter);\n\nexport { dayjs, __ngPackagrDayjsTypeScriptWorkaround };\n","//#region License\n/**\n * @license\n * Copyright 2020 Energinet DataHub A/S\n *\n * Licensed under the Apache License, Version 2.0 (the \"License2\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n//#endregion\nimport { Injectable } from '@angular/core';\nimport { NativeDateAdapter } from '@angular/material/core';\n\nexport type WattSupportedLocales = 'da' | 'en';\nconst danishLocale = 'da';\n\n@Injectable()\nexport class WattDateAdapter extends NativeDateAdapter {\n setActiveLocale(language: WattSupportedLocales): void {\n this.setLocale(language === danishLocale ? danishLocale : 'en-GB');\n }\n\n /**\n * This is necessary to remove the dots from the date (ordinals) for danish locale in the calendar view.\n * due to `Intl.DateTimeFormat`\n */\n override getDateNames(): string[] {\n const dateNames = super.getDateNames();\n\n return this.locale === danishLocale\n ? dateNames.map((dateName) => dateName.replace(/\\./g, ''))\n : dateNames;\n }\n\n /**\n * Our week starts on Monday\n * @returns 0 for Sunday, 1 for Monday, etc.\n */\n override getFirstDayOfWeek(): number {\n return 1;\n }\n}\n","//#region License\n/**\n * @license\n * Copyright 2020 Energinet DataHub A/S\n *\n * Licensed under the Apache License, Version 2.0 (the \"License2\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n//#endregion\nimport {\n DateAdapter,\n MAT_DATE_FORMATS,\n MAT_DATE_LOCALE,\n MAT_NATIVE_DATE_FORMATS,\n} from '@angular/material/core';\nimport { makeEnvironmentProviders } from '@angular/core';\n\nimport { WattDateAdapter } from './watt-date-adapter';\n\nexport const danishDatetimeProviders = makeEnvironmentProviders([\n { provide: MAT_DATE_LOCALE, useValue: 'da' },\n {\n provide: DateAdapter,\n useClass: WattDateAdapter,\n deps: [MAT_DATE_LOCALE],\n },\n { provide: MAT_DATE_FORMATS, useValue: MAT_NATIVE_DATE_FORMATS },\n]);\n","//#region License\n/**\n * @license\n * Copyright 2020 Energinet DataHub A/S\n *\n * Licensed under the Apache License, Version 2.0 (the \"License2\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n//#endregion\nimport { dayjs } from './dayjs';\n\nexport interface WattRange<T> {\n start: T;\n end: T | null;\n}\n\n/**\n * This is included for legacy reasons, components should return Date objects instead of strings.\n * @deprecated Avoid using strings as dates, use Date objects instead.\n */\nexport type WattDateRange = WattRange<string>;\n\n/**\n * Checks if a given date is within a specified date range.\n */\nexport function contains(interval: WattRange<Date>, date: Date) {\n const day = dayjs(date);\n const isSameOrAfterStart = day.isSame(interval.start) || day.isAfter(interval.start);\n if (!interval.end) return isSameOrAfterStart;\n const isSameOrBeforeEnd = day.isSame(interval.end) || day.isBefore(interval.end);\n return isSameOrAfterStart && isSameOrBeforeEnd;\n}\n","//#region License\n/**\n * @license\n * Copyright 2020 Energinet DataHub A/S\n *\n * Licensed under the Apache License, Version 2.0 (the \"License2\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n//#endregion\nimport { dayjs } from './dayjs';\nimport { WattRange } from './watt-date-range';\n\nexport const formatStrings = {\n year: 'YYYY',\n monthYear: 'MMMM YYYY',\n short: 'DD-MM-YYYY',\n shortAbbr: 'DD. MMM YYYY',\n long: 'DD-MM-YYYY HH:mm',\n longAbbr: 'DD. MMM YYYY HH:mm',\n time: 'HH:mm',\n longAbbrWithSeconds: 'DD-MMM YYYY HH:mm:ss',\n};\n\nexport function wattFormatDate(\n input?: WattRange<Date> | WattRange<string> | Date | string | number | null,\n format: keyof typeof formatStrings = 'short',\n timeZone = 'Europe/Copenhagen'\n): string | null {\n if (!input) return null;\n\n if (input instanceof Date || typeof input === 'string') {\n return dayjs(input).tz(timeZone).format(formatStrings[format]);\n } else if (typeof input === 'number') {\n return dayjs(new Date(input)).tz(timeZone).format(formatStrings[format]);\n } else {\n return transformRange(input, format);\n }\n}\n\nfunction transformRange(\n input: WattRange<Date | string>,\n format: keyof typeof formatStrings\n): string | null {\n if (dayjs(input.start).isSame(dayjs(input.end), 'day') || input.end === null) {\n return wattFormatDate(input.start, format);\n } else {\n return `${wattFormatDate(input.start, format)} ― ${wattFormatDate(input.end, format)}`;\n }\n}\n","//#region License\n/**\n * @license\n * Copyright 2020 Energinet DataHub A/S\n *\n * Licensed under the Apache License, Version 2.0 (the \"License2\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n//#endregion\nimport { Pipe, PipeTransform } from '@angular/core';\n\nimport { WattRange } from './watt-date-range';\nimport { formatStrings, wattFormatDate } from './watt-format-date';\n\n@Pipe({\n name: 'wattDate',\n})\nexport class WattDatePipe implements PipeTransform {\n /**\n * @param input WattDateRange or string in ISO 8601 format or unix timestamp number\n */\n transform(\n input?: WattRange<Date> | WattRange<string> | Date | string | number | null,\n format: keyof typeof formatStrings = 'short',\n timeZone = 'Europe/Copenhagen'\n ): string | null {\n return wattFormatDate(input, format, timeZone);\n }\n}\n","//#region License\n/**\n * @license\n * Copyright 2020 Energinet DataHub A/S\n *\n * Licensed under the Apache License, Version 2.0 (the \"License2\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n//#endregion\nimport { computed, inject, Injectable, LOCALE_ID, signal } from '@angular/core';\nimport { DateAdapter } from '@angular/material/core';\n\nimport { WattDateAdapter, WattSupportedLocales } from './watt-date-adapter';\nimport { dayjs } from './dayjs';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class WattLocaleService {\n private readonly dateAdapter = inject<DateAdapter<unknown>>(DateAdapter);\n\n locale = signal(inject<WattSupportedLocales>(LOCALE_ID));\n isDanish = computed(() => this.locale() == 'da');\n isEnglish = computed(() => this.locale() == 'en');\n\n async setActiveLocale(locale: WattSupportedLocales): Promise<void> {\n if (locale === 'da') {\n await import('dayjs/locale/da');\n }\n\n if (locale === 'en') {\n await import('dayjs/locale/en');\n }\n\n dayjs.locale(locale);\n dayjs.updateLocale(locale, {\n weekStart: 1,\n });\n (this.dateAdapter as WattDateAdapter).setActiveLocale(locale);\n this.locale.set(locale);\n }\n}\n","//#region License\n/**\n * @license\n * Copyright 2020 Energinet DataHub A/S\n *\n * Licensed under the Apache License, Version 2.0 (the \"License2\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n//#endregion\nexport { dayjs, __ngPackagrDayjsTypeScriptWorkaround } from './dayjs';\nexport { danishDatetimeProviders } from './watt-danish-datetime.providers';\nexport { WattDateAdapter, WattSupportedLocales } from './watt-date-adapter';\nexport { type WattRange, type WattDateRange, contains } from './watt-date-range';\nexport { WattDatePipe } from './watt-date.pipe';\nexport { wattFormatDate } from './watt-format-date';\nexport { WattLocaleService } from './watt-locale.service';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;;AAAA;AACA;;;;;;;;;;;;;;;AAeG;AACH;AAoBA,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC;AACjB,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC;AACtB,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC;AACtB,KAAK,CAAC,MAAM,CAAC,iBAAiB,CAAC;AAC/B,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC;AAC1B,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC;AACvB,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC;;AC3C3B;AACA;;;;;;;;;;;;;;;AAeG;AACH;AAKA,MAAM,YAAY,GAAG,IAAI;AAGnB,MAAO,eAAgB,SAAQ,iBAAiB,CAAA;AACpD,IAAA,eAAe,CAAC,QAA8B,EAAA;AAC5C,QAAA,IAAI,CAAC,SAAS,CAAC,QAAQ,KAAK,YAAY,GAAG,YAAY,G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M,KAAK,IAAI,EAAE;AACnB,YAAA,MAAM,OAAO,iBAAiB,CAAC;QACjC;AAEA,QAAA,IAAI,MAAM,KAAK,IAAI,EAAE;AACnB,YAAA,MAAM,OAAO,iBAAiB,CAAC;QACjC;AAEA,QAAA,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;AACpB,QAAA,KAAK,CAAC,YAAY,CAAC,MAAM,EAAE;AACzB,YAAA,SAAS,EAAE,CAAC;AACb,SAAA,CAAC;AACD,QAAA,IAAI,CAAC,WAA+B,CAAC,eAAe,CAAC,MAAM,CAAC;AAC7D,QAAA,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC;IACzB;uGAtBW,iBAAiB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;AAAjB,IAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,iBAAiB,cAFhB,MAAM,EAAA,CAAA;;2FAEP,iBAAiB,EAAA,UAAA,EAAA,CAAA;kBAH7B,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA;;;AC1BD;AACA;;;;;;;;;;;;;;;AAeG;AACH;;ACjBA;;AAEG;;;;"}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { model, input, computed, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
+
import { WattIconComponent } from '@energinet/watt/icon';
|
|
4
|
+
|
|
5
|
+
//#region License
|
|
6
|
+
/**
|
|
7
|
+
* @license
|
|
8
|
+
* Copyright 2020 Energinet DataHub A/S
|
|
9
|
+
*
|
|
10
|
+
* Licensed under the Apache License, Version 2.0 (the "License2");
|
|
11
|
+
* you may not use this file except in compliance with the License.
|
|
12
|
+
* You may obtain a copy of the License at
|
|
13
|
+
*
|
|
14
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
+
* See the License for the specific language governing permissions and
|
|
20
|
+
* limitations under the License.
|
|
21
|
+
*/
|
|
22
|
+
//#endregion
|
|
23
|
+
/**
|
|
24
|
+
* Usage:
|
|
25
|
+
* `import { WattExpandableLinkComponent } from '@energinet/watt/expandable-link';`
|
|
26
|
+
*
|
|
27
|
+
* A lightweight inline collapsible/disclosure styled as a link. Unlike
|
|
28
|
+
* `WattExpandableCardComponent`, this component renders no card chrome,
|
|
29
|
+
* only a clickable link-styled label row with a chevron and the projected
|
|
30
|
+
* content below.
|
|
31
|
+
*/
|
|
32
|
+
class WattExpandableLinkComponent {
|
|
33
|
+
/**
|
|
34
|
+
* @ignore
|
|
35
|
+
* Counter for unique `contentId` generation. Matches the static-counter
|
|
36
|
+
* pattern used by other Watt form components (see `WattDatepickerComponent`,
|
|
37
|
+
* `WattTimepickerComponent`). The IDs are not SSR-hydration-safe; if Watt
|
|
38
|
+
* ever enables SSR this needs to switch to Angular's `_IdGenerator` or
|
|
39
|
+
* deferred assignment.
|
|
40
|
+
*/
|
|
41
|
+
static nextId = 0;
|
|
42
|
+
/** Whether the expandable is expanded. Supports two-way binding via `[(expanded)]`. */
|
|
43
|
+
expanded = model(false, ...(ngDevMode ? [{ debugName: "expanded" }] : /* istanbul ignore next */ []));
|
|
44
|
+
/** Label shown when the content is collapsed (e.g. "Vis indhold"). */
|
|
45
|
+
labelCollapsed = input.required(...(ngDevMode ? [{ debugName: "labelCollapsed" }] : /* istanbul ignore next */ []));
|
|
46
|
+
/**
|
|
47
|
+
* Label shown when the content is expanded (e.g. "Skjul indhold").
|
|
48
|
+
* Optional. If omitted, the collapsed label is shown in both states, leaving the
|
|
49
|
+
* chevron rotation as the only visual state cue (screen readers still get
|
|
50
|
+
* `aria-expanded` for state).
|
|
51
|
+
*/
|
|
52
|
+
labelExpanded = input(...(ngDevMode ? [undefined, { debugName: "labelExpanded" }] : /* istanbul ignore next */ []));
|
|
53
|
+
/**
|
|
54
|
+
* @ignore
|
|
55
|
+
*/
|
|
56
|
+
instanceId = WattExpandableLinkComponent.nextId++;
|
|
57
|
+
/**
|
|
58
|
+
* @ignore
|
|
59
|
+
*/
|
|
60
|
+
triggerId = `watt-expandable-link-trigger-${this.instanceId}`;
|
|
61
|
+
/**
|
|
62
|
+
* @ignore
|
|
63
|
+
*/
|
|
64
|
+
contentId = `watt-expandable-link-content-${this.instanceId}`;
|
|
65
|
+
/**
|
|
66
|
+
* @ignore
|
|
67
|
+
*/
|
|
68
|
+
currentLabel = computed(() => this.expanded() ? (this.labelExpanded() ?? this.labelCollapsed()) : this.labelCollapsed(), ...(ngDevMode ? [{ debugName: "currentLabel" }] : /* istanbul ignore next */ []));
|
|
69
|
+
/**
|
|
70
|
+
* @ignore
|
|
71
|
+
*/
|
|
72
|
+
toggle() {
|
|
73
|
+
this.expanded.update((value) => !value);
|
|
74
|
+
}
|
|
75
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: WattExpandableLinkComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
76
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.5", type: WattExpandableLinkComponent, isStandalone: true, selector: "watt-expandable-link", inputs: { expanded: { classPropertyName: "expanded", publicName: "expanded", isSignal: true, isRequired: false, transformFunction: null }, labelCollapsed: { classPropertyName: "labelCollapsed", publicName: "labelCollapsed", isSignal: true, isRequired: true, transformFunction: null }, labelExpanded: { classPropertyName: "labelExpanded", publicName: "labelExpanded", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { expanded: "expandedChange" }, host: { properties: { "class.watt-expandable-link--expanded": "expanded()" }, classAttribute: "watt-expandable-link" }, ngImport: i0, template: `
|
|
77
|
+
<button
|
|
78
|
+
type="button"
|
|
79
|
+
[id]="triggerId"
|
|
80
|
+
class="watt-expandable-link__header"
|
|
81
|
+
[attr.aria-expanded]="expanded()"
|
|
82
|
+
[attr.aria-controls]="contentId"
|
|
83
|
+
(click)="toggle()"
|
|
84
|
+
>
|
|
85
|
+
<watt-icon
|
|
86
|
+
name="down"
|
|
87
|
+
size="s"
|
|
88
|
+
class="watt-expandable-link__chevron"
|
|
89
|
+
[attr.aria-hidden]="true"
|
|
90
|
+
/>
|
|
91
|
+
<span class="watt-expandable-link__label">{{ currentLabel() }}</span>
|
|
92
|
+
</button>
|
|
93
|
+
|
|
94
|
+
<div
|
|
95
|
+
[id]="contentId"
|
|
96
|
+
class="watt-expandable-link__body"
|
|
97
|
+
[class.watt-expandable-link__body--expanded]="expanded()"
|
|
98
|
+
[attr.inert]="expanded() ? null : ''"
|
|
99
|
+
[attr.aria-hidden]="expanded() ? null : true"
|
|
100
|
+
[attr.aria-labelledby]="triggerId"
|
|
101
|
+
role="region"
|
|
102
|
+
>
|
|
103
|
+
<div class="watt-expandable-link__body-inner">
|
|
104
|
+
<ng-content />
|
|
105
|
+
</div>
|
|
106
|
+
</div>
|
|
107
|
+
`, isInline: true, styles: [":host{display:block}.watt-expandable-link__header{color:var(--watt-typography-link-color);font-size:1rem;line-height:1.5rem;font-weight:400;text-transform:none;letter-spacing:0;text-decoration:underline;cursor:pointer;font-size:.875rem;line-height:1.25rem;text-decoration:none;display:inline-flex;align-items:center;gap:var(--watt-space-xs);padding:0;background:transparent;border:none;text-align:left}.watt-expandable-link__label{text-decoration:underline}.watt-expandable-link__header:focus-visible{outline:2px solid var(--watt-color-primary);outline-offset:2px}.watt-expandable-link__chevron{transition:transform var(--watt-time-short) var(--watt-move-inside-screen)}:host(.watt-expandable-link--expanded) .watt-expandable-link__chevron{transform:rotate(180deg)}.watt-expandable-link__body{display:grid;grid-template-rows:0fr;transition:grid-template-rows var(--watt-time-short) var(--watt-move-inside-screen)}.watt-expandable-link__body--expanded{grid-template-rows:1fr}.watt-expandable-link__body-inner{min-height:0;overflow:hidden}@media(prefers-reduced-motion:reduce){.watt-expandable-link__chevron,.watt-expandable-link__body{transition:none}}\n"], dependencies: [{ kind: "component", type: WattIconComponent, selector: "watt-icon", inputs: ["name", "label", "size", "state"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
108
|
+
}
|
|
109
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: WattExpandableLinkComponent, decorators: [{
|
|
110
|
+
type: Component,
|
|
111
|
+
args: [{ selector: 'watt-expandable-link', changeDetection: ChangeDetectionStrategy.OnPush, imports: [WattIconComponent], template: `
|
|
112
|
+
<button
|
|
113
|
+
type="button"
|
|
114
|
+
[id]="triggerId"
|
|
115
|
+
class="watt-expandable-link__header"
|
|
116
|
+
[attr.aria-expanded]="expanded()"
|
|
117
|
+
[attr.aria-controls]="contentId"
|
|
118
|
+
(click)="toggle()"
|
|
119
|
+
>
|
|
120
|
+
<watt-icon
|
|
121
|
+
name="down"
|
|
122
|
+
size="s"
|
|
123
|
+
class="watt-expandable-link__chevron"
|
|
124
|
+
[attr.aria-hidden]="true"
|
|
125
|
+
/>
|
|
126
|
+
<span class="watt-expandable-link__label">{{ currentLabel() }}</span>
|
|
127
|
+
</button>
|
|
128
|
+
|
|
129
|
+
<div
|
|
130
|
+
[id]="contentId"
|
|
131
|
+
class="watt-expandable-link__body"
|
|
132
|
+
[class.watt-expandable-link__body--expanded]="expanded()"
|
|
133
|
+
[attr.inert]="expanded() ? null : ''"
|
|
134
|
+
[attr.aria-hidden]="expanded() ? null : true"
|
|
135
|
+
[attr.aria-labelledby]="triggerId"
|
|
136
|
+
role="region"
|
|
137
|
+
>
|
|
138
|
+
<div class="watt-expandable-link__body-inner">
|
|
139
|
+
<ng-content />
|
|
140
|
+
</div>
|
|
141
|
+
</div>
|
|
142
|
+
`, host: {
|
|
143
|
+
class: 'watt-expandable-link',
|
|
144
|
+
'[class.watt-expandable-link--expanded]': 'expanded()',
|
|
145
|
+
}, styles: [":host{display:block}.watt-expandable-link__header{color:var(--watt-typography-link-color);font-size:1rem;line-height:1.5rem;font-weight:400;text-transform:none;letter-spacing:0;text-decoration:underline;cursor:pointer;font-size:.875rem;line-height:1.25rem;text-decoration:none;display:inline-flex;align-items:center;gap:var(--watt-space-xs);padding:0;background:transparent;border:none;text-align:left}.watt-expandable-link__label{text-decoration:underline}.watt-expandable-link__header:focus-visible{outline:2px solid var(--watt-color-primary);outline-offset:2px}.watt-expandable-link__chevron{transition:transform var(--watt-time-short) var(--watt-move-inside-screen)}:host(.watt-expandable-link--expanded) .watt-expandable-link__chevron{transform:rotate(180deg)}.watt-expandable-link__body{display:grid;grid-template-rows:0fr;transition:grid-template-rows var(--watt-time-short) var(--watt-move-inside-screen)}.watt-expandable-link__body--expanded{grid-template-rows:1fr}.watt-expandable-link__body-inner{min-height:0;overflow:hidden}@media(prefers-reduced-motion:reduce){.watt-expandable-link__chevron,.watt-expandable-link__body{transition:none}}\n"] }]
|
|
146
|
+
}], propDecorators: { expanded: [{ type: i0.Input, args: [{ isSignal: true, alias: "expanded", required: false }] }, { type: i0.Output, args: ["expandedChange"] }], labelCollapsed: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelCollapsed", required: true }] }], labelExpanded: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelExpanded", required: false }] }] } });
|
|
147
|
+
|
|
148
|
+
//#region License
|
|
149
|
+
/**
|
|
150
|
+
* @license
|
|
151
|
+
* Copyright 2020 Energinet DataHub A/S
|
|
152
|
+
*
|
|
153
|
+
* Licensed under the Apache License, Version 2.0 (the "License2");
|
|
154
|
+
* you may not use this file except in compliance with the License.
|
|
155
|
+
* You may obtain a copy of the License at
|
|
156
|
+
*
|
|
157
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
158
|
+
*
|
|
159
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
160
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
161
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
162
|
+
* See the License for the specific language governing permissions and
|
|
163
|
+
* limitations under the License.
|
|
164
|
+
*/
|
|
165
|
+
//#endregion
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Generated bundle index. Do not edit.
|
|
169
|
+
*/
|
|
170
|
+
|
|
171
|
+
export { WattExpandableLinkComponent };
|
|
172
|
+
//# sourceMappingURL=energinet-watt-expandable-link.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"energinet-watt-expandable-link.mjs","sources":["../../../libs/watt/package/expandable-link/watt-expandable-link.component.ts","../../../libs/watt/package/expandable-link/index.ts","../../../libs/watt/package/expandable-link/energinet-watt-expandable-link.ts"],"sourcesContent":["//#region License\n/**\n * @license\n * Copyright 2020 Energinet DataHub A/S\n *\n * Licensed under the Apache License, Version 2.0 (the \"License2\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n//#endregion\nimport { ChangeDetectionStrategy, Component, computed, input, model } from '@angular/core';\nimport { WattIconComponent } from '@energinet/watt/icon';\n\n/**\n * Usage:\n * `import { WattExpandableLinkComponent } from '@energinet/watt/expandable-link';`\n *\n * A lightweight inline collapsible/disclosure styled as a link. Unlike\n * `WattExpandableCardComponent`, this component renders no card chrome,\n * only a clickable link-styled label row with a chevron and the projected\n * content below.\n */\n@Component({\n selector: 'watt-expandable-link',\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [WattIconComponent],\n styleUrl: './watt-expandable-link.component.scss',\n template: `\n <button\n type=\"button\"\n [id]=\"triggerId\"\n class=\"watt-expandable-link__header\"\n [attr.aria-expanded]=\"expanded()\"\n [attr.aria-controls]=\"contentId\"\n (click)=\"toggle()\"\n >\n <watt-icon\n name=\"down\"\n size=\"s\"\n class=\"watt-expandable-link__chevron\"\n [attr.aria-hidden]=\"true\"\n />\n <span class=\"watt-expandable-link__label\">{{ currentLabel() }}</span>\n </button>\n\n <div\n [id]=\"contentId\"\n class=\"watt-expandable-link__body\"\n [class.watt-expandable-link__body--expanded]=\"expanded()\"\n [attr.inert]=\"expanded() ? null : ''\"\n [attr.aria-hidden]=\"expanded() ? null : true\"\n [attr.aria-labelledby]=\"triggerId\"\n role=\"region\"\n >\n <div class=\"watt-expandable-link__body-inner\">\n <ng-content />\n </div>\n </div>\n `,\n host: {\n class: 'watt-expandable-link',\n '[class.watt-expandable-link--expanded]': 'expanded()',\n },\n})\nexport class WattExpandableLinkComponent {\n /**\n * @ignore\n * Counter for unique `contentId` generation. Matches the static-counter\n * pattern used by other Watt form components (see `WattDatepickerComponent`,\n * `WattTimepickerComponent`). The IDs are not SSR-hydration-safe; if Watt\n * ever enables SSR this needs to switch to Angular's `_IdGenerator` or\n * deferred assignment.\n */\n private static nextId = 0;\n\n /** Whether the expandable is expanded. Supports two-way binding via `[(expanded)]`. */\n expanded = model(false);\n\n /** Label shown when the content is collapsed (e.g. \"Vis indhold\"). */\n labelCollapsed = input.required<string>();\n\n /**\n * Label shown when the content is expanded (e.g. \"Skjul indhold\").\n * Optional. If omitted, the collapsed label is shown in both states, leaving the\n * chevron rotation as the only visual state cue (screen readers still get\n * `aria-expanded` for state).\n */\n labelExpanded = input<string>();\n\n /**\n * @ignore\n */\n private readonly instanceId = WattExpandableLinkComponent.nextId++;\n\n /**\n * @ignore\n */\n readonly triggerId = `watt-expandable-link-trigger-${this.instanceId}`;\n\n /**\n * @ignore\n */\n readonly contentId = `watt-expandable-link-content-${this.instanceId}`;\n\n /**\n * @ignore\n */\n currentLabel = computed(() =>\n this.expanded() ? (this.labelExpanded() ?? this.labelCollapsed()) : this.labelCollapsed()\n );\n\n /**\n * @ignore\n */\n toggle(): void {\n this.expanded.update((value) => !value);\n }\n}\n","//#region License\n/**\n * @license\n * Copyright 2020 Energinet DataHub A/S\n *\n * Licensed under the Apache License, Version 2.0 (the \"License2\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n//#endregion\nexport { WattExpandableLinkComponent } from './watt-expandable-link.component';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAAA;AACA;;;;;;;;;;;;;;;AAeG;AACH;AAIA;;;;;;;;AAQG;MA2CU,2BAA2B,CAAA;AACtC;;;;;;;AAOG;AACK,IAAA,OAAO,MAAM,GAAG,CAAC;;AAGzB,IAAA,QAAQ,GAAG,KAAK,CAAC,KAAK,+EAAC;;AAGvB,IAAA,cAAc,GAAG,KAAK,CAAC,QAAQ,oFAAU;AAEzC;;;;;AAKG;IACH,aAAa,GAAG,KAAK,CAAA,IAAA,SAAA,GAAA,CAAA,SAAA,EAAA,EAAA,SAAA,EAAA,eAAA,EAAA,CAAA,8BAAA,EAAA,CAAA,CAAU;AAE/B;;AAEG;AACc,IAAA,UAAU,GAAG,2BAA2B,CAAC,MAAM,EAAE;AAElE;;AAEG;AACM,IAAA,SAAS,GAAG,CAAA,6BAAA,EAAgC,IAAI,CAAC,UAAU,EAAE;AAEtE;;AAEG;AACM,IAAA,SAAS,GAAG,CAAA,6BAAA,EAAgC,IAAI,CAAC,UAAU,EAAE;AAEtE;;AAEG;AACH,IAAA,YAAY,GA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;;;;;;;;AA+BT,EAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,MAAA,EAAA,CAAA,moCAAA,CAAA,EAAA,YAAA,EAAA,CAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EAjCS,iBAAiB,EAAA,QAAA,EAAA,WAAA,EAAA,MAAA,EAAA,CAAA,MAAA,EAAA,OAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA;;2FAuChB,2BAA2B,EAAA,UAAA,EAAA,CAAA;kBA1CvC,SAAS;+BACE,sBAAsB,EAAA,eAAA,EACf,uBAAuB,CAAC,MAAM,WACtC,CAAC,iBAAiB,CAAC,EAAA,QAAA,EAElB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BT,EAAA,IAAA,EACK;AACJ,wBAAA,KAAK,EAAE,sBAAsB;AAC7B,wBAAA,wCAAwC,EAAE,YAAY;AACvD,qBAAA,EAAA,MAAA,EAAA,CAAA,moCAAA,CAAA,EAAA;;;ACtEH;AACA;;;;;;;;;;;;;;;AAeG;AACH;;ACjBA;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@energinet/watt",
|
|
4
|
-
"version": "4.5.
|
|
4
|
+
"version": "4.5.4",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
@@ -91,6 +91,10 @@
|
|
|
91
91
|
"types": "./types/energinet-watt-expandable-card.d.ts",
|
|
92
92
|
"default": "./fesm2022/energinet-watt-expandable-card.mjs"
|
|
93
93
|
},
|
|
94
|
+
"./expandable-link": {
|
|
95
|
+
"types": "./types/energinet-watt-expandable-link.d.ts",
|
|
96
|
+
"default": "./fesm2022/energinet-watt-expandable-link.mjs"
|
|
97
|
+
},
|
|
94
98
|
"./field": {
|
|
95
99
|
"types": "./types/energinet-watt-field.d.ts",
|
|
96
100
|
"default": "./fesm2022/energinet-watt-field.mjs"
|
|
@@ -3,6 +3,8 @@ import timezone from 'dayjs/plugin/timezone';
|
|
|
3
3
|
import duration from 'dayjs/plugin/duration';
|
|
4
4
|
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
|
5
5
|
import updateLocale from 'dayjs/plugin/updateLocale';
|
|
6
|
+
import isBetween from 'dayjs/plugin/isBetween';
|
|
7
|
+
import isSameOrAfter from 'dayjs/plugin/isSameOrAfter';
|
|
6
8
|
import * as i0 from '@angular/core';
|
|
7
9
|
import { PipeTransform } from '@angular/core';
|
|
8
10
|
import { NativeDateAdapter } from '@angular/material/core';
|
|
@@ -25,7 +27,7 @@ export { default as dayjs } from 'dayjs';
|
|
|
25
27
|
* limitations under the License.
|
|
26
28
|
*/
|
|
27
29
|
|
|
28
|
-
type __ngPackagrDayjsTypeScriptWorkaround = typeof utc | typeof timezone | typeof duration | typeof customParseFormat | typeof updateLocale;
|
|
30
|
+
type __ngPackagrDayjsTypeScriptWorkaround = typeof utc | typeof timezone | typeof duration | typeof customParseFormat | typeof updateLocale | typeof isBetween | typeof isSameOrAfter;
|
|
29
31
|
|
|
30
32
|
declare const danishDatetimeProviders: i0.EnvironmentProviders;
|
|
31
33
|
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import * as _angular_core from '@angular/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Usage:
|
|
5
|
+
* `import { WattExpandableLinkComponent } from '@energinet/watt/expandable-link';`
|
|
6
|
+
*
|
|
7
|
+
* A lightweight inline collapsible/disclosure styled as a link. Unlike
|
|
8
|
+
* `WattExpandableCardComponent`, this component renders no card chrome,
|
|
9
|
+
* only a clickable link-styled label row with a chevron and the projected
|
|
10
|
+
* content below.
|
|
11
|
+
*/
|
|
12
|
+
declare class WattExpandableLinkComponent {
|
|
13
|
+
/**
|
|
14
|
+
* @ignore
|
|
15
|
+
* Counter for unique `contentId` generation. Matches the static-counter
|
|
16
|
+
* pattern used by other Watt form components (see `WattDatepickerComponent`,
|
|
17
|
+
* `WattTimepickerComponent`). The IDs are not SSR-hydration-safe; if Watt
|
|
18
|
+
* ever enables SSR this needs to switch to Angular's `_IdGenerator` or
|
|
19
|
+
* deferred assignment.
|
|
20
|
+
*/
|
|
21
|
+
private static nextId;
|
|
22
|
+
/** Whether the expandable is expanded. Supports two-way binding via `[(expanded)]`. */
|
|
23
|
+
expanded: _angular_core.ModelSignal<boolean>;
|
|
24
|
+
/** Label shown when the content is collapsed (e.g. "Vis indhold"). */
|
|
25
|
+
labelCollapsed: _angular_core.InputSignal<string>;
|
|
26
|
+
/**
|
|
27
|
+
* Label shown when the content is expanded (e.g. "Skjul indhold").
|
|
28
|
+
* Optional. If omitted, the collapsed label is shown in both states, leaving the
|
|
29
|
+
* chevron rotation as the only visual state cue (screen readers still get
|
|
30
|
+
* `aria-expanded` for state).
|
|
31
|
+
*/
|
|
32
|
+
labelExpanded: _angular_core.InputSignal<string | undefined>;
|
|
33
|
+
/**
|
|
34
|
+
* @ignore
|
|
35
|
+
*/
|
|
36
|
+
private readonly instanceId;
|
|
37
|
+
/**
|
|
38
|
+
* @ignore
|
|
39
|
+
*/
|
|
40
|
+
readonly triggerId: string;
|
|
41
|
+
/**
|
|
42
|
+
* @ignore
|
|
43
|
+
*/
|
|
44
|
+
readonly contentId: string;
|
|
45
|
+
/**
|
|
46
|
+
* @ignore
|
|
47
|
+
*/
|
|
48
|
+
currentLabel: _angular_core.Signal<string>;
|
|
49
|
+
/**
|
|
50
|
+
* @ignore
|
|
51
|
+
*/
|
|
52
|
+
toggle(): void;
|
|
53
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<WattExpandableLinkComponent, never>;
|
|
54
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<WattExpandableLinkComponent, "watt-expandable-link", never, { "expanded": { "alias": "expanded"; "required": false; "isSignal": true; }; "labelCollapsed": { "alias": "labelCollapsed"; "required": true; "isSignal": true; }; "labelExpanded": { "alias": "labelExpanded"; "required": false; "isSignal": true; }; }, { "expanded": "expandedChange"; }, never, ["*"], true, never>;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export { WattExpandableLinkComponent };
|