@stencil/angular-output-target 1.4.1 → 1.5.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 +89 -0
- package/angular-component-lib/boolean-attribute.ts +43 -0
- package/dist/generate-angular-component.d.ts +7 -1
- package/dist/generate-angular-component.js +19 -5
- package/dist/generate-transformtag-script.d.ts +3 -1
- package/dist/generate-transformtag-script.js +6 -2
- package/dist/index.cjs +129 -58
- package/dist/index.js +129 -58
- package/dist/output-angular.d.ts +6 -0
- package/dist/output-angular.js +102 -51
- package/dist/plugin.d.ts +7 -2
- package/dist/types.d.ts +41 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +3 -1
- package/dist/wizard.js +14 -1
- package/package.json +3 -3
package/dist/types.d.ts
CHANGED
|
@@ -94,6 +94,43 @@ export interface OutputTargetAngular {
|
|
|
94
94
|
* @default false
|
|
95
95
|
*/
|
|
96
96
|
esModules?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* When `true`, boolean properties are declared with an Angular input transform so they can
|
|
99
|
+
* be set using attribute presence syntax:
|
|
100
|
+
*
|
|
101
|
+
* ```html
|
|
102
|
+
* <!-- with booleanAttributes enabled -->
|
|
103
|
+
* <my-component disabled></my-component>
|
|
104
|
+
*
|
|
105
|
+
* <!-- otherwise the value has to be bound explicitly -->
|
|
106
|
+
* <my-component [disabled]="true"></my-component>
|
|
107
|
+
* ```
|
|
108
|
+
*
|
|
109
|
+
* Without a transform Angular resolves the bare attribute to the empty string and reports
|
|
110
|
+
* `Type 'string' is not assignable to type 'boolean'` under `strictTemplates`.
|
|
111
|
+
*
|
|
112
|
+
* Compile-time checking of these bindings also requires `inlineProperties`. Without it the
|
|
113
|
+
* generated wrappers declare no typed members for their inputs, so Angular never checks them
|
|
114
|
+
* and there is no error for the transform to resolve.
|
|
115
|
+
*
|
|
116
|
+
* The transform still runs either way, because Angular applies it from the component
|
|
117
|
+
* definition's input map rather than from a declared class member. Enabling this on its own
|
|
118
|
+
* therefore moves boolean coercion from Stencil to the transform with nothing checking what
|
|
119
|
+
* callers pass, so prefer enabling `inlineProperties` alongside it.
|
|
120
|
+
*
|
|
121
|
+
* The transform coerces strings the same way Angular's `booleanAttribute` does, but passes
|
|
122
|
+
* `null` and `undefined` through instead of coercing them to `false`. Refer to
|
|
123
|
+
* `nullableBooleanAttribute`.
|
|
124
|
+
*
|
|
125
|
+
* Properties are only transformed when Stencil reports their type as exactly `boolean`.
|
|
126
|
+
* Virtual properties, properties declared as `any`, and types that union `boolean` with
|
|
127
|
+
* something else (such as `boolean | 'auto'`, reported as `any`) get no transform, and the
|
|
128
|
+
* property receives the attribute's empty string rather than `true`. Only the union case fails
|
|
129
|
+
* to compile; the other two are silent. Refer to the README for the differences.
|
|
130
|
+
*
|
|
131
|
+
* @default false
|
|
132
|
+
*/
|
|
133
|
+
booleanAttributes?: boolean;
|
|
97
134
|
}
|
|
98
135
|
export type ValueAccessorTypes = 'text' | 'radio' | 'select' | 'number' | 'boolean';
|
|
99
136
|
export interface ValueAccessorConfig {
|
|
@@ -108,4 +145,8 @@ export interface PackageJSON {
|
|
|
108
145
|
export interface ComponentInputProperty {
|
|
109
146
|
name: string;
|
|
110
147
|
required: boolean;
|
|
148
|
+
/**
|
|
149
|
+
* Whether to declare an input transform so the property can be set by attribute presence.
|
|
150
|
+
*/
|
|
151
|
+
transform?: boolean;
|
|
111
152
|
}
|
package/dist/utils.d.ts
CHANGED
|
@@ -44,4 +44,6 @@ export declare const createComponentEventTypeImports: (componentTagName: string,
|
|
|
44
44
|
componentCorePackage: string;
|
|
45
45
|
customElementsDir?: string;
|
|
46
46
|
outputType: OutputType;
|
|
47
|
+
/** Import through the package's `exports` map (`./standalone` or `./loader`) instead of a deep path. */
|
|
48
|
+
exportMaps?: boolean;
|
|
47
49
|
}) => string;
|
package/dist/utils.js
CHANGED
|
@@ -118,7 +118,9 @@ export const createComponentEventTypeImports = (componentTagName, events, option
|
|
|
118
118
|
const imports = [];
|
|
119
119
|
const namedImports = new Set();
|
|
120
120
|
const isCustomElementsBuild = isOutputTypeCustomElementsBuild(options.outputType);
|
|
121
|
-
const
|
|
121
|
+
const exportMapEntry = isCustomElementsBuild ? '/standalone' : '/loader';
|
|
122
|
+
const importPathName = normalizePath(componentCorePackage) +
|
|
123
|
+
(options.exportMaps ? exportMapEntry : isCustomElementsBuild ? `/${customElementsDir}` : '');
|
|
122
124
|
/**
|
|
123
125
|
* Each component's events are typed with the per-component CustomEvent type
|
|
124
126
|
* generated by Stencil (e.g. `MyComponentCustomEvent<Detail>`), which carries a
|
package/dist/wizard.js
CHANGED
|
@@ -49,6 +49,19 @@ async function allowPnpmBuild(pkg, rootDir, workspaceRoot) {
|
|
|
49
49
|
// ---------------------------------------------------------------------------
|
|
50
50
|
// Wrapper package scaffolding
|
|
51
51
|
// ---------------------------------------------------------------------------
|
|
52
|
+
/**
|
|
53
|
+
* The core package's real npm name. This is not always its lowercased namespace
|
|
54
|
+
* (`testy-test` vs `testytest`), and it's what the wrapper has to depend on and import from.
|
|
55
|
+
*/
|
|
56
|
+
async function readCorePackageName(rootDir, fallback) {
|
|
57
|
+
try {
|
|
58
|
+
const { name } = JSON.parse(await readFile(join(rootDir, 'package.json'), 'utf8'));
|
|
59
|
+
return typeof name === 'string' && name ? name : fallback;
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return fallback;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
52
65
|
async function pathExists(p) {
|
|
53
66
|
try {
|
|
54
67
|
await access(p);
|
|
@@ -212,7 +225,7 @@ export const wizard = {
|
|
|
212
225
|
const directivesArrayFile = selectedOutputType === 'component'
|
|
213
226
|
? relative(config.rootDir, join(wrapperDir, 'src', 'lib', 'directives.array.ts')).replace(/\\/g, '/')
|
|
214
227
|
: undefined;
|
|
215
|
-
const componentCorePackage = config.fsNamespace;
|
|
228
|
+
const componentCorePackage = await readCorePackageName(config.rootDir, config.fsNamespace);
|
|
216
229
|
// Scaffold wrapper package if the directory doesn't exist yet
|
|
217
230
|
const shouldScaffold = !(await pathExists(wrapperDir));
|
|
218
231
|
if (shouldScaffold) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stencil/angular-output-target",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"description": "Angular output target for @stencil/core components.",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@angular/core": "8.2.14",
|
|
60
60
|
"@angular/forms": "8.2.14",
|
|
61
|
-
"@stencil/cli": "^5.0.0 || >=5.0.0-
|
|
61
|
+
"@stencil/cli": "^5.0.0 || >=5.0.0-beta.16 <5.0.0-next.0",
|
|
62
62
|
"@stencil/core": "4.41.0",
|
|
63
63
|
"@types/node": "^18.19.130",
|
|
64
64
|
"npm-run-all2": "^6.2.6",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"vitest": "^2.1.9"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
|
-
"@stencil/core": ">=2.0.0 || >=3 || >=4.0.0 || ^5.0.0 || >=5.0.0-
|
|
72
|
+
"@stencil/core": ">=2.0.0 || >=3 || >=4.0.0 || ^5.0.0 || >=5.0.0-beta.16 <5.0.0-next.0"
|
|
73
73
|
},
|
|
74
74
|
"gitHead": "a3588e905186a0e86e7f88418fd5b2f9531b55e0"
|
|
75
75
|
}
|