@momentum-design/components 0.140.0 → 0.141.0
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/dist/browser/index.js +424 -424
- package/dist/browser/index.js.map +4 -4
- package/dist/components/brandvisual/brandvisual.component.d.ts +49 -1
- package/dist/components/brandvisual/brandvisual.component.js +154 -19
- package/dist/components/brandvisualprovider/brandvisualprovider.component.d.ts +97 -0
- package/dist/components/brandvisualprovider/brandvisualprovider.component.js +105 -0
- package/dist/components/brandvisualprovider/brandvisualprovider.constants.d.ts +7 -0
- package/dist/components/brandvisualprovider/brandvisualprovider.constants.js +10 -0
- package/dist/components/brandvisualprovider/brandvisualprovider.context.d.ts +12 -0
- package/dist/components/brandvisualprovider/brandvisualprovider.context.js +7 -0
- package/dist/components/brandvisualprovider/brandvisualprovider.types.d.ts +3 -0
- package/dist/components/brandvisualprovider/brandvisualprovider.types.js +1 -0
- package/dist/components/brandvisualprovider/index.d.ts +7 -0
- package/dist/components/brandvisualprovider/index.js +4 -0
- package/dist/components/icon/icon.component.js +3 -2
- package/dist/components/illustration/illustration.component.js +3 -2
- package/dist/custom-elements.json +252 -7
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/react/brandvisualprovider/index.d.ts +24 -0
- package/dist/react/brandvisualprovider/index.js +17 -0
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.js +1 -0
- package/dist/utils/asset-fetch/index.d.ts +42 -0
- package/dist/utils/asset-fetch/index.js +101 -0
- package/package.json +1 -1
- package/dist/components/icon/icon.utils.d.ts +0 -32
- package/dist/components/icon/icon.utils.js +0 -91
- package/dist/components/illustration/illustration.utils.d.ts +0 -32
- package/dist/components/illustration/illustration.utils.js +0 -91
|
@@ -173,8 +173,8 @@
|
|
|
173
173
|
"attribute": "disabled",
|
|
174
174
|
"reflects": true,
|
|
175
175
|
"inheritedFrom": {
|
|
176
|
-
"name": "
|
|
177
|
-
"module": "
|
|
176
|
+
"name": "DisabledMixin",
|
|
177
|
+
"module": "utils/mixins/DisabledMixin.js"
|
|
178
178
|
}
|
|
179
179
|
},
|
|
180
180
|
{
|
|
@@ -493,8 +493,8 @@
|
|
|
493
493
|
"default": "undefined",
|
|
494
494
|
"fieldName": "disabled",
|
|
495
495
|
"inheritedFrom": {
|
|
496
|
-
"name": "
|
|
497
|
-
"module": "src/
|
|
496
|
+
"name": "DisabledMixin",
|
|
497
|
+
"module": "src/utils/mixins/DisabledMixin.ts"
|
|
498
498
|
}
|
|
499
499
|
},
|
|
500
500
|
{
|
|
@@ -4661,6 +4661,15 @@
|
|
|
4661
4661
|
}
|
|
4662
4662
|
],
|
|
4663
4663
|
"members": [
|
|
4664
|
+
{
|
|
4665
|
+
"kind": "field",
|
|
4666
|
+
"name": "abortController",
|
|
4667
|
+
"type": {
|
|
4668
|
+
"text": "AbortController | undefined"
|
|
4669
|
+
},
|
|
4670
|
+
"privacy": "private",
|
|
4671
|
+
"default": "new AbortController()"
|
|
4672
|
+
},
|
|
4664
4673
|
{
|
|
4665
4674
|
"kind": "field",
|
|
4666
4675
|
"name": "altText",
|
|
@@ -4671,6 +4680,25 @@
|
|
|
4671
4680
|
"attribute": "alt-text",
|
|
4672
4681
|
"reflects": true
|
|
4673
4682
|
},
|
|
4683
|
+
{
|
|
4684
|
+
"kind": "method",
|
|
4685
|
+
"name": "applyAltText",
|
|
4686
|
+
"privacy": "private",
|
|
4687
|
+
"return": {
|
|
4688
|
+
"type": {
|
|
4689
|
+
"text": "Element | TemplateResult"
|
|
4690
|
+
}
|
|
4691
|
+
},
|
|
4692
|
+
"parameters": [
|
|
4693
|
+
{
|
|
4694
|
+
"name": "brandVisual",
|
|
4695
|
+
"type": {
|
|
4696
|
+
"text": "Element | TemplateResult"
|
|
4697
|
+
}
|
|
4698
|
+
}
|
|
4699
|
+
],
|
|
4700
|
+
"description": "Labels the brandvisual with the alt text, if it has anything to label.\n\nThe dynamic import hands back a lit `TemplateResult`, whose markup has to be parsed before an\n`img` can be found in it, while both provider branches already produce an `Element` - so the\ntwo need different treatment. Only raster visuals have an `img` to label; vector ones are\n`aria-hidden` by design and are returned untouched."
|
|
4701
|
+
},
|
|
4674
4702
|
{
|
|
4675
4703
|
"kind": "field",
|
|
4676
4704
|
"name": "brandVisualData",
|
|
@@ -4679,10 +4707,31 @@
|
|
|
4679
4707
|
},
|
|
4680
4708
|
"privacy": "private"
|
|
4681
4709
|
},
|
|
4710
|
+
{
|
|
4711
|
+
"kind": "field",
|
|
4712
|
+
"name": "brandVisualProviderContext",
|
|
4713
|
+
"privacy": "private",
|
|
4714
|
+
"readonly": true
|
|
4715
|
+
},
|
|
4716
|
+
{
|
|
4717
|
+
"kind": "method",
|
|
4718
|
+
"name": "fetchBrandVisual",
|
|
4719
|
+
"privacy": "private",
|
|
4720
|
+
"parameters": [
|
|
4721
|
+
{
|
|
4722
|
+
"name": "{\n url,\n fileExtension,\n cacheName,\n cacheStrategy,\n }",
|
|
4723
|
+
"type": {
|
|
4724
|
+
"text": "{\n url: string;\n fileExtension: string;\n cacheName?: string;\n cacheStrategy?: CacheStrategy;\n }"
|
|
4725
|
+
}
|
|
4726
|
+
}
|
|
4727
|
+
],
|
|
4728
|
+
"description": "Fetches a vector brandvisual over HTTP and inlines it.\n\nThis method uses abortController.signal to cancel the fetch request when the component is\ndisconnected or updated. If the request is aborted after the fetch() call has been fulfilled\nbut before the response body has been read, then attempting to read the response body will\nreject with an AbortError exception."
|
|
4729
|
+
},
|
|
4682
4730
|
{
|
|
4683
4731
|
"kind": "method",
|
|
4684
4732
|
"name": "getBrandVisualData",
|
|
4685
|
-
"privacy": "private"
|
|
4733
|
+
"privacy": "private",
|
|
4734
|
+
"description": "Resolves the brandvisual, either over HTTP through a `BrandVisualProvider` or through a\ndynamic import of the lit template shipped in the `@momentum-design/brand-visuals` package.\n\nThe dynamic import is the fallback for every case that is not a fully configured custom set:\nno provider at all, the momentum set, or a custom set that is missing a url or file extension.\nKeeping it reachable without a provider is what makes this backwards compatible - a bare\n`<mdc-brandvisual name=\"…\">` behaves exactly as it did before the provider existed."
|
|
4686
4735
|
},
|
|
4687
4736
|
{
|
|
4688
4737
|
"kind": "method",
|
|
@@ -4706,9 +4755,9 @@
|
|
|
4706
4755
|
{
|
|
4707
4756
|
"name": "brandVisualHtml",
|
|
4708
4757
|
"type": {
|
|
4709
|
-
"text": "TemplateResult"
|
|
4758
|
+
"text": "Element | TemplateResult"
|
|
4710
4759
|
},
|
|
4711
|
-
"description": "The brandvisual
|
|
4760
|
+
"description": "The brandvisual which has been resolved, either as the lit template\nfrom the dynamic import or as an element built from the provider url."
|
|
4712
4761
|
}
|
|
4713
4762
|
],
|
|
4714
4763
|
"description": "Sets the brandVisualData state to the fetched brandvisual.\nDispatches a 'load' event on the component once the brandvisual has been successfully loaded."
|
|
@@ -4767,6 +4816,26 @@
|
|
|
4767
4816
|
}
|
|
4768
4817
|
]
|
|
4769
4818
|
},
|
|
4819
|
+
{
|
|
4820
|
+
"kind": "method",
|
|
4821
|
+
"name": "loadBrandVisualImage",
|
|
4822
|
+
"privacy": "private",
|
|
4823
|
+
"parameters": [
|
|
4824
|
+
{
|
|
4825
|
+
"name": "url",
|
|
4826
|
+
"type": {
|
|
4827
|
+
"text": "string"
|
|
4828
|
+
}
|
|
4829
|
+
},
|
|
4830
|
+
{
|
|
4831
|
+
"name": "fileExtension",
|
|
4832
|
+
"type": {
|
|
4833
|
+
"text": "string"
|
|
4834
|
+
}
|
|
4835
|
+
}
|
|
4836
|
+
],
|
|
4837
|
+
"description": "Points an `img` at the raster brandvisual and resolves once the browser has loaded it.\n\nThere is nothing to fetch here - assigning `src` starts the load even while the element is\ndetached - but we still wait for it so that `load` and `error` keep meaning the same thing\nthey do on the other two branches."
|
|
4838
|
+
},
|
|
4770
4839
|
{
|
|
4771
4840
|
"kind": "field",
|
|
4772
4841
|
"name": "name",
|
|
@@ -4776,6 +4845,26 @@
|
|
|
4776
4845
|
"description": "Name of the brandVisual (= filename)",
|
|
4777
4846
|
"attribute": "name",
|
|
4778
4847
|
"reflects": true
|
|
4848
|
+
},
|
|
4849
|
+
{
|
|
4850
|
+
"kind": "method",
|
|
4851
|
+
"name": "prepareBrandVisualElement",
|
|
4852
|
+
"privacy": "private",
|
|
4853
|
+
"return": {
|
|
4854
|
+
"type": {
|
|
4855
|
+
"text": ""
|
|
4856
|
+
}
|
|
4857
|
+
},
|
|
4858
|
+
"parameters": [
|
|
4859
|
+
{
|
|
4860
|
+
"name": "brandVisualData",
|
|
4861
|
+
"type": {
|
|
4862
|
+
"text": "string"
|
|
4863
|
+
},
|
|
4864
|
+
"description": "The brandvisual string to be parsed"
|
|
4865
|
+
}
|
|
4866
|
+
],
|
|
4867
|
+
"description": "Parse the fetched brandvisual string to an html element and set the attributes the\npackaged lit templates would otherwise carry."
|
|
4779
4868
|
}
|
|
4780
4869
|
],
|
|
4781
4870
|
"events": [
|
|
@@ -4828,6 +4917,162 @@
|
|
|
4828
4917
|
}
|
|
4829
4918
|
]
|
|
4830
4919
|
},
|
|
4920
|
+
{
|
|
4921
|
+
"kind": "javascript-module",
|
|
4922
|
+
"path": "components/brandvisualprovider/brandvisualprovider.component.js",
|
|
4923
|
+
"declarations": [
|
|
4924
|
+
{
|
|
4925
|
+
"kind": "class",
|
|
4926
|
+
"description": "",
|
|
4927
|
+
"name": "BrandVisualProvider",
|
|
4928
|
+
"slots": [
|
|
4929
|
+
{
|
|
4930
|
+
"description": "children",
|
|
4931
|
+
"name": ""
|
|
4932
|
+
}
|
|
4933
|
+
],
|
|
4934
|
+
"members": [
|
|
4935
|
+
{
|
|
4936
|
+
"kind": "field",
|
|
4937
|
+
"name": "brandVisualSet",
|
|
4938
|
+
"type": {
|
|
4939
|
+
"text": "BrandVisualSet | undefined"
|
|
4940
|
+
},
|
|
4941
|
+
"description": "Brand visual set to be used\n\nIf `momentum-brand-visuals` is selected, the brand visuals will be fetched from the\nMomentum Design System brand visual set per a dynamic JS Import (no need to provide a URL).\nThis requires the consumer to have the `@momentum-design/brand-visuals` package installed and the\nbuild tooling needs to support dynamic imports.\n\nIf `custom-brand-visuals` is selected, the brand visuals will be fetched from the provided URL.\nThis requires the consumer to provide a URL from which the brand visuals will be fetched and\nthe consumer needs to make sure to bundle the brand visuals in the application.",
|
|
4942
|
+
"default": "momentum-brand-visuals",
|
|
4943
|
+
"attribute": "brand-visual-set",
|
|
4944
|
+
"reflects": true
|
|
4945
|
+
},
|
|
4946
|
+
{
|
|
4947
|
+
"kind": "field",
|
|
4948
|
+
"name": "cacheName",
|
|
4949
|
+
"type": {
|
|
4950
|
+
"text": "string | undefined"
|
|
4951
|
+
},
|
|
4952
|
+
"description": "Brand visuals Cache Name to use (cache strategy must be provided)\n\nIf provided, Brand visuals inside the provider will be cached in the\ncache (determined by `cache-strategy`) with the provided name.\n\nBrand visuals cache name must be unique, independent from other asset caches.\n\nNOTE: `cache-name` requires `cache-strategy` to be set.\n\nIf not provided, the brand visuals will not be cached.",
|
|
4953
|
+
"default": "undefined",
|
|
4954
|
+
"attribute": "cache-name"
|
|
4955
|
+
},
|
|
4956
|
+
{
|
|
4957
|
+
"kind": "field",
|
|
4958
|
+
"name": "cacheStrategy",
|
|
4959
|
+
"type": {
|
|
4960
|
+
"text": "CacheStrategy | undefined"
|
|
4961
|
+
},
|
|
4962
|
+
"description": "Brand visuals Cache Strategy to use\n\n**Can only be used if Brand visual set is `custom-brand-visuals` and the file extension is `svg`**\n(`png` visuals are loaded by the browser through an `img` element and are subject to the\nregular HTTP cache instead).\n\nChoose `in-memory-cache` to cache brand visuals in a JS cache (in-memory cache).\nChoose `web-cache-api` to cache brand visuals using the Web Cache API.\n\nNOTE: `cache-name` must be provided if `cache-strategy` is provided.\n\nIf not provided or invalid value provided, the brand visuals will not be cached.",
|
|
4963
|
+
"default": "undefined",
|
|
4964
|
+
"attribute": "cache-strategy"
|
|
4965
|
+
},
|
|
4966
|
+
{
|
|
4967
|
+
"kind": "field",
|
|
4968
|
+
"name": "Context",
|
|
4969
|
+
"privacy": "public",
|
|
4970
|
+
"static": true,
|
|
4971
|
+
"description": "Context object of the BrandVisualProviderContext, to be consumed by child components",
|
|
4972
|
+
"readonly": true
|
|
4973
|
+
},
|
|
4974
|
+
{
|
|
4975
|
+
"kind": "field",
|
|
4976
|
+
"name": "fileExtension",
|
|
4977
|
+
"type": {
|
|
4978
|
+
"text": "string | undefined"
|
|
4979
|
+
},
|
|
4980
|
+
"description": "File extension of brand visuals\n(if Brand visual set is `custom-brand-visuals`, this will be the file extension for brand visuals)\n\n`svg` visuals are fetched and inlined, `png` visuals are set as the `src` of an `img` element.\nNote that the two sets are not interchangeable: the device visuals only ship as `png`,\nevery other visual only ships as `svg`.",
|
|
4981
|
+
"default": "svg",
|
|
4982
|
+
"attribute": "file-extension",
|
|
4983
|
+
"reflects": true
|
|
4984
|
+
},
|
|
4985
|
+
{
|
|
4986
|
+
"kind": "method",
|
|
4987
|
+
"name": "updateContext",
|
|
4988
|
+
"privacy": "protected",
|
|
4989
|
+
"return": {
|
|
4990
|
+
"type": {
|
|
4991
|
+
"text": "void"
|
|
4992
|
+
}
|
|
4993
|
+
}
|
|
4994
|
+
},
|
|
4995
|
+
{
|
|
4996
|
+
"kind": "method",
|
|
4997
|
+
"name": "updateValuesInContext",
|
|
4998
|
+
"privacy": "private"
|
|
4999
|
+
},
|
|
5000
|
+
{
|
|
5001
|
+
"kind": "field",
|
|
5002
|
+
"name": "url",
|
|
5003
|
+
"type": {
|
|
5004
|
+
"text": "string | undefined"
|
|
5005
|
+
},
|
|
5006
|
+
"description": "Url of where brand visuals will be fetched from\n(if Brand visual set is `custom-brand-visuals`, this will be the base url)",
|
|
5007
|
+
"attribute": "url"
|
|
5008
|
+
}
|
|
5009
|
+
],
|
|
5010
|
+
"attributes": [
|
|
5011
|
+
{
|
|
5012
|
+
"name": "brand-visual-set",
|
|
5013
|
+
"type": {
|
|
5014
|
+
"text": "BrandVisualSet | undefined"
|
|
5015
|
+
},
|
|
5016
|
+
"description": "Brand visual set to be used\n\nIf `momentum-brand-visuals` is selected, the brand visuals will be fetched from the\nMomentum Design System brand visual set per a dynamic JS Import (no need to provide a URL).\nThis requires the consumer to have the `@momentum-design/brand-visuals` package installed and the\nbuild tooling needs to support dynamic imports.\n\nIf `custom-brand-visuals` is selected, the brand visuals will be fetched from the provided URL.\nThis requires the consumer to provide a URL from which the brand visuals will be fetched and\nthe consumer needs to make sure to bundle the brand visuals in the application.",
|
|
5017
|
+
"default": "momentum-brand-visuals",
|
|
5018
|
+
"fieldName": "brandVisualSet"
|
|
5019
|
+
},
|
|
5020
|
+
{
|
|
5021
|
+
"name": "url",
|
|
5022
|
+
"type": {
|
|
5023
|
+
"text": "string | undefined"
|
|
5024
|
+
},
|
|
5025
|
+
"description": "Url of where brand visuals will be fetched from\n(if Brand visual set is `custom-brand-visuals`, this will be the base url)",
|
|
5026
|
+
"fieldName": "url"
|
|
5027
|
+
},
|
|
5028
|
+
{
|
|
5029
|
+
"name": "file-extension",
|
|
5030
|
+
"type": {
|
|
5031
|
+
"text": "string | undefined"
|
|
5032
|
+
},
|
|
5033
|
+
"description": "File extension of brand visuals\n(if Brand visual set is `custom-brand-visuals`, this will be the file extension for brand visuals)\n\n`svg` visuals are fetched and inlined, `png` visuals are set as the `src` of an `img` element.\nNote that the two sets are not interchangeable: the device visuals only ship as `png`,\nevery other visual only ships as `svg`.",
|
|
5034
|
+
"default": "svg",
|
|
5035
|
+
"fieldName": "fileExtension"
|
|
5036
|
+
},
|
|
5037
|
+
{
|
|
5038
|
+
"name": "cache-strategy",
|
|
5039
|
+
"type": {
|
|
5040
|
+
"text": "CacheStrategy | undefined"
|
|
5041
|
+
},
|
|
5042
|
+
"description": "Brand visuals Cache Strategy to use\n\n**Can only be used if Brand visual set is `custom-brand-visuals` and the file extension is `svg`**\n(`png` visuals are loaded by the browser through an `img` element and are subject to the\nregular HTTP cache instead).\n\nChoose `in-memory-cache` to cache brand visuals in a JS cache (in-memory cache).\nChoose `web-cache-api` to cache brand visuals using the Web Cache API.\n\nNOTE: `cache-name` must be provided if `cache-strategy` is provided.\n\nIf not provided or invalid value provided, the brand visuals will not be cached.",
|
|
5043
|
+
"default": "undefined",
|
|
5044
|
+
"fieldName": "cacheStrategy"
|
|
5045
|
+
},
|
|
5046
|
+
{
|
|
5047
|
+
"name": "cache-name",
|
|
5048
|
+
"type": {
|
|
5049
|
+
"text": "string | undefined"
|
|
5050
|
+
},
|
|
5051
|
+
"description": "Brand visuals Cache Name to use (cache strategy must be provided)\n\nIf provided, Brand visuals inside the provider will be cached in the\ncache (determined by `cache-strategy`) with the provided name.\n\nBrand visuals cache name must be unique, independent from other asset caches.\n\nNOTE: `cache-name` requires `cache-strategy` to be set.\n\nIf not provided, the brand visuals will not be cached.",
|
|
5052
|
+
"default": "undefined",
|
|
5053
|
+
"fieldName": "cacheName"
|
|
5054
|
+
}
|
|
5055
|
+
],
|
|
5056
|
+
"superclass": {
|
|
5057
|
+
"name": "Provider",
|
|
5058
|
+
"module": "/src/models"
|
|
5059
|
+
},
|
|
5060
|
+
"tagName": "mdc-brandvisualprovider",
|
|
5061
|
+
"jsDoc": "/**\n * @tagname mdc-brandvisualprovider\n *\n * @slot - children\n */",
|
|
5062
|
+
"customElement": true
|
|
5063
|
+
}
|
|
5064
|
+
],
|
|
5065
|
+
"exports": [
|
|
5066
|
+
{
|
|
5067
|
+
"kind": "js",
|
|
5068
|
+
"name": "default",
|
|
5069
|
+
"declaration": {
|
|
5070
|
+
"name": "BrandVisualProvider",
|
|
5071
|
+
"module": "components/brandvisualprovider/brandvisualprovider.component.js"
|
|
5072
|
+
}
|
|
5073
|
+
}
|
|
5074
|
+
]
|
|
5075
|
+
},
|
|
4831
5076
|
{
|
|
4832
5077
|
"kind": "javascript-module",
|
|
4833
5078
|
"path": "components/bullet/bullet.component.js",
|
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import Avatar from './components/avatar';
|
|
|
9
9
|
import AvatarButton from './components/avatarbutton';
|
|
10
10
|
import Badge from './components/badge';
|
|
11
11
|
import Brandvisual from './components/brandvisual';
|
|
12
|
+
import BrandVisualProvider from './components/brandvisualprovider';
|
|
12
13
|
import Bullet from './components/bullet';
|
|
13
14
|
import Button from './components/button';
|
|
14
15
|
import ButtonGroup from './components/buttongroup';
|
|
@@ -124,6 +125,6 @@ import type { TimePickerChangeEvent, TimePickerInputEvent } from './components/t
|
|
|
124
125
|
import type { DatePickerChangeEvent, DatePickerInputEvent } from './components/datepicker/datepicker.types';
|
|
125
126
|
import type { CalendarDateSelectedEvent, CalendarMonthChangedEvent } from './components/calendar/calendar.types';
|
|
126
127
|
import type { ListBoxChangeEvent } from './components/listbox/listbox.types';
|
|
127
|
-
export { Accordion, AccordionButton, AccordionGroup, AlertChip, Animation, AnnouncementDialog, Appheader, Avatar, AvatarButton, Badge, Brandvisual, Bullet, Button, ButtonGroup, ButtonLink, Calendar, Card, CardButton, CardCheckbox, CardRadio, Checkbox, Chip, Coachmark, ControlTypeProvider, DatePicker, Dialog, Divider, FilterChip, FormfieldGroup, Icon, IconProvider, Illustration, IllustrationProvider, Input, InputChip, Link, LinkButton, Linksimple, List, Listheader, ListItem, Marker, MenuBar, MenuItem, MenuItemCheckbox, MenuItemRadio, MenuPopover, MenuSection, NavMenuItem, NumberInput, OptGroup, Option, Password, Popover, Presence, Progressbar, Progressspinner, Radio, RadioGroup, ResponsiveSettingsProvider, ScreenreaderAnnouncer, Searchfield, Searchpopover, Select, SelectListbox, SideNavigation, Skeleton, Spinner, StaticChip, StaticCheckbox, StaticRadio, StaticToggle, Stepper, StepperConnector, StepperItem, Tab, TabList, Text, Textarea, TimePicker, ThemeProvider, Toast, Toggle, Typewriter, ToggleTip, Tooltip, VirtualizedList, Combobox, Slider, ListBox, Banner, Buttonsimple, Verticaltablist, StatusMessage, FocusTrap, CheckboxTree, };
|
|
128
|
+
export { Accordion, AccordionButton, AccordionGroup, AlertChip, Animation, AnnouncementDialog, Appheader, Avatar, AvatarButton, Badge, Brandvisual, BrandVisualProvider, Bullet, Button, ButtonGroup, ButtonLink, Calendar, Card, CardButton, CardCheckbox, CardRadio, Checkbox, Chip, Coachmark, ControlTypeProvider, DatePicker, Dialog, Divider, FilterChip, FormfieldGroup, Icon, IconProvider, Illustration, IllustrationProvider, Input, InputChip, Link, LinkButton, Linksimple, List, Listheader, ListItem, Marker, MenuBar, MenuItem, MenuItemCheckbox, MenuItemRadio, MenuPopover, MenuSection, NavMenuItem, NumberInput, OptGroup, Option, Password, Popover, Presence, Progressbar, Progressspinner, Radio, RadioGroup, ResponsiveSettingsProvider, ScreenreaderAnnouncer, Searchfield, Searchpopover, Select, SelectListbox, SideNavigation, Skeleton, Spinner, StaticChip, StaticCheckbox, StaticRadio, StaticToggle, Stepper, StepperConnector, StepperItem, Tab, TabList, Text, Textarea, TimePicker, ThemeProvider, Toast, Toggle, Typewriter, ToggleTip, Tooltip, VirtualizedList, Combobox, Slider, ListBox, Banner, Buttonsimple, Verticaltablist, StatusMessage, FocusTrap, CheckboxTree, };
|
|
128
129
|
export type { AvatarSize, BadgeType, ChipColorType, ButtonColor, ButtonVariant, IconButtonSize, MenuPopoverActionEvent, MenuPopoverChangeEvent, MenuSectionChangeEvent, PillButtonSize, PopoverPlacement, PresenceType, SkeletonVariant, SelectChangeEvent, SelectInputEvent, SpinnerSize, SpinnerVariant, SliderChangeEvent, StatusMessageSeverity, TextType, TypewriterType, InputInputEvent, InputChangeEvent, InputFocusEvent, InputBlurEvent, InputClearEvent, VirtualizedListScrollEvent, TablistChangeEvent, TextareaInputEvent, TextareaChangeEvent, TextareaFocusEvent, TextareaBlurEvent, TextareaLimitExceededEvent, ToggleOnChangeEvent, CheckboxOnChangeEvent, LinkButtonSize, TimePickerChangeEvent, TimePickerInputEvent, DatePickerChangeEvent, DatePickerInputEvent, CalendarDateSelectedEvent, CalendarMonthChangedEvent, VerticaltablistChangeEvent, ListBoxChangeEvent, };
|
|
129
130
|
export { BUTTON_COLORS, BUTTON_VARIANTS, ICON_BUTTON_SIZES, inMemoryCache, PILL_BUTTON_SIZES, SKELETON_VARIANTS, webAPIAssetsCache, };
|
package/dist/index.js
CHANGED
|
@@ -11,6 +11,7 @@ import Avatar from './components/avatar';
|
|
|
11
11
|
import AvatarButton from './components/avatarbutton';
|
|
12
12
|
import Badge from './components/badge';
|
|
13
13
|
import Brandvisual from './components/brandvisual';
|
|
14
|
+
import BrandVisualProvider from './components/brandvisualprovider';
|
|
14
15
|
import Bullet from './components/bullet';
|
|
15
16
|
import Button from './components/button';
|
|
16
17
|
import ButtonGroup from './components/buttongroup';
|
|
@@ -101,6 +102,6 @@ import { BUTTON_COLORS, BUTTON_VARIANTS, ICON_BUTTON_SIZES, PILL_BUTTON_SIZES, }
|
|
|
101
102
|
import { SKELETON_VARIANTS } from './components/skeleton/skeleton.constants';
|
|
102
103
|
import { inMemoryCache, webAPIAssetsCache } from './utils/assets-cache';
|
|
103
104
|
// Components Exports
|
|
104
|
-
export { Accordion, AccordionButton, AccordionGroup, AlertChip, Animation, AnnouncementDialog, Appheader, Avatar, AvatarButton, Badge, Brandvisual, Bullet, Button, ButtonGroup, ButtonLink, Calendar, Card, CardButton, CardCheckbox, CardRadio, Checkbox, Chip, Coachmark, ControlTypeProvider, DatePicker, Dialog, Divider, FilterChip, FormfieldGroup, Icon, IconProvider, Illustration, IllustrationProvider, Input, InputChip, Link, LinkButton, Linksimple, List, Listheader, ListItem, Marker, MenuBar, MenuItem, MenuItemCheckbox, MenuItemRadio, MenuPopover, MenuSection, NavMenuItem, NumberInput, OptGroup, Option, Password, Popover, Presence, Progressbar, Progressspinner, Radio, RadioGroup, ResponsiveSettingsProvider, ScreenreaderAnnouncer, Searchfield, Searchpopover, Select, SelectListbox, SideNavigation, Skeleton, Spinner, StaticChip, StaticCheckbox, StaticRadio, StaticToggle, Stepper, StepperConnector, StepperItem, Tab, TabList, Text, Textarea, TimePicker, ThemeProvider, Toast, Toggle, Typewriter, ToggleTip, Tooltip, VirtualizedList, Combobox, Slider, ListBox, Banner, Buttonsimple, Verticaltablist, StatusMessage, FocusTrap, CheckboxTree, };
|
|
105
|
+
export { Accordion, AccordionButton, AccordionGroup, AlertChip, Animation, AnnouncementDialog, Appheader, Avatar, AvatarButton, Badge, Brandvisual, BrandVisualProvider, Bullet, Button, ButtonGroup, ButtonLink, Calendar, Card, CardButton, CardCheckbox, CardRadio, Checkbox, Chip, Coachmark, ControlTypeProvider, DatePicker, Dialog, Divider, FilterChip, FormfieldGroup, Icon, IconProvider, Illustration, IllustrationProvider, Input, InputChip, Link, LinkButton, Linksimple, List, Listheader, ListItem, Marker, MenuBar, MenuItem, MenuItemCheckbox, MenuItemRadio, MenuPopover, MenuSection, NavMenuItem, NumberInput, OptGroup, Option, Password, Popover, Presence, Progressbar, Progressspinner, Radio, RadioGroup, ResponsiveSettingsProvider, ScreenreaderAnnouncer, Searchfield, Searchpopover, Select, SelectListbox, SideNavigation, Skeleton, Spinner, StaticChip, StaticCheckbox, StaticRadio, StaticToggle, Stepper, StepperConnector, StepperItem, Tab, TabList, Text, Textarea, TimePicker, ThemeProvider, Toast, Toggle, Typewriter, ToggleTip, Tooltip, VirtualizedList, Combobox, Slider, ListBox, Banner, Buttonsimple, Verticaltablist, StatusMessage, FocusTrap, CheckboxTree, };
|
|
105
106
|
// Constants / Utils Exports
|
|
106
107
|
export { BUTTON_COLORS, BUTTON_VARIANTS, ICON_BUTTON_SIZES, inMemoryCache, PILL_BUTTON_SIZES, SKELETON_VARIANTS, webAPIAssetsCache, };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import Component from '../../components/brandvisualprovider';
|
|
2
|
+
/**
|
|
3
|
+
* The brandvisualprovider is the context provider for `mdc-brandvisual`. It lets an application configure where brand visuals come from and how they are cached in one place, so every nested brand visual stays consistent without repeating that setup at each usage.
|
|
4
|
+
*
|
|
5
|
+
* Without a provider, `mdc-brandvisual` resolves its asset through a dynamic import of the lit template shipped in `@momentum-design/brand-visuals`. That import is not statically analysable, so bundlers have to account for every asset in the package. Pointing the provider at a URL replaces that import with an HTTP fetch, which lets an application serve the brand visual set itself and keep it out of the bundle entirely.
|
|
6
|
+
*
|
|
7
|
+
* **When to use**
|
|
8
|
+
*
|
|
9
|
+
* - Use `mdc-brandvisualprovider` to configure the brand visual source once for every nested `mdc-brandvisual` in a subtree.
|
|
10
|
+
* - Use `mdc-brandvisualprovider` with `brand-visual-set="custom-brand-visuals"` when brand visuals should be served over HTTP rather than bundled — for example in a host framework that cannot afford to bundle the full asset set.
|
|
11
|
+
* - Use `mdc-brandvisualprovider` when brand visuals should be cached across re-renders or navigations to avoid repeated network fetches.
|
|
12
|
+
*
|
|
13
|
+
* **When not to use**
|
|
14
|
+
*
|
|
15
|
+
* - Do not expect one provider to cover every brand visual when fetching over HTTP. The set is split across an `svg` and a `png` folder and a provider points at one of them, so a page using artwork from both needs one provider for each — see **Content guidance** below. Outside that case, prefer a single provider near the root and nest only when a subtree genuinely needs a different source.
|
|
16
|
+
* - Do not reach for `mdc-brandvisualprovider` to render a logo — it has no visible UI. Use `mdc-brandvisual` for the visual itself.
|
|
17
|
+
* - Do not add a provider purely to keep the existing behaviour. `mdc-brandvisual` works without one.
|
|
18
|
+
*
|
|
19
|
+
* @tagname mdc-brandvisualprovider
|
|
20
|
+
*
|
|
21
|
+
* @slot - children
|
|
22
|
+
*/
|
|
23
|
+
declare const reactWrapper: import("@lit/react").ReactWebComponent<Component, {}>;
|
|
24
|
+
export default reactWrapper;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { createComponent } from '@lit/react';
|
|
3
|
+
import Component from '../../components/brandvisualprovider';
|
|
4
|
+
import { TAG_NAME } from '../../components/brandvisualprovider/brandvisualprovider.constants';
|
|
5
|
+
/**
|
|
6
|
+
* @tagname mdc-brandvisualprovider
|
|
7
|
+
*
|
|
8
|
+
* @slot - children
|
|
9
|
+
*/
|
|
10
|
+
const reactWrapper = createComponent({
|
|
11
|
+
tagName: TAG_NAME,
|
|
12
|
+
elementClass: Component,
|
|
13
|
+
react: React,
|
|
14
|
+
events: {},
|
|
15
|
+
displayName: 'BrandVisualProvider',
|
|
16
|
+
});
|
|
17
|
+
export default reactWrapper;
|
package/dist/react/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export { default as AvatarButton } from './avatarbutton';
|
|
|
10
10
|
export { default as Badge } from './badge';
|
|
11
11
|
export { default as Banner } from './banner';
|
|
12
12
|
export { default as Brandvisual } from './brandvisual';
|
|
13
|
+
export { default as BrandVisualProvider } from './brandvisualprovider';
|
|
13
14
|
export { default as Bullet } from './bullet';
|
|
14
15
|
export { default as Button } from './button';
|
|
15
16
|
export { default as ButtonGroup } from './buttongroup';
|
package/dist/react/index.js
CHANGED
|
@@ -10,6 +10,7 @@ export { default as AvatarButton } from './avatarbutton';
|
|
|
10
10
|
export { default as Badge } from './badge';
|
|
11
11
|
export { default as Banner } from './banner';
|
|
12
12
|
export { default as Brandvisual } from './brandvisual';
|
|
13
|
+
export { default as BrandVisualProvider } from './brandvisualprovider';
|
|
13
14
|
export { default as Bullet } from './bullet';
|
|
14
15
|
export { default as Button } from './button';
|
|
15
16
|
export { default as ButtonGroup } from './buttongroup';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { CacheStrategy } from '../assets-cache';
|
|
2
|
+
interface Args {
|
|
3
|
+
url: string;
|
|
4
|
+
name: string;
|
|
5
|
+
fileExtension: string;
|
|
6
|
+
cacheStrategy?: CacheStrategy;
|
|
7
|
+
cacheName?: string;
|
|
8
|
+
renewSignal: () => AbortSignal;
|
|
9
|
+
/**
|
|
10
|
+
* The kind of asset being fetched (e.g. `icon`, `illustration`, `brand visual`).
|
|
11
|
+
* Used in error messages and to namespace the in-flight request map, so that two
|
|
12
|
+
* asset kinds resolving the same url never share a pending request.
|
|
13
|
+
*/
|
|
14
|
+
assetType: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Fetches a dynamic asset based on the provided `url`, `name` and `fileExtension`.
|
|
18
|
+
* The fetch is aborted if the signal is aborted.
|
|
19
|
+
*
|
|
20
|
+
* This function also includes the logic to cache the fetched asset using the In Memory Cache or Web Cache API.
|
|
21
|
+
* If the `cacheStrategy` is set to `web-cache-api` or `in-memory-cache` and `cacheName` is provided,
|
|
22
|
+
* the fetched asset will be cached using the respective cache.
|
|
23
|
+
*
|
|
24
|
+
* It will throw an error if the response is not ok.
|
|
25
|
+
*
|
|
26
|
+
* Shared by `mdc-icon`, `mdc-illustration` and `mdc-brandvisual`, all of which resolve assets
|
|
27
|
+
* the same way when their provider is configured with a custom set and a url.
|
|
28
|
+
*
|
|
29
|
+
* @param url - The base url of the asset
|
|
30
|
+
* @param name - The name of the asset
|
|
31
|
+
* @param fileExtension - The file extension of the asset
|
|
32
|
+
* @param signal - The signal to abort the fetch.
|
|
33
|
+
* It is used to cancel the fetch when the component is disconnected or updated.
|
|
34
|
+
* @param cacheStrategy - The cache strategy to use.
|
|
35
|
+
* @param cacheName - The cache name to use.
|
|
36
|
+
* @param assetType - The kind of asset being fetched.
|
|
37
|
+
*
|
|
38
|
+
* @returns Response string from the fetch
|
|
39
|
+
* @throws Error if the response is not ok
|
|
40
|
+
*/
|
|
41
|
+
declare const assetFetch: ({ url, name, fileExtension, cacheStrategy, cacheName, renewSignal, assetType, }: Args) => Promise<string>;
|
|
42
|
+
export { assetFetch };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { assetsCache } from '../assets-cache';
|
|
2
|
+
/**
|
|
3
|
+
* Utility function for fetching an asset from the provided `request`.
|
|
4
|
+
* It will throw an error if the response is not ok.
|
|
5
|
+
* @param request - The request object to fetch the asset
|
|
6
|
+
* @param assetType - The kind of asset being fetched, used in the error message
|
|
7
|
+
* @returns Promise<Response> - The response from the fetch
|
|
8
|
+
* @throws Error if the response is not ok
|
|
9
|
+
*/
|
|
10
|
+
const requestAsset = async (request, assetType) => fetch(request).then(response => {
|
|
11
|
+
if (!response.ok) {
|
|
12
|
+
throw new Error(`There was a problem while fetching the ${assetType}!`);
|
|
13
|
+
}
|
|
14
|
+
return response;
|
|
15
|
+
});
|
|
16
|
+
// Map of in-flight fetch promises used to deduplicate concurrent requests.
|
|
17
|
+
// The key is namespaced by asset type, since this map is shared by every asset kind and
|
|
18
|
+
// two of them may legitimately resolve to the same url.
|
|
19
|
+
const pendingFetches = new Map();
|
|
20
|
+
/**
|
|
21
|
+
* Fetches a dynamic asset based on the provided `url`, `name` and `fileExtension`.
|
|
22
|
+
* The fetch is aborted if the signal is aborted.
|
|
23
|
+
*
|
|
24
|
+
* This function also includes the logic to cache the fetched asset using the In Memory Cache or Web Cache API.
|
|
25
|
+
* If the `cacheStrategy` is set to `web-cache-api` or `in-memory-cache` and `cacheName` is provided,
|
|
26
|
+
* the fetched asset will be cached using the respective cache.
|
|
27
|
+
*
|
|
28
|
+
* It will throw an error if the response is not ok.
|
|
29
|
+
*
|
|
30
|
+
* Shared by `mdc-icon`, `mdc-illustration` and `mdc-brandvisual`, all of which resolve assets
|
|
31
|
+
* the same way when their provider is configured with a custom set and a url.
|
|
32
|
+
*
|
|
33
|
+
* @param url - The base url of the asset
|
|
34
|
+
* @param name - The name of the asset
|
|
35
|
+
* @param fileExtension - The file extension of the asset
|
|
36
|
+
* @param signal - The signal to abort the fetch.
|
|
37
|
+
* It is used to cancel the fetch when the component is disconnected or updated.
|
|
38
|
+
* @param cacheStrategy - The cache strategy to use.
|
|
39
|
+
* @param cacheName - The cache name to use.
|
|
40
|
+
* @param assetType - The kind of asset being fetched.
|
|
41
|
+
*
|
|
42
|
+
* @returns Response string from the fetch
|
|
43
|
+
* @throws Error if the response is not ok
|
|
44
|
+
*/
|
|
45
|
+
const assetFetch = async ({ url, name, fileExtension, cacheStrategy, cacheName, renewSignal, assetType, }) => {
|
|
46
|
+
// abort the previous fetch request if it is still pending
|
|
47
|
+
// and create a new signal
|
|
48
|
+
const signal = renewSignal();
|
|
49
|
+
const assetUrl = `${url}/${name}.${fileExtension}`;
|
|
50
|
+
const pendingKey = `${assetType}:${assetUrl}`;
|
|
51
|
+
const request = new Request(assetUrl, {
|
|
52
|
+
signal,
|
|
53
|
+
});
|
|
54
|
+
// if there is no cache defined (cacheName and cacheStrategy properly set),
|
|
55
|
+
// fetch the asset and return the response
|
|
56
|
+
if (!cacheName || !cacheStrategy || !['in-memory-cache', 'web-cache-api'].includes(cacheStrategy)) {
|
|
57
|
+
return requestAsset(request, assetType).then(response => response.text());
|
|
58
|
+
}
|
|
59
|
+
return assetsCache(cacheName, cacheStrategy).then(cache => cache
|
|
60
|
+
.get(request)
|
|
61
|
+
.then(responseFromCache => {
|
|
62
|
+
// **If entry in cache, return**
|
|
63
|
+
if (responseFromCache) {
|
|
64
|
+
return responseFromCache;
|
|
65
|
+
}
|
|
66
|
+
// **Check for in-flight fetch for the same asset**
|
|
67
|
+
const pending = pendingFetches.get(pendingKey);
|
|
68
|
+
if (pending) {
|
|
69
|
+
return pending;
|
|
70
|
+
}
|
|
71
|
+
// **Otherwise, fetch and cache if successful**
|
|
72
|
+
// Both requestAsset() and cache.set() "consume" the request,
|
|
73
|
+
// so we need to make a copy.
|
|
74
|
+
// (see https://developer.mozilla.org/en-US/docs/Web/API/Request/clone)
|
|
75
|
+
const fetchPromise = requestAsset(new Request(assetUrl), assetType)
|
|
76
|
+
.then(response => {
|
|
77
|
+
var _a;
|
|
78
|
+
// This avoids caching responses that we know are errors
|
|
79
|
+
// (i.e. HTTP status code of 4xx or 5xx).
|
|
80
|
+
if (response.status < 400 && response.headers.has('content-type')) {
|
|
81
|
+
// Call .clone() on the response to save copy to cache.
|
|
82
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Request/clone
|
|
83
|
+
return (_a = cache.set) === null || _a === void 0 ? void 0 : _a.call(cache, request, response.clone()).then(() => response.text());
|
|
84
|
+
}
|
|
85
|
+
return response.text();
|
|
86
|
+
})
|
|
87
|
+
.finally(() => {
|
|
88
|
+
pendingFetches.delete(pendingKey);
|
|
89
|
+
});
|
|
90
|
+
pendingFetches.set(pendingKey, fetchPromise);
|
|
91
|
+
return fetchPromise;
|
|
92
|
+
})
|
|
93
|
+
.catch(error => {
|
|
94
|
+
// Note that a HTTP error response (e.g. 404) will NOT trigger
|
|
95
|
+
// an exception.
|
|
96
|
+
// It will return a normal response object that has the appropriate
|
|
97
|
+
// error code set.
|
|
98
|
+
throw new Error(`Error in caching the ${assetType} ${name}, ${error}`);
|
|
99
|
+
}));
|
|
100
|
+
};
|
|
101
|
+
export { assetFetch };
|
package/package.json
CHANGED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { CacheStrategy } from '../../utils/assets-cache';
|
|
2
|
-
interface Args {
|
|
3
|
-
url: string;
|
|
4
|
-
name: string;
|
|
5
|
-
fileExtension: string;
|
|
6
|
-
cacheStrategy?: CacheStrategy;
|
|
7
|
-
cacheName?: string;
|
|
8
|
-
renewSignal: () => AbortSignal;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Fetches a dynamic SVG icon based on the provided `url`, `name` and `fileExtension`.
|
|
12
|
-
* The fetch is aborted if the signal is aborted.
|
|
13
|
-
*
|
|
14
|
-
* This function also includes the logic to cache the fetched icon using the In Memory Cache or Web Cache API.
|
|
15
|
-
* If the `cacheStrategy` is set to `web-cache-api` or `in-memory-cache` and `cacheName` is provided,
|
|
16
|
-
* the fetched icon will be cached using the respective cache.
|
|
17
|
-
*
|
|
18
|
-
* It will throw an error if the response is not ok.
|
|
19
|
-
*
|
|
20
|
-
* @param url - The base url of the icon
|
|
21
|
-
* @param name - The name of the icon
|
|
22
|
-
* @param fileExtension - The file extension of the icon
|
|
23
|
-
* @param signal - The signal to abort the fetch.
|
|
24
|
-
* It is used to cancel the fetch when the component is disconnected or updated.
|
|
25
|
-
* @param cacheStrategy - The cache strategy to use.
|
|
26
|
-
* @param cacheName - The cache name to use.
|
|
27
|
-
*
|
|
28
|
-
* @returns Response string from the fetch
|
|
29
|
-
* @throws Error if the response is not ok
|
|
30
|
-
*/
|
|
31
|
-
declare const svgFetch: ({ url, name, fileExtension, cacheStrategy, cacheName, renewSignal }: Args) => Promise<string>;
|
|
32
|
-
export { svgFetch };
|