scb-wc 0.1.26 → 0.1.28
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 +2 -1
- package/all.js +5 -0
- package/bin/scb-wc.mjs +51 -117
- package/index.js +5 -0
- package/mvc/components/all.js +5 -0
- package/mvc/components/scb-card/scb-action-card.js +1 -0
- package/mvc/components/scb-card/scb-card.js +70 -70
- package/mvc/components/scb-card/scb-container-card.js +1 -0
- package/mvc/components/scb-card/scb-link-card.js +1 -0
- package/mvc/components/scb-card/scb-list-card.js +1 -0
- package/mvc/components/scb-card/scb-social-card.js +1 -0
- package/mvc/components/scb-collapse/scb-collapse.js +6 -3
- package/package.json +22 -2
- package/scb-card/scb-action-card.js +1 -0
- package/scb-card/scb-card.js +54 -41
- package/scb-card/scb-container-card.js +1 -0
- package/scb-card/scb-link-card.js +1 -0
- package/scb-card/scb-list-card.js +1 -0
- package/scb-card/scb-social-card.js +1 -0
- package/scb-collapse/scb-collapse.js +6 -3
- package/scb-components/index.d.ts +5 -0
- package/scb-components/scb-card/scb-action-card.d.ts +1 -0
- package/scb-components/scb-card/scb-card.d.ts +2 -0
- package/scb-components/scb-card/scb-container-card.d.ts +1 -0
- package/scb-components/scb-card/scb-link-card.d.ts +1 -0
- package/scb-components/scb-card/scb-list-card.d.ts +1 -0
- package/scb-components/scb-card/scb-social-card.d.ts +1 -0
- package/scb-wc.bundle.js +48 -45
- package/scb-wc.d.ts +10 -0
- package/starters/blazor/Components/Pages/Home.razor +3 -3
- package/starters/blazor/README.md +1 -1
- package/starters/blazor/ScbStarterApp.csproj +1 -1
- package/starters/blazor-service/Components/App.razor +23 -0
- package/starters/blazor-service/Components/Layout/MainLayout.razor +13 -0
- package/starters/blazor-service/Components/Pages/Home.razor +55 -0
- package/starters/blazor-service/Components/Routes.razor +14 -0
- package/starters/blazor-service/Components/_Imports.razor +11 -0
- package/starters/blazor-service/Program.cs +23 -0
- package/starters/blazor-service/README.md +29 -0
- package/starters/blazor-service/ScbStarterApp.csproj +8 -0
- package/starters/blazor-service/dot-gitignore +3 -0
- package/starters/blazor-service/package.json +14 -0
- package/starters/blazor-service/wwwroot/app.css +54 -0
- package/starters/html/main.js +3 -3
- package/starters/html-service/README.md +24 -0
- package/starters/html-service/dot-gitignore +2 -0
- package/starters/html-service/index.html +12 -0
- package/starters/html-service/main.js +78 -0
- package/starters/html-service/package.json +16 -0
- package/starters/react/README.md +1 -2
- package/starters/react/src/App.jsx +4 -4
- package/starters/react-service/README.md +24 -0
- package/starters/react-service/dot-gitignore +2 -0
- package/starters/react-service/index.html +12 -0
- package/starters/react-service/package.json +19 -0
- package/starters/react-service/src/App.jsx +67 -0
- package/starters/react-service/src/main.jsx +22 -0
- package/starters/react-service/vite.config.js +6 -0
package/README.md
CHANGED
|
@@ -133,11 +133,12 @@ Behöver du en annan webbrotsökväg (t.ex. om din `wwwroot` ligger någon annan
|
|
|
133
133
|
## Alternativ 3: Bundlad version (IIFE) för äldre miljöer
|
|
134
134
|
|
|
135
135
|
Om ESM inte stöds kan du använda den bundlade test‑varianten från paketroten.
|
|
136
|
-
Flytta följande
|
|
136
|
+
Flytta följande tre filer från `node_modules/scb-wc` och använd dem i applikationen:
|
|
137
137
|
|
|
138
138
|
```text
|
|
139
139
|
node_modules/scb-wc/scb-wc.bundle.js
|
|
140
140
|
node_modules/scb-wc/scb-wc.css
|
|
141
|
+
node_modules/scb-wc/scb-typography.css
|
|
141
142
|
```
|
|
142
143
|
|
|
143
144
|
```html
|
package/all.js
CHANGED
|
@@ -9,7 +9,12 @@ import './scb-button/scb-button.js';
|
|
|
9
9
|
import './scb-calendar-card/scb-calendar-card.js';
|
|
10
10
|
import './scb-calendar/scb-calendar-event.js';
|
|
11
11
|
import './scb-calendar/scb-calendar.js';
|
|
12
|
+
import './scb-card/scb-action-card.js';
|
|
12
13
|
import './scb-card/scb-card.js';
|
|
14
|
+
import './scb-card/scb-container-card.js';
|
|
15
|
+
import './scb-card/scb-link-card.js';
|
|
16
|
+
import './scb-card/scb-list-card.js';
|
|
17
|
+
import './scb-card/scb-social-card.js';
|
|
13
18
|
import './scb-checkbox/scb-checkbox-group.js';
|
|
14
19
|
import './scb-checkbox/scb-checkbox.js';
|
|
15
20
|
import './scb-chevron/scb-chevron.js';
|
package/bin/scb-wc.mjs
CHANGED
|
@@ -1,159 +1,93 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import fs from 'fs';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
import { fileURLToPath } from 'url';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
6
|
|
|
7
7
|
const __filename = fileURLToPath(import.meta.url);
|
|
8
8
|
const __dirname = path.dirname(__filename);
|
|
9
9
|
const packageRoot = path.resolve(__dirname, '..');
|
|
10
|
-
const packageJson = JSON.parse(
|
|
11
|
-
|
|
12
|
-
);
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
const usage = `
|
|
16
|
-
SCB Web Components
|
|
17
|
-
|
|
18
|
-
Användning:
|
|
19
|
-
npx scb-wc init <html|react|blazor> [mapp]
|
|
20
|
-
|
|
21
|
-
Exempel:
|
|
22
|
-
npx scb-wc init html my-app
|
|
23
|
-
npx scb-wc init react my-react-app
|
|
24
|
-
npx scb-wc init blazor my-blazor-app
|
|
25
|
-
`.trim();
|
|
26
|
-
|
|
27
|
-
const textExtensions = new Set([
|
|
28
|
-
'.css',
|
|
29
|
-
'.cs',
|
|
30
|
-
'.csproj',
|
|
31
|
-
'.html',
|
|
32
|
-
'.js',
|
|
33
|
-
'.json',
|
|
34
|
-
'.jsx',
|
|
35
|
-
'.md',
|
|
36
|
-
'.razor',
|
|
37
|
-
'.txt',
|
|
38
|
-
]);
|
|
10
|
+
const packageJson = JSON.parse(fs.readFileSync(path.join(packageRoot, 'package.json'), 'utf8'));
|
|
11
|
+
const starterRoot = path.join(packageRoot, 'starters');
|
|
12
|
+
const templates = new Set(['html', 'html-service', 'react', 'react-service', 'blazor', 'blazor-service']);
|
|
13
|
+
const usage = 'npx scb-wc init <html|html-service|react|react-service|blazor|blazor-service> [mapp]';
|
|
39
14
|
|
|
40
15
|
function fail(message) {
|
|
41
|
-
console.error(
|
|
16
|
+
console.error(message);
|
|
17
|
+
console.error(`Användning: ${usage}`);
|
|
42
18
|
process.exit(1);
|
|
43
19
|
}
|
|
44
20
|
|
|
45
|
-
function
|
|
46
|
-
return
|
|
21
|
+
function toPackageName(value) {
|
|
22
|
+
return value
|
|
23
|
+
.trim()
|
|
24
|
+
.toLowerCase()
|
|
25
|
+
.replace(/[^a-z0-9._-]+/g, '-')
|
|
26
|
+
.replace(/^-+|-+$/g, '') || 'scb-starter-app';
|
|
47
27
|
}
|
|
48
28
|
|
|
49
|
-
function
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
29
|
+
function toNamespace(value) {
|
|
30
|
+
const parts = value
|
|
31
|
+
.replace(/[^a-zA-Z0-9]+/g, ' ')
|
|
32
|
+
.trim()
|
|
33
|
+
.split(/\s+/)
|
|
34
|
+
.filter(Boolean);
|
|
53
35
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
.split(/[^A-Za-z0-9]+/)
|
|
57
|
-
.filter(Boolean)
|
|
58
|
-
.map(toPascalCaseSegment)
|
|
36
|
+
const namespace = parts
|
|
37
|
+
.map((part) => `${part.charAt(0).toUpperCase()}${part.slice(1)}`)
|
|
59
38
|
.join('');
|
|
60
39
|
|
|
61
|
-
|
|
62
|
-
if (/^[0-9]/.test(pascalCaseName)) return `_${pascalCaseName}`;
|
|
63
|
-
return pascalCaseName;
|
|
40
|
+
return /^[A-Za-z_][A-Za-z0-9_]*$/.test(namespace) ? namespace : 'ScbStarterApp';
|
|
64
41
|
}
|
|
65
42
|
|
|
66
|
-
function
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
43
|
+
function replacePlaceholders(source, targetName) {
|
|
44
|
+
return source
|
|
45
|
+
.replaceAll('__SCB_WC_PACKAGE_NAME__', packageJson.name)
|
|
46
|
+
.replaceAll('__SCB_WC_VERSION__', packageJson.version)
|
|
47
|
+
.replaceAll('__STARTER_NAME__', toPackageName(targetName))
|
|
48
|
+
.replaceAll('__STARTER_NAMESPACE__', toNamespace(targetName));
|
|
72
49
|
}
|
|
73
50
|
|
|
74
|
-
function
|
|
51
|
+
function copyStarter(sourceDir, targetDir, targetName) {
|
|
75
52
|
fs.mkdirSync(targetDir, { recursive: true });
|
|
76
53
|
|
|
77
54
|
for (const entry of fs.readdirSync(sourceDir, { withFileTypes: true })) {
|
|
78
|
-
const
|
|
79
|
-
const
|
|
55
|
+
const sourcePath = path.join(sourceDir, entry.name);
|
|
56
|
+
const targetNameForEntry = entry.name === 'dot-gitignore' ? '.gitignore' : entry.name;
|
|
57
|
+
const targetPath = path.join(targetDir, targetNameForEntry);
|
|
80
58
|
|
|
81
59
|
if (entry.isDirectory()) {
|
|
82
|
-
|
|
60
|
+
copyStarter(sourcePath, targetPath, targetName);
|
|
83
61
|
continue;
|
|
84
62
|
}
|
|
85
63
|
|
|
86
|
-
fs.
|
|
87
|
-
fs.
|
|
64
|
+
const source = fs.readFileSync(sourcePath, 'utf8');
|
|
65
|
+
fs.writeFileSync(targetPath, replacePlaceholders(source, targetName), 'utf8');
|
|
88
66
|
}
|
|
89
67
|
}
|
|
90
68
|
|
|
91
|
-
|
|
92
|
-
const walk = (currentDir) => {
|
|
93
|
-
for (const entry of fs.readdirSync(currentDir, { withFileTypes: true })) {
|
|
94
|
-
const fullPath = path.join(currentDir, entry.name);
|
|
95
|
-
|
|
96
|
-
if (entry.isDirectory()) {
|
|
97
|
-
walk(fullPath);
|
|
98
|
-
continue;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const ext = path.extname(entry.name);
|
|
102
|
-
if (!textExtensions.has(ext)) continue;
|
|
103
|
-
|
|
104
|
-
let contents = fs.readFileSync(fullPath, 'utf8');
|
|
105
|
-
for (const [placeholder, value] of Object.entries(replacements)) {
|
|
106
|
-
contents = contents.replaceAll(placeholder, value);
|
|
107
|
-
}
|
|
108
|
-
fs.writeFileSync(fullPath, contents, 'utf8');
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
walk(rootDir);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const [, , command, template, maybeTargetDir] = process.argv;
|
|
116
|
-
|
|
117
|
-
if (!command || command === '--help' || command === '-h') {
|
|
118
|
-
console.log(usage);
|
|
119
|
-
process.exit(0);
|
|
120
|
-
}
|
|
69
|
+
const [, , command, template, targetArg] = process.argv;
|
|
121
70
|
|
|
122
71
|
if (command !== 'init') {
|
|
123
|
-
fail(
|
|
72
|
+
fail('Okänt kommando.');
|
|
124
73
|
}
|
|
125
74
|
|
|
126
|
-
if (!
|
|
127
|
-
fail(
|
|
75
|
+
if (!templates.has(template)) {
|
|
76
|
+
fail('Okänd mall.');
|
|
128
77
|
}
|
|
129
78
|
|
|
130
|
-
const
|
|
131
|
-
const sourceDir = path.join(
|
|
79
|
+
const targetName = targetArg ?? `scb-${template}-app`;
|
|
80
|
+
const sourceDir = path.join(starterRoot, template);
|
|
81
|
+
const targetDir = path.resolve(process.cwd(), targetName);
|
|
132
82
|
|
|
133
83
|
if (!fs.existsSync(sourceDir)) {
|
|
134
|
-
fail(`
|
|
84
|
+
fail(`Saknar starter: ${template}`);
|
|
135
85
|
}
|
|
136
86
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
replacePlaceholders(targetDir, {
|
|
140
|
-
'__SCB_WC_PACKAGE_NAME__': packageJson.name,
|
|
141
|
-
'__SCB_WC_VERSION__': packageJson.version,
|
|
142
|
-
'__STARTER_NAME__': path.basename(targetDir),
|
|
143
|
-
'__STARTER_NAMESPACE__': sanitizeStarterNamespace(path.basename(targetDir)),
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
console.log(`\nSkapade ${template}-starter i ${targetDir}\n`);
|
|
147
|
-
|
|
148
|
-
if (template === 'blazor') {
|
|
149
|
-
console.log('Nästa steg:');
|
|
150
|
-
console.log(` 1. cd ${targetDir}`);
|
|
151
|
-
console.log(' 2. npm install');
|
|
152
|
-
console.log(' 3. npm run ui:setup');
|
|
153
|
-
console.log(' 4. dotnet run');
|
|
154
|
-
} else {
|
|
155
|
-
console.log('Nästa steg:');
|
|
156
|
-
console.log(` 1. cd ${targetDir}`);
|
|
157
|
-
console.log(' 2. npm install');
|
|
158
|
-
console.log(' 3. npm run dev');
|
|
87
|
+
if (fs.existsSync(targetDir) && fs.readdirSync(targetDir).length > 0) {
|
|
88
|
+
fail(`Mappen finns redan och är inte tom: ${targetDir}`);
|
|
159
89
|
}
|
|
90
|
+
|
|
91
|
+
copyStarter(sourceDir, targetDir, path.basename(targetDir));
|
|
92
|
+
|
|
93
|
+
console.log(`Skapade ${template}-starter i ${targetDir}`);
|
package/index.js
CHANGED
|
@@ -27,6 +27,11 @@ import { ScbCalendar as T } from "./scb-calendar/scb-calendar.js";
|
|
|
27
27
|
import { ScbCalendarCard as E } from "./scb-calendar-card/scb-calendar-card.js";
|
|
28
28
|
import { ScbTooltip as D } from "./scb-tooltip/scb-tooltip.js";
|
|
29
29
|
import { ScbActionCard as O, ScbCard as k, ScbContainerCard as A, ScbLinkCard as j, ScbListCard as M, ScbSocialCard as N } from "./scb-card/scb-card.js";
|
|
30
|
+
import "./scb-card/scb-action-card.js";
|
|
31
|
+
import "./scb-card/scb-container-card.js";
|
|
32
|
+
import "./scb-card/scb-link-card.js";
|
|
33
|
+
import "./scb-card/scb-list-card.js";
|
|
34
|
+
import "./scb-card/scb-social-card.js";
|
|
30
35
|
import { ScbCollapse as P } from "./scb-collapse/scb-collapse.js";
|
|
31
36
|
import { ScbCookiesConsent as F } from "./scb-cookies-consent/scb-cookies-consent.js";
|
|
32
37
|
import { ScbDrawer as I } from "./scb-drawer/scb-drawer.js";
|
package/mvc/components/all.js
CHANGED
|
@@ -9,7 +9,12 @@ import './scb-button/scb-button.js';
|
|
|
9
9
|
import './scb-calendar-card/scb-calendar-card.js';
|
|
10
10
|
import './scb-calendar/scb-calendar.js';
|
|
11
11
|
import './scb-calendar/scb-calendar-event.js';
|
|
12
|
+
import './scb-card/scb-action-card.js';
|
|
12
13
|
import './scb-card/scb-card.js';
|
|
14
|
+
import './scb-card/scb-container-card.js';
|
|
15
|
+
import './scb-card/scb-link-card.js';
|
|
16
|
+
import './scb-card/scb-list-card.js';
|
|
17
|
+
import './scb-card/scb-social-card.js';
|
|
13
18
|
import './scb-checkbox/scb-checkbox.js';
|
|
14
19
|
import './scb-checkbox/scb-checkbox-group.js';
|
|
15
20
|
import './scb-chevron/scb-chevron.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./scb-card.js";(function(){try{var t=typeof globalThis<"u"?globalThis:window;if(!t.__scb_ce_guard_installed__){t.__scb_ce_guard_installed__=!0;var r=customElements.define.bind(customElements);customElements.define=function(e,o,c){try{customElements.get(e)||r(e,o,c)}catch(i){var n=String(i||"");if(n.indexOf("already been used")===-1&&n.indexOf("NotSupportedError")===-1)throw i}}}}catch{}})();
|