@salla.sa/twilight-bundles 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +90 -0
- package/bin/tw-component.js +273 -0
- package/dist/twilight-bundles.cjs +23 -0
- package/dist/twilight-bundles.js +707 -0
- package/dist/vite-plugins/build.cjs +1 -0
- package/dist/vite-plugins/build.js +46 -0
- package/dist/vite-plugins/demo.cjs +1560 -0
- package/dist/vite-plugins/demo.js +1678 -0
- package/dist/vite-plugins/index.cjs +1 -0
- package/dist/vite-plugins/index.js +8 -0
- package/dist/vite-plugins/transform.cjs +2 -0
- package/dist/vite-plugins/transform.js +22 -0
- package/package.json +62 -0
- package/scripts/dev.js +63 -0
- package/scripts/preinstall.js +5 -0
- package/src/components/salla-base-component.ts +25 -0
- package/src/components/salla-custom-component.ts +12 -0
- package/src/helpers/helpers.ts +65 -0
- package/src/index.ts +127 -0
- package/src/vite-plugins/build.ts +68 -0
- package/src/vite-plugins/demo/index.ts +161 -0
- package/src/vite-plugins/demo/template.ts +1620 -0
- package/src/vite-plugins/transform.ts +32 -0
- package/tsconfig.json +26 -0
- package/types/global.d.ts +18 -0
- package/types/vite-plugin.d.ts +34 -0
- package/vite-plugins.d.ts +13 -0
- package/vite-plugins.ts +14 -0
- package/vite.config.ts +49 -0
package/README.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# @salla.sa/twilight-bundles
|
|
2
|
+
|
|
3
|
+
Core build tools and plugins for Salla Twilight components. This package provides the build infrastructure used by the starter kit and other Twilight component packages.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Vite Plugins**: A set of plugins for building and developing Twilight components
|
|
8
|
+
- **Build Configuration**: Optimized build settings for component bundling
|
|
9
|
+
- **Development Tools**: Development server and demo environment
|
|
10
|
+
|
|
11
|
+
## Plugins
|
|
12
|
+
|
|
13
|
+
### 1. Transform Plugin (`sallaTransformPlugin`)
|
|
14
|
+
|
|
15
|
+
Transforms component files to ensure proper naming and registration in the Twilight system.
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { sallaTransformPlugin } from '@salla.sa/twilight-bundles/vite-plugins';
|
|
19
|
+
|
|
20
|
+
export default defineConfig({
|
|
21
|
+
plugins: [
|
|
22
|
+
sallaTransformPlugin()
|
|
23
|
+
]
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
The transform plugin:
|
|
28
|
+
- Matches components in `src/components/*/index.ts`
|
|
29
|
+
- Ensures proper component registration
|
|
30
|
+
- Handles component naming based on directory structure
|
|
31
|
+
|
|
32
|
+
### 2. Build Plugin (`sallaBuildPlugin`)
|
|
33
|
+
|
|
34
|
+
Handles component bundling and output configuration.
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { sallaBuildPlugin } from '@salla.sa/twilight-bundles/vite-plugins';
|
|
38
|
+
|
|
39
|
+
export default defineConfig({
|
|
40
|
+
plugins: [
|
|
41
|
+
sallaBuildPlugin()
|
|
42
|
+
]
|
|
43
|
+
});
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The build plugin:
|
|
47
|
+
- Automatically discovers components in `src/components/`
|
|
48
|
+
- Creates individual files for each component
|
|
49
|
+
- Configures external dependencies (lit libraries)
|
|
50
|
+
- Optimizes build output
|
|
51
|
+
|
|
52
|
+
### 3. Demo Plugin (`sallaDemoPlugin`)
|
|
53
|
+
|
|
54
|
+
Provides a development environment for testing components.
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
import { sallaDemoPlugin } from '@salla.sa/twilight-bundles/vite-plugins';
|
|
58
|
+
|
|
59
|
+
export default defineConfig({
|
|
60
|
+
plugins: [
|
|
61
|
+
sallaDemoPlugin()
|
|
62
|
+
]
|
|
63
|
+
});
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
The demo plugin:
|
|
67
|
+
- Creates a demo page with all components
|
|
68
|
+
- Configures hot module reloading
|
|
69
|
+
- Sets up the development server
|
|
70
|
+
- Provides a testing environment
|
|
71
|
+
|
|
72
|
+
## Usage
|
|
73
|
+
|
|
74
|
+
This package is typically used as a dependency in Twilight component packages. See the starter kit for a complete example of how to use these plugins.
|
|
75
|
+
|
|
76
|
+
## Development
|
|
77
|
+
|
|
78
|
+
1. Install dependencies:
|
|
79
|
+
```bash
|
|
80
|
+
pnpm install
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
2. Build the package:
|
|
84
|
+
```bash
|
|
85
|
+
pnpm run build
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## License
|
|
89
|
+
|
|
90
|
+
MIT
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
7
|
+
import readline from 'readline';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Validates if a string is in kebab-case
|
|
11
|
+
* @param {string} str - String to validate
|
|
12
|
+
* @returns {boolean} - True if string is in kebab-case
|
|
13
|
+
*/
|
|
14
|
+
function isKebabCase(str) {
|
|
15
|
+
return /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/.test(str);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Capitalizes the first letter of each word in a kebab-case string
|
|
20
|
+
* @param {string} str - Kebab-case string
|
|
21
|
+
* @returns {string} - Title case string
|
|
22
|
+
*/
|
|
23
|
+
function kebabToTitleCase(str) {
|
|
24
|
+
return str.split('-')
|
|
25
|
+
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
|
26
|
+
.join(' ');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Capitalizes the first letter of each word in a kebab-case string and removes spaces
|
|
31
|
+
* @param {string} str - Kebab-case string
|
|
32
|
+
* @returns {string} - PascalCase string
|
|
33
|
+
*/
|
|
34
|
+
function kebabToPascalCase(str) {
|
|
35
|
+
return str.split('-')
|
|
36
|
+
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
|
37
|
+
.join('');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Checks if a component with the given name already exists
|
|
42
|
+
* @param {string} componentName - Name of the component to check
|
|
43
|
+
* @param {string} projectRoot - Root directory of the project
|
|
44
|
+
* @returns {boolean} - True if component already exists
|
|
45
|
+
*/
|
|
46
|
+
function componentExists(componentName, projectRoot) {
|
|
47
|
+
const componentsDir = path.join(projectRoot, 'src', 'components');
|
|
48
|
+
const componentDir = path.join(componentsDir, componentName);
|
|
49
|
+
return fs.existsSync(componentDir);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Checks if a component with the given name exists in twilight-bundle.json
|
|
54
|
+
* @param {string} componentName - Name of the component to check
|
|
55
|
+
* @param {string} projectRoot - Root directory of the project
|
|
56
|
+
* @returns {boolean} - True if component already exists in twilight-bundle.json
|
|
57
|
+
*/
|
|
58
|
+
function componentExistsInBundle(componentName, projectRoot) {
|
|
59
|
+
const bundlePath = path.join(projectRoot, 'twilight-bundle.json');
|
|
60
|
+
|
|
61
|
+
if (!fs.existsSync(bundlePath)) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const bundleContent = JSON.parse(fs.readFileSync(bundlePath, 'utf8'));
|
|
66
|
+
|
|
67
|
+
if (!bundleContent.components || !Array.isArray(bundleContent.components)) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return bundleContent.components.some(component => component.name === componentName);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Creates a new component
|
|
76
|
+
* @param {string} componentName - Name of the component to create
|
|
77
|
+
* @param {string} projectRoot - Root directory of the project
|
|
78
|
+
*/
|
|
79
|
+
function createComponent(componentName, projectRoot) {
|
|
80
|
+
const componentsDir = path.join(projectRoot, 'src', 'components');
|
|
81
|
+
const componentDir = path.join(componentsDir, componentName);
|
|
82
|
+
|
|
83
|
+
// Create component directory
|
|
84
|
+
fs.mkdirSync(componentDir, { recursive: true });
|
|
85
|
+
|
|
86
|
+
// Create component index.ts file
|
|
87
|
+
const className = kebabToPascalCase(componentName);
|
|
88
|
+
const indexContent = `import { css, html, LitElement } from "lit";
|
|
89
|
+
import { property } from "lit/decorators.js";
|
|
90
|
+
|
|
91
|
+
export default class ${className} extends LitElement {
|
|
92
|
+
@property({ type: Object })
|
|
93
|
+
config?: Record<string, any>;
|
|
94
|
+
|
|
95
|
+
static styles = css\`
|
|
96
|
+
:host {
|
|
97
|
+
display: block;
|
|
98
|
+
}
|
|
99
|
+
.${componentName} {
|
|
100
|
+
padding: 1rem;
|
|
101
|
+
background: white;
|
|
102
|
+
border-radius: 8px;
|
|
103
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
104
|
+
}
|
|
105
|
+
.${componentName}-title {
|
|
106
|
+
font-weight: 500;
|
|
107
|
+
color: #2c3e50;
|
|
108
|
+
margin: 0 0 1rem;
|
|
109
|
+
}
|
|
110
|
+
.${componentName}-content {
|
|
111
|
+
color: #666;
|
|
112
|
+
}
|
|
113
|
+
\`;
|
|
114
|
+
|
|
115
|
+
render() {
|
|
116
|
+
return html\`
|
|
117
|
+
<div class="${componentName}">
|
|
118
|
+
<h3 class="${componentName}-title">\${this.config?.title || '${kebabToTitleCase(componentName)}'}</h3>
|
|
119
|
+
<div class="${componentName}-content">
|
|
120
|
+
\${this.config?.content || 'This is a new ${kebabToTitleCase(componentName)} component'}
|
|
121
|
+
</div>
|
|
122
|
+
</div>
|
|
123
|
+
\`;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
`;
|
|
127
|
+
|
|
128
|
+
fs.writeFileSync(path.join(componentDir, 'index.ts'), indexContent);
|
|
129
|
+
|
|
130
|
+
console.log(`ā
Component files created at ${componentDir}`);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Updates the twilight-bundle.json file with the new component
|
|
135
|
+
* @param {string} componentName - Name of the component to add
|
|
136
|
+
* @param {string} projectRoot - Root directory of the project
|
|
137
|
+
*/
|
|
138
|
+
function updateBundleJson(componentName, projectRoot) {
|
|
139
|
+
const bundlePath = path.join(projectRoot, 'twilight-bundle.json');
|
|
140
|
+
|
|
141
|
+
if (!fs.existsSync(bundlePath)) {
|
|
142
|
+
console.error('ā twilight-bundle.json not found');
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const bundleContent = JSON.parse(fs.readFileSync(bundlePath, 'utf8'));
|
|
147
|
+
|
|
148
|
+
if (!bundleContent.components || !Array.isArray(bundleContent.components)) {
|
|
149
|
+
bundleContent.components = [];
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Create new component definition
|
|
153
|
+
const componentTitle = kebabToTitleCase(componentName);
|
|
154
|
+
const componentDefinition = {
|
|
155
|
+
"title": componentTitle,
|
|
156
|
+
"icon": "sicon-layout-grid",
|
|
157
|
+
"name": componentName,
|
|
158
|
+
"key": uuidv4(),
|
|
159
|
+
"image": "https://cdn.salla.network/images/themes/default/placeholder.jpg",
|
|
160
|
+
"fields": [
|
|
161
|
+
{
|
|
162
|
+
"id": "title",
|
|
163
|
+
"icon": "sicon-format-text-alt",
|
|
164
|
+
"type": "string",
|
|
165
|
+
"label": "Title",
|
|
166
|
+
"format": "text",
|
|
167
|
+
"required": true,
|
|
168
|
+
"placeholder": "Enter component title...",
|
|
169
|
+
"value": componentTitle
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
"id": "content",
|
|
173
|
+
"icon": "sicon-paragraph",
|
|
174
|
+
"type": "string",
|
|
175
|
+
"label": "Content",
|
|
176
|
+
"format": "textarea",
|
|
177
|
+
"required": false,
|
|
178
|
+
"placeholder": "Enter component content...",
|
|
179
|
+
"value": `This is a new ${componentTitle} component`
|
|
180
|
+
}
|
|
181
|
+
]
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
// Add the new component definition
|
|
185
|
+
bundleContent.components.push(componentDefinition);
|
|
186
|
+
|
|
187
|
+
// Write the updated content back to the file
|
|
188
|
+
fs.writeFileSync(bundlePath, JSON.stringify(bundleContent, null, 4));
|
|
189
|
+
|
|
190
|
+
console.log(`ā
Component added to twilight-bundle.json`);
|
|
191
|
+
return true;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Main function to create a new component
|
|
196
|
+
* @param {string} [componentNameArg] - Optional component name from command line
|
|
197
|
+
* @param {string} [projectRootArg] - Optional project root directory
|
|
198
|
+
*/
|
|
199
|
+
function createNewComponent(componentNameArg, projectRootArg) {
|
|
200
|
+
// Get project root from arguments or default to current directory
|
|
201
|
+
const projectRoot = projectRootArg || process.cwd();
|
|
202
|
+
|
|
203
|
+
console.log('š§© Salla Twilight Component Generator š§©\n');
|
|
204
|
+
|
|
205
|
+
// If component name is provided as argument, use it directly
|
|
206
|
+
if (componentNameArg) {
|
|
207
|
+
processComponentName(componentNameArg, projectRoot);
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// Otherwise, prompt for component name
|
|
212
|
+
const rl = readline.createInterface({
|
|
213
|
+
input: process.stdin,
|
|
214
|
+
output: process.stdout
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
rl.question('Enter the component name (in kebab-case, e.g., "my-component"): ', (componentName) => {
|
|
218
|
+
processComponentName(componentName, projectRoot);
|
|
219
|
+
rl.close();
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Process the component name, validate it, and create the component
|
|
225
|
+
* @param {string} componentName - The component name to process
|
|
226
|
+
* @param {string} projectRoot - The project root directory
|
|
227
|
+
*/
|
|
228
|
+
function processComponentName(componentName, projectRoot) {
|
|
229
|
+
// Validate component name
|
|
230
|
+
if (!componentName) {
|
|
231
|
+
console.error('ā Component name is required');
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if (!isKebabCase(componentName)) {
|
|
236
|
+
console.error('ā Component name must be in kebab-case (e.g., "my-component")');
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// Check if component already exists
|
|
241
|
+
if (componentExists(componentName, projectRoot)) {
|
|
242
|
+
console.error(`ā Component "${componentName}" already exists`);
|
|
243
|
+
return false;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// Check if component already exists in twilight-bundle.json
|
|
247
|
+
if (componentExistsInBundle(componentName, projectRoot)) {
|
|
248
|
+
console.error(`ā Component "${componentName}" already exists in twilight-bundle.json`);
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// Create component
|
|
253
|
+
createComponent(componentName, projectRoot);
|
|
254
|
+
|
|
255
|
+
// Update twilight-bundle.json
|
|
256
|
+
updateBundleJson(componentName, projectRoot);
|
|
257
|
+
|
|
258
|
+
console.log(`\nš Component "${componentName}" created successfully!\n`);
|
|
259
|
+
console.log(`Next steps:`);
|
|
260
|
+
console.log(`1. Run "pnpm run dev" to see your component in action`);
|
|
261
|
+
console.log(`2. Edit the component files in src/components/${componentName}/`);
|
|
262
|
+
console.log(`3. Customize the component definition in twilight-bundle.json`);
|
|
263
|
+
|
|
264
|
+
return true;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// Parse command-line arguments and run the script
|
|
268
|
+
const args = process.argv.slice(2);
|
|
269
|
+
const componentName = args[0]; // First argument is the component name
|
|
270
|
+
const projectRoot = process.cwd(); // Use current directory as project root
|
|
271
|
+
|
|
272
|
+
// Run the script with the parsed arguments
|
|
273
|
+
createNewComponent(componentName, projectRoot);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2019 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
*/const H=globalThis,V=H.ShadowRoot&&(H.ShadyCSS===void 0||H.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,q=Symbol(),F=new WeakMap;let rt=class{constructor(t,e,s){if(this._$cssResult$=!0,s!==q)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(V&&t===void 0){const s=e!==void 0&&e.length===1;s&&(t=F.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),s&&F.set(e,t))}return t}toString(){return this.cssText}};const dt=n=>new rt(typeof n=="string"?n:n+"",void 0,q),ut=(n,...t)=>{const e=n.length===1?n[0]:t.reduce((s,i,r)=>s+(o=>{if(o._$cssResult$===!0)return o.cssText;if(typeof o=="number")return o;throw Error("Value passed to 'css' function must be a 'css' function result: "+o+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+n[r+1],n[0]);return new rt(e,n,q)},pt=(n,t)=>{if(V)n.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const e of t){const s=document.createElement("style"),i=H.litNonce;i!==void 0&&s.setAttribute("nonce",i),s.textContent=e.cssText,n.appendChild(s)}},G=V?n=>n:n=>n instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return dt(e)})(n):n;/**
|
|
6
|
+
* @license
|
|
7
|
+
* Copyright 2017 Google LLC
|
|
8
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
9
|
+
*/const{is:mt,defineProperty:$t,getOwnPropertyDescriptor:ft,getOwnPropertyNames:gt,getOwnPropertySymbols:_t,getPrototypeOf:yt}=Object,f=globalThis,Q=f.trustedTypes,At=Q?Q.emptyScript:"",L=f.reactiveElementPolyfillSupport,C=(n,t)=>n,N={toAttribute(n,t){switch(t){case Boolean:n=n?At:null;break;case Object:case Array:n=n==null?n:JSON.stringify(n)}return n},fromAttribute(n,t){let e=n;switch(t){case Boolean:e=n!==null;break;case Number:e=n===null?null:Number(n);break;case Object:case Array:try{e=JSON.parse(n)}catch{e=null}}return e}},J=(n,t)=>!mt(n,t),X={attribute:!0,type:String,converter:N,reflect:!1,hasChanged:J};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),f.litPropertyMetadata??(f.litPropertyMetadata=new WeakMap);class v extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??(this.l=[])).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=X){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const s=Symbol(),i=this.getPropertyDescriptor(t,s,e);i!==void 0&&$t(this.prototype,t,i)}}static getPropertyDescriptor(t,e,s){const{get:i,set:r}=ft(this.prototype,t)??{get(){return this[e]},set(o){this[e]=o}};return{get(){return i==null?void 0:i.call(this)},set(o){const l=i==null?void 0:i.call(this);r.call(this,o),this.requestUpdate(t,l,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??X}static _$Ei(){if(this.hasOwnProperty(C("elementProperties")))return;const t=yt(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(C("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(C("properties"))){const e=this.properties,s=[...gt(e),..._t(e)];for(const i of s)this.createProperty(i,e[i])}const t=this[Symbol.metadata];if(t!==null){const e=litPropertyMetadata.get(t);if(e!==void 0)for(const[s,i]of e)this.elementProperties.set(s,i)}this._$Eh=new Map;for(const[e,s]of this.elementProperties){const i=this._$Eu(e,s);i!==void 0&&this._$Eh.set(i,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const i of s)e.unshift(G(i))}else t!==void 0&&e.push(G(t));return e}static _$Eu(t,e){const s=e.attribute;return s===!1?void 0:typeof s=="string"?s:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var t;this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),(t=this.constructor.l)==null||t.forEach(e=>e(this))}addController(t){var e;(this._$EO??(this._$EO=new Set)).add(t),this.renderRoot!==void 0&&this.isConnected&&((e=t.hostConnected)==null||e.call(t))}removeController(t){var e;(e=this._$EO)==null||e.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const s of e.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return pt(t,this.constructor.elementStyles),t}connectedCallback(){var t;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$EO)==null||t.forEach(e=>{var s;return(s=e.hostConnected)==null?void 0:s.call(e)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$EO)==null||t.forEach(e=>{var s;return(s=e.hostDisconnected)==null?void 0:s.call(e)})}attributeChangedCallback(t,e,s){this._$AK(t,s)}_$EC(t,e){var r;const s=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,s);if(i!==void 0&&s.reflect===!0){const o=(((r=s.converter)==null?void 0:r.toAttribute)!==void 0?s.converter:N).toAttribute(e,s.type);this._$Em=t,o==null?this.removeAttribute(i):this.setAttribute(i,o),this._$Em=null}}_$AK(t,e){var r;const s=this.constructor,i=s._$Eh.get(t);if(i!==void 0&&this._$Em!==i){const o=s.getPropertyOptions(i),l=typeof o.converter=="function"?{fromAttribute:o.converter}:((r=o.converter)==null?void 0:r.fromAttribute)!==void 0?o.converter:N;this._$Em=i,this[i]=l.fromAttribute(e,o.type),this._$Em=null}}requestUpdate(t,e,s){if(t!==void 0){if(s??(s=this.constructor.getPropertyOptions(t)),!(s.hasChanged??J)(this[t],e))return;this.P(t,e,s)}this.isUpdatePending===!1&&(this._$ES=this._$ET())}P(t,e,s){this._$AL.has(t)||this._$AL.set(t,e),s.reflect===!0&&this._$Em!==t&&(this._$Ej??(this._$Ej=new Set)).add(t)}async _$ET(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var s;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[r,o]of this._$Ep)this[r]=o;this._$Ep=void 0}const i=this.constructor.elementProperties;if(i.size>0)for(const[r,o]of i)o.wrapped!==!0||this._$AL.has(r)||this[r]===void 0||this.P(r,this[r],o)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),(s=this._$EO)==null||s.forEach(i=>{var r;return(r=i.hostUpdate)==null?void 0:r.call(i)}),this.update(e)):this._$EU()}catch(i){throw t=!1,this._$EU(),i}t&&this._$AE(e)}willUpdate(t){}_$AE(t){var e;(e=this._$EO)==null||e.forEach(s=>{var i;return(i=s.hostUpdated)==null?void 0:i.call(s)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Ej&&(this._$Ej=this._$Ej.forEach(e=>this._$EC(e,this[e]))),this._$EU()}updated(t){}firstUpdated(t){}}v.elementStyles=[],v.shadowRootOptions={mode:"open"},v[C("elementProperties")]=new Map,v[C("finalized")]=new Map,L==null||L({ReactiveElement:v}),(f.reactiveElementVersions??(f.reactiveElementVersions=[])).push("2.0.4");/**
|
|
10
|
+
* @license
|
|
11
|
+
* Copyright 2017 Google LLC
|
|
12
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
13
|
+
*/const P=globalThis,k=P.trustedTypes,Y=k?k.createPolicy("lit-html",{createHTML:n=>n}):void 0,at="$lit$",$=`lit$${Math.random().toFixed(9).slice(2)}$`,lt="?"+$,vt=`<${lt}>`,y=document,U=()=>y.createComment(""),x=n=>n===null||typeof n!="object"&&typeof n!="function",K=Array.isArray,St=n=>K(n)||typeof(n==null?void 0:n[Symbol.iterator])=="function",j=`[
|
|
14
|
+
\f\r]`,E=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,tt=/-->/g,et=/>/g,g=RegExp(`>|${j}(?:([^\\s"'>=/]+)(${j}*=${j}*(?:[^
|
|
15
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),st=/'/g,it=/"/g,ht=/^(?:script|style|textarea|title)$/i,b=Symbol.for("lit-noChange"),d=Symbol.for("lit-nothing"),nt=new WeakMap,_=y.createTreeWalker(y,129);function ct(n,t){if(!K(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return Y!==void 0?Y.createHTML(t):t}const bt=(n,t)=>{const e=n.length-1,s=[];let i,r=t===2?"<svg>":t===3?"<math>":"",o=E;for(let l=0;l<e;l++){const a=n[l];let c,u,h=-1,p=0;for(;p<a.length&&(o.lastIndex=p,u=o.exec(a),u!==null);)p=o.lastIndex,o===E?u[1]==="!--"?o=tt:u[1]!==void 0?o=et:u[2]!==void 0?(ht.test(u[2])&&(i=RegExp("</"+u[2],"g")),o=g):u[3]!==void 0&&(o=g):o===g?u[0]===">"?(o=i??E,h=-1):u[1]===void 0?h=-2:(h=o.lastIndex-u[2].length,c=u[1],o=u[3]===void 0?g:u[3]==='"'?it:st):o===it||o===st?o=g:o===tt||o===et?o=E:(o=g,i=void 0);const m=o===g&&n[l+1].startsWith("/>")?" ":"";r+=o===E?a+vt:h>=0?(s.push(c),a.slice(0,h)+at+a.slice(h)+$+m):a+$+(h===-2?l:m)}return[ct(n,r+(n[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),s]};class R{constructor({strings:t,_$litType$:e},s){let i;this.parts=[];let r=0,o=0;const l=t.length-1,a=this.parts,[c,u]=bt(t,e);if(this.el=R.createElement(c,s),_.currentNode=this.el.content,e===2||e===3){const h=this.el.content.firstChild;h.replaceWith(...h.childNodes)}for(;(i=_.nextNode())!==null&&a.length<l;){if(i.nodeType===1){if(i.hasAttributes())for(const h of i.getAttributeNames())if(h.endsWith(at)){const p=u[o++],m=i.getAttribute(h).split($),O=/([.?@])?(.*)/.exec(p);a.push({type:1,index:r,name:O[2],strings:m,ctor:O[1]==="."?Et:O[1]==="?"?Ct:O[1]==="@"?Pt:D}),i.removeAttribute(h)}else h.startsWith($)&&(a.push({type:6,index:r}),i.removeAttribute(h));if(ht.test(i.tagName)){const h=i.textContent.split($),p=h.length-1;if(p>0){i.textContent=k?k.emptyScript:"";for(let m=0;m<p;m++)i.append(h[m],U()),_.nextNode(),a.push({type:2,index:++r});i.append(h[p],U())}}}else if(i.nodeType===8)if(i.data===lt)a.push({type:2,index:r});else{let h=-1;for(;(h=i.data.indexOf($,h+1))!==-1;)a.push({type:7,index:r}),h+=$.length-1}r++}}static createElement(t,e){const s=y.createElement("template");return s.innerHTML=t,s}}function w(n,t,e=n,s){var o,l;if(t===b)return t;let i=s!==void 0?(o=e._$Co)==null?void 0:o[s]:e._$Cl;const r=x(t)?void 0:t._$litDirective$;return(i==null?void 0:i.constructor)!==r&&((l=i==null?void 0:i._$AO)==null||l.call(i,!1),r===void 0?i=void 0:(i=new r(n),i._$AT(n,e,s)),s!==void 0?(e._$Co??(e._$Co=[]))[s]=i:e._$Cl=i),i!==void 0&&(t=w(n,i._$AS(n,t.values),i,s)),t}class wt{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:s}=this._$AD,i=((t==null?void 0:t.creationScope)??y).importNode(e,!0);_.currentNode=i;let r=_.nextNode(),o=0,l=0,a=s[0];for(;a!==void 0;){if(o===a.index){let c;a.type===2?c=new M(r,r.nextSibling,this,t):a.type===1?c=new a.ctor(r,a.name,a.strings,this,t):a.type===6&&(c=new Tt(r,this,t)),this._$AV.push(c),a=s[++l]}o!==(a==null?void 0:a.index)&&(r=_.nextNode(),o++)}return _.currentNode=y,i}p(t){let e=0;for(const s of this._$AV)s!==void 0&&(s.strings!==void 0?(s._$AI(t,s,e),e+=s.strings.length-2):s._$AI(t[e])),e++}}class M{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,e,s,i){this.type=2,this._$AH=d,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=s,this.options=i,this._$Cv=(i==null?void 0:i.isConnected)??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=w(this,t,e),x(t)?t===d||t==null||t===""?(this._$AH!==d&&this._$AR(),this._$AH=d):t!==this._$AH&&t!==b&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):St(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==d&&x(this._$AH)?this._$AA.nextSibling.data=t:this.T(y.createTextNode(t)),this._$AH=t}$(t){var r;const{values:e,_$litType$:s}=t,i=typeof s=="number"?this._$AC(t):(s.el===void 0&&(s.el=R.createElement(ct(s.h,s.h[0]),this.options)),s);if(((r=this._$AH)==null?void 0:r._$AD)===i)this._$AH.p(e);else{const o=new wt(i,this),l=o.u(this.options);o.p(e),this.T(l),this._$AH=o}}_$AC(t){let e=nt.get(t.strings);return e===void 0&&nt.set(t.strings,e=new R(t)),e}k(t){K(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let s,i=0;for(const r of t)i===e.length?e.push(s=new M(this.O(U()),this.O(U()),this,this.options)):s=e[i],s._$AI(r),i++;i<e.length&&(this._$AR(s&&s._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){var s;for((s=this._$AP)==null?void 0:s.call(this,!1,!0,e);t&&t!==this._$AB;){const i=t.nextSibling;t.remove(),t=i}}setConnected(t){var e;this._$AM===void 0&&(this._$Cv=t,(e=this._$AP)==null||e.call(this,t))}}class D{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,s,i,r){this.type=1,this._$AH=d,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=r,s.length>2||s[0]!==""||s[1]!==""?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=d}_$AI(t,e=this,s,i){const r=this.strings;let o=!1;if(r===void 0)t=w(this,t,e,0),o=!x(t)||t!==this._$AH&&t!==b,o&&(this._$AH=t);else{const l=t;let a,c;for(t=r[0],a=0;a<r.length-1;a++)c=w(this,l[s+a],e,a),c===b&&(c=this._$AH[a]),o||(o=!x(c)||c!==this._$AH[a]),c===d?t=d:t!==d&&(t+=(c??"")+r[a+1]),this._$AH[a]=c}o&&!i&&this.j(t)}j(t){t===d?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class Et extends D{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===d?void 0:t}}class Ct extends D{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==d)}}class Pt extends D{constructor(t,e,s,i,r){super(t,e,s,i,r),this.type=5}_$AI(t,e=this){if((t=w(this,t,e,0)??d)===b)return;const s=this._$AH,i=t===d&&s!==d||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,r=t!==d&&(s===d||i);i&&this.element.removeEventListener(this.name,this,s),r&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e;typeof this._$AH=="function"?this._$AH.call(((e=this.options)==null?void 0:e.host)??this.element,t):this._$AH.handleEvent(t)}}class Tt{constructor(t,e,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){w(this,t)}}const B=P.litHtmlPolyfillSupport;B==null||B(R,M),(P.litHtmlVersions??(P.litHtmlVersions=[])).push("3.2.1");const Ut=(n,t,e)=>{const s=(e==null?void 0:e.renderBefore)??t;let i=s._$litPart$;if(i===void 0){const r=(e==null?void 0:e.renderBefore)??null;s._$litPart$=i=new M(t.insertBefore(U(),r),r,void 0,e??{})}return i._$AI(n),i};/**
|
|
16
|
+
* @license
|
|
17
|
+
* Copyright 2017 Google LLC
|
|
18
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
19
|
+
*/let T=class extends v{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e;const t=super.createRenderRoot();return(e=this.renderOptions).renderBefore??(e.renderBefore=t.firstChild),t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=Ut(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this._$Do)==null||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this._$Do)==null||t.setConnected(!1)}render(){return b}};var ot;T._$litElement$=!0,T.finalized=!0,(ot=globalThis.litElementHydrateSupport)==null||ot.call(globalThis,{LitElement:T});const W=globalThis.litElementPolyfillSupport;W==null||W({LitElement:T});(globalThis.litElementVersions??(globalThis.litElementVersions=[])).push("4.1.1");/**
|
|
20
|
+
* @license
|
|
21
|
+
* Copyright 2017 Google LLC
|
|
22
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
23
|
+
*/const xt={attribute:!0,type:String,converter:N,reflect:!1,hasChanged:J},Rt=(n=xt,t,e)=>{const{kind:s,metadata:i}=e;let r=globalThis.litPropertyMetadata.get(i);if(r===void 0&&globalThis.litPropertyMetadata.set(i,r=new Map),r.set(e.name,n),s==="accessor"){const{name:o}=e;return{set(l){const a=t.get.call(this);t.set.call(this,l),this.requestUpdate(o,a,n)},init(l){return l!==void 0&&this.P(o,void 0,n),l}}}if(s==="setter"){const{name:o}=e;return function(l){const a=this[o];t.call(this,l),this.requestUpdate(o,a,n)}}throw Error("Unsupported decorator location: "+s)};function z(n){return(t,e)=>typeof e=="object"?Rt(n,t,e):((s,i,r)=>{const o=i.hasOwnProperty(r);return i.constructor.createProperty(r,o?{...s,wrapped:!0}:s),o?Object.getOwnPropertyDescriptor(i,r):void 0})(n,t,e)}class S{static onBundlesReady(){return S.makeSureSallaIsReady().then(()=>Salla.event.onlyWhen("twilight-bundles::initiated"))}static initializeSalla(){if(Salla.status==="ready"){salla.log("Salla is ready");return}const t=document.currentScript||document.querySelector('script[src*="twilight-bundles.js"]'),e=t==null?void 0:t.hasAttribute("demo-mode"),s=t==null?void 0:t.getAttribute("store-id"),i=JSON.parse((t==null?void 0:t.getAttribute("config"))||"false");return e||i||s?Salla.init(i||{debug:!0,store:{id:s||1510890315}}):Salla.onReady()}static makeSureSallaIsReady(){return window.Salla?Promise.resolve(S.initializeSalla()):new Promise((t,e)=>{let s;const i=setTimeout(()=>{window.clearInterval(s),e(new Error("Timeout: Salla object not found after 10 seconds"))},1e4);s=window.setInterval(()=>{window.Salla&&(window.clearInterval(s),clearTimeout(i),t(S.initializeSalla()))},50)})}}var Mt=Object.defineProperty,I=(n,t,e,s)=>{for(var i=void 0,r=n.length-1,o;r>=0;r--)(o=n[r])&&(i=o(t,e,i)||i);return i&&Mt(t,e,i),i};const Z=class Z extends T{constructor(){super(...arguments),this.key="",this.data={},this.imports={},this.shadowRootMode="open"}createRenderRoot(){return this.shadowRootMode!==!1?this.attachShadow({mode:this.shadowRootMode||"closed"}):this}static register(t){const e={component:this,dynamicTagName:`${t}-${Math.random().toString(36).substring(2,8)}`};return S.onBundlesReady().then(()=>Salla.bundles.registerComponent(t,e))}};Z.styles=ut`:host { display: block; }`;let A=Z;I([z()],A.prototype,"key");I([z()],A.prototype,"data");I([z()],A.prototype,"imports");I([z()],A.prototype,"shadowRootMode");class Ot extends HTMLElement{connectedCallback(){var e;let t=(e=this.getAttribute("component-name"))==null?void 0:e.replace(/^salla-/,"");if(!t)return Salla.error("Component name is required",this),Promise.resolve();this.innerHTML=`<!-- Loading ${t} -->`,this.removeAttribute("component-name"),Salla.bundles.renderCustomComponentDom(`salla-${t}`,this)}}class Ht{constructor(){this.components=new Map,this.pendingComponents=[],this.initialized=!1,Salla.onReady().then(()=>{if(Salla.bundles){Salla.log("TwilightBundles is already initialized");return}this.init(),Salla.bundles=this,Salla.event.emit("twilight-bundles::initiated"),this.registerCustomComponents()})}async init(){this.initialized||(this.initialized=!0)}registerCustomComponents(){var t;HTMLElement.registerSallaComponent=function(e){Salla.bundles.registerComponent(e,{component:this,dynamicTagName:`${e}-${Math.random().toString(36).substring(2,8)}`})},(t=window.customComponents)==null||t.forEach(e=>{const s=document.createElement("script");s.type="module",s.src=e,document.head.appendChild(s)})}renderCustomComponentDom(t,e){salla.log("Rendering custom component",t),e.getAttribute("component-name");const s=this.components.get(t);return s?this.renderDynamicCustomComponentDom(s.dynamicTagName,e):this.pendingComponents.push({tagName:t,component:e})}renderDynamicCustomComponentDom(t,e){const s=document.createElement(t);Array.from(e.attributes).forEach(i=>s.setAttribute(i.name,i.value||"")),e.before(s),e.remove()}registerComponent(t,e){if(this.components.has(t))return console.warn(`Component ${t} is already registered into the this.components map. Skipping.`);if(!e.dynamicTagName)return console.warn(`Component ${t} is missing dynamicTagName. Skipping.`);if(!e.component)return console.warn(`Component ${t} is missing component. Skipping.`);if(window.customElements.get(e.dynamicTagName))return console.warn(`Component ${e.dynamicTagName} is already registered into the window custom elements. Skipping.`);window.customElements.define(e.dynamicTagName,e.component),this.components.set(t,e),Salla.log("Component registered:",e.dynamicTagName);const s=this.pendingComponents.filter(i=>i.tagName===t);s.length&&(s.forEach(i=>{this.renderDynamicCustomComponentDom(e.dynamicTagName,i.component)}),this.pendingComponents=this.pendingComponents.filter(i=>i.tagName!==t),Salla.log("Pending Components rendered:",t,e.dynamicTagName))}}S.makeSureSallaIsReady().then(()=>new Ht).then(()=>window.customElements.get("salla-custom-component")||window.customElements.define("salla-custom-component",Ot));exports.SallaComponent=A;
|