@microsoft/fast-html 1.0.0-alpha.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/CHANGELOG.json +26 -0
- package/CHANGELOG.md +14 -0
- package/README.md +129 -0
- package/docs/api-report.api.md +18 -0
- package/package.json +82 -0
- package/webpack.common.config.js +18 -0
package/CHANGELOG.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@microsoft/fast-html",
|
|
3
|
+
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"date": "Mon, 24 Mar 2025 18:06:22 GMT",
|
|
6
|
+
"version": "1.0.0-alpha.1",
|
|
7
|
+
"tag": "@microsoft/fast-html_v1.0.0-alpha.1",
|
|
8
|
+
"comments": {
|
|
9
|
+
"prerelease": [
|
|
10
|
+
{
|
|
11
|
+
"author": "7559015+janechu@users.noreply.github.com",
|
|
12
|
+
"package": "@microsoft/fast-html",
|
|
13
|
+
"commit": "9740d42f280b335b0b5b45c5fe63d1251bae263e",
|
|
14
|
+
"comment": "Update private flag for initial release"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"author": "beachball",
|
|
18
|
+
"package": "@microsoft/fast-html",
|
|
19
|
+
"comment": "Bump @microsoft/fast-element to v2.2.0",
|
|
20
|
+
"commit": "not available"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
}
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Change Log - @microsoft/fast-html
|
|
2
|
+
|
|
3
|
+
<!-- This log was last generated on Mon, 24 Mar 2025 18:06:22 GMT and should not be manually modified. -->
|
|
4
|
+
|
|
5
|
+
<!-- Start content -->
|
|
6
|
+
|
|
7
|
+
## 1.0.0-alpha.1
|
|
8
|
+
|
|
9
|
+
Mon, 24 Mar 2025 18:06:22 GMT
|
|
10
|
+
|
|
11
|
+
### Changes
|
|
12
|
+
|
|
13
|
+
- Update private flag for initial release (7559015+janechu@users.noreply.github.com)
|
|
14
|
+
- Bump @microsoft/fast-element to v2.2.0
|
package/README.md
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# FAST HTML
|
|
2
|
+
|
|
3
|
+
[](https://opensource.org/licenses/MIT)
|
|
4
|
+
[](https://badge.fury.io/js/%40microsoft%2Ffast-html)
|
|
5
|
+
|
|
6
|
+
The `@microsoft/fast-html` package contains a method to interpret FAST declarative HTML syntax as a template for a FAST web component.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
### From NPM
|
|
11
|
+
|
|
12
|
+
To install the latest `fast-html` library using `npm`:
|
|
13
|
+
|
|
14
|
+
```shell
|
|
15
|
+
npm install --save @microsoft/fast-html
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Declarative HTML
|
|
19
|
+
|
|
20
|
+
### Usage
|
|
21
|
+
|
|
22
|
+
In your JS bundle you will need to include the `@microsoft/fast-html` package:
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { TemplateElement } from "@microsoft/fast-html";
|
|
26
|
+
|
|
27
|
+
TemplateElement.define({
|
|
28
|
+
name: "f-template",
|
|
29
|
+
});
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
This will include the `<f-template>` custom element and all logic for interpreting the declarative HTML syntax for a FAST web component.
|
|
33
|
+
|
|
34
|
+
The template must be wrapped in `<f-template name="[custom-element-name]"><template>[template logic]</template></f-template>` with a `name` attribute for the custom elements name, and the template logic inside.
|
|
35
|
+
|
|
36
|
+
Example:
|
|
37
|
+
```html
|
|
38
|
+
<my-custom-element greeting="Hello world">
|
|
39
|
+
<template shadowrootmode="open">
|
|
40
|
+
Hello world
|
|
41
|
+
</template>
|
|
42
|
+
</my-custom-element>
|
|
43
|
+
<f-template name="my-custom-element">
|
|
44
|
+
<template>{{greeting}}</template>
|
|
45
|
+
</f-template>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Syntax
|
|
49
|
+
|
|
50
|
+
All bindings use a handlebars syntax.
|
|
51
|
+
|
|
52
|
+
#### Content binding
|
|
53
|
+
|
|
54
|
+
```html
|
|
55
|
+
{{text}}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
#### Event binding
|
|
59
|
+
|
|
60
|
+
Event bindings must include the `()` as well as being preceeded by `@` in keeping with `@microsoft/fast-element` tagged template `html` syntax.
|
|
61
|
+
|
|
62
|
+
```html
|
|
63
|
+
<button @click="{{handleClick()}}"></button>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
#### Directives
|
|
67
|
+
|
|
68
|
+
Directives are assumed to be either an attribute directive or a directive that also serves a template. Both are prepended by `f-`. The logic of these directives and what their use cases are is explained in the [FAST html documentation](https://fast.design/docs/getting-started/html-directives).
|
|
69
|
+
|
|
70
|
+
Attribute directives include:
|
|
71
|
+
- **slotted**
|
|
72
|
+
|
|
73
|
+
Example:
|
|
74
|
+
```html
|
|
75
|
+
<slot f-slotted="{{slottedNodes}}"></slot>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
- **children**
|
|
79
|
+
|
|
80
|
+
Example:
|
|
81
|
+
```html
|
|
82
|
+
<ul f-children="{{listItems}}"><f-repeat value="{{item in list}}"><li>{{item}}</li></f-repeat></ul>
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
- **ref**
|
|
86
|
+
|
|
87
|
+
Example:
|
|
88
|
+
```html
|
|
89
|
+
<video f-ref="{{video}}"></video>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Template directives include:
|
|
93
|
+
- **when**
|
|
94
|
+
|
|
95
|
+
Example:
|
|
96
|
+
```html
|
|
97
|
+
<f-when value="{{show}}">Hello world</f-when>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
- **repeat**
|
|
101
|
+
|
|
102
|
+
Example:
|
|
103
|
+
```html
|
|
104
|
+
<ul><f-repeat value="{{item in list}}"><li>{{item}}</li></f-repeat></ul>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
- **partial & apply**
|
|
108
|
+
|
|
109
|
+
These directives are new to the declarative HTML model and allow for the ability to declare a `partial` directive containing a template partial which can then be referenced by an `apply` directive.
|
|
110
|
+
|
|
111
|
+
Example:
|
|
112
|
+
```html
|
|
113
|
+
<f-partial id="test">
|
|
114
|
+
<ul>
|
|
115
|
+
<f-repeat value="{{item in items}}">
|
|
116
|
+
<li>{{item.text}}<f-apply partial="test" value="{{item.items}}"></f-apply></li>
|
|
117
|
+
</f-repeat>
|
|
118
|
+
</ul>
|
|
119
|
+
</f-partial>
|
|
120
|
+
<f-apply partial="test" value="{{items}}"></f-apply>
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Writing Components
|
|
124
|
+
|
|
125
|
+
When writing components with the intention of using the declarative HTML syntax, it is imperative that components are written with styling and rendering of the component to be less reliant on any JavaScript state management. An example of this is relying on `elementInterals` state to style a component.
|
|
126
|
+
|
|
127
|
+
## Acknowledgements
|
|
128
|
+
|
|
129
|
+
This project has been heavily inspired by [Handlebars](https://handlebarsjs.com/) and [Vue.js](https://vuejs.org/).
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
## API Report File for "@microsoft/fast-html"
|
|
2
|
+
|
|
3
|
+
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
|
|
7
|
+
import { FASTElement } from '@microsoft/fast-element';
|
|
8
|
+
|
|
9
|
+
// @public
|
|
10
|
+
export class TemplateElement extends FASTElement {
|
|
11
|
+
// (undocumented)
|
|
12
|
+
connectedCallback(): void;
|
|
13
|
+
name?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// (No @packageDocumentation comment for this package)
|
|
17
|
+
|
|
18
|
+
```
|
package/package.json
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@microsoft/fast-html",
|
|
3
|
+
"version": "1.0.0-alpha.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Microsoft",
|
|
7
|
+
"url": "https://discord.gg/FcSNfg4"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://www.fast.design/",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/Microsoft/fast.git",
|
|
14
|
+
"directory": "packages/web-components/fast-html"
|
|
15
|
+
},
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/Microsoft/fast/issues/new/choose"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"clean": "tsc -b --clean src",
|
|
21
|
+
"clean:dist": "node ../../../build/clean.js dist",
|
|
22
|
+
"build": "tsc -b src && npm run doc",
|
|
23
|
+
"build:attribute": "webpack --config ./src/fixtures/attribute/webpack.config.js",
|
|
24
|
+
"build:event": "webpack --config ./src/fixtures/event/webpack.config.js",
|
|
25
|
+
"build:binding": "webpack --config ./src/fixtures/binding/webpack.config.js",
|
|
26
|
+
"build:children": "webpack --config ./src/fixtures/children/webpack.config.js",
|
|
27
|
+
"build:dot-syntax": "webpack --config ./src/fixtures/dot-syntax/webpack.config.js",
|
|
28
|
+
"build:partial": "webpack --config ./src/fixtures/partial/webpack.config.js",
|
|
29
|
+
"build:when": "webpack --config ./src/fixtures/when/webpack.config.js",
|
|
30
|
+
"build:ref": "webpack --config ./src/fixtures/ref/webpack.config.js",
|
|
31
|
+
"build:repeat": "webpack --config ./src/fixtures/repeat/webpack.config.js",
|
|
32
|
+
"build:slotted": "webpack --config ./src/fixtures/slotted/webpack.config.js",
|
|
33
|
+
"build-app": "npm run build:attribute && npm run build:dot-syntax && npm run build:partial && npm run build:event && npm run build:children && npm run build:binding && npm run build:when && npm run build:ref && npm run build:repeat && npm run build:slotted",
|
|
34
|
+
"build-server": "tsc -b server",
|
|
35
|
+
"doc": "api-extractor run --local",
|
|
36
|
+
"doc:ci": "api-extractor run",
|
|
37
|
+
"eslint": "eslint . --ext .ts",
|
|
38
|
+
"eslint:fix": "eslint . --ext .ts --fix",
|
|
39
|
+
"prepublishOnly": "npm run clean && npm run build",
|
|
40
|
+
"pretest": "npm run build && npm run build-server",
|
|
41
|
+
"prettier:diff": "prettier --config ../../../.prettierrc \"**/*.{ts,html}\" --list-different",
|
|
42
|
+
"prettier": "prettier --config ../../../.prettierrc --write \"**/*.{ts,html}\"",
|
|
43
|
+
"test": "npm run build-app && playwright test --config=playwright.config.cjs",
|
|
44
|
+
"test-server": "node server/dist/server.js",
|
|
45
|
+
"install-playwright-browsers": "npm run playwright install",
|
|
46
|
+
"dev": "npm run build && npm run build-app && npm run build-server && npm run test-server"
|
|
47
|
+
},
|
|
48
|
+
"description": "A package for facilitating rendering FAST Web Components in a non-browser environment.",
|
|
49
|
+
"exports": {
|
|
50
|
+
".": {
|
|
51
|
+
"types": "./dist/dts/index.d.ts",
|
|
52
|
+
"default": "./dist/esm/index.js"
|
|
53
|
+
},
|
|
54
|
+
"./package.json": "./package.json"
|
|
55
|
+
},
|
|
56
|
+
"sideEffects": [
|
|
57
|
+
"./dist/esm/index.js"
|
|
58
|
+
],
|
|
59
|
+
"peerDependencies": {
|
|
60
|
+
"@microsoft/fast-element": "^2.2.0"
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"@microsoft/api-extractor": "^7.47.0",
|
|
64
|
+
"@microsoft/fast-element": "^2.2.0",
|
|
65
|
+
"@playwright/test": "^1.49.0",
|
|
66
|
+
"@types/express": "^4.17.21",
|
|
67
|
+
"@types/node": "^17.0.17",
|
|
68
|
+
"express": "^4.19.2",
|
|
69
|
+
"typescript": "~5.3.0",
|
|
70
|
+
"webpack": "^5.97.1",
|
|
71
|
+
"webpack-cli": "^6.0.1",
|
|
72
|
+
"webpack-merge": "^6.0.1"
|
|
73
|
+
},
|
|
74
|
+
"beachball": {
|
|
75
|
+
"disallowedChangeTypes": [
|
|
76
|
+
"major",
|
|
77
|
+
"minor",
|
|
78
|
+
"patch"
|
|
79
|
+
],
|
|
80
|
+
"tag": "alpha"
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
mode: "production",
|
|
3
|
+
devServer: {
|
|
4
|
+
static: "./public",
|
|
5
|
+
port: 3001
|
|
6
|
+
},
|
|
7
|
+
resolve: {
|
|
8
|
+
extensions: [".ts", ".js"],
|
|
9
|
+
extensionAlias: {
|
|
10
|
+
".js": [".js", ".ts"],
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
module: {
|
|
14
|
+
rules: [
|
|
15
|
+
{ test: /\.([cm]?ts)$/, loader: "ts-loader" }
|
|
16
|
+
]
|
|
17
|
+
},
|
|
18
|
+
};
|