@nanoporetech-digital/components 4.10.0 → 5.1.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/CHANGELOG.md +46 -0
- package/dist/cjs/{form-control-2e900f54.js → form-control-443e90bf.js} +2 -3
- package/dist/cjs/form-control-443e90bf.js.map +1 -0
- package/dist/cjs/index-71f899a7.js +6 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/nano-components.cjs.js +1 -1
- package/dist/cjs/nano-dropdown.cjs.entry.js +1 -1
- package/dist/cjs/nano-dropdown.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-global-nav-user-profile_3.cjs.entry.js +2 -2
- package/dist/cjs/nano-global-nav-user-profile_3.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-grid-item.cjs.entry.js +29 -0
- package/dist/cjs/nano-grid-item.cjs.entry.js.map +1 -0
- package/dist/cjs/nano-grid_2.cjs.entry.js +443 -0
- package/dist/cjs/nano-grid_2.cjs.entry.js.map +1 -0
- package/dist/cjs/nano-hero.cjs.entry.js +4 -10
- package/dist/cjs/nano-hero.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-icon-button_2.cjs.entry.js +2 -2
- package/dist/cjs/nano-icon-button_2.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-input.cjs.entry.js +2 -2
- package/dist/cjs/nano-input.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-range.cjs.entry.js +1 -1
- package/dist/cjs/nano-range.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-sortable.cjs.entry.js +1 -0
- package/dist/cjs/nano-sortable.cjs.entry.js.map +1 -1
- package/dist/cjs/{nano-table-ff33dc43.js → nano-table-5587101f.js} +37 -30
- package/dist/cjs/nano-table-5587101f.js.map +1 -0
- package/dist/cjs/nano-table.cjs.entry.js +1 -1
- package/dist/cjs/{table.worker-0a6bc962.js → table.worker-abba820e.js} +2 -2
- package/dist/cjs/table.worker-abba820e.js.map +1 -0
- package/dist/collection/components/dropdown/dropdown.css +2 -1
- package/dist/collection/components/form-control/form-control.js +1 -2
- package/dist/collection/components/form-control/form-control.js.map +1 -1
- package/dist/collection/components/grid/grid-item.js +11 -136
- package/dist/collection/components/grid/grid-item.js.map +1 -1
- package/dist/collection/components/grid/grid.css +9 -242
- package/dist/collection/components/grid/grid.js +255 -240
- package/dist/collection/components/grid/grid.js.map +1 -1
- package/dist/collection/components/hero/hero.css +42 -89
- package/dist/collection/components/hero/hero.js +4 -11
- package/dist/collection/components/hero/hero.js.map +1 -1
- package/dist/collection/components/icon-button/icon-button.css +12 -0
- package/dist/collection/components/icon-button/icon-button.js +1 -1
- package/dist/collection/components/icon-button/icon-button.js.map +1 -1
- package/dist/collection/components/input/input.css +8 -9
- package/dist/collection/components/range/range.css +0 -3
- package/dist/collection/components/select/select.css +8 -9
- package/dist/collection/components/sortable/sortable.js +2 -1
- package/dist/collection/components/sortable/sortable.js.map +1 -1
- package/dist/collection/components/table/table.css +6 -0
- package/dist/collection/components/table/table.js +25 -18
- package/dist/collection/components/table/table.js.map +1 -1
- package/dist/collection/components/table/table.row.js +7 -7
- package/dist/collection/components/table/table.row.js.map +1 -1
- package/dist/collection/utils/constructible-style.js +129 -0
- package/dist/collection/utils/constructible-style.js.map +1 -0
- package/dist/components/dropdown.js +1 -1
- package/dist/components/dropdown.js.map +1 -1
- package/dist/components/form-control.js +1 -2
- package/dist/components/form-control.js.map +1 -1
- package/dist/components/grid.js +275 -183
- package/dist/components/grid.js.map +1 -1
- package/dist/components/icon-button.js +2 -2
- package/dist/components/icon-button.js.map +1 -1
- package/dist/components/input.js +1 -1
- package/dist/components/input.js.map +1 -1
- package/dist/components/nano-grid-item.js +33 -1
- package/dist/components/nano-grid-item.js.map +1 -1
- package/dist/components/nano-hero.js +6 -19
- package/dist/components/nano-hero.js.map +1 -1
- package/dist/components/nano-range.js +1 -1
- package/dist/components/nano-range.js.map +1 -1
- package/dist/components/nano-sortable.js +1 -0
- package/dist/components/nano-sortable.js.map +1 -1
- package/dist/components/select.js +1 -1
- package/dist/components/select.js.map +1 -1
- package/dist/components/table.js +36 -29
- package/dist/components/table.js.map +1 -1
- package/dist/esm/{form-control-269ba84f.js → form-control-e8739b2e.js} +2 -3
- package/dist/esm/form-control-e8739b2e.js.map +1 -0
- package/dist/esm/index-dad5627b.js +6 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/nano-components.js +1 -1
- package/dist/esm/nano-dropdown.entry.js +1 -1
- package/dist/esm/nano-dropdown.entry.js.map +1 -1
- package/dist/esm/nano-global-nav-user-profile_3.entry.js +2 -2
- package/dist/esm/nano-global-nav-user-profile_3.entry.js.map +1 -1
- package/dist/esm/nano-grid-item.entry.js +25 -0
- package/dist/esm/nano-grid-item.entry.js.map +1 -0
- package/dist/esm/nano-grid_2.entry.js +438 -0
- package/dist/esm/nano-grid_2.entry.js.map +1 -0
- package/dist/esm/nano-hero.entry.js +4 -10
- package/dist/esm/nano-hero.entry.js.map +1 -1
- package/dist/esm/nano-icon-button_2.entry.js +2 -2
- package/dist/esm/nano-icon-button_2.entry.js.map +1 -1
- package/dist/esm/nano-input.entry.js +2 -2
- package/dist/esm/nano-input.entry.js.map +1 -1
- package/dist/esm/nano-range.entry.js +1 -1
- package/dist/esm/nano-range.entry.js.map +1 -1
- package/dist/esm/nano-sortable.entry.js +1 -0
- package/dist/esm/nano-sortable.entry.js.map +1 -1
- package/dist/esm/{nano-table-ec980076.js → nano-table-fb6b3bcb.js} +37 -30
- package/dist/esm/nano-table-fb6b3bcb.js.map +1 -0
- package/dist/esm/nano-table.entry.js +1 -1
- package/dist/esm/{table.worker-b53db58e.js → table.worker-43365547.js} +2 -2
- package/dist/esm/table.worker-43365547.js.map +1 -0
- package/dist/nano-components/nano-components.css +1 -1
- package/dist/nano-components/nano-components.esm.js +1 -1
- package/dist/nano-components/nano-components.esm.js.map +1 -1
- package/dist/nano-components/p-17b099cc.entry.js +5 -0
- package/dist/nano-components/p-17b099cc.entry.js.map +1 -0
- package/dist/nano-components/p-553acf24.entry.js +5 -0
- package/dist/nano-components/{p-58b53239.entry.js.map → p-553acf24.entry.js.map} +1 -1
- package/dist/nano-components/p-6975f110.entry.js +5 -0
- package/dist/nano-components/p-6975f110.entry.js.map +1 -0
- package/dist/nano-components/p-71057181.js +5 -0
- package/dist/nano-components/p-71057181.js.map +1 -0
- package/dist/nano-components/{p-f591400b.entry.js → p-913cf45f.entry.js} +2 -2
- package/dist/nano-components/p-99914796.js +5 -0
- package/dist/nano-components/p-99914796.js.map +1 -0
- package/dist/nano-components/p-9b5429e1.entry.js +5 -0
- package/dist/nano-components/p-9b5429e1.entry.js.map +1 -0
- package/dist/nano-components/p-ad6209ec.entry.js +5 -0
- package/dist/nano-components/p-ad6209ec.entry.js.map +1 -0
- package/dist/nano-components/p-bdef618c.entry.js +5 -0
- package/dist/nano-components/p-bdef618c.entry.js.map +1 -0
- package/dist/nano-components/{p-241baff8.entry.js → p-d79c6862.entry.js} +2 -2
- package/dist/nano-components/p-d79c6862.entry.js.map +1 -0
- package/dist/nano-components/{p-806bcd46.js → p-daa6f834.js} +2 -2
- package/dist/nano-components/p-deb0799c.entry.js +5 -0
- package/dist/nano-components/{p-6a3a29c6.entry.js.map → p-deb0799c.entry.js.map} +1 -1
- package/dist/nano-components/p-ebb98a9e.entry.js +5 -0
- package/dist/nano-components/p-ebb98a9e.entry.js.map +1 -0
- package/dist/types/components/grid/grid-item.d.ts +3 -11
- package/dist/types/components/grid/grid.d.ts +44 -68
- package/dist/types/components/hero/hero.d.ts +1 -3
- package/dist/types/components/table/table.d.ts +5 -0
- package/dist/types/components.d.ts +85 -61
- package/dist/types/utils/constructible-style.d.ts +31 -0
- package/docs-json.json +152 -88
- package/docs-vscode.json +28 -21
- package/hydrate/index.js +348 -307
- package/package.json +2 -2
- package/dist/cjs/form-control-2e900f54.js.map +0 -1
- package/dist/cjs/nano-grid_3.cjs.entry.js +0 -431
- package/dist/cjs/nano-grid_3.cjs.entry.js.map +0 -1
- package/dist/cjs/nano-table-ff33dc43.js.map +0 -1
- package/dist/cjs/table.worker-0a6bc962.js.map +0 -1
- package/dist/collection/components/grid/grid-item.css +0 -15
- package/dist/components/grid-item.js +0 -107
- package/dist/components/grid-item.js.map +0 -1
- package/dist/esm/form-control-269ba84f.js.map +0 -1
- package/dist/esm/nano-grid_3.entry.js +0 -425
- package/dist/esm/nano-grid_3.entry.js.map +0 -1
- package/dist/esm/nano-table-ec980076.js.map +0 -1
- package/dist/esm/table.worker-b53db58e.js.map +0 -1
- package/dist/nano-components/p-064af7d0.js +0 -5
- package/dist/nano-components/p-064af7d0.js.map +0 -1
- package/dist/nano-components/p-107d4549.entry.js +0 -5
- package/dist/nano-components/p-107d4549.entry.js.map +0 -1
- package/dist/nano-components/p-239d343a.entry.js +0 -5
- package/dist/nano-components/p-239d343a.entry.js.map +0 -1
- package/dist/nano-components/p-241baff8.entry.js.map +0 -1
- package/dist/nano-components/p-58b53239.entry.js +0 -5
- package/dist/nano-components/p-5ac74848.js +0 -5
- package/dist/nano-components/p-5ac74848.js.map +0 -1
- package/dist/nano-components/p-6a3a29c6.entry.js +0 -5
- package/dist/nano-components/p-87bc66b5.entry.js +0 -5
- package/dist/nano-components/p-87bc66b5.entry.js.map +0 -1
- package/dist/nano-components/p-d3de231c.entry.js +0 -5
- package/dist/nano-components/p-d3de231c.entry.js.map +0 -1
- package/dist/nano-components/p-d792f692.entry.js +0 -5
- package/dist/nano-components/p-d792f692.entry.js.map +0 -1
- /package/dist/nano-components/{p-806bcd46.js.map → p-913cf45f.entry.js.map} +0 -0
- /package/dist/nano-components/{p-f591400b.entry.js.map → p-daa6f834.js.map} +0 -0
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nanoporetech-digital/components",
|
3
|
-
"version": "
|
3
|
+
"version": "5.1.0",
|
4
4
|
"repository": {
|
5
5
|
"type": "git",
|
6
6
|
"url": "https://git.oxfordnanolabs.local/Digital/nano-components"
|
@@ -131,7 +131,7 @@
|
|
131
131
|
"nanopore",
|
132
132
|
"digital"
|
133
133
|
],
|
134
|
-
"gitHead": "
|
134
|
+
"gitHead": "467a4c6f441b604c55cef60fa1b9c4aa0ef637ff",
|
135
135
|
"volta": {
|
136
136
|
"node": "14.18.1",
|
137
137
|
"npm": "8.6.0"
|
@@ -1 +0,0 @@
|
|
1
|
-
{"file":"form-control-2e900f54.js","mappings":";;;;;;;AAyCA,MAAM,WAAW,GAAG,CAAC,EACnB,KAAK,EACL,YAAY,EACZ,SAAS,EACT,OAAO,EACP,UAAU,EACV,WAAW,EACX,SAAS,EACT,QAAQ,EACR,GAAG,EACH,aAAa,EACb,SAAS,EACT,SAAS,GACE;EACX,IAAI,CAAC,KAAK,IAAI,CAAC,YAAY;IAAE,OAAO;EACpC,IAAI,UAAU,EAAE;IACd,QACEA,mBAAO,KAAK,EAAC,wBAAwB,EAAC,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,OAAO;MAClE,KAAK,IAAI,KAAK;MACd,CAAC,KAAK,IAAI,YAAY,IAAIA,kBAAM,IAAI,EAAC,OAAO,GAAG;MAC/C,aAAa,KACZA,kBAAM,KAAK,EAAC,4BAA4B,IACrC,SAAS,GAAG,IAAI,SAAS,IAAI,SAAS,EAAE,GAAG,IAAI,SAAS,EAAE,CACtD,CACR,CACK,EACR;GACH;OAAM;IACL,QACEA,mBACE,KAAK,EAAE,EAAE,kBAAkB,EAAE,IAAI,EAAE,eAAe,EAAE,SAAS,EAAE,EAC/D,OAAO,EAAE,SAAS,EAClB,EAAE,EAAE,OAAO;MAEXA,iBAAK,KAAK,EAAC,uBAAuB;QAC/B,WAAW,IAAI,QAAQ,IAAI,GAAG,KAC7BA,kBAAM,KAAK,EAAC,8BAA8B;UAAE,WAAW;gBAAW,CACnE;QACDA,kBAAM,KAAK,EAAC,sBAAsB;UAC/B,KAAK,IAAI,KAAK;UACd,CAAC,KAAK,IAAI,YAAY,IAAIA,kBAAM,IAAI,EAAC,O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ources":["./src/components/form-control/form-control.tsx"],"sourcesContent":["import { FunctionalComponent, h, VNode } from '@stencil/core';\nimport type { TextFieldTypes } from '../../interface';\n\ninterface FormControlWrapProps {\n rtl: boolean;\n floatLabel: boolean;\n labelId: string;\n label: string;\n moreId: string;\n helperEndId: string;\n type?: TextFieldTypes;\n showInlineError: boolean;\n hasHelperSlot: boolean;\n errorMessage: string;\n controlId: string;\n hasLabelSlot: boolean;\n hideLabel: boolean;\n placeholder: string;\n hasValue: boolean;\n showCharCount?: boolean;\n maxlength?: number;\n charCount?: number;\n hasHelperEndSlot?: boolean;\n}\n\ninterface FormControlProps {\n clearControl: boolean;\n onClearText?: () => void;\n readonly: boolean;\n disabled: boolean;\n control: HTMLNanoInputElement | HTMLNanoSelectElement;\n ref?: (elm?: HTMLElement) => void;\n endSlot?: VNode;\n endValueSlot?: VNode;\n startSlot?: VNode;\n}\n\ninterface LabelProps extends FormControlWrapProps {\n rtl: boolean;\n}\n\nconst renderLabel = ({\n label,\n hasLabelSlot,\n controlId,\n labelId,\n floatLabel,\n placeholder,\n hideLabel,\n hasValue,\n rtl,\n showCharCount,\n maxlength,\n charCount,\n}: LabelProps) => {\n if (!label && !hasLabelSlot) return;\n if (floatLabel) {\n return (\n <label class=\"form-ctrl__float-label\" htmlFor={controlId} id={labelId}>\n {label && label}\n {!label && hasLabelSlot && <slot name=\"label\" />}\n {showCharCount && (\n <span class=\"form-ctrl__label-charcount\">\n {maxlength ? ` ${charCount}/${maxlength}` : ` ${charCount}`}\n </span>\n )}\n </label>\n );\n } else {\n return (\n <label\n class={{ 'form-ctrl__label': true, 'visually-hide': hideLabel }}\n htmlFor={controlId}\n id={labelId}\n >\n <div class=\"form-ctrl__label-wrap\">\n {placeholder && hasValue && rtl && (\n <span class=\"form-ctrl__label-placeholder\">{placeholder} / </span>\n )}\n <span class=\"form-ctrl__labeltext\">\n {label && label}\n {!label && hasLabelSlot && <slot name=\"label\" />}\n </span>\n {placeholder && hasValue && !rtl && (\n <span class=\"form-ctrl__label-placeholder\"> / {placeholder}</span>\n )}\n </div>\n {showCharCount && (\n <span class=\"form-ctrl__label-charcount\">\n {maxlength\n ? maxlength - charCount + ' left'\n : charCount + ' characters'}\n </span>\n )}\n </label>\n );\n }\n};\n\nexport const FormControlWrap: FunctionalComponent<FormControlWrapProps> = (\n props: FormControlWrapProps,\n children\n) => {\n const {\n rtl,\n floatLabel,\n label,\n moreId,\n helperEndId,\n type,\n hasHelperSlot,\n showInlineError,\n errorMessage,\n hasHelperEndSlot,\n } = props;\n\n const MainTag = hasHelperEndSlot ? 'nano-resize-observe' : 'div';\n\n return (\n <MainTag\n states=\"350w has-enough-width\"\n class={{\n 'has-label': label !== null && !floatLabel,\n 'has-float-label': label !== null && floatLabel,\n 'has-helper-end': hasHelperEndSlot,\n rtl,\n 'form-ctrl': true,\n }}\n >\n <div class=\"form-ctrl__wrapper\">\n {!floatLabel ? renderLabel({ ...props }) : ''}\n <div\n class={{\n 'form-ctrl__input': true,\n 'form-ctrl__textarea': type === 'textarea',\n }}\n >\n {floatLabel && renderLabel({ ...props, rtl })}\n {children}\n </div>\n {showInlineError || hasHelperSlot ? (\n <div class=\"form-ctrl__more\" id={moreId}>\n {!!showInlineError ? (\n <div class=\"form-ctrl__error\" aria-live=\"polite\">\n {errorMessage}\n </div>\n ) : (\n ''\n )}\n <div class=\"form-ctrl__helper\">\n <slot name=\"helper\" />\n </div>\n </div>\n ) : (\n ''\n )}\n </div>\n {hasHelperEndSlot ? (\n <div class=\"form-ctrl__helper-end\" id={helperEndId}>\n <slot name=\"helper-end\" />\n </div>\n ) : (\n ''\n )}\n </MainTag>\n );\n};\n\nexport const FormControl: FunctionalComponent<FormControlProps> = (\n props: FormControlProps,\n children\n) => {\n const {\n clearControl,\n onClearText,\n readonly,\n disabled,\n control,\n ref,\n endSlot,\n endValueSlot,\n startSlot,\n } = props;\n const clickThrough = () => {\n control.setFocus();\n };\n\n return (\n <div\n class=\"form-ctrl__input-wrap\"\n ref={(el) => {\n if (ref) ref(el);\n }}\n >\n <span class=\"form-ctrl__slot-start\">\n <slot name=\"start\" />\n {startSlot}\n </span>\n {children}\n {clearControl && !readonly && !disabled && (\n <button\n type=\"button\"\n class=\"icon form-ctrl__clear-btn\"\n tabindex=\"-1\"\n onTouchStart={onClearText}\n onMouseDown={onClearText}\n >\n <nano-icon name=\"light/times\"></nano-icon>\n </button>\n )}\n <span class=\"form-ctrl__slot-value-end\" onClick={clickThrough}>\n <slot name=\"value-end\" />\n {endValueSlot}\n </span>\n <span class=\"form-ctrl__slot-end\">\n <slot name=\"end\" />\n {endSlot}\n </span>\n </div>\n );\n};\n"],"version":3}
|
@@ -1,431 +0,0 @@
|
|
1
|
-
/*!
|
2
|
-
* Web Components for Nanopore digital Web Apps
|
3
|
-
*/
|
4
|
-
'use strict';
|
5
|
-
|
6
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
7
|
-
|
8
|
-
const index = require('./index-71f899a7.js');
|
9
|
-
const throttle = require('./throttle-f55496c8.js');
|
10
|
-
|
11
|
-
const gridCss = ":host{box-sizing:border-box}*,*::before,*::after{box-sizing:border-box}[hidden]{display:none !important}:host{--grid-col-gap:var(--nano-spacing-medium, 16px);--grid-row-gap:var(--nano-spacing-medium, 16px);--current-grid-size:\"'grid size: sm'\";display:block;opacity:0;transition:0.2s ease opacity;max-width:100%}:host .grid{display:grid;grid-gap:var(--grid-row-gap) var(--grid-col-gap);block-size:inherit;min-block-size:inherit}:host(.ready){opacity:1}:host(.has-grid) .grid{display:grid}:host(.has-grid) .grid ::slotted(.nano-grid-col-start-1){grid-column-start:1 !important}:host(.has-grid) .grid ::slotted(.nano-grid-row-start-1){grid-row-start:1 !important}:host(.has-grid) .grid ::slotted(.nano-grid-col-span-1){grid-column-end:span 1 !important}:host(.has-grid) .grid ::slotted(.nano-grid-row-span-1){grid-row-end:span 1 !important}:host(.has-grid) .grid ::slotted(.nano-grid-col-start-2){grid-column-start:2 !important}:host(.has-grid) .grid ::slotted(.nano-grid-row-start-2){grid-row-start:2 !important}:host(.has-grid) .grid ::slotted(.nano-grid-col-span-2){grid-column-end:span 2 !important}:host(.has-grid) .grid ::slotted(.nano-grid-row-span-2){grid-row-end:span 2 !important}:host(.has-grid) .grid ::slotted(.nano-grid-col-start-3){grid-column-start:3 !important}:host(.has-grid) .grid ::slotted(.nano-grid-row-start-3){grid-row-start:3 !important}:host(.has-grid) .grid ::slotted(.nano-grid-col-span-3){grid-column-end:span 3 !important}:host(.has-grid) .grid ::slotted(.nano-grid-row-span-3){grid-row-end:span 3 !important}:host(.has-grid) .grid ::slotted(.nano-grid-col-start-4){grid-column-start:4 !important}:host(.has-grid) .grid ::slotted(.nano-grid-row-start-4){grid-row-start:4 !important}:host(.has-grid) .grid ::slotted(.nano-grid-col-span-4){grid-column-end:span 4 !important}:host(.has-grid) .grid ::slotted(.nano-grid-row-span-4){grid-row-end:span 4 !important}:host(.has-grid) .grid ::slotted(.nano-grid-col-start-5){grid-column-start:5 !important}:host(.has-grid) .grid ::slotted(.nano-grid-row-start-5){grid-row-start:5 !important}:host(.has-grid) .grid ::slotted(.nano-grid-col-span-5){grid-column-end:span 5 !important}:host(.has-grid) .grid ::slotted(.nano-grid-row-span-5){grid-row-end:span 5 !important}:host(.has-grid) .grid ::slotted(.nano-grid-col-start-6){grid-column-start:6 !important}:host(.has-grid) .grid ::slotted(.nano-grid-row-start-6){grid-row-start:6 !important}:host(.has-grid) .grid ::slotted(.nano-grid-col-span-6){grid-column-end:span 6 !important}:host(.has-grid) .grid ::slotted(.nano-grid-row-span-6){grid-row-end:span 6 !important}:host(.has-grid) .grid ::slotted(.nano-grid-col-start-7){grid-column-start:7 !important}:host(.has-grid) .grid ::slotted(.nano-grid-row-start-7){grid-row-start:7 !important}:host(.has-grid) .grid ::slotted(.nano-grid-col-span-7){grid-column-end:span 7 !important}:host(.has-grid) .grid ::slotted(.nano-grid-row-span-7){grid-row-end:span 7 !important}:host(.has-grid) .grid ::slotted(.nano-grid-col-start-8){grid-column-start:8 !important}:host(.has-grid) .grid ::slotted(.nano-grid-row-start-8){grid-row-start:8 !important}:host(.has-grid) .grid ::slotted(.nano-grid-col-span-8){grid-column-end:span 8 !important}:host(.has-grid) .grid ::slotted(.nano-grid-row-span-8){grid-row-end:span 8 !important}:host(.has-grid) .grid ::slotted(.nano-grid-col-start-9){grid-column-start:9 !important}:host(.has-grid) .grid ::slotted(.nano-grid-row-start-9){grid-row-start:9 !important}:host(.has-grid) .grid ::slotted(.nano-grid-col-span-9){grid-column-end:span 9 !important}:host(.has-grid) .grid ::slotted(.nano-grid-row-span-9){grid-row-end:span 9 !important}:host(.has-grid) .grid ::slotted(.nano-grid-col-start-10){grid-column-start:10 !important}:host(.has-grid) .grid ::slotted(.nano-grid-row-start-10){grid-row-start:10 !important}:host(.has-grid) .grid ::slotted(.nano-grid-col-span-10){grid-column-end:span 10 !important}:host(.has-grid) .grid ::slotted(.nano-grid-row-span-10){grid-row-end:span 10 !important}:host([content-panel]:not([content-panel=false])) .grid{grid-template-rows:auto 1fr}:host([full-height]:not([full-height=false])){block-size:100%}:host([full-height]:not([full-height=false])) .grid{grid-template-rows:1fr}:host([show-helper]:not([show-helper=false])) .grid{position:relative}:host([show-helper]:not([show-helper=false])) .grid::after{content:\"\";position:absolute;inset:0;pointer-events:none;background-image:repeating-linear-gradient(to right, rgba(126, 195, 241, 0.25), rgba(126, 195, 241, 0.25) var(--col-width), transparent var(--col-width), transparent var(--repeat-width));background-size:calc(100% + var(--grid-col-gap)) 100%;z-index:100}:host([show-helper]:not([show-helper=false])) .grid::before{content:var(--current-grid-size);font-size:30px;position:absolute;inline-size:100%;inset-inline-start:0;text-align:center;inset-block-start:50%;transform:translateY(-50%);color:rgba(0, 0, 0, 0.2);text-transform:uppercase;z-index:99;pointer-events:none}:host(.nano-grid-1){--current-grid-size:\"grid size: 1\";--col-width:calc(100% - var(--grid-col-gap));--repeat-width:calc(100% / 1)}:host(.nano-grid-1) .grid{grid-template-columns:repeat(1, minmax(var(--col-width), 1fr))}:host(.nano-grid-2){--current-grid-size:\"grid size: 2\";--col-width:calc(50% - var(--grid-col-gap));--repeat-width:calc(100% / 2)}:host(.nano-grid-2) .grid{grid-template-columns:repeat(2, minmax(var(--col-width), 1fr))}:host(.nano-grid-3){--current-grid-size:\"grid size: 3\";--col-width:calc(33.3333333333% - var(--grid-col-gap));--repeat-width:calc(100% / 3)}:host(.nano-grid-3) .grid{grid-template-columns:repeat(3, minmax(var(--col-width), 1fr))}:host(.nano-grid-4){--current-grid-size:\"grid size: 4\";--col-width:calc(25% - var(--grid-col-gap));--repeat-width:calc(100% / 4)}:host(.nano-grid-4) .grid{grid-template-columns:repeat(4, minmax(var(--col-width), 1fr))}:host(.nano-grid-5){--current-grid-size:\"grid size: 5\";--col-width:calc(20% - var(--grid-col-gap));--repeat-width:calc(100% / 5)}:host(.nano-grid-5) .grid{grid-template-columns:repeat(5, minmax(var(--col-width), 1fr))}:host(.nano-grid-6){--current-grid-size:\"grid size: 6\";--col-width:calc(16.6666666667% - var(--grid-col-gap));--repeat-width:calc(100% / 6)}:host(.nano-grid-6) .grid{grid-template-columns:repeat(6, minmax(var(--col-width), 1fr))}:host(.nano-grid-7){--current-grid-size:\"grid size: 7\";--col-width:calc(14.2857142857% - var(--grid-col-gap));--repeat-width:calc(100% / 7)}:host(.nano-grid-7) .grid{grid-template-columns:repeat(7, minmax(var(--col-width), 1fr))}:host(.nano-grid-8){--current-grid-size:\"grid size: 8\";--col-width:calc(12.5% - var(--grid-col-gap));--repeat-width:calc(100% / 8)}:host(.nano-grid-8) .grid{grid-template-columns:repeat(8, minmax(var(--col-width), 1fr))}:host(.nano-grid-9){--current-grid-size:\"grid size: 9\";--col-width:calc(11.1111111111% - var(--grid-col-gap));--repeat-width:calc(100% / 9)}:host(.nano-grid-9) .grid{grid-template-columns:repeat(9, minmax(var(--col-width), 1fr))}:host(.nano-grid-10){--current-grid-size:\"grid size: 10\";--col-width:calc(10% - var(--grid-col-gap));--repeat-width:calc(100% / 10)}:host(.nano-grid-10) .grid{grid-template-columns:repeat(10, minmax(var(--col-width), 1fr))}";
|
12
|
-
|
13
|
-
const STATEOPTS$1 = ['col-span', 'col-start', 'row-span', 'row-start'];
|
14
|
-
const Grid = class {
|
15
|
-
constructor(hostRef) {
|
16
|
-
index.registerInstance(this, hostRef);
|
17
|
-
this.nanoBpChange = index.createEvent(this, "nanoBpChange", 7);
|
18
|
-
this.generalClasses = [''];
|
19
|
-
this.gridClass = null;
|
20
|
-
this.isSizes = [null];
|
21
|
-
this.ready = false;
|
22
|
-
this.isSmall = false;
|
23
|
-
this.isMedium = false;
|
24
|
-
this.isLarge = false;
|
25
|
-
this.isXL = false;
|
26
|
-
this.isXXL = false;
|
27
|
-
this.sSize = 300;
|
28
|
-
this.mSize = 550;
|
29
|
-
this.lSize = 800;
|
30
|
-
this.xlSize = 1000;
|
31
|
-
this.sCols = undefined;
|
32
|
-
this.mCols = undefined;
|
33
|
-
this.lCols = undefined;
|
34
|
-
this.xlCols = undefined;
|
35
|
-
this.xxlCols = undefined;
|
36
|
-
this.showHelper = false;
|
37
|
-
this.contentPanel = false;
|
38
|
-
this.fullHeight = false;
|
39
|
-
this.stateChange = throttle.debounce(this.stateChange.bind(this), 100);
|
40
|
-
}
|
41
|
-
propChanged() {
|
42
|
-
this.applySizeClasses();
|
43
|
-
}
|
44
|
-
applySizeClasses() {
|
45
|
-
const size = this.currentWidth;
|
46
|
-
this.isSmall = false;
|
47
|
-
this.isMedium = false;
|
48
|
-
this.isLarge = false;
|
49
|
-
this.isXL = false;
|
50
|
-
this.isXXL = false;
|
51
|
-
this.generalClasses = [];
|
52
|
-
this.gridClass = null;
|
53
|
-
this.isSizes = [null];
|
54
|
-
this.isSmall = true;
|
55
|
-
this.generalClasses.push('is-small');
|
56
|
-
if (this.sCols)
|
57
|
-
this.gridClass = `nano-grid-${this.sCols}`;
|
58
|
-
this.isSizes.push({ size: 's', active: true });
|
59
|
-
if (size > this.sSize) {
|
60
|
-
this.isMedium = true;
|
61
|
-
this.generalClasses.push('is-medium');
|
62
|
-
if (this.mCols)
|
63
|
-
this.gridClass = `nano-grid-${this.mCols}`;
|
64
|
-
this.isSizes.push({ size: 'm', active: true });
|
65
|
-
}
|
66
|
-
if (size > this.mSize) {
|
67
|
-
this.isLarge = true;
|
68
|
-
this.generalClasses.push('is-large');
|
69
|
-
if (this.lCols)
|
70
|
-
this.gridClass = `nano-grid-${this.lCols}`;
|
71
|
-
this.isSizes.push({ size: 'l', active: true });
|
72
|
-
}
|
73
|
-
if (size > this.lSize) {
|
74
|
-
this.isXL = true;
|
75
|
-
this.generalClasses.push('is-xl');
|
76
|
-
if (this.xlCols)
|
77
|
-
this.gridClass = `nano-grid-${this.xlCols}`;
|
78
|
-
this.isSizes.push({ size: 'xl', active: true });
|
79
|
-
}
|
80
|
-
if (size > this.xlSize) {
|
81
|
-
this.isXXL = true;
|
82
|
-
this.generalClasses.push('is-xxl');
|
83
|
-
if (this.xxlCols)
|
84
|
-
this.gridClass = `nano-grid-${this.xxlCols}`;
|
85
|
-
this.isSizes.push({ size: 'xxl', active: true });
|
86
|
-
}
|
87
|
-
this.el.style.setProperty('--current-grid-size', `'grid size: ${this.isSizes.slice().pop().size}'`);
|
88
|
-
this.applyChildrenClasses();
|
89
|
-
setTimeout(() => (this.ready = true), 0);
|
90
|
-
}
|
91
|
-
stateChange() {
|
92
|
-
this.nanoBpChange.emit(this.generalClasses);
|
93
|
-
}
|
94
|
-
applyChildrenClasses() {
|
95
|
-
const gridItems = this.el.querySelectorAll('nano-grid-item');
|
96
|
-
if (gridItems.length) {
|
97
|
-
gridItems.forEach((gridItem) => {
|
98
|
-
gridItem.changeBP(this.isSizes);
|
99
|
-
});
|
100
|
-
return;
|
101
|
-
}
|
102
|
-
// this logic has been put into grid-item. Keep here for legacy for now
|
103
|
-
let stateArr = [''];
|
104
|
-
let itemState = '';
|
105
|
-
let found;
|
106
|
-
let classes;
|
107
|
-
const ctx = this.el;
|
108
|
-
// item states come in 4 possible flavours at every breakpoint. E.g.
|
109
|
-
// xl-col-span-2
|
110
|
-
// xl-col-start-2
|
111
|
-
// xl-row-span-2
|
112
|
-
// xl-row-start-2
|
113
|
-
// loop through all grid items with states.
|
114
|
-
[].map.call(ctx.children, (gItem) => {
|
115
|
-
if (!gItem.hasAttribute('grid-states'))
|
116
|
-
return;
|
117
|
-
// gridItems.forEach(gItem => {
|
118
|
-
// clear all previous grid state classnames
|
119
|
-
classes = gItem.className
|
120
|
-
.split(' ')
|
121
|
-
.filter((c) => !c.startsWith('nano-grid-'));
|
122
|
-
gItem.className = classes.join(' ').trim();
|
123
|
-
// get all potential states this element can have
|
124
|
-
const itemStates = gItem.getAttribute('grid-states').split(' ');
|
125
|
-
// loop through all potential state options: col & row span & start
|
126
|
-
STATEOPTS$1.forEach((stateOpt) => {
|
127
|
-
// reset found flag
|
128
|
-
found = false;
|
129
|
-
// loop through all the current valid breakpoints / sizes backwards because
|
130
|
-
// we only care about the item's state at the largest current breakpoint.
|
131
|
-
this.isSizes
|
132
|
-
.slice()
|
133
|
-
.reverse()
|
134
|
-
.forEach(function (size) {
|
135
|
-
if (found || !size)
|
136
|
-
return;
|
137
|
-
found = itemStates.find((state) => state.indexOf(`${size.size}-${stateOpt}`) === 0);
|
138
|
-
// found a state at this current size. apply class.
|
139
|
-
if (found) {
|
140
|
-
// clear previous grid state classname
|
141
|
-
classes = gItem.className
|
142
|
-
.split(' ')
|
143
|
-
.filter((c) => !c.includes('nano-grid-${stateOpt}'));
|
144
|
-
gItem.className = classes.join(' ').trim();
|
145
|
-
stateArr = found.split('-');
|
146
|
-
// remove the size of the state
|
147
|
-
stateArr.shift();
|
148
|
-
itemState = stateArr.join('-');
|
149
|
-
// add new class
|
150
|
-
gItem.classList.add(`nano-grid-${itemState}`);
|
151
|
-
}
|
152
|
-
});
|
153
|
-
});
|
154
|
-
});
|
155
|
-
}
|
156
|
-
componentWillLoad() {
|
157
|
-
const ctx = this.el;
|
158
|
-
[].map.call(ctx.children, (ele) => ele.classList.add('nano-griditem'));
|
159
|
-
}
|
160
|
-
componentDidLoad() {
|
161
|
-
if (!window['ResizeObserver'])
|
162
|
-
return;
|
163
|
-
this.ro = new ResizeObserver((entries) => {
|
164
|
-
for (const entry of entries) {
|
165
|
-
if (!entry.contentRect.width)
|
166
|
-
return;
|
167
|
-
this.currentWidth = entry.contentRect.width;
|
168
|
-
this.applySizeClasses();
|
169
|
-
}
|
170
|
-
});
|
171
|
-
this.ro.observe(this.el);
|
172
|
-
}
|
173
|
-
disconnectedCallback() {
|
174
|
-
if (this.ro)
|
175
|
-
this.ro.disconnect();
|
176
|
-
}
|
177
|
-
render() {
|
178
|
-
return (index.h(index.Host, { class: {
|
179
|
-
[this.generalClasses.join(' ')]: true,
|
180
|
-
'has-grid': !!this.gridClass,
|
181
|
-
ready: this.ready,
|
182
|
-
[this.gridClass]: true,
|
183
|
-
} }, index.h("div", { class: {
|
184
|
-
grid: true,
|
185
|
-
} }, index.h("slot", null))));
|
186
|
-
}
|
187
|
-
get el() { return index.getElement(this); }
|
188
|
-
static get watchers() { return {
|
189
|
-
"sSize": ["propChanged"],
|
190
|
-
"mSize": ["propChanged"],
|
191
|
-
"lSize": ["propChanged"],
|
192
|
-
"xlSize": ["propChanged"],
|
193
|
-
"sCols": ["propChanged"],
|
194
|
-
"mCols": ["propChanged"],
|
195
|
-
"lCols": ["propChanged"],
|
196
|
-
"xlCols": ["propChanged"],
|
197
|
-
"xxlCols": ["propChanged"],
|
198
|
-
"isSmall": ["stateChange"],
|
199
|
-
"isMedium": ["stateChange"],
|
200
|
-
"isLarge": ["stateChange"],
|
201
|
-
"isXL": ["stateChange"],
|
202
|
-
"isXXL": ["stateChange"]
|
203
|
-
}; }
|
204
|
-
};
|
205
|
-
Grid.style = gridCss;
|
206
|
-
|
207
|
-
const gridItemCss = ":host{box-sizing:border-box}*,*::before,*::after{box-sizing:border-box}[hidden]{display:none !important}:host{display:inline-block}";
|
208
|
-
|
209
|
-
const STATEOPTS = ['col-span', 'col-start', 'row-span', 'row-start'];
|
210
|
-
const GridItem = class {
|
211
|
-
constructor(hostRef) {
|
212
|
-
index.registerInstance(this, hostRef);
|
213
|
-
this.currGridSizes = [null];
|
214
|
-
this.gridStates = '';
|
215
|
-
}
|
216
|
-
updateGridClasses() {
|
217
|
-
this.applyChildrenClasses();
|
218
|
-
}
|
219
|
-
/**
|
220
|
-
* Called by parent grid to trigger new classes
|
221
|
-
* @internal
|
222
|
-
*/
|
223
|
-
async changeBP(newGridSizes) {
|
224
|
-
if (this.currGridSizes === newGridSizes)
|
225
|
-
return;
|
226
|
-
this.currGridSizes = newGridSizes;
|
227
|
-
if (!this.gridStates.length)
|
228
|
-
return;
|
229
|
-
this.applyChildrenClasses();
|
230
|
-
}
|
231
|
-
applyChildrenClasses() {
|
232
|
-
let stateArr = [''];
|
233
|
-
let itemState = '';
|
234
|
-
let found;
|
235
|
-
let classes;
|
236
|
-
// item states come in 4 possible flavours at every breakpoint. E.g.
|
237
|
-
// xl-col-span-2
|
238
|
-
// xl-col-start-2
|
239
|
-
// xl-row-span-2
|
240
|
-
// xl-row-start-2
|
241
|
-
// clear all previous grid state classnames
|
242
|
-
classes = this.el.className
|
243
|
-
.split(' ')
|
244
|
-
.filter((c) => !c.startsWith('nano-grid-'));
|
245
|
-
this.el.className = classes.join(' ').trim();
|
246
|
-
// get all potential states this element can have
|
247
|
-
const itemStates = this.gridStates.split(' ');
|
248
|
-
// loop through all potential state options: col & row span & start
|
249
|
-
STATEOPTS.forEach((stateOpt) => {
|
250
|
-
// reset found flag
|
251
|
-
found = false;
|
252
|
-
// loop through all the current valid breakpoints / sizes backwards because
|
253
|
-
// we only care about the item's state at the largest current breakpoint.
|
254
|
-
this.currGridSizes
|
255
|
-
.slice()
|
256
|
-
.reverse()
|
257
|
-
.forEach((size) => {
|
258
|
-
if (found || !size)
|
259
|
-
return;
|
260
|
-
found = itemStates.find((state) => state.indexOf(`${size.size}-${stateOpt}`) === 0);
|
261
|
-
// found a state at this current size. apply class.
|
262
|
-
if (found) {
|
263
|
-
// clear previous grid state classname
|
264
|
-
classes = this.el.className
|
265
|
-
.split(' ')
|
266
|
-
.filter((c) => !c.includes('nano-grid-${stateOpt}'));
|
267
|
-
this.el.className = classes.join(' ').trim();
|
268
|
-
stateArr = found.split('-');
|
269
|
-
// remove the size of the state
|
270
|
-
stateArr.shift();
|
271
|
-
itemState = stateArr.join('-');
|
272
|
-
// add new class
|
273
|
-
this.el.classList.add(`nano-grid-${itemState}`);
|
274
|
-
}
|
275
|
-
});
|
276
|
-
});
|
277
|
-
}
|
278
|
-
render() {
|
279
|
-
return index.h("slot", null);
|
280
|
-
}
|
281
|
-
get el() { return index.getElement(this); }
|
282
|
-
static get watchers() { return {
|
283
|
-
"gridStates": ["updateGridClasses"]
|
284
|
-
}; }
|
285
|
-
};
|
286
|
-
GridItem.style = gridItemCss;
|
287
|
-
|
288
|
-
const imgCss = ":host{box-sizing:border-box}*,*::before,*::after{box-sizing:border-box}[hidden]{display:none !important}:host{--padding:0;display:inline-block;object-fit:cover;object-position:center;background-size:cover;background-position:center}:host *{border-radius:inherit}:host([background]:not([background=false])){display:block}.img{position:relative;object-fit:inherit;object-position:inherit;background-color:inherit;background-position:inherit;background-size:inherit;background-origin:inherit;background-attachment:inherit;background-repeat:inherit;flex:1 1 100%;display:flex;flex-direction:column;min-block-size:inherit;max-block-size:inherit;max-inline-size:inherit;min-height:inherit;min-width:inherit;block-size:inherit;inline-size:inherit;height:inherit;width:inherit;max-height:inherit;max-width:inherit;aspect-ratio:inherit}.img__loader,.img__observer{position:absolute;inset:0;block-size:100%;inline-size:100%;z-index:-1}.img__image,.img__bg{border-radius:inherit;display:block;opacity:0;transition:0.5s ease opacity, 0.3s ease filter 0.4s;filter:blur(5px);flex:1}.img__image.loaded,.img__bg.loaded{opacity:1;filter:blur(0)}@media not all and (min-resolution: 0.001dpcm){@supports (-webkit-appearance: none){.img__image.loaded,.img__bg.loaded{filter:blur(0)}}}.img__image{object-fit:inherit;object-position:inherit;max-inline-size:100%;min-block-size:inherit;max-block-size:inherit;min-height:inherit;min-width:inherit;block-size:auto;inline-size:inherit;height:inherit;width:inherit;max-height:inherit;max-width:inherit;aspect-ratio:inherit}.img__image.hide{visibility:hidden}.img__image.hide.no-height{block-size:1px;position:absolute;z-index:-1}.img__bg{background-color:inherit;background-position:inherit;background-size:inherit;background-origin:inherit;background-attachment:inherit;background-repeat:inherit;overflow:auto;padding:var(--padding)}.img__bg.no-height{position:absolute;inset:0}";
|
289
|
-
|
290
|
-
const Img = class {
|
291
|
-
constructor(hostRef) {
|
292
|
-
index.registerInstance(this, hostRef);
|
293
|
-
this.nanoImgWillLoad = index.createEvent(this, "nanoImgWillLoad", 7);
|
294
|
-
this.nanoImgDidLoad = index.createEvent(this, "nanoImgDidLoad", 7);
|
295
|
-
this.nanoImgError = index.createEvent(this, "nanoImgError", 7);
|
296
|
-
this._srcSet = {};
|
297
|
-
this.onLoad = () => {
|
298
|
-
this.nanoImgDidLoad.emit();
|
299
|
-
setTimeout(() => (this.hasLoaded = true), 50);
|
300
|
-
};
|
301
|
-
this.onError = () => {
|
302
|
-
this.nanoImgError.emit();
|
303
|
-
};
|
304
|
-
this.onResize = (e) => {
|
305
|
-
Object.entries(e.detail).forEach(([bp, active]) => {
|
306
|
-
this._srcSet[bp].active = active;
|
307
|
-
});
|
308
|
-
// sort and find the highest sized matching image.
|
309
|
-
const srcOpts = [];
|
310
|
-
Object.keys(this._srcSet)
|
311
|
-
.sort()
|
312
|
-
.forEach((bp) => {
|
313
|
-
if (this._srcSet[bp].active)
|
314
|
-
srcOpts.push(this._srcSet[bp].src);
|
315
|
-
});
|
316
|
-
if (srcOpts.length)
|
317
|
-
this._src = srcOpts.slice(-1)[0];
|
318
|
-
// no matching image? Set back to default
|
319
|
-
else
|
320
|
-
this._src = this.src;
|
321
|
-
};
|
322
|
-
this.loadSrc = undefined;
|
323
|
-
this.loadError = undefined;
|
324
|
-
this.hasLoaded = false;
|
325
|
-
this.imgStates = null;
|
326
|
-
this._src = undefined;
|
327
|
-
this.alt = undefined;
|
328
|
-
this.src = undefined;
|
329
|
-
this.srcSet = undefined;
|
330
|
-
this.lazy = true;
|
331
|
-
this.background = undefined;
|
332
|
-
this.autoHeight = 'content';
|
333
|
-
}
|
334
|
-
_srcChanged() {
|
335
|
-
this.hasLoaded = false;
|
336
|
-
this.addIO();
|
337
|
-
}
|
338
|
-
srcChanged() {
|
339
|
-
this._src = this.src;
|
340
|
-
}
|
341
|
-
srcSetChanged() {
|
342
|
-
if (!this.srcSet)
|
343
|
-
return;
|
344
|
-
delete this._srcSet;
|
345
|
-
this._srcSet = {};
|
346
|
-
this.imgStates = this.srcSet
|
347
|
-
.split(',')
|
348
|
-
.map((bpSrc) => {
|
349
|
-
const [bp, src] = bpSrc.split(' ').filter((bp) => bp.length);
|
350
|
-
this._srcSet[bp] = { src: src, active: false };
|
351
|
-
return bp;
|
352
|
-
})
|
353
|
-
.join(', ');
|
354
|
-
}
|
355
|
-
lazyChanged() {
|
356
|
-
if (!this.lazy)
|
357
|
-
this.load();
|
358
|
-
}
|
359
|
-
addIO() {
|
360
|
-
if (!this._src || this.hasLoaded)
|
361
|
-
return;
|
362
|
-
if (!this.lazy) {
|
363
|
-
this.load();
|
364
|
-
return;
|
365
|
-
}
|
366
|
-
if (typeof window !== 'undefined' &&
|
367
|
-
'IntersectionObserver' in window) {
|
368
|
-
this.removeIO();
|
369
|
-
this.io = new IntersectionObserver((data) => {
|
370
|
-
if (data[0].isIntersecting) {
|
371
|
-
this.load();
|
372
|
-
this.removeIO();
|
373
|
-
}
|
374
|
-
});
|
375
|
-
this.io.observe(this.host);
|
376
|
-
}
|
377
|
-
else
|
378
|
-
setTimeout(() => this.load(), 200);
|
379
|
-
}
|
380
|
-
load() {
|
381
|
-
this.loadError = this.onError;
|
382
|
-
this.loadSrc = this._src;
|
383
|
-
this.nanoImgWillLoad.emit();
|
384
|
-
}
|
385
|
-
removeIO() {
|
386
|
-
if (this.io) {
|
387
|
-
this.io.disconnect();
|
388
|
-
this.io = undefined;
|
389
|
-
}
|
390
|
-
}
|
391
|
-
connectedCallback() {
|
392
|
-
this.srcChanged();
|
393
|
-
this.srcSetChanged();
|
394
|
-
this.lazyChanged();
|
395
|
-
}
|
396
|
-
componentDidLoad() {
|
397
|
-
this.addIO();
|
398
|
-
}
|
399
|
-
disconnectedCallback() {
|
400
|
-
this.removeIO();
|
401
|
-
}
|
402
|
-
render() {
|
403
|
-
const bgStyle = !!this.loadSrc
|
404
|
-
? { 'background-image': `url(${this.loadSrc})` }
|
405
|
-
: {};
|
406
|
-
return (index.h("div", { class: "img" }, index.h("nano-skeleton", { class: "img__loader" }), !!this.background && (index.h("div", { class: {
|
407
|
-
loaded: this.hasLoaded,
|
408
|
-
img__bg: true,
|
409
|
-
'no-height': this.autoHeight === 'image',
|
410
|
-
}, style: bgStyle }, index.h("slot", null))), index.h("img", { class: {
|
411
|
-
img__image: true,
|
412
|
-
loaded: this.hasLoaded,
|
413
|
-
hide: this.background,
|
414
|
-
'no-height': this.autoHeight === 'content',
|
415
|
-
}, decoding: "async", src: this.loadSrc, loading: undefined, alt: this.alt, onLoad: this.onLoad, onError: this.loadError }), index.h("nano-resize-observe", { class: "img__observer", onNanoResizeStateChange: this.onResize, states: this.imgStates })));
|
416
|
-
}
|
417
|
-
get host() { return index.getElement(this); }
|
418
|
-
static get watchers() { return {
|
419
|
-
"_src": ["_srcChanged"],
|
420
|
-
"src": ["srcChanged"],
|
421
|
-
"srcSet": ["srcSetChanged"],
|
422
|
-
"lazy": ["lazyChanged"]
|
423
|
-
}; }
|
424
|
-
};
|
425
|
-
Img.style = imgCss;
|
426
|
-
|
427
|
-
exports.nano_grid = Grid;
|
428
|
-
exports.nano_grid_item = GridItem;
|
429
|
-
exports.nano_img = Img;
|
430
|
-
|
431
|
-
//# sourceMappingURL=nano-grid_3.cjs.entry.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"file":"nano-grid.nano-grid-item.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BAAuB,EAAE,IAAI,CAAC,QAAQ,EACtC,MAAM,EAAE,IAAI,CAAC,SAAS,GACtB,CACE,EACN;GACH;;;;;;;;;;;;;;;","names":["STATEOPTS","debounce","h","Host"],"sources":["./src/components/grid/grid.scss?tag=nano-grid&encapsulation=shadow","./src/components/grid/grid.tsx","./src/components/grid/grid-item.scss?tag=nano-grid-item&encapsulation=shadow","./src/components/grid/grid-item.tsx","./src/components/img/img.scss?tag=nano-img&encapsulation=shadow","./src/components/img/img.tsx"],"sourcesContent":["@use 'sass:math';\n\n@import '../../global/style/nano-theme/base';\n\n// ie 11 fixes ... maximum numbers we can place on the grid ... upping this number decreases performance a lot.\n$max-grid-cols: 10;\n\n@mixin grid($size: 1) {\n @at-root :host(.nano-grid-#{$size}) {\n --current-grid-size: 'grid size: #{$size}';\n --col-width: calc(#{math.div(100, $size)}% - var(--grid-col-gap));\n --repeat-width: calc(100% / #{$size});\n\n .grid {\n grid-template-columns: repeat(#{$size}, minmax(var(--col-width), 1fr));\n\n $current-column: 1;\n $current-row: 1;\n\n @for $i from 1 through ($max-grid-cols * 2) {\n @if $current-column > $size {\n $current-column: 1;\n $current-row: $current-row + 1;\n }\n $current-column: $current-column + 1;\n }\n }\n }\n}\n\n@mixin grid-spans {\n @for $i from 1 through $max-grid-cols {\n ::slotted(.nano-grid-col-start-#{$i}) {\n grid-column-start: #{$i} !important;\n }\n\n ::slotted(.nano-grid-row-start-#{$i}) {\n grid-row-start: #{$i} !important;\n }\n\n ::slotted(.nano-grid-col-span-#{$i}) {\n grid-column-end: span #{$i} !important;\n }\n\n ::slotted(.nano-grid-row-span-#{$i}) {\n grid-row-end: span #{$i} !important;\n }\n }\n}\n\n:host {\n /**\n * @prop --grid-col-gap: gap between all columns. Defaults to theme's global padding\n * @prop --grid-row-gap: gap between all rows. Defaults to theme's global padding\n */\n\n --grid-col-gap: #{$spacing-medium};\n --grid-row-gap: #{$spacing-medium};\n --current-grid-size: \"'grid size: sm'\";\n\n display: block;\n opacity: 0;\n transition: 0.2s ease opacity;\n max-width: 100%;\n\n .grid {\n /* autoprefixer: ignore next */\n display: grid;\n\n /* autoprefixer: ignore next */\n grid-gap: var(--grid-row-gap) var(--grid-col-gap);\n block-size: inherit;\n min-block-size: inherit;\n }\n}\n\n:host(.ready) {\n opacity: 1;\n}\n\n:host(.has-grid) {\n .grid {\n display: grid;\n\n @include grid-spans;\n }\n}\n\n:host([content-panel]:not([content-panel='false'])) {\n .grid {\n grid-template-rows: auto 1fr;\n }\n}\n\n:host([full-height]:not([full-height='false'])) {\n block-size: 100%;\n\n .grid {\n grid-template-rows: 1fr;\n }\n}\n\n:host([show-helper]:not([show-helper='false'])) {\n .grid {\n position: relative;\n\n &::after {\n content: '';\n position: absolute;\n inset: 0;\n pointer-events: none;\n background-image:\n repeating-linear-gradient(\n to right,\n hsl(204deg 80% 72% / 25%),\n hsl(204deg 80% 72% / 25%) var(--col-width),\n transparent var(--col-width),\n transparent var(--repeat-width)\n );\n background-size: calc(100% + var(--grid-col-gap)) 100%;\n z-index: 100;\n }\n\n &::before {\n content: var(--current-grid-size);\n font-size: 30px;\n position: absolute;\n inline-size: 100%;\n inset-inline-start: 0;\n text-align: center;\n inset-block-start: 50%;\n transform: translateY(-50%);\n color: rgb(0 0 0 / 20%);\n text-transform: uppercase;\n z-index: 99;\n pointer-events: none;\n }\n }\n}\n\n@for $i from 1 through $max-grid-cols {\n @include grid($i);\n}\n","import {\n Component,\n h,\n Prop,\n Element,\n Host,\n State,\n Watch,\n Event,\n EventEmitter,\n} from '@stencil/core';\nimport { debounce } from '../../utils/throttle';\nimport type { GridSizes } from '../../interface';\n\nconst STATEOPTS = ['col-span', 'col-start', 'row-span', 'row-start'];\n\n/**\n * A context-aware CSS grid implementation.\n * Uses it's own width to choose column number - not screen width.\n */\n@Component({\n tag: 'nano-grid',\n styleUrl: 'grid.scss',\n shadow: true,\n})\nexport class Grid {\n @Element() private el: HTMLNanoGridElement;\n private ro: ResizeObserver;\n private generalClasses: Array<string> = [''];\n private gridClass: string = null;\n private isSizes: GridSizes[] = [null];\n private currentWidth: number;\n\n constructor() {\n this.stateChange = debounce(this.stateChange.bind(this), 100);\n }\n\n @State() ready: boolean = false;\n @State() isSmall = false;\n @State() isMedium = false;\n @State() isLarge = false;\n @State() isXL = false;\n @State() isXXL = false;\n\n /**\n * the component's small breakpoint. Note - all breakpoints are based on component width, not screen width.\n */\n @Prop() sSize: number = 300;\n\n /**\n * the component's medium breakpoint. Note - all breakpoints are based on component width, not screen width.\n */\n @Prop() mSize: number = 550;\n\n /**\n * the component's large breakpoint. Note - all breakpoints are based on component width, not screen width.\n */\n @Prop() lSize: number = 800;\n\n /**\n * the component's xl breakpoint. Note - all breakpoints are based on component width, not screen width.\n */\n @Prop() xlSize: number = 1000;\n\n /**\n * the number of columns the grid has at the small breakpoint.\n */\n @Prop() sCols: number;\n\n /**\n * the number of columns the grid has at the medium breakpoint.\n */\n @Prop() mCols: number;\n\n /**\n * the number of columns the grid has at the large breakpoint.\n */\n @Prop() lCols: number;\n\n /**\n * the number of columns the grid has at the xl breakpoint.\n */\n @Prop() xlCols: number;\n\n /**\n * the number of columns the grid has at the xxl breakpoint (anything greater than the xl breakpoint)\n */\n @Prop() xxlCols: number;\n\n /**\n * shows a grid helper to visualise where columns are\n */\n @Prop({ reflect: true }) showHelper: boolean = false;\n\n /**\n * shortcut for a traditional website like grid (requires more than one row). The second row will auto expand to fill the grid height. The first row and > 2nd row will be the size of their content. e.g. header, body and footer.\n */\n @Prop({ reflect: true }) contentPanel: boolean = false;\n\n /**\n * Helper to make grid items expand to full height in IE11\n */\n @Prop({ reflect: true }) fullHeight: boolean = false;\n\n /**\n * Emitted when the `nano-grid` changes breakpoint\n */\n @Event() nanoBpChange: EventEmitter<string[]>;\n\n @Watch('sSize')\n @Watch('mSize')\n @Watch('lSize')\n @Watch('xlSize')\n @Watch('sCols')\n @Watch('mCols')\n @Watch('lCols')\n @Watch('xlCols')\n @Watch('xxlCols')\n propChanged() {\n this.applySizeClasses();\n }\n\n private applySizeClasses() {\n const size = this.currentWidth;\n\n this.isSmall = false;\n this.isMedium = false;\n this.isLarge = false;\n this.isXL = false;\n this.isXXL = false;\n\n this.generalClasses = [];\n this.gridClass = null;\n this.isSizes = [null];\n\n this.isSmall = true;\n this.generalClasses.push('is-small');\n if (this.sCols) this.gridClass = `nano-grid-${this.sCols}`;\n this.isSizes.push({ size: 's', active: true });\n\n if (size > this.sSize) {\n this.isMedium = true;\n this.generalClasses.push('is-medium');\n if (this.mCols) this.gridClass = `nano-grid-${this.mCols}`;\n this.isSizes.push({ size: 'm', active: true });\n }\n\n if (size > this.mSize) {\n this.isLarge = true;\n this.generalClasses.push('is-large');\n if (this.lCols) this.gridClass = `nano-grid-${this.lCols}`;\n this.isSizes.push({ size: 'l', active: true });\n }\n\n if (size > this.lSize) {\n this.isXL = true;\n this.generalClasses.push('is-xl');\n if (this.xlCols) this.gridClass = `nano-grid-${this.xlCols}`;\n this.isSizes.push({ size: 'xl', active: true });\n }\n\n if (size > this.xlSize) {\n this.isXXL = true;\n this.generalClasses.push('is-xxl');\n if (this.xxlCols) this.gridClass = `nano-grid-${this.xxlCols}`;\n this.isSizes.push({ size: 'xxl', active: true });\n }\n\n this.el.style.setProperty(\n '--current-grid-size',\n `'grid size: ${this.isSizes.slice().pop().size}'`\n );\n this.applyChildrenClasses();\n setTimeout(() => (this.ready = true), 0);\n }\n\n @Watch('isSmall')\n @Watch('isMedium')\n @Watch('isLarge')\n @Watch('isXL')\n @Watch('isXXL')\n stateChange() {\n this.nanoBpChange.emit(this.generalClasses);\n }\n\n private applyChildrenClasses() {\n const gridItems = this.el.querySelectorAll('nano-grid-item');\n if (gridItems.length) {\n gridItems.forEach((gridItem: HTMLNanoGridItemElement) => {\n gridItem.changeBP(this.isSizes);\n });\n return;\n }\n\n // this logic has been put into grid-item. Keep here for legacy for now\n let stateArr: Array<string> = [''];\n let itemState: string = '';\n let found: any;\n let classes: Array<string>;\n\n const ctx = this.el;\n\n // item states come in 4 possible flavours at every breakpoint. E.g.\n // xl-col-span-2\n // xl-col-start-2\n // xl-row-span-2\n // xl-row-start-2\n\n // loop through all grid items with states.\n [].map.call(ctx.children, (gItem: HTMLElement) => {\n if (!gItem.hasAttribute('grid-states')) return;\n\n // gridItems.forEach(gItem => {\n\n // clear all previous grid state classnames\n classes = gItem.className\n .split(' ')\n .filter((c) => !c.startsWith('nano-grid-'));\n gItem.className = classes.join(' ').trim();\n\n // get all potential states this element can have\n const itemStates = gItem.getAttribute('grid-states').split(' ');\n\n // loop through all potential state options: col & row span & start\n STATEOPTS.forEach((stateOpt) => {\n // reset found flag\n found = false;\n\n // loop through all the current valid breakpoints / sizes backwards because\n // we only care about the item's state at the largest current breakpoint.\n this.isSizes\n .slice()\n .reverse()\n .forEach(function (size) {\n if (found || !size) return;\n found = itemStates.find(\n (state) => state.indexOf(`${size.size}-${stateOpt}`) === 0\n );\n\n // found a state at this current size. apply class.\n if (found) {\n // clear previous grid state classname\n classes = gItem.className\n .split(' ')\n .filter((c) => !c.includes('nano-grid-${stateOpt}'));\n gItem.className = classes.join(' ').trim();\n\n stateArr = found.split('-');\n\n // remove the size of the state\n stateArr.shift();\n itemState = stateArr.join('-');\n\n // add new class\n gItem.classList.add(`nano-grid-${itemState}`);\n }\n });\n });\n });\n }\n\n componentWillLoad() {\n const ctx = this.el;\n [].map.call(ctx.children, (ele: HTMLElement) =>\n ele.classList.add('nano-griditem')\n );\n }\n\n componentDidLoad() {\n if (!window['ResizeObserver']) return;\n\n this.ro = new ResizeObserver((entries) => {\n for (const entry of entries) {\n if (!entry.contentRect.width) return;\n this.currentWidth = entry.contentRect.width;\n this.applySizeClasses();\n }\n });\n this.ro.observe(this.el);\n }\n\n disconnectedCallback() {\n if (this.ro) this.ro.disconnect();\n }\n\n render() {\n return (\n <Host\n class={{\n [this.generalClasses.join(' ')]: true,\n 'has-grid': !!this.gridClass,\n ready: this.ready,\n [this.gridClass]: true,\n }}\n >\n <div\n class={{\n grid: true,\n }}\n >\n <slot />\n </div>\n </Host>\n );\n }\n}\n",":host {\n display: inline-block;\n}\n","import { Component, h, Prop, Element, Method, Watch } from '@stencil/core';\nimport type { GridSizes } from '../../interface';\n\nconst STATEOPTS = ['col-span', 'col-start', 'row-span', 'row-start'];\n\n/**\n * Grid items to be used with [grid](/story/nano-components-grid) elements\n */\n@Component({\n tag: 'nano-grid-item',\n styleUrl: 'grid-item.scss',\n shadow: true,\n})\nexport class GridItem {\n private currGridSizes: GridSizes[] = [null];\n\n @Element() private el: HTMLNanoGridItemElement;\n /**\n * How to position this item within it's parent grid at different break points. Examples:\n * xl-col-span-2\n * l-col-start-2\n * xxl-row-span-2\n * m-row-start-2\n */\n @Prop() gridStates: string = '';\n\n @Watch('gridStates')\n updateGridClasses() {\n this.applyChildrenClasses();\n }\n\n /**\n * Called by parent grid to trigger new classes\n * @internal\n */\n @Method()\n async changeBP(newGridSizes: GridSizes[]) {\n if (this.currGridSizes === newGridSizes) return;\n this.currGridSizes = newGridSizes;\n\n if (!this.gridStates.length) return;\n this.applyChildrenClasses();\n }\n\n private applyChildrenClasses() {\n let stateArr: Array<string> = [''];\n let itemState: string = '';\n let found: any;\n let classes: Array<string>;\n\n // item states come in 4 possible flavours at every breakpoint. E.g.\n // xl-col-span-2\n // xl-col-start-2\n // xl-row-span-2\n // xl-row-start-2\n\n // clear all previous grid state classnames\n classes = this.el.className\n .split(' ')\n .filter((c) => !c.startsWith('nano-grid-'));\n this.el.className = classes.join(' ').trim();\n\n // get all potential states this element can have\n const itemStates = this.gridStates.split(' ');\n\n // loop through all potential state options: col & row span & start\n STATEOPTS.forEach((stateOpt) => {\n // reset found flag\n found = false;\n\n // loop through all the current valid breakpoints / sizes backwards because\n // we only care about the item's state at the largest current breakpoint.\n this.currGridSizes\n .slice()\n .reverse()\n .forEach((size) => {\n if (found || !size) return;\n found = itemStates.find(\n (state) => state.indexOf(`${size.size}-${stateOpt}`) === 0\n );\n\n // found a state at this current size. apply class.\n if (found) {\n // clear previous grid state classname\n classes = this.el.className\n .split(' ')\n .filter((c) => !c.includes('nano-grid-${stateOpt}'));\n this.el.className = classes.join(' ').trim();\n\n stateArr = found.split('-');\n\n // remove the size of the state\n stateArr.shift();\n itemState = stateArr.join('-');\n\n // add new class\n this.el.classList.add(`nano-grid-${itemState}`);\n }\n });\n });\n }\n\n render() {\n return <slot />;\n }\n}\n",":host {\n /**\n * @prop --padding: padding around any content. Only relevent on `<nano-img background>`\n */\n --padding: 0;\n\n display: inline-block;\n object-fit: cover;\n object-position: center;\n background-size: cover;\n background-position: center;\n\n * {\n border-radius: inherit;\n }\n}\n\n:host([background]:not([background='false'])) {\n display: block;\n}\n\n.img {\n position: relative;\n object-fit: inherit;\n object-position: inherit;\n background-color: inherit;\n background-position: inherit;\n background-size: inherit;\n background-origin: inherit;\n background-attachment: inherit;\n background-repeat: inherit;\n flex: 1 1 100%;\n display: flex;\n flex-direction: column;\n min-block-size: inherit;\n max-block-size: inherit;\n max-inline-size: inherit;\n min-height: inherit;\n min-width: inherit;\n block-size: inherit;\n inline-size: inherit;\n height: inherit;\n width: inherit;\n max-height: inherit;\n max-width: inherit;\n aspect-ratio: inherit;\n}\n\n.img__loader,\n.img__observer {\n position: absolute;\n inset: 0;\n block-size: 100%;\n inline-size: 100%;\n z-index: -1;\n}\n\n.img__image,\n.img__bg {\n border-radius: inherit;\n display: block;\n opacity: 0;\n transition: 0.5s ease opacity, 0.3s ease filter 0.4s;\n filter: blur(5px);\n flex: 1;\n\n &.loaded {\n opacity: 1;\n filter: blur(0);\n\n @media not all and (min-resolution: 0.001dpcm) {\n @supports (-webkit-appearance: none) {\n filter: blur(0);\n }\n }\n }\n}\n\n.img__image {\n object-fit: inherit;\n object-position: inherit;\n max-inline-size: 100%;\n min-block-size: inherit;\n max-block-size: inherit;\n min-height: inherit;\n min-width: inherit;\n block-size: auto;\n inline-size: inherit;\n height: inherit;\n width: inherit;\n max-height: inherit;\n max-width: inherit;\n aspect-ratio: inherit;\n\n &.hide {\n visibility: hidden;\n\n &.no-height {\n block-size: 1px;\n position: absolute;\n z-index: -1;\n }\n }\n}\n\n.img__bg {\n background-color: inherit;\n background-position: inherit;\n background-size: inherit;\n background-origin: inherit;\n background-attachment: inherit;\n background-repeat: inherit;\n overflow: auto;\n padding: var(--padding);\n\n &.no-height {\n position: absolute;\n inset: 0;\n }\n}\n","import {\n Component,\n Element,\n Event,\n EventEmitter,\n State,\n Prop,\n Watch,\n h,\n ComponentInterface,\n Build,\n} from '@stencil/core';\nimport type { ResizeStateChangeEventDetail } from '../../interface';\n\n/**\n * Img with benefits. Lazy loading. Simple `srcSet` solution for both `<img>` and `background-image` varieties.\n * @slot - Main slot. Only relevant with `<nano-img background>`\n */\n@Component({\n tag: 'nano-img',\n styleUrl: 'img.scss',\n shadow: true,\n})\nexport class Img implements ComponentInterface {\n private io?: IntersectionObserver;\n private _srcSet: { [key: string]: { src: string; active: boolean } } = {};\n\n @Element() host!: HTMLNanoImgElement;\n\n @State() loadSrc?: string;\n @State() loadError?: () => void;\n @State() hasLoaded: boolean = false;\n @State() imgStates: string = null;\n @State() _src: string;\n @Watch('_src')\n _srcChanged() {\n this.hasLoaded = false;\n this.addIO();\n }\n\n /** This attribute defines the alternative text describing the image.\n * Users will see this text displayed if the image URL is wrong, or if the image is not yet downloaded. */\n @Prop() alt?: string;\n\n /** The image URL. This attribute is mandatory for the `<img>` element. */\n @Prop() src!: string;\n @Watch('src')\n srcChanged() {\n this._src = this.src;\n }\n\n /** Optional list string providing media sizes with corresponding image srcs.\n * i.e. show img-x at 300px wide. Format `srcSet=\"200w src/imgSmall.jpg, 500h src/imgMed.png\"` */\n @Prop() srcSet?: string;\n @Watch('srcSet')\n srcSetChanged() {\n if (!this.srcSet) return;\n\n delete this._srcSet;\n this._srcSet = {};\n\n this.imgStates = this.srcSet\n .split(',')\n .map((bpSrc) => {\n const [bp, src] = bpSrc.split(' ').filter((bp) => bp.length);\n this._srcSet[bp] = { src: src, active: false };\n return bp;\n })\n .join(', ');\n }\n\n /** Render image lazily, when it comes into the browser viewport **/\n @Prop() lazy: boolean = true;\n @Watch('lazy')\n lazyChanged() {\n if (!this.lazy) this.load();\n }\n\n /** Render the image as a background image **/\n @Prop() background?: boolean;\n\n /** When the image is rendered as a background, and there is no preset dimensions of the component,\n * you can set how the component height will be set. Via image size or via the content **/\n @Prop() autoHeight: 'content' | 'image' = 'content';\n\n /** Emitted when the img src has been set */\n @Event() nanoImgWillLoad!: EventEmitter<void>;\n\n /** Emitted when the image has finished loading */\n @Event() nanoImgDidLoad!: EventEmitter<void>;\n\n /** Emitted when the img fails to load */\n @Event() nanoImgError!: EventEmitter<void>;\n\n private addIO() {\n if (!this._src || this.hasLoaded) return;\n if (!this.lazy) {\n this.load();\n return;\n }\n if (\n typeof (window as any) !== 'undefined' &&\n 'IntersectionObserver' in window\n ) {\n this.removeIO();\n this.io = new IntersectionObserver((data) => {\n if (data[0].isIntersecting) {\n this.load();\n this.removeIO();\n }\n });\n\n this.io.observe(this.host);\n } else setTimeout(() => this.load(), 200);\n }\n\n private load() {\n this.loadError = this.onError;\n this.loadSrc = this._src;\n this.nanoImgWillLoad.emit();\n }\n\n private onLoad = () => {\n this.nanoImgDidLoad.emit();\n setTimeout(() => (this.hasLoaded = true), 50);\n };\n\n private onError = () => {\n this.nanoImgError.emit();\n };\n\n private onResize = (e: { detail: ResizeStateChangeEventDetail }) => {\n Object.entries(e.detail).forEach(([bp, active]) => {\n this._srcSet[bp].active = active;\n });\n\n // sort and find the highest sized matching image.\n const srcOpts = [];\n Object.keys(this._srcSet)\n .sort()\n .forEach((bp) => {\n if (this._srcSet[bp].active) srcOpts.push(this._srcSet[bp].src);\n });\n\n if (srcOpts.length) this._src = srcOpts.slice(-1)[0];\n // no matching image? Set back to default\n else this._src = this.src;\n };\n\n private removeIO() {\n if (this.io) {\n this.io.disconnect();\n this.io = undefined;\n }\n }\n\n connectedCallback() {\n this.srcChanged();\n this.srcSetChanged();\n this.lazyChanged();\n }\n\n componentDidLoad() {\n this.addIO();\n }\n\n disconnectedCallback() {\n this.removeIO();\n }\n\n render() {\n const bgStyle = !!this.loadSrc\n ? { 'background-image': `url(${this.loadSrc})` }\n : {};\n\n return (\n <div class=\"img\">\n <nano-skeleton class=\"img__loader\"></nano-skeleton>\n {!!this.background && (\n <div\n class={{\n loaded: this.hasLoaded,\n img__bg: true,\n 'no-height': this.autoHeight === 'image',\n }}\n style={bgStyle}\n >\n <slot />\n </div>\n )}\n <img\n class={{\n img__image: true,\n loaded: this.hasLoaded,\n hide: this.background,\n 'no-height': this.autoHeight === 'content',\n }}\n decoding=\"async\"\n src={Build.isServer ? this.src : this.loadSrc}\n loading={Build.isServer && this.lazy ? 'lazy' : undefined}\n alt={this.alt}\n onLoad={this.onLoad}\n onError={this.loadError}\n />\n <nano-resize-observe\n class=\"img__observer\"\n onNanoResizeStateChange={this.onResize}\n states={this.imgStates}\n />\n </div>\n );\n }\n}\n"],"version":3}
|