@material/auto-init
Advanced tools
Comparing version 15.0.0-canary.9bfd12f01.0 to 15.0.0-canary.9cec94097.0
@@ -6,4 +6,4 @@ # Change Log | ||
# [15.0.0-canary.9bfd12f01.0](https://github.com/material-components/material-components-web/compare/v14.0.0...v15.0.0-canary.9bfd12f01.0) (2022-06-22) | ||
# [15.0.0-canary.9cec94097.0](https://github.com/material-components/material-components-web/compare/v14.0.0...v15.0.0-canary.9cec94097.0) (2023-10-19) | ||
**Note:** Version bump only for package @material/auto-init |
@@ -25,4 +25,4 @@ /** | ||
AUTO_INIT_ATTR: string; | ||
AUTO_INIT_STATE_ATTR: string; | ||
DATASET_AUTO_INIT_STATE: string; | ||
INITIALIZED_STATE: string; | ||
}; |
@@ -25,5 +25,5 @@ /** | ||
AUTO_INIT_ATTR: 'data-mdc-auto-init', | ||
AUTO_INIT_STATE_ATTR: 'data-mdc-auto-init-state', | ||
DATASET_AUTO_INIT_STATE: 'mdcAutoInitState', | ||
INITIALIZED_STATE: 'initialized', | ||
}; | ||
//# sourceMappingURL=constants.js.map |
@@ -142,3 +142,3 @@ /** | ||
AUTO_INIT_ATTR: 'data-mdc-auto-init', | ||
AUTO_INIT_STATE_ATTR: 'data-mdc-auto-init-state', | ||
DATASET_AUTO_INIT_STATE: 'mdcAutoInitState', | ||
INITIALIZED_STATE: 'initialized' | ||
@@ -198,21 +198,22 @@ }; | ||
var AUTO_INIT_ATTR = constants_1.strings.AUTO_INIT_ATTR, | ||
AUTO_INIT_STATE_ATTR = constants_1.strings.AUTO_INIT_STATE_ATTR, | ||
DATASET_AUTO_INIT_STATE = constants_1.strings.DATASET_AUTO_INIT_STATE, | ||
INITIALIZED_STATE = constants_1.strings.INITIALIZED_STATE; | ||
var registry = {}; | ||
var CONSOLE_WARN = console.warn.bind(console); // tslint:disable-line:no-console | ||
function emit(evtType, evtData, shouldBubble) { | ||
// tslint:disable-next-line:no-console | ||
var CONSOLE_WARN = console.warn.bind(console); | ||
function emit(eventType, eventData, shouldBubble) { | ||
if (shouldBubble === void 0) { | ||
shouldBubble = false; | ||
} | ||
var evt; | ||
var event; | ||
if (typeof CustomEvent === 'function') { | ||
evt = new CustomEvent(evtType, { | ||
event = new CustomEvent(eventType, { | ||
bubbles: shouldBubble, | ||
detail: evtData | ||
detail: eventData | ||
}); | ||
} else { | ||
evt = document.createEvent('CustomEvent'); | ||
evt.initCustomEvent(evtType, shouldBubble, false, evtData); | ||
event = document.createEvent('CustomEvent'); | ||
event.initCustomEvent(eventType, shouldBubble, false, eventData); | ||
} | ||
document.dispatchEvent(evt); | ||
document.dispatchEvent(event); | ||
} | ||
@@ -229,5 +230,5 @@ /* istanbul ignore next: optional argument is not a branch statement */ | ||
var components = []; | ||
var nodes = [].slice.call(root.querySelectorAll("[" + AUTO_INIT_ATTR + "]")); | ||
var nodes = Array.from(root.querySelectorAll("[" + AUTO_INIT_ATTR + "]")); | ||
nodes = nodes.filter(function (node) { | ||
return node.getAttribute(AUTO_INIT_STATE_ATTR) !== INITIALIZED_STATE; | ||
return node.dataset[DATASET_AUTO_INIT_STATE] !== INITIALIZED_STATE; | ||
}); | ||
@@ -241,3 +242,4 @@ try { | ||
} | ||
var Constructor = registry[ctorName]; // tslint:disable-line:variable-name | ||
// tslint:disable-next-line:enforce-name-casing | ||
var Constructor = registry[ctorName]; | ||
if (typeof Constructor !== 'function') { | ||
@@ -247,3 +249,4 @@ throw new Error("(mdc-auto-init) Could not find constructor in registry for " + ctorName); | ||
// TODO: Should we make an eslint rule for an attachTo() static method? | ||
// See https://github.com/Microsoft/TypeScript/issues/14600 for discussion of static interface support in TS | ||
// See https://github.com/Microsoft/TypeScript/issues/14600 for discussion | ||
// of static interface support in TS | ||
var component = Constructor.attachTo(node); | ||
@@ -257,3 +260,3 @@ Object.defineProperty(node, ctorName, { | ||
components.push(component); | ||
node.setAttribute(AUTO_INIT_STATE_ATTR, INITIALIZED_STATE); | ||
node.dataset[DATASET_AUTO_INIT_STATE] = INITIALIZED_STATE; | ||
} | ||
@@ -273,5 +276,7 @@ } catch (e_1_1) { | ||
exports.mdcAutoInit = mdcAutoInit; | ||
// Constructor is PascalCased because it is a direct reference to a class, rather than an instance of a class. | ||
// tslint:disable-next-line:variable-name | ||
mdcAutoInit.register = function (componentName, Constructor, warn) { | ||
// Constructor is PascalCased because it is a direct reference to a class, | ||
// rather than an instance of a class. | ||
mdcAutoInit.register = function (componentName, | ||
// tslint:disable-next-line:enforce-name-casing | ||
Constructor, warn) { | ||
if (warn === void 0) { | ||
@@ -278,0 +283,0 @@ warn = CONSOLE_WARN; |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("@material/auto-init",[],e):"object"==typeof exports?exports["auto-init"]=e():(t.mdc=t.mdc||{},t.mdc["auto-init"]=e())}(this,function(){return n={},o.m=r={137:function(t,e,r){"use strict";var d=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(e,"__esModule",{value:!0}),e.mdcAutoInit=void 0;var n=r(138),s=n.strings.AUTO_INIT_ATTR,v=n.strings.AUTO_INIT_STATE_ATTR,y=n.strings.INITIALIZED_STATE,b={},o=console.warn.bind(console);function i(t){var e,r;void 0===t&&(t=document);var n=[],o=[].slice.call(t.querySelectorAll("["+s+"]"));o=o.filter(function(t){return t.getAttribute(v)!==y});try{for(var i=d(o),u=i.next();!u.done;u=i.next()){var a=u.value,c=a.getAttribute(s);if(!c)throw new Error("(mdc-auto-init) Constructor name must be given.");var l=b[c];if("function"!=typeof l)throw new Error("(mdc-auto-init) Could not find constructor in registry for "+c);var f=l.attachTo(a);Object.defineProperty(a,c,{configurable:!0,enumerable:!1,value:f,writable:!1}),n.push(f),a.setAttribute(v,y)}}catch(t){e={error:t}}finally{try{u&&!u.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}return function(t,e,r){var n;void 0===r&&(r=!1),"function"==typeof CustomEvent?n=new CustomEvent(t,{bubbles:r,detail:e}):(n=document.createEvent("CustomEvent")).initCustomEvent(t,r,!1,e),document.dispatchEvent(n)}("MDCAutoInit:End",{}),n}(e.mdcAutoInit=i).register=function(t,e,r){if(void 0===r&&(r=o),"function"!=typeof e)throw new Error("(mdc-auto-init) Invalid Constructor value: "+e+". Expected function.");var n=b[t];n&&r("(mdc-auto-init) Overriding registration for "+t+" with "+e+". Was: "+n),b[t]=e},i.deregister=function(t){delete b[t]},i.deregisterAll=function(){var e,t;try{for(var r=d(Object.keys(b)),n=r.next();!n.done;n=r.next()){var o=n.value;i.deregister(o)}}catch(t){e={error:t}}finally{try{n&&!n.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}},e.default=i},138:function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.strings=void 0,e.strings={AUTO_INIT_ATTR:"data-mdc-auto-init",AUTO_INIT_STATE_ATTR:"data-mdc-auto-init-state",INITIALIZED_STATE:"initialized"}}},o.c=n,o.d=function(t,e,r){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(o.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)o.d(r,n,function(t){return e[t]}.bind(null,n));return r},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=137);function o(t){if(n[t])return n[t].exports;var e=n[t]={i:t,l:!1,exports:{}};return r[t].call(e.exports,e,e.exports,o),e.l=!0,e.exports}var r,n}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("@material/auto-init",[],e):"object"==typeof exports?exports["auto-init"]=e():(t.mdc=t.mdc||{},t.mdc["auto-init"]=e())}(this,function(){return n={},o.m=r={184:function(t,e,r){"use strict";var d=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(e,"__esModule",{value:!0}),e.mdcAutoInit=void 0;var n=r(185),s=n.strings.AUTO_INIT_ATTR,v=n.strings.DATASET_AUTO_INIT_STATE,y=n.strings.INITIALIZED_STATE,m={},o=console.warn.bind(console);function i(t){var e,r;void 0===t&&(t=document);var n=[],o=Array.from(t.querySelectorAll("["+s+"]"));o=o.filter(function(t){return t.dataset[v]!==y});try{for(var i=d(o),u=i.next();!u.done;u=i.next()){var a=u.value,c=a.getAttribute(s);if(!c)throw new Error("(mdc-auto-init) Constructor name must be given.");var f=m[c];if("function"!=typeof f)throw new Error("(mdc-auto-init) Could not find constructor in registry for "+c);var l=f.attachTo(a);Object.defineProperty(a,c,{configurable:!0,enumerable:!1,value:l,writable:!1}),n.push(l),a.dataset[v]=y}}catch(t){e={error:t}}finally{try{u&&!u.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}return function(t,e,r){var n;void 0===r&&(r=!1),"function"==typeof CustomEvent?n=new CustomEvent(t,{bubbles:r,detail:e}):(n=document.createEvent("CustomEvent")).initCustomEvent(t,r,!1,e),document.dispatchEvent(n)}("MDCAutoInit:End",{}),n}(e.mdcAutoInit=i).register=function(t,e,r){if(void 0===r&&(r=o),"function"!=typeof e)throw new Error("(mdc-auto-init) Invalid Constructor value: "+e+". Expected function.");var n=m[t];n&&r("(mdc-auto-init) Overriding registration for "+t+" with "+e+". Was: "+n),m[t]=e},i.deregister=function(t){delete m[t]},i.deregisterAll=function(){var e,t;try{for(var r=d(Object.keys(m)),n=r.next();!n.done;n=r.next()){var o=n.value;i.deregister(o)}}catch(t){e={error:t}}finally{try{n&&!n.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}},e.default=i},185:function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.strings=void 0,e.strings={AUTO_INIT_ATTR:"data-mdc-auto-init",DATASET_AUTO_INIT_STATE:"mdcAutoInitState",INITIALIZED_STATE:"initialized"}}},o.c=n,o.d=function(t,e,r){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(o.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)o.d(r,n,function(t){return e[t]}.bind(null,n));return r},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=184);function o(t){if(n[t])return n[t].exports;var e=n[t]={i:t,l:!1,exports:{}};return r[t].call(e.exports,e,e.exports,o),e.l=!0,e.exports}var r,n}); |
@@ -25,4 +25,5 @@ /** | ||
import { MDCFoundation } from '@material/base/foundation'; | ||
/** MDC Attachable */ | ||
export interface MDCAttachable extends Function { | ||
attachTo(root: Element): MDCComponent<MDCFoundation>; | ||
attachTo(root: HTMLElement): MDCComponent<MDCFoundation>; | ||
} | ||
@@ -32,3 +33,3 @@ /** | ||
*/ | ||
declare function mdcAutoInit(root?: Document): MDCComponent<MDCFoundation<{}>>[]; | ||
declare function mdcAutoInit(root?: ParentNode): MDCComponent<MDCFoundation<{}>>[]; | ||
declare namespace mdcAutoInit { | ||
@@ -35,0 +36,0 @@ var register: (componentName: string, Constructor: MDCAttachable, warn?: (...data: any[]) => void) => void; |
39
index.js
@@ -25,19 +25,20 @@ /** | ||
import { strings } from './constants'; | ||
var AUTO_INIT_ATTR = strings.AUTO_INIT_ATTR, AUTO_INIT_STATE_ATTR = strings.AUTO_INIT_STATE_ATTR, INITIALIZED_STATE = strings.INITIALIZED_STATE; | ||
var AUTO_INIT_ATTR = strings.AUTO_INIT_ATTR, DATASET_AUTO_INIT_STATE = strings.DATASET_AUTO_INIT_STATE, INITIALIZED_STATE = strings.INITIALIZED_STATE; | ||
var registry = {}; | ||
var CONSOLE_WARN = console.warn.bind(console); // tslint:disable-line:no-console | ||
function emit(evtType, evtData, shouldBubble) { | ||
// tslint:disable-next-line:no-console | ||
var CONSOLE_WARN = console.warn.bind(console); | ||
function emit(eventType, eventData, shouldBubble) { | ||
if (shouldBubble === void 0) { shouldBubble = false; } | ||
var evt; | ||
var event; | ||
if (typeof CustomEvent === 'function') { | ||
evt = new CustomEvent(evtType, { | ||
event = new CustomEvent(eventType, { | ||
bubbles: shouldBubble, | ||
detail: evtData, | ||
detail: eventData, | ||
}); | ||
} | ||
else { | ||
evt = document.createEvent('CustomEvent'); | ||
evt.initCustomEvent(evtType, shouldBubble, false, evtData); | ||
event = document.createEvent('CustomEvent'); | ||
event.initCustomEvent(eventType, shouldBubble, false, eventData); | ||
} | ||
document.dispatchEvent(evt); | ||
document.dispatchEvent(event); | ||
} | ||
@@ -52,4 +53,4 @@ /* istanbul ignore next: optional argument is not a branch statement */ | ||
var components = []; | ||
var nodes = [].slice.call(root.querySelectorAll("[" + AUTO_INIT_ATTR + "]")); | ||
nodes = nodes.filter(function (node) { return node.getAttribute(AUTO_INIT_STATE_ATTR) !== INITIALIZED_STATE; }); | ||
var nodes = Array.from(root.querySelectorAll("[" + AUTO_INIT_ATTR + "]")); | ||
nodes = nodes.filter(function (node) { return node.dataset[DATASET_AUTO_INIT_STATE] !== INITIALIZED_STATE; }); | ||
try { | ||
@@ -62,3 +63,4 @@ for (var nodes_1 = __values(nodes), nodes_1_1 = nodes_1.next(); !nodes_1_1.done; nodes_1_1 = nodes_1.next()) { | ||
} | ||
var Constructor = registry[ctorName]; // tslint:disable-line:variable-name | ||
// tslint:disable-next-line:enforce-name-casing | ||
var Constructor = registry[ctorName]; | ||
if (typeof Constructor !== 'function') { | ||
@@ -68,3 +70,4 @@ throw new Error("(mdc-auto-init) Could not find constructor in registry for " + ctorName); | ||
// TODO: Should we make an eslint rule for an attachTo() static method? | ||
// See https://github.com/Microsoft/TypeScript/issues/14600 for discussion of static interface support in TS | ||
// See https://github.com/Microsoft/TypeScript/issues/14600 for discussion | ||
// of static interface support in TS | ||
var component = Constructor.attachTo(node); | ||
@@ -78,3 +81,3 @@ Object.defineProperty(node, ctorName, { | ||
components.push(component); | ||
node.setAttribute(AUTO_INIT_STATE_ATTR, INITIALIZED_STATE); | ||
node.dataset[DATASET_AUTO_INIT_STATE] = INITIALIZED_STATE; | ||
} | ||
@@ -92,5 +95,7 @@ } | ||
} | ||
// Constructor is PascalCased because it is a direct reference to a class, rather than an instance of a class. | ||
// tslint:disable-next-line:variable-name | ||
mdcAutoInit.register = function (componentName, Constructor, warn) { | ||
// Constructor is PascalCased because it is a direct reference to a class, | ||
// rather than an instance of a class. | ||
mdcAutoInit.register = function (componentName, | ||
// tslint:disable-next-line:enforce-name-casing | ||
Constructor, warn) { | ||
if (warn === void 0) { warn = CONSOLE_WARN; } | ||
@@ -97,0 +102,0 @@ if (typeof Constructor !== 'function') { |
{ | ||
"name": "@material/auto-init", | ||
"description": "Declarative, easy-to-use auto-initialization for Material Components for the web", | ||
"version": "15.0.0-canary.9bfd12f01.0", | ||
"version": "15.0.0-canary.9cec94097.0", | ||
"main": "dist/mdc.autoInit.js", | ||
@@ -15,6 +15,6 @@ "module": "index.js", | ||
"dependencies": { | ||
"@material/base": "15.0.0-canary.9bfd12f01.0", | ||
"@material/base": "15.0.0-canary.9cec94097.0", | ||
"tslib": "^2.1.0" | ||
}, | ||
"gitHead": "ba7b0d01530df70f39142820ab69babfc9cf5b8e" | ||
"gitHead": "1a8019402daf97efb72456551503dfb3fa31466b" | ||
} |
@@ -68,3 +68,3 @@ <!--docs: | ||
```js | ||
document.querySelector('.mdc-text-field').MDCTextField.disabled = true; | ||
document.querySelector<HTMLElement>('.mdc-text-field').MDCTextField.disabled = true; | ||
``` | ||
@@ -71,0 +71,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
50059
523
+ Added@material/base@15.0.0-canary.9cec94097.0(transitive)
- Removed@material/base@15.0.0-canary.9bfd12f01.0(transitive)