@fluentui/web-components 2.5.0 → 2.5.3

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.
Files changed (65) hide show
  1. package/CHANGELOG.json +76 -1
  2. package/CHANGELOG.md +29 -2
  3. package/dist/dts/_docs/design-system/color-explorer/app.d.ts +25 -0
  4. package/dist/dts/_docs/design-system/color-explorer/colors.d.ts +13 -0
  5. package/dist/dts/_docs/design-system/color-explorer/component-types.d.ts +6 -0
  6. package/dist/dts/_docs/design-system/color-explorer/components/color-block.d.ts +10 -0
  7. package/dist/dts/_docs/design-system/color-explorer/components/color-picker/color-picker.d.ts +190 -0
  8. package/dist/dts/_docs/design-system/color-explorer/components/color-picker/color-picker.form-associated.d.ts +15 -0
  9. package/dist/dts/_docs/design-system/color-explorer/components/color-picker/color-picker.styles.d.ts +3 -0
  10. package/dist/dts/_docs/design-system/color-explorer/components/color-picker/color-picker.template.d.ts +8 -0
  11. package/dist/dts/_docs/design-system/color-explorer/components/color-picker/index.d.ts +9 -0
  12. package/dist/dts/_docs/design-system/color-explorer/components/control-pane/control-pane.d.ts +8 -0
  13. package/dist/dts/_docs/design-system/color-explorer/components/control-pane/control-pane.styles.d.ts +1 -0
  14. package/dist/dts/_docs/design-system/color-explorer/components/control-pane/control-pane.template.d.ts +2 -0
  15. package/dist/dts/_docs/design-system/color-explorer/components/control-pane/index.d.ts +6 -0
  16. package/dist/dts/_docs/design-system/color-explorer/components/gradient/gradient.d.ts +5 -0
  17. package/dist/dts/_docs/design-system/color-explorer/components/gradient/gradient.styles.d.ts +1 -0
  18. package/dist/dts/_docs/design-system/color-explorer/components/gradient/gradient.template.d.ts +2 -0
  19. package/dist/dts/_docs/design-system/color-explorer/components/gradient/index.d.ts +6 -0
  20. package/dist/dts/_docs/design-system/color-explorer/components/layer-background/index.d.ts +21 -0
  21. package/dist/dts/_docs/design-system/color-explorer/components/sample-app/index.d.ts +6 -0
  22. package/dist/dts/_docs/design-system/color-explorer/components/sample-app/sample-app.d.ts +3 -0
  23. package/dist/dts/_docs/design-system/color-explorer/components/sample-app/sample-app.styles.d.ts +1 -0
  24. package/dist/dts/_docs/design-system/color-explorer/components/sample-app/sample-app.template.d.ts +1 -0
  25. package/dist/dts/_docs/design-system/color-explorer/components/sample-page/index.d.ts +6 -0
  26. package/dist/dts/_docs/design-system/color-explorer/components/sample-page/sample-page.d.ts +3 -0
  27. package/dist/dts/_docs/design-system/color-explorer/components/sample-page/sample-page.styles.d.ts +1 -0
  28. package/dist/dts/_docs/design-system/color-explorer/components/sample-page/sample-page.template.d.ts +1 -0
  29. package/dist/dts/_docs/design-system/color-explorer/components/swatch.d.ts +30 -0
  30. package/dist/dts/_docs/design-system/color-explorer/custom-elements.d.ts +7 -0
  31. package/dist/dts/_docs/design-system/color-explorer/index.d.ts +2 -0
  32. package/dist/esm/_docs/design-system/color-explorer/app.js +247 -0
  33. package/dist/esm/_docs/design-system/color-explorer/colors.js +24 -0
  34. package/dist/esm/_docs/design-system/color-explorer/component-types.js +7 -0
  35. package/dist/esm/_docs/design-system/color-explorer/components/color-block.js +408 -0
  36. package/dist/esm/_docs/design-system/color-explorer/components/color-picker/color-picker.form-associated.js +16 -0
  37. package/dist/esm/_docs/design-system/color-explorer/components/color-picker/color-picker.js +297 -0
  38. package/dist/esm/_docs/design-system/color-explorer/components/color-picker/color-picker.styles.js +124 -0
  39. package/dist/esm/_docs/design-system/color-explorer/components/color-picker/color-picker.template.js +130 -0
  40. package/dist/esm/_docs/design-system/color-explorer/components/color-picker/index.js +15 -0
  41. package/dist/esm/_docs/design-system/color-explorer/components/control-pane/control-pane.js +24 -0
  42. package/dist/esm/_docs/design-system/color-explorer/components/control-pane/control-pane.styles.js +19 -0
  43. package/dist/esm/_docs/design-system/color-explorer/components/control-pane/control-pane.template.js +52 -0
  44. package/dist/esm/_docs/design-system/color-explorer/components/control-pane/index.js +18 -0
  45. package/dist/esm/_docs/design-system/color-explorer/components/gradient/gradient.js +11 -0
  46. package/dist/esm/_docs/design-system/color-explorer/components/gradient/gradient.styles.js +31 -0
  47. package/dist/esm/_docs/design-system/color-explorer/components/gradient/gradient.template.js +21 -0
  48. package/dist/esm/_docs/design-system/color-explorer/components/gradient/index.js +18 -0
  49. package/dist/esm/_docs/design-system/color-explorer/components/layer-background/index.js +70 -0
  50. package/dist/esm/_docs/design-system/color-explorer/components/sample-app/index.js +18 -0
  51. package/dist/esm/_docs/design-system/color-explorer/components/sample-app/sample-app.js +3 -0
  52. package/dist/esm/_docs/design-system/color-explorer/components/sample-app/sample-app.styles.js +166 -0
  53. package/dist/esm/_docs/design-system/color-explorer/components/sample-app/sample-app.template.js +97 -0
  54. package/dist/esm/_docs/design-system/color-explorer/components/sample-page/index.js +18 -0
  55. package/dist/esm/_docs/design-system/color-explorer/components/sample-page/sample-page.js +3 -0
  56. package/dist/esm/_docs/design-system/color-explorer/components/sample-page/sample-page.styles.js +130 -0
  57. package/dist/esm/_docs/design-system/color-explorer/components/sample-page/sample-page.template.js +82 -0
  58. package/dist/esm/_docs/design-system/color-explorer/components/swatch.js +163 -0
  59. package/dist/esm/_docs/design-system/color-explorer/custom-elements.js +3 -0
  60. package/dist/esm/_docs/design-system/color-explorer/index.js +14 -0
  61. package/dist/esm/card/card.stories.js +1 -1
  62. package/dist/esm/data-grid/data-grid.stories.js +1 -1
  63. package/dist/web-components.js +634 -278
  64. package/dist/web-components.min.js +222 -222
  65. package/package.json +6 -6
@@ -0,0 +1,82 @@
1
+ import { html } from '@microsoft/fast-element';
2
+ // import MoreIcon from "@fluentui/svg-icons/icons/more_horizontal_20_regular.svg";
3
+ // import DownloadIcon from "@fluentui/svg-icons/icons/arrow_download_20_regular.svg";
4
+ // import PlayIcon from "@fluentui/svg-icons/icons/play_20_regular.svg";
5
+ export const samplePageTemplate = html `
6
+ <template>
7
+ <fluent-card>
8
+ <div class="image-container">
9
+ <fluent-badge fill="primary" color="primary" class="badge"> Badge </fluent-badge>
10
+ </div>
11
+ <div class="text-container">
12
+ <h3>Example card</h3>
13
+ <p>
14
+ At purus lectus quis habitant commodo, cras. Aliquam malesuada velit a tortor. Felis orci tellus netus risus
15
+ et ultricies augue aliquet. Suscipit mattis mus amet nibh...
16
+ </p>
17
+ <fluent-divider></fluent-divider>
18
+ <div class="sample-control">
19
+ <span class="sample-control-icon"></span>
20
+ <span class="sample-control-text">Label</span>
21
+ <div class="sample-control-actions">
22
+ <fluent-button appearance="stealth" aria-label="Example 'more' button">
23
+ <svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
24
+ <path
25
+ d="M6.25 10a1.25 1.25 0 11-2.5 0 1.25 1.25 0 012.5 0zm5 0a1.25 1.25 0 11-2.5 0 1.25 1.25 0 012.5 0zM15 11.25a1.25 1.25 0 100-2.5 1.25 1.25 0 000 2.5z"
26
+ />
27
+ </svg>
28
+ </fluent-button>
29
+ </div>
30
+ </div>
31
+ </div>
32
+ </fluent-card>
33
+ <div class="preview-controls">
34
+ <fluent-progress aria-label="Example progress bar"></fluent-progress>
35
+ <fluent-menu aria-label="Example menu">
36
+ <fluent-menu-item role="menuitem" aria-label="Example menu item"> Menu item 1 </fluent-menu-item>
37
+ <fluent-menu-item role="menuitem" aria-label="Example menu item"> Menu item 2 </fluent-menu-item>
38
+ <fluent-menu-item role="menuitem" aria-label="Example menu item"> Menu item 3 </fluent-menu-item>
39
+ <fluent-divider></fluent-divider>
40
+ <fluent-menu-item role="menuitem" aria-label="Example menu item"> Menu item 4 </fluent-menu-item>
41
+ </fluent-menu>
42
+ <div class="control-container">
43
+ <fluent-radio-group class="example-radios" name="example radio group" orientation="vertical">
44
+ <fluent-radio aria-label="Example radio 1">Radio 1</fluent-radio>
45
+ <fluent-radio aria-label="Example radio 2">Radio 2</fluent-radio>
46
+ </fluent-radio-group>
47
+ <div class="control-container-grid">
48
+ <fluent-switch aria-label="Example toggle">Toggle</fluent-switch>
49
+ <fluent-checkbox class="checkbox" aria-label="Example checkbox"> Checkbox </fluent-checkbox>
50
+ </div>
51
+ </div>
52
+ <fluent-text-field placeholder="Text field" aria-label="Example text field"></fluent-text-field>
53
+ <div class="control-container-2">
54
+ <fluent-slider aria-label="Example slider"></fluent-slider>
55
+ <fluent-flipper></fluent-flipper>
56
+ <fluent-flipper disabled></fluent-flipper>
57
+ </div>
58
+ <div class="control-container">
59
+ <fluent-button appearance="accent" aria-label="Example 'download' button">
60
+ Button
61
+ <span slot="start">
62
+ <svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
63
+ <path
64
+ d="M15.5 17a.5.5 0 01.09 1H4.5a.5.5 0 01-.09-1H15.5zM10 2a.5.5 0 01.5.41V14.3l3.64-3.65a.5.5 0 01.64-.06l.07.06c.17.17.2.44.06.63l-.06.07-4.5 4.5a.5.5 0 01-.25.14L10 16a.5.5 0 01-.4-.2l-4.46-4.45a.5.5 0 01.64-.76l.07.06 3.65 3.64V2.5c0-.27.22-.5.5-.5z"
65
+ />
66
+ </svg>
67
+ </span>
68
+ </fluent-button>
69
+ <fluent-button appearance="neutral" aria-label="Example 'play' button">
70
+ Button
71
+ <span slot="start">
72
+ <svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
73
+ <path
74
+ d="M17.22 8.69a1.5 1.5 0 010 2.62l-10 5.5A1.5 1.5 0 015 15.5v-11A1.5 1.5 0 017.22 3.2l10 5.5zm-.48 1.75a.5.5 0 000-.88l-10-5.5A.5.5 0 006 4.5v11c0 .38.4.62.74.44l10-5.5z"
75
+ />
76
+ </svg>
77
+ </span>
78
+ </fluent-button>
79
+ </div>
80
+ </div>
81
+ </template>
82
+ `;
@@ -0,0 +1,163 @@
1
+ import { __decorate } from "tslib";
2
+ import { contrastRatio, parseColor } from '@microsoft/fast-colors';
3
+ import { attr, css, customElement, html, observable } from '@microsoft/fast-element';
4
+ import { FoundationElement } from '@microsoft/fast-foundation';
5
+ import { elevation, fillColor, neutralForegroundHint } from '../../../../index-rollup';
6
+ export var SwatchTypes;
7
+ (function (SwatchTypes) {
8
+ SwatchTypes["fill"] = "fill";
9
+ SwatchTypes["foreground"] = "foreground";
10
+ SwatchTypes["outline"] = "outline";
11
+ })(SwatchTypes || (SwatchTypes = {}));
12
+ const template = html `
13
+ <template class="${x => x.type}">
14
+ <div class="icon" style="${x => x.iconStyle}" title="${x => x.contrastMessage}"></div>
15
+ <code class="recipe-name"> ${x => x.recipeName} </code>
16
+ <code class="hex-code"> ${x => x.colorValue} </code>
17
+ </template>
18
+ `;
19
+ const styles = css `
20
+ :host {
21
+ display: grid;
22
+ grid-template-columns: auto 1fr auto;
23
+ grid-template-rows: auto;
24
+ align-items: center;
25
+ width: 100%;
26
+ padding: 4px 0;
27
+ box-sizing: border-box;
28
+ color: ${neutralForegroundHint};
29
+ font-size: 12px;
30
+ grid-column-gap: 16px;
31
+ justify-items: start;
32
+ }
33
+ :host(.foreground) .icon {
34
+ border: 1px solid black;
35
+ }
36
+ :host(.foreground) .icon::before {
37
+ font-size: 13px;
38
+ content: 'A';
39
+ font-weight: 400;
40
+ }
41
+ .icon {
42
+ display: flex;
43
+ align-items: center;
44
+ justify-content: center;
45
+ width: 20px;
46
+ height: 20px;
47
+ border-radius: 2px;
48
+ box-sizing: border-box;
49
+ --elevation: 4;
50
+ ${elevation}
51
+ }
52
+ .recipe-name {
53
+ grid-column: 2;
54
+ grid-row: 1;
55
+ }
56
+ .hex-code {
57
+ grid-column: 3;
58
+ grid-row: 1;
59
+ }
60
+ `;
61
+ let AppSwatch = class AppSwatch extends FoundationElement {
62
+ foregroundRecipeChanged() {
63
+ this.updateObservables();
64
+ }
65
+ fillRecipeChanged() {
66
+ this.updateObservables();
67
+ }
68
+ outlineRecipeChanged() {
69
+ this.updateObservables();
70
+ }
71
+ connectedCallback() {
72
+ super.connectedCallback();
73
+ const fillColorChangeHandler = () => {
74
+ this.updateObservables();
75
+ };
76
+ fillColor.subscribe({
77
+ handleChange: fillColorChangeHandler,
78
+ }, this);
79
+ this.updateObservables();
80
+ }
81
+ updateObservables() {
82
+ this.updateIconStyle();
83
+ this.updateContrastMessage();
84
+ this.updateColorValue();
85
+ }
86
+ tokenCSS(token) {
87
+ return token && typeof token.createCSS === 'function' ? token.createCSS() : '';
88
+ }
89
+ evaluateToken(token) {
90
+ return (token === null || token === void 0 ? void 0 : token.getValueFor(this).toColorString()) || '';
91
+ }
92
+ updateIconStyle() {
93
+ const background = `background-color: ${this.tokenCSS(this.fillRecipe)}`;
94
+ this.iconStyle =
95
+ this.type === SwatchTypes.outline
96
+ ? `border: 4px solid ${this.tokenCSS(this.outlineRecipe)}; ${background}`
97
+ : this.type === SwatchTypes.foreground
98
+ ? `color: ${this.tokenCSS(this.foregroundRecipe)}; ${background}`
99
+ : background;
100
+ }
101
+ formatContrast(a, b) {
102
+ return a && b
103
+ ? contrastRatio(parseColor(this.evaluateToken(a)), parseColor(this.evaluateToken(b))).toFixed(2)
104
+ : '';
105
+ }
106
+ formatBackgroundContrast(a, b) {
107
+ return `BG contrast: ${this.formatContrast(a, b)} : 1`;
108
+ }
109
+ formatForegroundContrast(a, b) {
110
+ return `Text contrast: ${this.formatContrast(a, b)} : 1`;
111
+ }
112
+ updateContrastMessage() {
113
+ const backgroundContrastMessage = this.formatBackgroundContrast(this.type === SwatchTypes.foreground
114
+ ? this.foregroundRecipe
115
+ : this.type === SwatchTypes.outline
116
+ ? this.outlineRecipe
117
+ : this.fillRecipe, this.type === SwatchTypes.foreground || this.type === SwatchTypes.outline ? this.fillRecipe : fillColor);
118
+ this.contrastMessage =
119
+ this.type === SwatchTypes.fill
120
+ ? backgroundContrastMessage.concat('\n', this.formatForegroundContrast(this.fillRecipe, this.foregroundRecipe))
121
+ : backgroundContrastMessage;
122
+ }
123
+ updateColorValue() {
124
+ const recipe = this.type === SwatchTypes.outline
125
+ ? this.outlineRecipe
126
+ : this.type === SwatchTypes.foreground
127
+ ? this.foregroundRecipe
128
+ : this.fillRecipe;
129
+ this.colorValue = this.evaluateToken(recipe).toUpperCase();
130
+ }
131
+ };
132
+ __decorate([
133
+ attr
134
+ ], AppSwatch.prototype, "type", void 0);
135
+ __decorate([
136
+ attr({ attribute: 'recipe-name' })
137
+ ], AppSwatch.prototype, "recipeName", void 0);
138
+ __decorate([
139
+ observable
140
+ ], AppSwatch.prototype, "foregroundRecipe", void 0);
141
+ __decorate([
142
+ observable
143
+ ], AppSwatch.prototype, "fillRecipe", void 0);
144
+ __decorate([
145
+ observable
146
+ ], AppSwatch.prototype, "outlineRecipe", void 0);
147
+ __decorate([
148
+ observable
149
+ ], AppSwatch.prototype, "iconStyle", void 0);
150
+ __decorate([
151
+ observable
152
+ ], AppSwatch.prototype, "contrastMessage", void 0);
153
+ __decorate([
154
+ observable
155
+ ], AppSwatch.prototype, "colorValue", void 0);
156
+ AppSwatch = __decorate([
157
+ customElement({
158
+ name: 'app-swatch',
159
+ template,
160
+ styles,
161
+ })
162
+ ], AppSwatch);
163
+ export { AppSwatch };
@@ -0,0 +1,3 @@
1
+ import { layerBackground } from './components/layer-background';
2
+ export { layerBackground };
3
+ export const appComponents = [layerBackground()];
@@ -0,0 +1,14 @@
1
+ import { allComponents as fluentComponents, provideFluentDesignSystem } from '../../../index-rollup';
2
+ import { fastToolingColorPicker } from './components/color-picker';
3
+ import { App } from './app';
4
+ import { appComponents } from './custom-elements';
5
+ export function init() {
6
+ provideFluentDesignSystem()
7
+ .register(fluentComponents)
8
+ .withPrefix('fast-tooling')
9
+ .register(fastToolingColorPicker())
10
+ .withPrefix('app')
11
+ .register(appComponents);
12
+ }
13
+ App;
14
+ export { App } from './app';
@@ -4,7 +4,7 @@ import { DesignSystemProvider, StandardLuminance } from '../index-rollup';
4
4
  import CardTemplate from './fixtures/card.html';
5
5
  import './index';
6
6
  addons.getChannel().addListener(DOCS_RENDERED, name => {
7
- if (name.toLowerCase() === 'components/card') {
7
+ if (name.toLowerCase().includes('card')) {
8
8
  const els = document.getElementsByClassName('darkMode');
9
9
  for (let i = 0; i < els.length; i++) {
10
10
  const el = els[i];
@@ -40,7 +40,7 @@ const customHeaderCellItemTemplate = html `
40
40
  ></fast-data-grid-header-cell>
41
41
  `;
42
42
  addons.getChannel().addListener(DOCS_RENDERED, (name) => {
43
- if (name.toLowerCase().includes('components/data grid')) {
43
+ if (name.toLowerCase().includes('data-grid')) {
44
44
  defaultGridElement = document.getElementById('defaultGrid');
45
45
  reset();
46
46
  const defaultGridRow = document.getElementById('defaultGridRow');