winui-svelte 0.0.1 → 0.0.2
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 +5 -1
- package/dist/bindings/.dynwinrt-js-types +1333 -51
- package/dist/bindings/.dynwinrt-managed +1 -1
- package/dist/bindings/index.d.ts +95 -1
- package/dist/bindings/index.js +146 -2
- package/dist/bindings/index.mjs +4437 -4293
- package/dist/bindings/index.proxy.js +73 -1
- package/dist/components/generated/controls/AnimatedVisualPlayer.svelte.d.ts +2 -0
- package/dist/components/generated/controls/AnimatedVisualPlayer.svelte.d.ts.map +1 -1
- package/dist/components/generated/controls/AnimatedVisualPlayer.svelte.js.map +1 -1
- package/dist/components/generated/controls/Block.svelte.d.ts +6 -0
- package/dist/components/generated/controls/Block.svelte.d.ts.map +1 -1
- package/dist/components/generated/controls/Block.svelte.js.map +1 -1
- package/dist/components/generated/controls/Border.svelte.d.ts +6 -0
- package/dist/components/generated/controls/Border.svelte.d.ts.map +1 -1
- package/dist/components/generated/controls/Border.svelte.js.map +1 -1
- package/dist/components/generated/controls/ContentPresenter.svelte.d.ts +19 -1
- package/dist/components/generated/controls/ContentPresenter.svelte.d.ts.map +1 -1
- package/dist/components/generated/controls/ContentPresenter.svelte.js.map +1 -1
- package/dist/components/generated/controls/Control.svelte.d.ts +12 -0
- package/dist/components/generated/controls/Control.svelte.d.ts.map +1 -1
- package/dist/components/generated/controls/Control.svelte.js.map +1 -1
- package/dist/components/generated/controls/EllipseGeometry.svelte.d.ts +4 -0
- package/dist/components/generated/controls/EllipseGeometry.svelte.d.ts.map +1 -1
- package/dist/components/generated/controls/EllipseGeometry.svelte.js.map +1 -1
- package/dist/components/generated/controls/FrameworkElement.svelte.d.ts +10 -0
- package/dist/components/generated/controls/FrameworkElement.svelte.d.ts.map +1 -1
- package/dist/components/generated/controls/FrameworkElement.svelte.js.map +1 -1
- package/dist/components/generated/controls/Glyphs.svelte.d.ts +2 -0
- package/dist/components/generated/controls/Glyphs.svelte.d.ts.map +1 -1
- package/dist/components/generated/controls/Glyphs.svelte.js.map +1 -1
- package/dist/components/generated/controls/Grid.svelte.d.ts +6 -0
- package/dist/components/generated/controls/Grid.svelte.d.ts.map +1 -1
- package/dist/components/generated/controls/Grid.svelte.js.map +1 -1
- package/dist/components/generated/controls/Hyperlink.svelte.d.ts +2 -0
- package/dist/components/generated/controls/Hyperlink.svelte.d.ts.map +1 -1
- package/dist/components/generated/controls/Hyperlink.svelte.js.map +1 -1
- package/dist/components/generated/controls/Image.svelte.d.ts +2 -0
- package/dist/components/generated/controls/Image.svelte.d.ts.map +1 -1
- package/dist/components/generated/controls/Image.svelte.js.map +1 -1
- package/dist/components/generated/controls/ItemsPresenter.svelte.d.ts +2 -0
- package/dist/components/generated/controls/ItemsPresenter.svelte.d.ts.map +1 -1
- package/dist/components/generated/controls/ItemsPresenter.svelte.js.map +1 -1
- package/dist/components/generated/controls/LinedFlowLayout.svelte.d.ts +2 -0
- package/dist/components/generated/controls/LinedFlowLayout.svelte.d.ts.map +1 -1
- package/dist/components/generated/controls/LinedFlowLayout.svelte.js.map +1 -1
- package/dist/components/generated/controls/MediaPlayerElement.svelte.d.ts +2 -0
- package/dist/components/generated/controls/MediaPlayerElement.svelte.d.ts.map +1 -1
- package/dist/components/generated/controls/MediaPlayerElement.svelte.js.map +1 -1
- package/dist/components/generated/controls/MediaPlayerPresenter.svelte.d.ts +2 -0
- package/dist/components/generated/controls/MediaPlayerPresenter.svelte.d.ts.map +1 -1
- package/dist/components/generated/controls/MediaPlayerPresenter.svelte.js.map +1 -1
- package/dist/components/generated/controls/RadialGradientBrush.svelte.d.ts +4 -0
- package/dist/components/generated/controls/RadialGradientBrush.svelte.d.ts.map +1 -1
- package/dist/components/generated/controls/RadialGradientBrush.svelte.js.map +1 -1
- package/dist/components/generated/controls/Rectangle.svelte.d.ts +4 -0
- package/dist/components/generated/controls/Rectangle.svelte.d.ts.map +1 -1
- package/dist/components/generated/controls/Rectangle.svelte.js.map +1 -1
- package/dist/components/generated/controls/RelativePanel.svelte.d.ts +6 -0
- package/dist/components/generated/controls/RelativePanel.svelte.d.ts.map +1 -1
- package/dist/components/generated/controls/RelativePanel.svelte.js.map +1 -1
- package/dist/components/generated/controls/RichEditBox.svelte.d.ts +1 -1
- package/dist/components/generated/controls/RichTextBlock.svelte.d.ts +14 -2
- package/dist/components/generated/controls/RichTextBlock.svelte.d.ts.map +1 -1
- package/dist/components/generated/controls/RichTextBlock.svelte.js.map +1 -1
- package/dist/components/generated/controls/RichTextBlockOverflow.svelte.d.ts +4 -0
- package/dist/components/generated/controls/RichTextBlockOverflow.svelte.d.ts.map +1 -1
- package/dist/components/generated/controls/RichTextBlockOverflow.svelte.js.map +1 -1
- package/dist/components/generated/controls/ScrollView.svelte.d.ts +4 -0
- package/dist/components/generated/controls/ScrollView.svelte.d.ts.map +1 -1
- package/dist/components/generated/controls/ScrollView.svelte.js.map +1 -1
- package/dist/components/generated/controls/ScrollViewer.svelte.d.ts +4 -0
- package/dist/components/generated/controls/ScrollViewer.svelte.d.ts.map +1 -1
- package/dist/components/generated/controls/ScrollViewer.svelte.js.map +1 -1
- package/dist/components/generated/controls/Shape.svelte.d.ts +10 -0
- package/dist/components/generated/controls/Shape.svelte.d.ts.map +1 -1
- package/dist/components/generated/controls/Shape.svelte.js.map +1 -1
- package/dist/components/generated/controls/StackPanel.svelte.d.ts +6 -0
- package/dist/components/generated/controls/StackPanel.svelte.d.ts.map +1 -1
- package/dist/components/generated/controls/StackPanel.svelte.js.map +1 -1
- package/dist/components/generated/controls/TextBlock.svelte.d.ts +14 -2
- package/dist/components/generated/controls/TextBlock.svelte.d.ts.map +1 -1
- package/dist/components/generated/controls/TextBlock.svelte.js.map +1 -1
- package/dist/components/generated/controls/TextBox.svelte.d.ts +1 -1
- package/dist/components/generated/controls/TextElement.svelte.d.ts +3 -1
- package/dist/components/generated/controls/TextElement.svelte.d.ts.map +1 -1
- package/dist/components/generated/controls/TextElement.svelte.js.map +1 -1
- package/dist/components/generated/controls/TickBar.svelte.d.ts +2 -0
- package/dist/components/generated/controls/TickBar.svelte.d.ts.map +1 -1
- package/dist/components/generated/controls/TickBar.svelte.js.map +1 -1
- package/dist/components/generated/controls/TileBrush.svelte.d.ts +2 -0
- package/dist/components/generated/controls/TileBrush.svelte.d.ts.map +1 -1
- package/dist/components/generated/controls/TileBrush.svelte.js.map +1 -1
- package/dist/components/generated/controls/UIElement.svelte.d.ts +7 -1
- package/dist/components/generated/controls/UIElement.svelte.d.ts.map +1 -1
- package/dist/components/generated/controls/UIElement.svelte.js.map +1 -1
- package/dist/components/generated/controls/Viewbox.svelte.d.ts +2 -0
- package/dist/components/generated/controls/Viewbox.svelte.d.ts.map +1 -1
- package/dist/components/generated/controls/Viewbox.svelte.js.map +1 -1
- package/dist/css/control.d.ts +2 -0
- package/dist/css/control.d.ts.map +1 -0
- package/dist/css/control.js +5 -0
- package/dist/css/control.js.map +1 -0
- package/dist/css/shape.d.ts +2 -0
- package/dist/css/shape.d.ts.map +1 -0
- package/dist/css/shape.js +5 -0
- package/dist/css/shape.js.map +1 -0
- package/dist/css/translate/lazy-groups.d.ts.map +1 -1
- package/dist/css/translate/lazy-groups.js +14 -0
- package/dist/css/translate/lazy-groups.js.map +1 -1
- package/dist/css/translate/shape-properties.d.ts +24 -0
- package/dist/css/translate/shape-properties.d.ts.map +1 -0
- package/dist/css/translate/shape-properties.js +207 -0
- package/dist/css/translate/shape-properties.js.map +1 -0
- package/dist/css/translate/text-control-properties.d.ts +21 -0
- package/dist/css/translate/text-control-properties.d.ts.map +1 -0
- package/dist/css/translate/text-control-properties.js +120 -0
- package/dist/css/translate/text-control-properties.js.map +1 -0
- package/dist/css/translate/unsupported-properties.d.ts.map +1 -1
- package/dist/css/translate/unsupported-properties.js +2 -0
- package/dist/css/translate/unsupported-properties.js.map +1 -1
- package/dist/css/validate/vscode-css-data.json +370 -0
- package/dist/css/validate/vscode-data.d.ts +2 -1
- package/dist/css/validate/vscode-data.d.ts.map +1 -1
- package/dist/css/validate/vscode-data.js +31 -1
- package/dist/css/validate/vscode-data.js.map +1 -1
- package/package.json +9 -1
- package/src/components/generated/controls/AnimatedVisualPlayer.svelte.ts +2 -0
- package/src/components/generated/controls/Block.svelte.ts +6 -0
- package/src/components/generated/controls/Border.svelte.ts +6 -0
- package/src/components/generated/controls/ContentPresenter.svelte.ts +19 -1
- package/src/components/generated/controls/Control.svelte.ts +12 -0
- package/src/components/generated/controls/EllipseGeometry.svelte.ts +4 -0
- package/src/components/generated/controls/FrameworkElement.svelte.ts +10 -0
- package/src/components/generated/controls/Glyphs.svelte.ts +2 -0
- package/src/components/generated/controls/Grid.svelte.ts +6 -0
- package/src/components/generated/controls/Hyperlink.svelte.ts +2 -0
- package/src/components/generated/controls/Image.svelte.ts +2 -0
- package/src/components/generated/controls/ItemsPresenter.svelte.ts +2 -0
- package/src/components/generated/controls/LinedFlowLayout.svelte.ts +2 -0
- package/src/components/generated/controls/MediaPlayerElement.svelte.ts +2 -0
- package/src/components/generated/controls/MediaPlayerPresenter.svelte.ts +2 -0
- package/src/components/generated/controls/RadialGradientBrush.svelte.ts +4 -0
- package/src/components/generated/controls/Rectangle.svelte.ts +4 -0
- package/src/components/generated/controls/RelativePanel.svelte.ts +6 -0
- package/src/components/generated/controls/RichEditBox.svelte.ts +1 -1
- package/src/components/generated/controls/RichTextBlock.svelte.ts +14 -2
- package/src/components/generated/controls/RichTextBlockOverflow.svelte.ts +4 -0
- package/src/components/generated/controls/ScrollView.svelte.ts +4 -0
- package/src/components/generated/controls/ScrollViewer.svelte.ts +4 -0
- package/src/components/generated/controls/Shape.svelte.ts +10 -0
- package/src/components/generated/controls/StackPanel.svelte.ts +6 -0
- package/src/components/generated/controls/TextBlock.svelte.ts +14 -2
- package/src/components/generated/controls/TextBox.svelte.ts +1 -1
- package/src/components/generated/controls/TextElement.svelte.ts +3 -1
- package/src/components/generated/controls/TickBar.svelte.ts +2 -0
- package/src/components/generated/controls/TileBrush.svelte.ts +2 -0
- package/src/components/generated/controls/UIElement.svelte.ts +7 -1
- package/src/components/generated/controls/Viewbox.svelte.ts +2 -0
- package/src/css/API.md +32 -0
- package/src/css/control.ts +5 -0
- package/src/css/shape.ts +5 -0
- package/src/css/translate/lazy-groups.ts +14 -0
- package/src/css/translate/shape-properties.ts +250 -0
- package/src/css/translate/text-control-properties.ts +135 -0
- package/src/css/translate/unsupported-properties.ts +2 -0
- package/src/css/validate/vscode-data.ts +38 -1
- package/web-types.json +460 -90
- package/dist/bindings/microsoft/ui/xaml/controls/SwapChainBackgroundPanel.d.ts +0 -731
- package/dist/bindings/microsoft/ui/xaml/controls/SwapChainBackgroundPanel.js +0 -2806
|
@@ -29,6 +29,8 @@ export interface ViewboxProps extends FrameworkElementProps {
|
|
|
29
29
|
/**
|
|
30
30
|
* Gets or sets the Stretch mode, which determines how content fits into the available space. A Stretch mode, which determines how content fits in the available space. The default is Uniform.
|
|
31
31
|
*
|
|
32
|
+
* Also settable in CSS as `object-fit`
|
|
33
|
+
*
|
|
32
34
|
* @see https://learn.microsoft.com/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.viewbox.stretch
|
|
33
35
|
*/
|
|
34
36
|
stretch?: EnumInput<typeof Stretch>;
|
package/src/css/API.md
CHANGED
|
@@ -200,6 +200,8 @@ window in, with or without a `<style>` that uses the property
|
|
|
200
200
|
| `winui-svelte/css/filter` | `filter`, `backdrop-filter`, `mix-blend-mode`, `mask`, `mask-image` | Filters, blends and masks |
|
|
201
201
|
| `winui-svelte/css/clip` | `clip-path` | Clip shapes |
|
|
202
202
|
| `winui-svelte/css/cursor` | `cursor` | Cursor |
|
|
203
|
+
| `winui-svelte/css/control` | `font-stretch`, `direction`, `background-clip`, `tab-index` | Control properties (`controlGroups`) |
|
|
204
|
+
| `winui-svelte/css/shape` | `fill`, `stroke-dasharray`, `stroke-dashoffset`, `stroke-linecap`, `stroke-linejoin`, `stroke-miterlimit`, `rx`, `ry`, `fill-rule` | Shapes |
|
|
203
205
|
| `winui-svelte/css/focus` | `outline`, `outline-offset` | Focus ring |
|
|
204
206
|
| `winui-svelte/css/surface` | `-winui-elevation`, `box-shadow` | Elevation |
|
|
205
207
|
| `winui-svelte/css/position` | `position`, `top`, `left`, `right`, `bottom`, `inset` | Position |
|
|
@@ -480,6 +482,27 @@ iterations start from where the last one ended
|
|
|
480
482
|
.badge { animation: pulse 1.2s ease-in-out infinite }
|
|
481
483
|
```
|
|
482
484
|
|
|
485
|
+
## Shapes: `fill`, `stroke-*`, `rx`, `ry`, `fill-rule`
|
|
486
|
+
|
|
487
|
+
A WinUI Shape (`rectangle`, `ellipse`, `line`, `polyline`, `polygon`, `path`)
|
|
488
|
+
draws with these, besides `stroke` and `stroke-width`; a sheet that uses one
|
|
489
|
+
imports `winui-svelte/css/shape` (`shapeGroups`), which the build adds:
|
|
490
|
+
|
|
491
|
+
| CSS | WinUI |
|
|
492
|
+
|---|---|
|
|
493
|
+
| `fill` | `Fill`, a color or `var()` brush; `none` is a transparent one |
|
|
494
|
+
| `stroke-dasharray` | `StrokeDashArray`; WinUI counts dashes in multiples of the stroke's thickness, so the px lengths are divided by `stroke-width` (1px when it is not written); `none` clears them |
|
|
495
|
+
| `stroke-dashoffset` | `StrokeDashOffset`, in multiples of the thickness as well |
|
|
496
|
+
| `stroke-linecap` | `StrokeStartLineCap` and `StrokeEndLineCap`: `butt` is Flat, `round` Round, `square` Square |
|
|
497
|
+
| `stroke-linejoin` | `StrokeLineJoin`: `miter`, `bevel`, `round` |
|
|
498
|
+
| `stroke-miterlimit` | `StrokeMiterLimit`, a number of at least 1 |
|
|
499
|
+
| `rx`, `ry` | `RadiusX` and `RadiusY` of a `rectangle` |
|
|
500
|
+
| `fill-rule` | `FillRule` of a `polygon`: `nonzero` is Nonzero, `evenodd` EvenOdd |
|
|
501
|
+
|
|
502
|
+
A `path` has no `FillRule` of its own (it belongs to the `PathGeometry` in its
|
|
503
|
+
`data`), so a Style cannot set it there
|
|
504
|
+
Lengths are in px (`stroke-dasharray: 8px 4px`), as everywhere else
|
|
505
|
+
|
|
483
506
|
## Focus ring: `outline`
|
|
484
507
|
|
|
485
508
|
`outline` styles the control's focus visual:
|
|
@@ -675,6 +698,7 @@ the panel; the CSS names what it does
|
|
|
675
698
|
| `flex-wrap` | none | error: WinUI has no wrapping panel |
|
|
676
699
|
| `align-self`, `justify-self`, `place-self` | `VerticalAlignment`, `HorizontalAlignment` (`start` is Top / Left) | on the child |
|
|
677
700
|
| `align-items`, `justify-items`, `place-items`, `justify-content`, `align-content` | each child's `align-self` / `justify-self`, or spacer tracks | lowered into the children by the build (see Containers) |
|
|
701
|
+
| `justify-content`, `align-items` on a control (`<expander>`, `<button>`, `<list-view-item>`) | `HorizontalContentAlignment`, `VerticalContentAlignment` (`start` is Left / Top) | on a panel they are lowered into the children instead (see Containers) |
|
|
678
702
|
| `width`, `height` in px, `calc()` of them, `auto`, `100%` | `Width`, `Height` (NaN for auto and 100%: a stretching element fills) | another % is an error: use a `*` track |
|
|
679
703
|
| `min-*`, `max-*` | `MinWidth`... | |
|
|
680
704
|
| `box-sizing: border-box` | nothing: WinUI's size includes padding and border | `content-box` is an error |
|
|
@@ -1150,6 +1174,13 @@ The secondary option `{ "ignore": ["partial-support"] }` skips codes
|
|
|
1150
1174
|
WebStorm reads the same data from `web-types.json` (no setting needed), so
|
|
1151
1175
|
`-winui-elevation`, `-winui-based-on` and the Windows font families of
|
|
1152
1176
|
`font-family` complete in a `<style>` and a `.css` file
|
|
1177
|
+
Both editors also offer the keywords of every property that takes a fixed set
|
|
1178
|
+
(`text-align`, `white-space`, `visibility`, `display` and the rest of the
|
|
1179
|
+
keyword table), each with the WinUI value it stands for, and describe
|
|
1180
|
+
`align-items` and `justify-content` as the build lowers them into the children
|
|
1181
|
+
A property's hover in WinUI's own components names the CSS property that also
|
|
1182
|
+
sets it, found by asking the translator, so `padding`, `border-radius` and
|
|
1183
|
+
`border-width` are named as well as the single-member ones
|
|
1153
1184
|
|
|
1154
1185
|
A diagnostic is `{ code, severity, message, filename, start, end, frame, suggestion }`
|
|
1155
1186
|
with Svelte's position shape (`line` from 1, `column` from 0, `character`)
|
|
@@ -1194,6 +1225,7 @@ Declarations like these fail the build with it:
|
|
|
1194
1225
|
| `animation` without its module | see Animations |
|
|
1195
1226
|
| `text-transform: uppercase`, `lowercase`, `capitalize` | the text an element shows is written through the change, in a `<text-block>`, a `<run>`, a button's content and the text of an inline element: the tree keeps the text as written, and the control reports the changed one (`none` is no change; an inherited transform is not: write it on the element that holds the text) |
|
|
1196
1227
|
| `user-select`, `object-fit`, `line-clamp` (`-webkit-line-clamp`), `word-break` | `IsTextSelectionEnabled`, an image's `Stretch` (`contain` is `Uniform`, `cover` `UniformToFill`; `scale-down` is an error), `MaxLines` (with `Wrap` and an ellipsis, which `text-wrap` and `text-overflow` override), `TextWrapping` |
|
|
1228
|
+
| `caret-color`, `text-box-trim`, `background-clip: content-box` and `text` | the bindings have no `CaretBrush`, and no WinUI property trims the line box the way `text-box-trim` does; a WinUI background paints to the `OuterBorderEdge` (`border-box`) or the `InnerBorderEdge` (`padding-box`) only |
|
|
1197
1229
|
| `float`, `flex-wrap` other than `nowrap`, `content`, `list-style`, `text-indent` | no WinUI equivalent in a Style; each message names the nearest WinUI way |
|
|
1198
1230
|
| `text-transform: full-width` and `full-size-kana` | WinUI has no such transform of a string (`uppercase`, `lowercase` and `capitalize` work) |
|
|
1199
1231
|
| the container properties in an `@media`, in a stylesheet that is not a component, or on a container that is a component | the build lowers them against the component's markup; elsewhere the message says where they work |
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// The control properties of the CSS part (`font-stretch`, `direction`, `background-clip`,
|
|
2
|
+
// `tab-index`), apart from the entry (index.ts) so a window's bundle carries their parser
|
|
3
|
+
// only when a sheet uses one: the module a compiled sheet imports when it has one.
|
|
4
|
+
|
|
5
|
+
export { controlGroups } from "./translate/text-control-properties.ts";
|
package/src/css/shape.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// The shape properties of the CSS part, apart from the entry (index.ts) so a
|
|
2
|
+
// window's bundle carries their parser only when a sheet uses one: the module a
|
|
3
|
+
// compiled sheet imports when it has a `fill`, a `stroke-dasharray` and the like.
|
|
4
|
+
|
|
5
|
+
export { shapeGroups } from "./translate/shape-properties.ts";
|
|
@@ -11,7 +11,9 @@ import { POSITION_MEMBERS, positionGroups } from "./position-properties.ts";
|
|
|
11
11
|
import type { PropertyGroup } from "./property-kit.ts";
|
|
12
12
|
import { queryGroups } from "./query-properties.ts";
|
|
13
13
|
import { resourceGroups } from "./resource-properties.ts";
|
|
14
|
+
import { SHAPE_MEMBERS, shapeGroups } from "./shape-properties.ts";
|
|
14
15
|
import { SURFACE_MEMBERS, surfaceGroups } from "./surface-properties.ts";
|
|
16
|
+
import { CONTROL_MEMBERS, controlGroups } from "./text-control-properties.ts";
|
|
15
17
|
import { transformGroups } from "./transform-properties.ts";
|
|
16
18
|
import type { Rule } from "./types.ts";
|
|
17
19
|
import { VISUAL_EFFECT_MEMBERS, visualEffectGroups } from "./visual-effect-properties.ts";
|
|
@@ -89,6 +91,18 @@ export const LAZY_GROUPS: readonly LazyGroups[] = [
|
|
|
89
91
|
exportName: "cursorGroups",
|
|
90
92
|
groups: cursorGroups
|
|
91
93
|
},
|
|
94
|
+
{
|
|
95
|
+
isNeededBy: usesProperties(CONTROL_MEMBERS),
|
|
96
|
+
subpath: "/control",
|
|
97
|
+
exportName: "controlGroups",
|
|
98
|
+
groups: controlGroups
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
isNeededBy: usesProperties(SHAPE_MEMBERS),
|
|
102
|
+
subpath: "/shape",
|
|
103
|
+
exportName: "shapeGroups",
|
|
104
|
+
groups: shapeGroups
|
|
105
|
+
},
|
|
92
106
|
{
|
|
93
107
|
isNeededBy: usesProperties(POSITION_MEMBERS),
|
|
94
108
|
subpath: "/position",
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import {
|
|
2
|
+
enumMap,
|
|
3
|
+
keywordProperty,
|
|
4
|
+
lengthProperty,
|
|
5
|
+
setter,
|
|
6
|
+
simple
|
|
7
|
+
} from "./property-kit.ts";
|
|
8
|
+
import type { GroupInput } from "./property-kit.ts";
|
|
9
|
+
import type { Reader } from "#src/css/parse/reader.js";
|
|
10
|
+
import { parseLength, parseNumber, splitWords } from "#src/css/parse/values.js";
|
|
11
|
+
|
|
12
|
+
const STROKE_WIDTH = "stroke-width";
|
|
13
|
+
const STROKE_DASHARRAY = "stroke-dasharray";
|
|
14
|
+
const STROKE_DASHOFFSET = "stroke-dashoffset";
|
|
15
|
+
const STROKE_LINECAP = "stroke-linecap";
|
|
16
|
+
const NONE = "none";
|
|
17
|
+
const TRANSPARENT = "transparent";
|
|
18
|
+
const DEFAULT_THICKNESS = 1;
|
|
19
|
+
const MINIMUM_MITER_LIMIT = 1;
|
|
20
|
+
const DASH_PRECISION = 1000;
|
|
21
|
+
|
|
22
|
+
/** `stroke-linecap`, as PenLineCap. */
|
|
23
|
+
const lineCaps = enumMap([
|
|
24
|
+
["butt", "Flat"],
|
|
25
|
+
["round", "Round"],
|
|
26
|
+
["square", "Square"]
|
|
27
|
+
]);
|
|
28
|
+
|
|
29
|
+
/** `stroke-linejoin`, as PenLineJoin. */
|
|
30
|
+
const lineJoins = enumMap([
|
|
31
|
+
["miter", "Miter"],
|
|
32
|
+
["bevel", "Bevel"],
|
|
33
|
+
["round", "Round"]
|
|
34
|
+
]);
|
|
35
|
+
|
|
36
|
+
/** `fill-rule`, as FillRule. */
|
|
37
|
+
const fillRules = enumMap([
|
|
38
|
+
["nonzero", "Nonzero"],
|
|
39
|
+
["evenodd", "EvenOdd"]
|
|
40
|
+
]);
|
|
41
|
+
|
|
42
|
+
// WinUI counts dashes in multiples of the stroke's thickness, CSS in pixels.
|
|
43
|
+
function thicknessOf({ input, reader }: {
|
|
44
|
+
input: GroupInput;
|
|
45
|
+
reader: Reader;
|
|
46
|
+
}) {
|
|
47
|
+
const declaration = input.computed.get(STROKE_WIDTH);
|
|
48
|
+
const hasThickness = declaration !== undefined;
|
|
49
|
+
if (!hasThickness) {
|
|
50
|
+
return DEFAULT_THICKNESS;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const thickness = parseLength(declaration.value.trim());
|
|
54
|
+
const isUsable = thickness !== null && thickness > 0;
|
|
55
|
+
if (isUsable) {
|
|
56
|
+
return thickness;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
reader.warn(`${reader.declaration.property}: ${STROKE_WIDTH} is not a length in px, so the dashes are read as multiples of 1px`);
|
|
60
|
+
return DEFAULT_THICKNESS;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function inThicknesses({ pixels, thickness }: {
|
|
64
|
+
pixels: number;
|
|
65
|
+
thickness: number;
|
|
66
|
+
}) {
|
|
67
|
+
return Math.round(pixels / thickness * DASH_PRECISION) / DASH_PRECISION;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function dashLengths({ reader, thickness }: {
|
|
71
|
+
reader: Reader;
|
|
72
|
+
thickness: number;
|
|
73
|
+
}) {
|
|
74
|
+
const lengths: number[] = [];
|
|
75
|
+
for (const token of splitWords(reader.declaration.value.replaceAll(",", " "))) {
|
|
76
|
+
const pixels = parseLength(token);
|
|
77
|
+
const isLength = pixels !== null && pixels >= 0;
|
|
78
|
+
if (!isLength) {
|
|
79
|
+
return reader.expectedToken({
|
|
80
|
+
what: "lengths in px, not negative",
|
|
81
|
+
token
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
lengths.push(
|
|
86
|
+
inThicknesses({
|
|
87
|
+
pixels,
|
|
88
|
+
thickness
|
|
89
|
+
})
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return lengths;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** `stroke-dasharray`: lengths in px (or `none`), as StrokeDashArray in multiples of the stroke's thickness. */
|
|
97
|
+
function strokeDashArray(input: GroupInput) {
|
|
98
|
+
const reader = input.reading(STROKE_DASHARRAY);
|
|
99
|
+
const isNone = reader.declaration.value.trim().toLowerCase() === NONE;
|
|
100
|
+
if (isNone) {
|
|
101
|
+
return [setter({
|
|
102
|
+
property: "StrokeDashArray",
|
|
103
|
+
value: ""
|
|
104
|
+
})];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const lengths = dashLengths({
|
|
108
|
+
reader,
|
|
109
|
+
thickness: thicknessOf({
|
|
110
|
+
input,
|
|
111
|
+
reader
|
|
112
|
+
})
|
|
113
|
+
});
|
|
114
|
+
const isUnreadable = lengths === null || lengths.length === 0;
|
|
115
|
+
return isUnreadable ? [] : [setter({
|
|
116
|
+
property: "StrokeDashArray",
|
|
117
|
+
value: lengths.join(",")
|
|
118
|
+
})];
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** `stroke-dashoffset`: a length in px, as StrokeDashOffset in multiples of the stroke's thickness. */
|
|
122
|
+
function strokeDashOffset(input: GroupInput) {
|
|
123
|
+
const reader = input.reading(STROKE_DASHOFFSET);
|
|
124
|
+
const word = reader.single();
|
|
125
|
+
const pixels = word === null ? null : reader.pixels(word);
|
|
126
|
+
const isPixelsMissing = pixels === null;
|
|
127
|
+
if (isPixelsMissing) {
|
|
128
|
+
return [];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return [setter({
|
|
132
|
+
property: "StrokeDashOffset",
|
|
133
|
+
value: String(
|
|
134
|
+
inThicknesses({
|
|
135
|
+
pixels,
|
|
136
|
+
thickness: thicknessOf({
|
|
137
|
+
input,
|
|
138
|
+
reader
|
|
139
|
+
})
|
|
140
|
+
})
|
|
141
|
+
)
|
|
142
|
+
})];
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** `stroke-linecap`: WinUI caps the two ends apart; CSS caps both alike. */
|
|
146
|
+
function strokeLineCap(input: GroupInput) {
|
|
147
|
+
const reader = input.reading(STROKE_LINECAP);
|
|
148
|
+
const word = reader.single();
|
|
149
|
+
const cap = word === null ? null : reader.keyword({
|
|
150
|
+
token: word,
|
|
151
|
+
choices: lineCaps
|
|
152
|
+
});
|
|
153
|
+
const isCapMissing = cap === null;
|
|
154
|
+
if (isCapMissing) {
|
|
155
|
+
return [];
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return ["StrokeStartLineCap", "StrokeEndLineCap"].map(property => setter({
|
|
159
|
+
property,
|
|
160
|
+
value: cap
|
|
161
|
+
}));
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** `stroke-miterlimit`: a number of at least 1. */
|
|
165
|
+
function miterLimit(reader: Reader) {
|
|
166
|
+
const word = reader.single();
|
|
167
|
+
const isWordMissing = word === null;
|
|
168
|
+
if (isWordMissing) {
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const limit = parseNumber(word);
|
|
173
|
+
const isInRange = limit !== null && limit >= MINIMUM_MITER_LIMIT;
|
|
174
|
+
return isInRange ? String(limit) : reader.expectedToken({
|
|
175
|
+
what: "a number of at least 1",
|
|
176
|
+
token: word
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** `fill`: a color or `var()` as the Fill brush; `none` is a transparent one. */
|
|
181
|
+
function fillBrush(reader: Reader) {
|
|
182
|
+
const word = reader.single();
|
|
183
|
+
const isWordMissing = word === null;
|
|
184
|
+
if (isWordMissing) {
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return reader.brush(word.toLowerCase() === NONE ? TRANSPARENT : word);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** The members the shape groups lower, which a sheet using one opts in for. */
|
|
192
|
+
export const SHAPE_MEMBERS = [
|
|
193
|
+
"fill",
|
|
194
|
+
STROKE_DASHARRAY,
|
|
195
|
+
STROKE_DASHOFFSET,
|
|
196
|
+
STROKE_LINECAP,
|
|
197
|
+
"stroke-linejoin",
|
|
198
|
+
"stroke-miterlimit",
|
|
199
|
+
"rx",
|
|
200
|
+
"ry",
|
|
201
|
+
"fill-rule"
|
|
202
|
+
];
|
|
203
|
+
|
|
204
|
+
/** The CSS properties of an SVG shape that a WinUI Shape draws with. */
|
|
205
|
+
export function shapeGroups() {
|
|
206
|
+
return [
|
|
207
|
+
simple({
|
|
208
|
+
member: "fill",
|
|
209
|
+
property: "Fill",
|
|
210
|
+
parse: fillBrush
|
|
211
|
+
}),
|
|
212
|
+
{
|
|
213
|
+
members: [STROKE_DASHARRAY],
|
|
214
|
+
property: "StrokeDashArray",
|
|
215
|
+
lower: strokeDashArray
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
members: [STROKE_DASHOFFSET],
|
|
219
|
+
property: "StrokeDashOffset",
|
|
220
|
+
lower: strokeDashOffset
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
members: [STROKE_LINECAP],
|
|
224
|
+
lower: strokeLineCap
|
|
225
|
+
},
|
|
226
|
+
keywordProperty({
|
|
227
|
+
member: "stroke-linejoin",
|
|
228
|
+
property: "StrokeLineJoin",
|
|
229
|
+
choices: lineJoins
|
|
230
|
+
}),
|
|
231
|
+
simple({
|
|
232
|
+
member: "stroke-miterlimit",
|
|
233
|
+
property: "StrokeMiterLimit",
|
|
234
|
+
parse: miterLimit
|
|
235
|
+
}),
|
|
236
|
+
lengthProperty({
|
|
237
|
+
member: "rx",
|
|
238
|
+
property: "RadiusX"
|
|
239
|
+
}),
|
|
240
|
+
lengthProperty({
|
|
241
|
+
member: "ry",
|
|
242
|
+
property: "RadiusY"
|
|
243
|
+
}),
|
|
244
|
+
keywordProperty({
|
|
245
|
+
member: "fill-rule",
|
|
246
|
+
property: "FillRule",
|
|
247
|
+
choices: fillRules
|
|
248
|
+
})
|
|
249
|
+
];
|
|
250
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { alignmentProperty } from "./layout-properties.ts";
|
|
2
|
+
import { enumMap, keywordProperty, multiple, setter } from "./property-kit.ts";
|
|
3
|
+
import type { PropertyGroup } from "./property-kit.ts";
|
|
4
|
+
import { parseNumber } from "#src/css/parse/values.js";
|
|
5
|
+
|
|
6
|
+
/** `font-stretch`, as the Windows.UI.Text.FontStretch of a control or text element. */
|
|
7
|
+
const FONT_STRETCHES = "ultra-condensed extra-condensed condensed semi-condensed normal semi-expanded expanded"
|
|
8
|
+
+ " extra-expanded ultra-expanded";
|
|
9
|
+
const fontStretches = enumMap(
|
|
10
|
+
FONT_STRETCHES.split(" ").map(word => [
|
|
11
|
+
word,
|
|
12
|
+
word.replaceAll(/(?:^|-)([a-z])/gu, (_, letter: string) => letter.toUpperCase())
|
|
13
|
+
])
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
/** `direction`, as FlowDirection. */
|
|
17
|
+
const directions = enumMap([
|
|
18
|
+
["ltr", "LeftToRight"],
|
|
19
|
+
["rtl", "RightToLeft"]
|
|
20
|
+
]);
|
|
21
|
+
|
|
22
|
+
/** The keyword properties of the control group: the WinUI property each sets and the value of each keyword. */
|
|
23
|
+
export const CONTROL_KEYWORDS = new Map([
|
|
24
|
+
["font-stretch", {
|
|
25
|
+
property: "FontStretch",
|
|
26
|
+
choices: fontStretches
|
|
27
|
+
}],
|
|
28
|
+
["direction", {
|
|
29
|
+
property: "FlowDirection",
|
|
30
|
+
choices: directions
|
|
31
|
+
}]
|
|
32
|
+
]);
|
|
33
|
+
|
|
34
|
+
/** `background-clip`: the edge a Background paints to; WinUI has no `text` or `content-box` clip. */
|
|
35
|
+
const backgroundClips = enumMap([
|
|
36
|
+
["border-box", "OuterBorderEdge"],
|
|
37
|
+
["padding-box", "InnerBorderEdge"]
|
|
38
|
+
]);
|
|
39
|
+
|
|
40
|
+
const backgroundClip = {
|
|
41
|
+
members: ["background-clip"],
|
|
42
|
+
property: "BackgroundSizing",
|
|
43
|
+
lower(input) {
|
|
44
|
+
const reader = input.reading("background-clip");
|
|
45
|
+
const word = reader.single();
|
|
46
|
+
const isWordMissing = word === null;
|
|
47
|
+
if (isWordMissing) {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const value = backgroundClips.get(word.toLowerCase());
|
|
52
|
+
const hasValue = value !== undefined;
|
|
53
|
+
if (hasValue) {
|
|
54
|
+
return [setter({
|
|
55
|
+
property: "BackgroundSizing",
|
|
56
|
+
value
|
|
57
|
+
})];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
reader.expectedToken({
|
|
61
|
+
what: "border-box (OuterBorderEdge) or padding-box (InnerBorderEdge); a WinUI background has no content-box or text clip",
|
|
62
|
+
token: word
|
|
63
|
+
});
|
|
64
|
+
return [];
|
|
65
|
+
}
|
|
66
|
+
} satisfies PropertyGroup;
|
|
67
|
+
|
|
68
|
+
// A negative index takes the control out of the tab order, as tabindex="-1" does.
|
|
69
|
+
const tabIndex = multiple({
|
|
70
|
+
member: "tab-index",
|
|
71
|
+
parse(reader) {
|
|
72
|
+
const word = reader.single();
|
|
73
|
+
const isWordMissing = word === null;
|
|
74
|
+
if (isWordMissing) {
|
|
75
|
+
return [];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const index = parseNumber(word);
|
|
79
|
+
const isIndexInvalid = index === null || !Number.isInteger(index);
|
|
80
|
+
if (isIndexInvalid) {
|
|
81
|
+
reader.expectedToken({
|
|
82
|
+
what: "an integer",
|
|
83
|
+
token: word
|
|
84
|
+
});
|
|
85
|
+
return [];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const isNegative = index < 0;
|
|
89
|
+
if (isNegative) {
|
|
90
|
+
return [setter({
|
|
91
|
+
property: "IsTabStop",
|
|
92
|
+
value: "False"
|
|
93
|
+
})];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return [setter({
|
|
97
|
+
property: "TabIndex",
|
|
98
|
+
value: String(index)
|
|
99
|
+
})];
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
/** The members the control groups lower, which a sheet using one opts in for. */
|
|
104
|
+
export const CONTROL_MEMBERS = [
|
|
105
|
+
"font-stretch",
|
|
106
|
+
"direction",
|
|
107
|
+
"background-clip",
|
|
108
|
+
"tab-index",
|
|
109
|
+
"align-items",
|
|
110
|
+
"justify-content"
|
|
111
|
+
];
|
|
112
|
+
|
|
113
|
+
/** The groups of the control properties that CONTROL_MEMBERS lists. */
|
|
114
|
+
export function controlGroups() {
|
|
115
|
+
return [
|
|
116
|
+
...[...CONTROL_KEYWORDS].map(([member, spec]) => keywordProperty({
|
|
117
|
+
member,
|
|
118
|
+
...spec
|
|
119
|
+
})),
|
|
120
|
+
backgroundClip,
|
|
121
|
+
tabIndex,
|
|
122
|
+
alignmentProperty({
|
|
123
|
+
member: "align-items",
|
|
124
|
+
property: "VerticalContentAlignment",
|
|
125
|
+
startName: "Top",
|
|
126
|
+
endName: "Bottom"
|
|
127
|
+
}),
|
|
128
|
+
alignmentProperty({
|
|
129
|
+
member: "justify-content",
|
|
130
|
+
property: "HorizontalContentAlignment",
|
|
131
|
+
startName: "Left",
|
|
132
|
+
endName: "Right"
|
|
133
|
+
})
|
|
134
|
+
];
|
|
135
|
+
}
|
|
@@ -40,6 +40,8 @@ const UNSUPPORTED_REASONS: ReadonlyMap<string, string> = new Map([
|
|
|
40
40
|
["content", "WinUI has no generated content"],
|
|
41
41
|
["list-style", "WinUI has no lists to mark"],
|
|
42
42
|
["text-indent", "WinUI has no text indent"],
|
|
43
|
+
["caret-color", "the caret follows Foreground"],
|
|
44
|
+
["text-box-trim", "WinUI cannot trim the line box"],
|
|
43
45
|
["aspect-ratio", `a ratio ${OPT_IN}`],
|
|
44
46
|
["clip-path", `a clip ${OPT_IN}`],
|
|
45
47
|
["mix-blend-mode", `a blend mode ${OPT_IN}`],
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { FONT_FAMILY_NAMES } from "#src/components/font-family-name.js";
|
|
2
2
|
import { LENGTH_UNITS, LengthUnitKind } from "#src/css/parse/units.js";
|
|
3
|
+
import {
|
|
4
|
+
DISCRETE_MEMBERS,
|
|
5
|
+
discretePropertyOf,
|
|
6
|
+
discreteValueOf,
|
|
7
|
+
discreteWordsOf
|
|
8
|
+
} from "#src/css/translate/discrete-properties.js";
|
|
3
9
|
import { GRID_TRACK_PROPERTIES } from "#src/css/translate/grid-track-verdicts.js";
|
|
10
|
+
import { CONTROL_KEYWORDS } from "#src/css/translate/text-control-properties.js";
|
|
4
11
|
import { WINUI_ONLY_PROPERTIES } from "#src/css/translate/winui-only-properties.js";
|
|
5
12
|
|
|
6
13
|
const CUSTOM_DATA_VERSION = 1.1;
|
|
@@ -11,11 +18,28 @@ function unitsOf(kind: LengthUnitKind) {
|
|
|
11
18
|
|
|
12
19
|
const TRACK_DESCRIPTION = "WinUI: a track is auto, a length or an fr size, and they mix freely; repeat(N, ...) is expanded when building. No WinUI equivalent: repeat(auto-fill|auto-fit, ...), subgrid, masonry, named lines and % tracks (the editor's diagnostics say what to write instead).";
|
|
13
20
|
|
|
21
|
+
const LAYOUT_ALIGNMENT_DESCRIPTION = "WinUI: on a stack panel or grid the build lowers it into the children (each child's align-self or justify-self, or spacer tracks), so it applies to a container written in the component, outside an @media.";
|
|
22
|
+
|
|
23
|
+
function discreteProperty(member: string) {
|
|
24
|
+
return {
|
|
25
|
+
name: member,
|
|
26
|
+
description: `WinUI: sets ${discretePropertyOf(member)}; only these keywords are accepted.`,
|
|
27
|
+
values: discreteWordsOf(member).map(word => ({
|
|
28
|
+
name: word,
|
|
29
|
+
description: `${discretePropertyOf(member)}: ${discreteValueOf({
|
|
30
|
+
member,
|
|
31
|
+
word
|
|
32
|
+
})}`
|
|
33
|
+
}))
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
14
37
|
/**
|
|
15
38
|
* The VS Code custom data (`css.customData`) for WinUI's CSS dialect, built
|
|
16
39
|
* from the same tables the translation and the validator read: the `-winui-*`
|
|
17
40
|
* properties an editor's own CSS checker does not know, and what WinUI allows
|
|
18
|
-
* for the properties it limits (grid tracks, units
|
|
41
|
+
* for the properties it limits (grid tracks, units, the keywords of a property
|
|
42
|
+
* that takes a fixed set). Written to
|
|
19
43
|
* `vscode-css-data.json` by `scripts/css/export-vscode-css-data.ts`.
|
|
20
44
|
*/
|
|
21
45
|
export function vscodeCssData() {
|
|
@@ -38,6 +62,19 @@ export function vscodeCssData() {
|
|
|
38
62
|
name: `"${name}"`
|
|
39
63
|
}))
|
|
40
64
|
},
|
|
65
|
+
...DISCRETE_MEMBERS.map(discreteProperty),
|
|
66
|
+
...[...CONTROL_KEYWORDS].map(([member, spec]) => ({
|
|
67
|
+
name: member,
|
|
68
|
+
description: `WinUI: sets ${spec.property}; only these keywords are accepted.`,
|
|
69
|
+
values: [...spec.choices].map(([word, value]) => ({
|
|
70
|
+
name: word,
|
|
71
|
+
description: `${spec.property}: ${value}`
|
|
72
|
+
}))
|
|
73
|
+
})),
|
|
74
|
+
...["align-items", "justify-content"].map(name => ({
|
|
75
|
+
name,
|
|
76
|
+
description: LAYOUT_ALIGNMENT_DESCRIPTION
|
|
77
|
+
})),
|
|
41
78
|
...[...GRID_TRACK_PROPERTIES].map(name => ({
|
|
42
79
|
name,
|
|
43
80
|
description: TRACK_DESCRIPTION
|