@c2n/core 0.0.12 → 0.0.14
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/.tsbuildinfo +1 -1
- package/dist/dom-helper.d.ts +24 -0
- package/dist/dom-helper.d.ts.map +1 -1
- package/dist/dom-helper.js +79 -0
- package/dist/dom-helper.js.map +1 -1
- package/dist/lit-helper.d.ts +39 -0
- package/dist/lit-helper.d.ts.map +1 -1
- package/dist/lit-helper.js +91 -0
- package/dist/lit-helper.js.map +1 -1
- package/package.json +4 -3
package/dist/.tsbuildinfo
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"fileNames":["../../../node_modules/typescript/lib/lib.es5.d.ts","../../../node_modules/typescript/lib/lib.es2015.d.ts","../../../node_modules/typescript/lib/lib.es2016.d.ts","../../../node_modules/typescript/lib/lib.es2017.d.ts","../../../node_modules/typescript/lib/lib.es2018.d.ts","../../../node_modules/typescript/lib/lib.es2019.d.ts","../../../node_modules/typescript/lib/lib.es2020.d.ts","../../../node_modules/typescript/lib/lib.dom.d.ts","../../../node_modules/typescript/lib/lib.dom.iterable.d.ts","../../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../node_modules/typescript/lib/lib.es2016.intl.d.ts","../../../node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts","../../../node_modules/typescript/lib/lib.es2017.date.d.ts","../../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../node_modules/typescript/lib/lib.es2019.intl.d.ts","../../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../node_modules/typescript/lib/lib.es2020.date.d.ts","../../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../node_modules/typescript/lib/lib.es2020.number.d.ts","../../../node_modules/typescript/lib/lib.decorators.d.ts","../../../node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../../node_modules/lit-html/development/directive.d.ts","../../../node_modules/@types/trusted-types/lib/index.d.ts","../../../node_modules/lit-html/development/lit-html.d.ts","../../../node_modules/lit-html/development/directives/class-map.d.ts","../src/css-helper.ts","../src/data-helper.ts","../../../node_modules/lit-html/development/is-server.d.ts","../src/dom-helper.ts","../../../node_modules/@lit/reactive-element/development/decorators/base.d.ts","../../../node_modules/@lit/reactive-element/development/decorators/custom-element.d.ts","../src/element-helper.ts","../src/event-helper.ts","../src/lit-helper.ts","../../../node_modules/@lit/context/development/lib/create-context.d.ts","../../../node_modules/@lit/context/development/lib/context-request-event.d.ts","../../../node_modules/@lit/reactive-element/development/css-tag.d.ts","../../../node_modules/@lit/reactive-element/development/reactive-controller.d.ts","../../../node_modules/@lit/reactive-element/development/reactive-element.d.ts","../../../node_modules/@lit/context/development/lib/controllers/context-consumer.d.ts","../../../node_modules/@lit/context/development/lib/value-notifier.d.ts","../../../node_modules/@lit/context/development/lib/controllers/context-provider.d.ts","../../../node_modules/@lit/context/development/lib/context-root.d.ts","../../../node_modules/@lit/context/development/lib/decorators/provide.d.ts","../../../node_modules/@lit/context/development/lib/decorators/consume.d.ts","../../../node_modules/@lit/context/development/index.d.ts","../src/contexts/pager.ts","../src/controllers/breakpoints-observer.ts","../src/controllers/context-consumer.ts","../../../node_modules/lit-element/development/lit-element.d.ts","../../../node_modules/lit/development/index.d.ts","../src/controllers/virtual-scroll.ts"],"fileIdsList":[[61,62,66,68,69,70,71],[61],[61,65],[61,62,65,67],[62],[56],[63,64],[50,65],[50],[48,50],[48,49],[50,54,65,76],[72],[65],[65,72],[77],[51],[54],[57]],"fileInfos":[{"version":"bcd24271a113971ba9eb71ff8cb01bc6b0f872a85c23fdbe5d93065b375933cd","affectsGlobalScope":true,"impliedFormat":1},{"version":"3f88bedbeb09c6f5a6645cb24c7c55f1aa22d19ae96c8e6959cbd8b85a707bc6","impliedFormat":1},{"version":"7fe93b39b810eadd916be8db880dd7f0f7012a5cc6ffb62de8f62a2117fa6f1f","impliedFormat":1},{"version":"bb0074cc08b84a2374af33d8bf044b80851ccc9e719a5e202eacf40db2c31600","impliedFormat":1},{"version":"1a7daebe4f45fb03d9ec53d60008fbf9ac45a697fdc89e4ce218bc94b94f94d6","impliedFormat":1},{"version":"f94b133a3cb14a288803be545ac2683e0d0ff6661bcd37e31aaaec54fc382aed","impliedFormat":1},{"version":"f59d0650799f8782fd74cf73c19223730c6d1b9198671b1c5b3a38e1188b5953","impliedFormat":1},{"version":"d6b1eba8496bdd0eed6fc8a685768fe01b2da4a0388b5fe7df558290bffcf32f","affectsGlobalScope":true,"impliedFormat":1},{"version":"7f57fc4404ff020bc45b9c620aff2b40f700b95fe31164024c453a5e3c163c54","impliedFormat":1},{"version":"eadcffda2aa84802c73938e589b9e58248d74c59cb7fcbca6474e3435ac15504","affectsGlobalScope":true,"impliedFormat":1},{"version":"105ba8ff7ba746404fe1a2e189d1d3d2e0eb29a08c18dded791af02f29fb4711","affectsGlobalScope":true,"impliedFormat":1},{"version":"00343ca5b2e3d48fa5df1db6e32ea2a59afab09590274a6cccb1dbae82e60c7c","affectsGlobalScope":true,"impliedFormat":1},{"version":"ebd9f816d4002697cb2864bea1f0b70a103124e18a8cd9645eeccc09bdf80ab4","affectsGlobalScope":true,"impliedFormat":1},{"version":"2c1afac30a01772cd2a9a298a7ce7706b5892e447bb46bdbeef720f7b5da77ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"7b0225f483e4fa685625ebe43dd584bb7973bbd84e66a6ba7bbe175ee1048b4f","affectsGlobalScope":true,"impliedFormat":1},{"version":"c0a4b8ac6ce74679c1da2b3795296f5896e31c38e888469a8e0f99dc3305de60","affectsGlobalScope":true,"impliedFormat":1},{"version":"3084a7b5f569088e0146533a00830e206565de65cae2239509168b11434cd84f","affectsGlobalScope":true,"impliedFormat":1},{"version":"c5079c53f0f141a0698faa903e76cb41cd664e3efb01cc17a5c46ec2eb0bef42","affectsGlobalScope":true,"impliedFormat":1},{"version":"32cafbc484dea6b0ab62cf8473182bbcb23020d70845b406f80b7526f38ae862","affectsGlobalScope":true,"impliedFormat":1},{"version":"fca4cdcb6d6c5ef18a869003d02c9f0fd95df8cfaf6eb431cd3376bc034cad36","affectsGlobalScope":true,"impliedFormat":1},{"version":"b93ec88115de9a9dc1b602291b85baf825c85666bf25985cc5f698073892b467","affectsGlobalScope":true,"impliedFormat":1},{"version":"f5c06dcc3fe849fcb297c247865a161f995cc29de7aa823afdd75aaaddc1419b","affectsGlobalScope":true,"impliedFormat":1},{"version":"b77e16112127a4b169ef0b8c3a4d730edf459c5f25fe52d5e436a6919206c4d7","affectsGlobalScope":true,"impliedFormat":1},{"version":"fbffd9337146eff822c7c00acbb78b01ea7ea23987f6c961eba689349e744f8c","affectsGlobalScope":true,"impliedFormat":1},{"version":"a995c0e49b721312f74fdfb89e4ba29bd9824c770bbb4021d74d2bf560e4c6bd","affectsGlobalScope":true,"impliedFormat":1},{"version":"c7b3542146734342e440a84b213384bfa188835537ddbda50d30766f0593aff9","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce6180fa19b1cccd07ee7f7dbb9a367ac19c0ed160573e4686425060b6df7f57","affectsGlobalScope":true,"impliedFormat":1},{"version":"3f02e2476bccb9dbe21280d6090f0df17d2f66b74711489415a8aa4df73c9675","affectsGlobalScope":true,"impliedFormat":1},{"version":"45e3ab34c1c013c8ab2dc1ba4c80c780744b13b5676800ae2e3be27ae862c40c","affectsGlobalScope":true,"impliedFormat":1},{"version":"805c86f6cca8d7702a62a844856dbaa2a3fd2abef0536e65d48732441dde5b5b","affectsGlobalScope":true,"impliedFormat":1},{"version":"e42e397f1a5a77994f0185fd1466520691456c772d06bf843e5084ceb879a0ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"f4c2b41f90c95b1c532ecc874bd3c111865793b23aebcc1c3cbbabcd5d76ffb0","affectsGlobalScope":true,"impliedFormat":1},{"version":"ab26191cfad5b66afa11b8bf935ef1cd88fabfcb28d30b2dfa6fad877d050332","affectsGlobalScope":true,"impliedFormat":1},{"version":"2088bc26531e38fb05eedac2951480db5309f6be3fa4a08d2221abb0f5b4200d","affectsGlobalScope":true,"impliedFormat":1},{"version":"cb9d366c425fea79716a8fb3af0d78e6b22ebbab3bd64d25063b42dc9f531c1e","affectsGlobalScope":true,"impliedFormat":1},{"version":"500934a8089c26d57ebdb688fc9757389bb6207a3c8f0674d68efa900d2abb34","affectsGlobalScope":true,"impliedFormat":1},{"version":"689da16f46e647cef0d64b0def88910e818a5877ca5379ede156ca3afb780ac3","affectsGlobalScope":true,"impliedFormat":1},{"version":"bc21cc8b6fee4f4c2440d08035b7ea3c06b3511314c8bab6bef7a92de58a2593","affectsGlobalScope":true,"impliedFormat":1},{"version":"7ca53d13d2957003abb47922a71866ba7cb2068f8d154877c596d63c359fed25","affectsGlobalScope":true,"impliedFormat":1},{"version":"54725f8c4df3d900cb4dac84b64689ce29548da0b4e9b7c2de61d41c79293611","affectsGlobalScope":true,"impliedFormat":1},{"version":"e5594bc3076ac29e6c1ebda77939bc4c8833de72f654b6e376862c0473199323","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f3eb332c2d73e729f3364fcc0c2b375e72a121e8157d25a82d67a138c83a95c","affectsGlobalScope":true,"impliedFormat":1},{"version":"6f4427f9642ce8d500970e4e69d1397f64072ab73b97e476b4002a646ac743b1","affectsGlobalScope":true,"impliedFormat":1},{"version":"48915f327cd1dea4d7bd358d9dc7732f58f9e1626a29cc0c05c8c692419d9bb7","affectsGlobalScope":true,"impliedFormat":1},{"version":"b7bf9377723203b5a6a4b920164df22d56a43f593269ba6ae1fdc97774b68855","affectsGlobalScope":true,"impliedFormat":1},{"version":"1ce14b81c5cc821994aa8ec1d42b220dd41b27fcc06373bce3958af7421b77d4","affectsGlobalScope":true,"impliedFormat":1},{"version":"b3a048b3e9302ef9a34ef4ebb9aecfb28b66abb3bce577206a79fee559c230da","affectsGlobalScope":true,"impliedFormat":1},{"version":"00cb63103f9670f8094c238a4a7e252c8b4c06ba371fea5c44add7e41b7247e4","impliedFormat":99},{"version":"15fe687c59d62741b4494d5e623d497d55eb38966ecf5bea7f36e48fc3fbe15e","impliedFormat":1},{"version":"e09db3291e6b440f7debed2227d8357e80c95987a0d0d67ac17521d8f7b11bdb","impliedFormat":99},{"version":"9e77270468dc77ee3f0182f377a6022b37cce590cab79205c497cfb964ee2d20","impliedFormat":99},{"version":"f320b8514d20e37f6b957334b715d79c9781baf54fda8f9192c1dc38e16d449b","signature":"bb7529605ce5ea3a70da2155f39510884954a39abd51cf787eb8a303f1e3ca5d"},{"version":"8404c6b0cd89fd85702086ab27d550099cc9ccb1b6670fc6484da5efe71c3c41","signature":"3e18169106207e83a0a2bc59e357d1473584a83a25641474f105ab56fd9490b3"},{"version":"1bcd560deed90a43c51b08aa18f7f55229f2e30974ab5ed1b7bb5721be379013","impliedFormat":99},{"version":"52865298e93dc534cf51bac827c8064311b75eca118256721b7726553e4a3859","signature":"433215f0a8ea23a761650809ab2f6f00596010d56c9dc9e56953dab5fab52d93"},{"version":"cdeae34aca6700620ebf3f27cf7d439c3af97595dd6e2729fa4780483add5680","impliedFormat":99},{"version":"3ff87ea3471b51beaf4aa8fd8f4422862b11d343fdbb55bf383e0f8cc195a445","impliedFormat":99},{"version":"2d8757dd5fdb0b2f6c09f327d14f854202db1e3c0abf3e5d35c071055d167b92","signature":"0e50c13d260e97a5961bd202fe17232fb0301f668c3ba420beeecd213b0005e9"},{"version":"3e42659da436c840334cf9e989ab14009e5d3f5f62f75633d1d906c57f8634ab","signature":"a1ffd1c477e4c44624597d5a4232a6f4dc42dcda9f9b74ab2ff85f1819a95f18"},{"version":"9a626f36942689d75dc9a3b0f30e4f82218edec7daa65f561ee923fbbd322ddb","signature":"b86fc55138b5ae447f6665eb3dfa633bfacd5714e767caafef8ec437f8ea9008"},{"version":"7455f2d44bbd248413e4ab8c3ff847413d9ce327967dba66f0b51880f60fb653","impliedFormat":99},{"version":"9dd82c87281e106bdcb227550251fcc6b55a6eb555152bec5c6ce408345ffc57","affectsGlobalScope":true,"impliedFormat":99},{"version":"74012d464fbc5354ca3a7d5e71bee43b17da01a853c8ff10971bbe3680c76f40","impliedFormat":99},{"version":"5e30131b6a5587fe666926ad1d9807e733c0a597ed12d682669fcaa331aea576","impliedFormat":99},{"version":"a0f82d2f9450bd147a8c137798d9501bd49b7c9e118f75b07b76709ff39b6b55","affectsGlobalScope":true,"impliedFormat":99},{"version":"38df32d74f5cb92d08a7ace088d631e65fd4ae41fd1098ef74ad8efab03763ac","impliedFormat":99},{"version":"ff169075cb4df455eaa1dc4972416ae6981adca96429ed698a306da3d5a2e241","impliedFormat":99},{"version":"5dd01302b91c8fb2aea381396623c5463c47a41c1b5d675672a075c5d8aa164c","affectsGlobalScope":true,"impliedFormat":99},{"version":"f3731eb0da8be50797a04467e9021082654c55d6cbabaf17a9d505c0ff3033cc","impliedFormat":99},{"version":"6146b370459b8f7e81f61b7dd9022fb06509cc20d34514dc782c9ce538fd8ec9","impliedFormat":99},{"version":"a585baba6d92b7f5052a11c3a5d0bcc73657180bb6066cf70e1b4664df4e8363","impliedFormat":99},{"version":"1aacab8ad3bd52a3a508b9c07bb341d680448fc9ee45591708ded8113c1be517","impliedFormat":99},{"version":"375ccf781ce7f845db6d13839e6085e520dac2a024679528229823d402ba1edc","signature":"4d4573b5fe4e0012638e5faaf0d8f77365359ce60cde1b0bafc62f48400a7e3d"},{"version":"361aaaeedfa37b1da60c8017b07a9968062968f71561c479bc83944063f5804d","signature":"cc8929ab4c4e9be68dd16405c46e97463b36038700f49d070e2d24ee4139c87c"},{"version":"d719146ac4cda335a8e970ba5918cf154be98b83c6f4b3acb4c02f6617cd92f6","signature":"75f5083114303492bddf59e3b81debed86d2a422666bb2d7c69513ad64a61a26"},{"version":"9a318e3a8900672b85cd3c8c3a5acf51b88049557a3ae897ccdcf2b85a8f61f9","impliedFormat":99},{"version":"dc08fe04e50bc24d1baded4f33e942222bbdd5d77d6341a93cfe6e4e4586a3be","impliedFormat":99},{"version":"348c8e833a387ff25bdec06826c01c364738982079c2ba1cb390847141721ad1","signature":"a19c051036e9cb67b13b0b536c2ea9c8a8444e8797ece8db8963abd141f05017"}],"root":[52,53,55,[58,60],[73,75],78],"options":{"allowImportingTsExtensions":false,"allowSyntheticDefaultImports":true,"composite":true,"declaration":true,"declarationMap":true,"emitDeclarationOnly":false,"experimentalDecorators":true,"inlineSources":true,"module":99,"noFallthroughCasesInSwitch":true,"noImplicitAny":true,"noImplicitOverride":true,"noImplicitReturns":true,"noImplicitThis":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./","rootDir":"../src","skipLibCheck":true,"sourceMap":true,"strict":true,"target":7,"tsBuildInfoFile":"./.tsbuildinfo","useDefineForClassFields":false,"verbatimModuleSyntax":true},"referencedMap":[[72,1],[62,2],[66,3],[68,4],[71,3],[70,3],[67,5],[57,6],[65,7],[76,8],[48,9],[51,10],[50,11],[77,12],[73,13],[74,14],[75,15],[78,16],[52,17],[55,18],[58,19]],"latestChangedDtsFile":"./controllers/virtual-scroll.d.ts","version":"6.0.3"}
|
|
1
|
+
{"fileNames":["../../../node_modules/typescript/lib/lib.es5.d.ts","../../../node_modules/typescript/lib/lib.es2015.d.ts","../../../node_modules/typescript/lib/lib.es2016.d.ts","../../../node_modules/typescript/lib/lib.es2017.d.ts","../../../node_modules/typescript/lib/lib.es2018.d.ts","../../../node_modules/typescript/lib/lib.es2019.d.ts","../../../node_modules/typescript/lib/lib.es2020.d.ts","../../../node_modules/typescript/lib/lib.dom.d.ts","../../../node_modules/typescript/lib/lib.dom.iterable.d.ts","../../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../node_modules/typescript/lib/lib.es2016.intl.d.ts","../../../node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts","../../../node_modules/typescript/lib/lib.es2017.date.d.ts","../../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../node_modules/typescript/lib/lib.es2019.intl.d.ts","../../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../node_modules/typescript/lib/lib.es2020.date.d.ts","../../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../node_modules/typescript/lib/lib.es2020.number.d.ts","../../../node_modules/typescript/lib/lib.decorators.d.ts","../../../node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../../node_modules/lit-html/development/directive.d.ts","../../../node_modules/@types/trusted-types/lib/index.d.ts","../../../node_modules/lit-html/development/lit-html.d.ts","../../../node_modules/lit-html/development/directives/class-map.d.ts","../src/css-helper.ts","../src/data-helper.ts","../../../node_modules/lit-html/development/is-server.d.ts","../../../node_modules/@lit/reactive-element/development/css-tag.d.ts","../../../node_modules/@lit/reactive-element/development/reactive-controller.d.ts","../../../node_modules/@lit/reactive-element/development/reactive-element.d.ts","../../../node_modules/lit-element/development/lit-element.d.ts","../../../node_modules/lit/development/index.d.ts","../src/dom-helper.ts","../../../node_modules/@lit/reactive-element/development/decorators/base.d.ts","../../../node_modules/@lit/reactive-element/development/decorators/custom-element.d.ts","../src/element-helper.ts","../src/event-helper.ts","../../../node_modules/@lit/reactive-element/development/decorators/property.d.ts","../src/lit-helper.ts","../../../node_modules/@lit/context/development/lib/create-context.d.ts","../../../node_modules/@lit/context/development/lib/context-request-event.d.ts","../../../node_modules/@lit/context/development/lib/controllers/context-consumer.d.ts","../../../node_modules/@lit/context/development/lib/value-notifier.d.ts","../../../node_modules/@lit/context/development/lib/controllers/context-provider.d.ts","../../../node_modules/@lit/context/development/lib/context-root.d.ts","../../../node_modules/@lit/context/development/lib/decorators/provide.d.ts","../../../node_modules/@lit/context/development/lib/decorators/consume.d.ts","../../../node_modules/@lit/context/development/index.d.ts","../src/contexts/pager.ts","../src/controllers/breakpoints-observer.ts","../src/controllers/context-consumer.ts","../src/controllers/virtual-scroll.ts"],"fileIdsList":[[67,68,69,71,72,73,74],[67],[57,67],[57,67,68,70],[68],[61],[57,61],[55,56],[50,57],[50],[48,50],[48,49],[50,54,57,58],[75],[57],[57,75],[59],[51],[54,59],[62],[57,59,65]],"fileInfos":[{"version":"bcd24271a113971ba9eb71ff8cb01bc6b0f872a85c23fdbe5d93065b375933cd","affectsGlobalScope":true,"impliedFormat":1},{"version":"3f88bedbeb09c6f5a6645cb24c7c55f1aa22d19ae96c8e6959cbd8b85a707bc6","impliedFormat":1},{"version":"7fe93b39b810eadd916be8db880dd7f0f7012a5cc6ffb62de8f62a2117fa6f1f","impliedFormat":1},{"version":"bb0074cc08b84a2374af33d8bf044b80851ccc9e719a5e202eacf40db2c31600","impliedFormat":1},{"version":"1a7daebe4f45fb03d9ec53d60008fbf9ac45a697fdc89e4ce218bc94b94f94d6","impliedFormat":1},{"version":"f94b133a3cb14a288803be545ac2683e0d0ff6661bcd37e31aaaec54fc382aed","impliedFormat":1},{"version":"f59d0650799f8782fd74cf73c19223730c6d1b9198671b1c5b3a38e1188b5953","impliedFormat":1},{"version":"d6b1eba8496bdd0eed6fc8a685768fe01b2da4a0388b5fe7df558290bffcf32f","affectsGlobalScope":true,"impliedFormat":1},{"version":"7f57fc4404ff020bc45b9c620aff2b40f700b95fe31164024c453a5e3c163c54","impliedFormat":1},{"version":"eadcffda2aa84802c73938e589b9e58248d74c59cb7fcbca6474e3435ac15504","affectsGlobalScope":true,"impliedFormat":1},{"version":"105ba8ff7ba746404fe1a2e189d1d3d2e0eb29a08c18dded791af02f29fb4711","affectsGlobalScope":true,"impliedFormat":1},{"version":"00343ca5b2e3d48fa5df1db6e32ea2a59afab09590274a6cccb1dbae82e60c7c","affectsGlobalScope":true,"impliedFormat":1},{"version":"ebd9f816d4002697cb2864bea1f0b70a103124e18a8cd9645eeccc09bdf80ab4","affectsGlobalScope":true,"impliedFormat":1},{"version":"2c1afac30a01772cd2a9a298a7ce7706b5892e447bb46bdbeef720f7b5da77ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"7b0225f483e4fa685625ebe43dd584bb7973bbd84e66a6ba7bbe175ee1048b4f","affectsGlobalScope":true,"impliedFormat":1},{"version":"c0a4b8ac6ce74679c1da2b3795296f5896e31c38e888469a8e0f99dc3305de60","affectsGlobalScope":true,"impliedFormat":1},{"version":"3084a7b5f569088e0146533a00830e206565de65cae2239509168b11434cd84f","affectsGlobalScope":true,"impliedFormat":1},{"version":"c5079c53f0f141a0698faa903e76cb41cd664e3efb01cc17a5c46ec2eb0bef42","affectsGlobalScope":true,"impliedFormat":1},{"version":"32cafbc484dea6b0ab62cf8473182bbcb23020d70845b406f80b7526f38ae862","affectsGlobalScope":true,"impliedFormat":1},{"version":"fca4cdcb6d6c5ef18a869003d02c9f0fd95df8cfaf6eb431cd3376bc034cad36","affectsGlobalScope":true,"impliedFormat":1},{"version":"b93ec88115de9a9dc1b602291b85baf825c85666bf25985cc5f698073892b467","affectsGlobalScope":true,"impliedFormat":1},{"version":"f5c06dcc3fe849fcb297c247865a161f995cc29de7aa823afdd75aaaddc1419b","affectsGlobalScope":true,"impliedFormat":1},{"version":"b77e16112127a4b169ef0b8c3a4d730edf459c5f25fe52d5e436a6919206c4d7","affectsGlobalScope":true,"impliedFormat":1},{"version":"fbffd9337146eff822c7c00acbb78b01ea7ea23987f6c961eba689349e744f8c","affectsGlobalScope":true,"impliedFormat":1},{"version":"a995c0e49b721312f74fdfb89e4ba29bd9824c770bbb4021d74d2bf560e4c6bd","affectsGlobalScope":true,"impliedFormat":1},{"version":"c7b3542146734342e440a84b213384bfa188835537ddbda50d30766f0593aff9","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce6180fa19b1cccd07ee7f7dbb9a367ac19c0ed160573e4686425060b6df7f57","affectsGlobalScope":true,"impliedFormat":1},{"version":"3f02e2476bccb9dbe21280d6090f0df17d2f66b74711489415a8aa4df73c9675","affectsGlobalScope":true,"impliedFormat":1},{"version":"45e3ab34c1c013c8ab2dc1ba4c80c780744b13b5676800ae2e3be27ae862c40c","affectsGlobalScope":true,"impliedFormat":1},{"version":"805c86f6cca8d7702a62a844856dbaa2a3fd2abef0536e65d48732441dde5b5b","affectsGlobalScope":true,"impliedFormat":1},{"version":"e42e397f1a5a77994f0185fd1466520691456c772d06bf843e5084ceb879a0ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"f4c2b41f90c95b1c532ecc874bd3c111865793b23aebcc1c3cbbabcd5d76ffb0","affectsGlobalScope":true,"impliedFormat":1},{"version":"ab26191cfad5b66afa11b8bf935ef1cd88fabfcb28d30b2dfa6fad877d050332","affectsGlobalScope":true,"impliedFormat":1},{"version":"2088bc26531e38fb05eedac2951480db5309f6be3fa4a08d2221abb0f5b4200d","affectsGlobalScope":true,"impliedFormat":1},{"version":"cb9d366c425fea79716a8fb3af0d78e6b22ebbab3bd64d25063b42dc9f531c1e","affectsGlobalScope":true,"impliedFormat":1},{"version":"500934a8089c26d57ebdb688fc9757389bb6207a3c8f0674d68efa900d2abb34","affectsGlobalScope":true,"impliedFormat":1},{"version":"689da16f46e647cef0d64b0def88910e818a5877ca5379ede156ca3afb780ac3","affectsGlobalScope":true,"impliedFormat":1},{"version":"bc21cc8b6fee4f4c2440d08035b7ea3c06b3511314c8bab6bef7a92de58a2593","affectsGlobalScope":true,"impliedFormat":1},{"version":"7ca53d13d2957003abb47922a71866ba7cb2068f8d154877c596d63c359fed25","affectsGlobalScope":true,"impliedFormat":1},{"version":"54725f8c4df3d900cb4dac84b64689ce29548da0b4e9b7c2de61d41c79293611","affectsGlobalScope":true,"impliedFormat":1},{"version":"e5594bc3076ac29e6c1ebda77939bc4c8833de72f654b6e376862c0473199323","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f3eb332c2d73e729f3364fcc0c2b375e72a121e8157d25a82d67a138c83a95c","affectsGlobalScope":true,"impliedFormat":1},{"version":"6f4427f9642ce8d500970e4e69d1397f64072ab73b97e476b4002a646ac743b1","affectsGlobalScope":true,"impliedFormat":1},{"version":"48915f327cd1dea4d7bd358d9dc7732f58f9e1626a29cc0c05c8c692419d9bb7","affectsGlobalScope":true,"impliedFormat":1},{"version":"b7bf9377723203b5a6a4b920164df22d56a43f593269ba6ae1fdc97774b68855","affectsGlobalScope":true,"impliedFormat":1},{"version":"1ce14b81c5cc821994aa8ec1d42b220dd41b27fcc06373bce3958af7421b77d4","affectsGlobalScope":true,"impliedFormat":1},{"version":"b3a048b3e9302ef9a34ef4ebb9aecfb28b66abb3bce577206a79fee559c230da","affectsGlobalScope":true,"impliedFormat":1},{"version":"00cb63103f9670f8094c238a4a7e252c8b4c06ba371fea5c44add7e41b7247e4","impliedFormat":99},{"version":"15fe687c59d62741b4494d5e623d497d55eb38966ecf5bea7f36e48fc3fbe15e","impliedFormat":1},{"version":"e09db3291e6b440f7debed2227d8357e80c95987a0d0d67ac17521d8f7b11bdb","impliedFormat":99},{"version":"9e77270468dc77ee3f0182f377a6022b37cce590cab79205c497cfb964ee2d20","impliedFormat":99},{"version":"f320b8514d20e37f6b957334b715d79c9781baf54fda8f9192c1dc38e16d449b","signature":"bb7529605ce5ea3a70da2155f39510884954a39abd51cf787eb8a303f1e3ca5d"},{"version":"8404c6b0cd89fd85702086ab27d550099cc9ccb1b6670fc6484da5efe71c3c41","signature":"3e18169106207e83a0a2bc59e357d1473584a83a25641474f105ab56fd9490b3"},{"version":"1bcd560deed90a43c51b08aa18f7f55229f2e30974ab5ed1b7bb5721be379013","impliedFormat":99},{"version":"74012d464fbc5354ca3a7d5e71bee43b17da01a853c8ff10971bbe3680c76f40","impliedFormat":99},{"version":"5e30131b6a5587fe666926ad1d9807e733c0a597ed12d682669fcaa331aea576","impliedFormat":99},{"version":"a0f82d2f9450bd147a8c137798d9501bd49b7c9e118f75b07b76709ff39b6b55","affectsGlobalScope":true,"impliedFormat":99},{"version":"9a318e3a8900672b85cd3c8c3a5acf51b88049557a3ae897ccdcf2b85a8f61f9","impliedFormat":99},{"version":"dc08fe04e50bc24d1baded4f33e942222bbdd5d77d6341a93cfe6e4e4586a3be","impliedFormat":99},{"version":"00355f69398fa5d25778aefb29561e3718687fb930308c7b25bf40d951592152","signature":"06c27bacf3b20a46a0702910aff8d9ad4817681d7b3e14f450f856ba78ea7f76"},{"version":"cdeae34aca6700620ebf3f27cf7d439c3af97595dd6e2729fa4780483add5680","impliedFormat":99},{"version":"3ff87ea3471b51beaf4aa8fd8f4422862b11d343fdbb55bf383e0f8cc195a445","impliedFormat":99},{"version":"2d8757dd5fdb0b2f6c09f327d14f854202db1e3c0abf3e5d35c071055d167b92","signature":"0e50c13d260e97a5961bd202fe17232fb0301f668c3ba420beeecd213b0005e9"},{"version":"3e42659da436c840334cf9e989ab14009e5d3f5f62f75633d1d906c57f8634ab","signature":"a1ffd1c477e4c44624597d5a4232a6f4dc42dcda9f9b74ab2ff85f1819a95f18"},{"version":"99bdf729529cdbf12e2bf76ea751b662011133dcf9e35abcb3def47bb02f7b0a","impliedFormat":99},{"version":"e3ae5966ff412fa4b84b44359d356282194623750eadd8e3e20c0763efc6c811","signature":"f0223b66a3c156c00a5815a5853cbaf830636dc53bd6c328ee8389be92eec8e6"},{"version":"7455f2d44bbd248413e4ab8c3ff847413d9ce327967dba66f0b51880f60fb653","impliedFormat":99},{"version":"9dd82c87281e106bdcb227550251fcc6b55a6eb555152bec5c6ce408345ffc57","affectsGlobalScope":true,"impliedFormat":99},{"version":"38df32d74f5cb92d08a7ace088d631e65fd4ae41fd1098ef74ad8efab03763ac","impliedFormat":99},{"version":"ff169075cb4df455eaa1dc4972416ae6981adca96429ed698a306da3d5a2e241","impliedFormat":99},{"version":"5dd01302b91c8fb2aea381396623c5463c47a41c1b5d675672a075c5d8aa164c","affectsGlobalScope":true,"impliedFormat":99},{"version":"f3731eb0da8be50797a04467e9021082654c55d6cbabaf17a9d505c0ff3033cc","impliedFormat":99},{"version":"6146b370459b8f7e81f61b7dd9022fb06509cc20d34514dc782c9ce538fd8ec9","impliedFormat":99},{"version":"a585baba6d92b7f5052a11c3a5d0bcc73657180bb6066cf70e1b4664df4e8363","impliedFormat":99},{"version":"1aacab8ad3bd52a3a508b9c07bb341d680448fc9ee45591708ded8113c1be517","impliedFormat":99},{"version":"375ccf781ce7f845db6d13839e6085e520dac2a024679528229823d402ba1edc","signature":"4d4573b5fe4e0012638e5faaf0d8f77365359ce60cde1b0bafc62f48400a7e3d"},{"version":"361aaaeedfa37b1da60c8017b07a9968062968f71561c479bc83944063f5804d","signature":"cc8929ab4c4e9be68dd16405c46e97463b36038700f49d070e2d24ee4139c87c"},{"version":"d719146ac4cda335a8e970ba5918cf154be98b83c6f4b3acb4c02f6617cd92f6","signature":"75f5083114303492bddf59e3b81debed86d2a422666bb2d7c69513ad64a61a26"},{"version":"348c8e833a387ff25bdec06826c01c364738982079c2ba1cb390847141721ad1","signature":"a19c051036e9cb67b13b0b536c2ea9c8a8444e8797ece8db8963abd141f05017"}],"root":[52,53,60,63,64,66,[76,79]],"options":{"allowImportingTsExtensions":false,"allowSyntheticDefaultImports":true,"composite":true,"declaration":true,"declarationMap":true,"emitDeclarationOnly":false,"experimentalDecorators":true,"inlineSources":true,"module":99,"noFallthroughCasesInSwitch":true,"noImplicitAny":true,"noImplicitOverride":true,"noImplicitReturns":true,"noImplicitThis":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./","rootDir":"../src","skipLibCheck":true,"sourceMap":true,"strict":true,"target":7,"tsBuildInfoFile":"./.tsbuildinfo","useDefineForClassFields":false,"verbatimModuleSyntax":true},"referencedMap":[[75,1],[68,2],[69,3],[71,4],[74,3],[73,3],[70,5],[62,6],[65,7],[57,8],[58,9],[48,10],[51,11],[50,12],[59,13],[76,14],[77,15],[78,16],[79,17],[52,18],[60,19],[63,20],[66,21]],"latestChangedDtsFile":"./controllers/virtual-scroll.d.ts","version":"6.0.3"}
|
package/dist/dom-helper.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ReactiveController, ReactiveControllerHost } from 'lit';
|
|
1
2
|
export declare const Breakpoints: {
|
|
2
3
|
Phone: string;
|
|
3
4
|
Tablet: string;
|
|
@@ -15,6 +16,28 @@ export declare function redispatchEvent(host: HTMLElement, event: Event): boolea
|
|
|
15
16
|
* Returns `false` on the server, where the light DOM is not available.
|
|
16
17
|
*/
|
|
17
18
|
export declare function hasSlottedContent(host: Element, name?: string): boolean;
|
|
19
|
+
export type SlotPresence = 'unknown' | 'present' | 'empty';
|
|
20
|
+
type SlotPresenceHost = HTMLElement & ReactiveControllerHost & {
|
|
21
|
+
readonly updateComplete: Promise<boolean>;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Tracks whether named light-DOM regions contain meaningful content without hiding authored SSR content.
|
|
25
|
+
*
|
|
26
|
+
* The server cannot inspect a custom element's light DOM, so every region starts as `unknown`, which is rendered
|
|
27
|
+
* conservatively as present. Client-created elements resolve directly from their children before the first update.
|
|
28
|
+
* An element adopting declarative shadow DOM waits until Lit has completed that initial hydration pass, then requests
|
|
29
|
+
* one safe reconciliation update. Later slot changes use the same element/non-whitespace-text predicate.
|
|
30
|
+
*/
|
|
31
|
+
export declare class SlotPresenceController implements ReactiveController {
|
|
32
|
+
#private;
|
|
33
|
+
constructor(host: SlotPresenceHost, names: readonly string[]);
|
|
34
|
+
state(name?: string): SlotPresence;
|
|
35
|
+
/** Unknown is intentionally visible until the client has authoritative assignment information. */
|
|
36
|
+
has(name?: string): boolean;
|
|
37
|
+
readonly handleSlotChange: (event: Event) => void;
|
|
38
|
+
hostConnected(): void;
|
|
39
|
+
hostUpdated(): void;
|
|
40
|
+
}
|
|
18
41
|
/**
|
|
19
42
|
* Counted page-scroll lock, shared by every overlay so nested ones restore in the right order: a sheet that opens a
|
|
20
43
|
* modal and closes after it must not hand the page back while the modal is still up. Call the returned function to
|
|
@@ -23,4 +46,5 @@ export declare function hasSlottedContent(host: Element, name?: string): boolean
|
|
|
23
46
|
export declare function lockPageScroll(): () => void;
|
|
24
47
|
export declare function smartFixedPosition(fixed: boolean): void;
|
|
25
48
|
export declare function convertToUnit(str: string | number | null | undefined, unit?: string): string | undefined;
|
|
49
|
+
export {};
|
|
26
50
|
//# sourceMappingURL=dom-helper.d.ts.map
|
package/dist/dom-helper.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom-helper.d.ts","sourceRoot":"","sources":["../src/dom-helper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dom-helper.d.ts","sourceRoot":"","sources":["../src/dom-helper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,KAAK,CAAA;AAErE,eAAO,MAAM,WAAW;;;;CAIvB,CAAA;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,WAW9D;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,SAAK,GAAG,OAAO,CAUnE;AAED,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAA;AAE1D,KAAK,gBAAgB,GAAG,WAAW,GAAG,sBAAsB,GAAG;IAAE,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC,OAAO,CAAC,CAAA;CAAE,CAAA;AAM5G;;;;;;;GAOG;AACH,qBAAa,sBAAuB,YAAW,kBAAkB;;gBAOnD,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE;IAM5D,KAAK,CAAC,IAAI,SAAK,GAAG,YAAY;IAI9B,kGAAkG;IAClG,GAAG,CAAC,IAAI,SAAK,GAAG,OAAO;IAIvB,QAAQ,CAAC,gBAAgB,GAAI,OAAO,KAAK,KAAG,IAAI,CAG/C;IAED,aAAa,IAAI,IAAI;IAYrB,WAAW,IAAI,IAAI;CAiBpB;AAKD;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,MAAM,IAAI,CAY3C;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,QAkChD;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,IAAI,SAAO,GAAG,MAAM,GAAG,SAAS,CAUtG"}
|
package/dist/dom-helper.js
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _SlotPresenceController_instances, _SlotPresenceController_host, _SlotPresenceController_presence, _SlotPresenceController_hydrating, _SlotPresenceController_reconciled, _SlotPresenceController_connected, _SlotPresenceController_resolveFromLightDom, _SlotPresenceController_set;
|
|
1
13
|
import { isServer } from 'lit-html/is-server.js';
|
|
2
14
|
export const Breakpoints = {
|
|
3
15
|
Phone: '(max-width: 599.98px)',
|
|
@@ -39,6 +51,73 @@ export function hasSlottedContent(host, name = '') {
|
|
|
39
51
|
}
|
|
40
52
|
return false;
|
|
41
53
|
}
|
|
54
|
+
function hasMeaningfulSlotNode(node) {
|
|
55
|
+
return node.nodeType === Node.ELEMENT_NODE || (node.textContent ?? '').trim() !== '';
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Tracks whether named light-DOM regions contain meaningful content without hiding authored SSR content.
|
|
59
|
+
*
|
|
60
|
+
* The server cannot inspect a custom element's light DOM, so every region starts as `unknown`, which is rendered
|
|
61
|
+
* conservatively as present. Client-created elements resolve directly from their children before the first update.
|
|
62
|
+
* An element adopting declarative shadow DOM waits until Lit has completed that initial hydration pass, then requests
|
|
63
|
+
* one safe reconciliation update. Later slot changes use the same element/non-whitespace-text predicate.
|
|
64
|
+
*/
|
|
65
|
+
export class SlotPresenceController {
|
|
66
|
+
constructor(host, names) {
|
|
67
|
+
_SlotPresenceController_instances.add(this);
|
|
68
|
+
_SlotPresenceController_host.set(this, void 0);
|
|
69
|
+
_SlotPresenceController_presence.set(this, new Map());
|
|
70
|
+
_SlotPresenceController_hydrating.set(this, false);
|
|
71
|
+
_SlotPresenceController_reconciled.set(this, false);
|
|
72
|
+
_SlotPresenceController_connected.set(this, false);
|
|
73
|
+
this.handleSlotChange = (event) => {
|
|
74
|
+
const slot = event.target;
|
|
75
|
+
__classPrivateFieldGet(this, _SlotPresenceController_instances, "m", _SlotPresenceController_set).call(this, slot.name, slot.assignedNodes({ flatten: true }).some(hasMeaningfulSlotNode), true);
|
|
76
|
+
};
|
|
77
|
+
__classPrivateFieldSet(this, _SlotPresenceController_host, host, "f");
|
|
78
|
+
for (const name of names)
|
|
79
|
+
__classPrivateFieldGet(this, _SlotPresenceController_presence, "f").set(name, 'unknown');
|
|
80
|
+
host.addController(this);
|
|
81
|
+
}
|
|
82
|
+
state(name = '') {
|
|
83
|
+
return __classPrivateFieldGet(this, _SlotPresenceController_presence, "f").get(name) ?? 'unknown';
|
|
84
|
+
}
|
|
85
|
+
/** Unknown is intentionally visible until the client has authoritative assignment information. */
|
|
86
|
+
has(name = '') {
|
|
87
|
+
return this.state(name) !== 'empty';
|
|
88
|
+
}
|
|
89
|
+
hostConnected() {
|
|
90
|
+
if (isServer)
|
|
91
|
+
return;
|
|
92
|
+
if (__classPrivateFieldGet(this, _SlotPresenceController_connected, "f")) {
|
|
93
|
+
__classPrivateFieldGet(this, _SlotPresenceController_instances, "m", _SlotPresenceController_resolveFromLightDom).call(this, true);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
__classPrivateFieldSet(this, _SlotPresenceController_connected, true, "f");
|
|
97
|
+
__classPrivateFieldSet(this, _SlotPresenceController_hydrating, Boolean(__classPrivateFieldGet(this, _SlotPresenceController_host, "f").shadowRoot?.hasChildNodes()), "f");
|
|
98
|
+
if (!__classPrivateFieldGet(this, _SlotPresenceController_hydrating, "f"))
|
|
99
|
+
__classPrivateFieldGet(this, _SlotPresenceController_instances, "m", _SlotPresenceController_resolveFromLightDom).call(this, false);
|
|
100
|
+
}
|
|
101
|
+
hostUpdated() {
|
|
102
|
+
if (!__classPrivateFieldGet(this, _SlotPresenceController_hydrating, "f") || __classPrivateFieldGet(this, _SlotPresenceController_reconciled, "f"))
|
|
103
|
+
return;
|
|
104
|
+
__classPrivateFieldSet(this, _SlotPresenceController_reconciled, true, "f");
|
|
105
|
+
void __classPrivateFieldGet(this, _SlotPresenceController_host, "f").updateComplete.then(() => __classPrivateFieldGet(this, _SlotPresenceController_instances, "m", _SlotPresenceController_resolveFromLightDom).call(this, true));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
_SlotPresenceController_host = new WeakMap(), _SlotPresenceController_presence = new WeakMap(), _SlotPresenceController_hydrating = new WeakMap(), _SlotPresenceController_reconciled = new WeakMap(), _SlotPresenceController_connected = new WeakMap(), _SlotPresenceController_instances = new WeakSet(), _SlotPresenceController_resolveFromLightDom = function _SlotPresenceController_resolveFromLightDom(notify) {
|
|
109
|
+
for (const name of __classPrivateFieldGet(this, _SlotPresenceController_presence, "f").keys())
|
|
110
|
+
__classPrivateFieldGet(this, _SlotPresenceController_instances, "m", _SlotPresenceController_set).call(this, name, hasSlottedContent(__classPrivateFieldGet(this, _SlotPresenceController_host, "f"), name), notify);
|
|
111
|
+
}, _SlotPresenceController_set = function _SlotPresenceController_set(name, present, notify) {
|
|
112
|
+
if (!__classPrivateFieldGet(this, _SlotPresenceController_presence, "f").has(name))
|
|
113
|
+
return;
|
|
114
|
+
const next = present ? 'present' : 'empty';
|
|
115
|
+
if (__classPrivateFieldGet(this, _SlotPresenceController_presence, "f").get(name) === next)
|
|
116
|
+
return;
|
|
117
|
+
__classPrivateFieldGet(this, _SlotPresenceController_presence, "f").set(name, next);
|
|
118
|
+
if (notify)
|
|
119
|
+
__classPrivateFieldGet(this, _SlotPresenceController_host, "f").requestUpdate();
|
|
120
|
+
};
|
|
42
121
|
let scrollLocks = 0;
|
|
43
122
|
let previousOverflow = '';
|
|
44
123
|
/**
|
package/dist/dom-helper.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom-helper.js","sourceRoot":"","sources":["../src/dom-helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAEhD,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,KAAK,EAAE,uBAAuB;IAC9B,MAAM,EAAE,8CAA8C;IACtD,O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cAAc,CAAC,wBAAwB,CAAC,CAAA;QACjD,EAAE,CAAC,UAAU,GAAG,CAAC,CAAC,CAAA;QAClB,EAAE,CAAC,SAAS,GAAG,CAAC,CAAC,CAAA;IACnB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,GAAuC,EAAE,IAAI,GAAG,IAAI;IAChF,IAAI,GAAG,IAAI,IAAI,IAAI,GAAG,KAAK,EAAE,EAAE,CAAC;QAC9B,OAAO,SAAS,CAAA;IAClB,CAAC;SAAM,IAAI,KAAK,CAAC,CAAC,GAAI,CAAC,EAAE,CAAC;QACxB,OAAO,MAAM,CAAC,GAAG,CAAC,CAAA;IACpB,CAAC;SAAM,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAI,CAAC,EAAE,CAAC;QAC5B,OAAO,SAAS,CAAA;IAClB,CAAC;SAAM,CAAC;QACN,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,CAAA;IAChC,CAAC;AACH,CAAC","sourcesContent":["import { isServer } from 'lit-html/is-server.js'\n\nexport const Breakpoints = {\n Phone: '(max-width: 599.98px)',\n Tablet: '(min-width: 600px) and (max-width: 959.98px)',\n Desktop: '(min-width: 960px)',\n}\n\nexport function redispatchEvent(host: HTMLElement, event: Event) {\n if (event.bubbles) {\n event.stopPropagation()\n }\n\n const copy = Reflect.construct(event.constructor, [event.type, event])\n const dispatched = host.dispatchEvent(copy)\n if (!dispatched) {\n event.preventDefault()\n }\n return dispatched\n}\n\n/**\n * Whether the host has light-DOM content for a slot — the default slot when `name` is omitted — read from its\n * children rather than from `assignedNodes()`, so the answer is available before the first render.\n *\n * A component that hides a row when its slot is empty needs the flag for the first paint. Reading the slots in\n * `firstUpdated` sets state after an update and costs a second render (Lit's `change-in-update` warning), and a\n * server-rendered slot never fires `slotchange`, so the flag cannot start as `false` and wait for the event. Read\n * this in `willUpdate` before the first update instead, and let `slotchange` keep the flag current afterwards.\n * Returns `false` on the server, where the light DOM is not available.\n */\nexport function hasSlottedContent(host: Element, name = ''): boolean {\n if (isServer) return false\n for (const node of host.childNodes) {\n if (node.nodeType === Node.ELEMENT_NODE) {\n if (((node as Element).getAttribute('slot') ?? '') === name) return true\n } else if (name === '' && node.nodeType === Node.TEXT_NODE && (node.textContent ?? '').trim() !== '') {\n return true\n }\n }\n return false\n}\n\nlet scrollLocks = 0\nlet previousOverflow = ''\n\n/**\n * Counted page-scroll lock, shared by every overlay so nested ones restore in the right order: a sheet that opens a\n * modal and closes after it must not hand the page back while the modal is still up. Call the returned function to\n * release; releasing twice is a no-op.\n */\nexport function lockPageScroll(): () => void {\n if (isServer) return () => {}\n if (scrollLocks++ === 0) {\n previousOverflow = document.documentElement.style.overflow\n document.documentElement.style.overflow = 'hidden'\n }\n let released = false\n return () => {\n if (released) return\n released = true\n if (--scrollLocks === 0) document.documentElement.style.overflow = previousOverflow\n }\n}\n\nexport function smartFixedPosition(fixed: boolean) {\n if (isServer) return\n const el = document.documentElement\n const scrollbarWidth = window.innerWidth - document.documentElement.offsetWidth\n if (fixed) {\n el.style.setProperty('--c2n-body-scroll-x', convertToUnit(-el.scrollLeft)!)\n el.style.setProperty('--c2n-body-scroll-y', convertToUnit(-el.scrollTop)!)\n el.style.setProperty('--c2n-scrollbar-offset', convertToUnit(scrollbarWidth)!)\n\n el.style.setProperty('overflow', 'hidden')\n el.style.setProperty('padding-inline-end', 'var(--c2n-scrollbar-offset)')\n el.style.setProperty('position', 'fixed')\n el.style.setProperty('top', 'var(--c2n-body-scroll-y)')\n el.style.setProperty('left', 'var(--c2n-body-scroll-x)')\n el.style.setProperty('width', '100%')\n el.style.setProperty('height', '100%')\n } else if (el.style.getPropertyValue('--c2n-body-scroll-x')) {\n const x = parseFloat(el.style.getPropertyValue('--c2n-body-scroll-x'))\n const y = parseFloat(el.style.getPropertyValue('--c2n-body-scroll-y'))\n\n el.style.removeProperty('overflow')\n el.style.removeProperty('padding-inline-end')\n el.style.removeProperty('position')\n el.style.removeProperty('top')\n el.style.removeProperty('left')\n el.style.removeProperty('width')\n el.style.removeProperty('height')\n\n el.style.removeProperty('--c2n-body-scroll-x')\n el.style.removeProperty('--c2n-body-scroll-y')\n el.style.removeProperty('--c2n-scrollbar-offset')\n el.scrollLeft = -x\n el.scrollTop = -y\n }\n}\n\nexport function convertToUnit(str: string | number | null | undefined, unit = 'px'): string | undefined {\n if (str == null || str === '') {\n return undefined\n } else if (isNaN(+str!)) {\n return String(str)\n } else if (!isFinite(+str!)) {\n return undefined\n } else {\n return `${Number(str)}${unit}`\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dom-helper.js","sourceRoot":"","sources":["../src/dom-helper.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAGhD,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,KAAK,EAAE,uBAAuB;IAC9B,MAAM,EAAE,8CAA8C;IACtD,OAAO,EAAE,oBAAoB;CAC9B,CAAA;AAED,MAAM,UAAU,eAAe,CAAC,IAAiB,EAAE,KAAY;IAC7D,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;QAClB,KAAK,CAAC,eAAe,EAAE,CAAA;IACzB,CAAC;IAED,MAAM,IAAI,GAAG,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAA;IACtE,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAA;IAC3C,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,KAAK,CAAC,cAAc,EAAE,CAAA;IACxB,CAAC;IACD,OAAO,UAAU,CAAA;AACnB,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAa,EAAE,IAAI,GAAG,EAAE;IACxD,IAAI,QAAQ;QAAE,OAAO,KAAK,CAAA;IAC1B,KAAK,MAAM,IAAI,IAAI,IAAI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SAAM,CAAC;QACN,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,CAAA;IAChC,CAAC;AACH,CAAC","sourcesContent":["import { isServer } from 'lit-html/is-server.js'\nimport type { ReactiveController, ReactiveControllerHost } from 'lit'\n\nexport const Breakpoints = {\n Phone: '(max-width: 599.98px)',\n Tablet: '(min-width: 600px) and (max-width: 959.98px)',\n Desktop: '(min-width: 960px)',\n}\n\nexport function redispatchEvent(host: HTMLElement, event: Event) {\n if (event.bubbles) {\n event.stopPropagation()\n }\n\n const copy = Reflect.construct(event.constructor, [event.type, event])\n const dispatched = host.dispatchEvent(copy)\n if (!dispatched) {\n event.preventDefault()\n }\n return dispatched\n}\n\n/**\n * Whether the host has light-DOM content for a slot — the default slot when `name` is omitted — read from its\n * children rather than from `assignedNodes()`, so the answer is available before the first render.\n *\n * A component that hides a row when its slot is empty needs the flag for the first paint. Reading the slots in\n * `firstUpdated` sets state after an update and costs a second render (Lit's `change-in-update` warning), and a\n * server-rendered slot never fires `slotchange`, so the flag cannot start as `false` and wait for the event. Read\n * this in `willUpdate` before the first update instead, and let `slotchange` keep the flag current afterwards.\n * Returns `false` on the server, where the light DOM is not available.\n */\nexport function hasSlottedContent(host: Element, name = ''): boolean {\n if (isServer) return false\n for (const node of host.childNodes) {\n if (node.nodeType === Node.ELEMENT_NODE) {\n if (((node as Element).getAttribute('slot') ?? '') === name) return true\n } else if (name === '' && node.nodeType === Node.TEXT_NODE && (node.textContent ?? '').trim() !== '') {\n return true\n }\n }\n return false\n}\n\nexport type SlotPresence = 'unknown' | 'present' | 'empty'\n\ntype SlotPresenceHost = HTMLElement & ReactiveControllerHost & { readonly updateComplete: Promise<boolean> }\n\nfunction hasMeaningfulSlotNode(node: Node): boolean {\n return node.nodeType === Node.ELEMENT_NODE || (node.textContent ?? '').trim() !== ''\n}\n\n/**\n * Tracks whether named light-DOM regions contain meaningful content without hiding authored SSR content.\n *\n * The server cannot inspect a custom element's light DOM, so every region starts as `unknown`, which is rendered\n * conservatively as present. Client-created elements resolve directly from their children before the first update.\n * An element adopting declarative shadow DOM waits until Lit has completed that initial hydration pass, then requests\n * one safe reconciliation update. Later slot changes use the same element/non-whitespace-text predicate.\n */\nexport class SlotPresenceController implements ReactiveController {\n readonly #host: SlotPresenceHost\n readonly #presence = new Map<string, SlotPresence>()\n #hydrating = false\n #reconciled = false\n #connected = false\n\n constructor(host: SlotPresenceHost, names: readonly string[]) {\n this.#host = host\n for (const name of names) this.#presence.set(name, 'unknown')\n host.addController(this)\n }\n\n state(name = ''): SlotPresence {\n return this.#presence.get(name) ?? 'unknown'\n }\n\n /** Unknown is intentionally visible until the client has authoritative assignment information. */\n has(name = ''): boolean {\n return this.state(name) !== 'empty'\n }\n\n readonly handleSlotChange = (event: Event): void => {\n const slot = event.target as HTMLSlotElement\n this.#set(slot.name, slot.assignedNodes({ flatten: true }).some(hasMeaningfulSlotNode), true)\n }\n\n hostConnected(): void {\n if (isServer) return\n if (this.#connected) {\n this.#resolveFromLightDom(true)\n return\n }\n\n this.#connected = true\n this.#hydrating = Boolean(this.#host.shadowRoot?.hasChildNodes())\n if (!this.#hydrating) this.#resolveFromLightDom(false)\n }\n\n hostUpdated(): void {\n if (!this.#hydrating || this.#reconciled) return\n this.#reconciled = true\n void this.#host.updateComplete.then(() => this.#resolveFromLightDom(true))\n }\n\n #resolveFromLightDom(notify: boolean): void {\n for (const name of this.#presence.keys()) this.#set(name, hasSlottedContent(this.#host, name), notify)\n }\n\n #set(name: string, present: boolean, notify: boolean): void {\n if (!this.#presence.has(name)) return\n const next: SlotPresence = present ? 'present' : 'empty'\n if (this.#presence.get(name) === next) return\n this.#presence.set(name, next)\n if (notify) this.#host.requestUpdate()\n }\n}\n\nlet scrollLocks = 0\nlet previousOverflow = ''\n\n/**\n * Counted page-scroll lock, shared by every overlay so nested ones restore in the right order: a sheet that opens a\n * modal and closes after it must not hand the page back while the modal is still up. Call the returned function to\n * release; releasing twice is a no-op.\n */\nexport function lockPageScroll(): () => void {\n if (isServer) return () => {}\n if (scrollLocks++ === 0) {\n previousOverflow = document.documentElement.style.overflow\n document.documentElement.style.overflow = 'hidden'\n }\n let released = false\n return () => {\n if (released) return\n released = true\n if (--scrollLocks === 0) document.documentElement.style.overflow = previousOverflow\n }\n}\n\nexport function smartFixedPosition(fixed: boolean) {\n if (isServer) return\n const el = document.documentElement\n const scrollbarWidth = window.innerWidth - document.documentElement.offsetWidth\n if (fixed) {\n el.style.setProperty('--c2n-body-scroll-x', convertToUnit(-el.scrollLeft)!)\n el.style.setProperty('--c2n-body-scroll-y', convertToUnit(-el.scrollTop)!)\n el.style.setProperty('--c2n-scrollbar-offset', convertToUnit(scrollbarWidth)!)\n\n el.style.setProperty('overflow', 'hidden')\n el.style.setProperty('padding-inline-end', 'var(--c2n-scrollbar-offset)')\n el.style.setProperty('position', 'fixed')\n el.style.setProperty('top', 'var(--c2n-body-scroll-y)')\n el.style.setProperty('left', 'var(--c2n-body-scroll-x)')\n el.style.setProperty('width', '100%')\n el.style.setProperty('height', '100%')\n } else if (el.style.getPropertyValue('--c2n-body-scroll-x')) {\n const x = parseFloat(el.style.getPropertyValue('--c2n-body-scroll-x'))\n const y = parseFloat(el.style.getPropertyValue('--c2n-body-scroll-y'))\n\n el.style.removeProperty('overflow')\n el.style.removeProperty('padding-inline-end')\n el.style.removeProperty('position')\n el.style.removeProperty('top')\n el.style.removeProperty('left')\n el.style.removeProperty('width')\n el.style.removeProperty('height')\n\n el.style.removeProperty('--c2n-body-scroll-x')\n el.style.removeProperty('--c2n-body-scroll-y')\n el.style.removeProperty('--c2n-scrollbar-offset')\n el.scrollLeft = -x\n el.scrollTop = -y\n }\n}\n\nexport function convertToUnit(str: string | number | null | undefined, unit = 'px'): string | undefined {\n if (str == null || str === '') {\n return undefined\n } else if (isNaN(+str!)) {\n return String(str)\n } else if (!isFinite(+str!)) {\n return undefined\n } else {\n return `${Number(str)}${unit}`\n }\n}\n"]}
|
package/dist/lit-helper.d.ts
CHANGED
|
@@ -1,14 +1,53 @@
|
|
|
1
|
+
import { type PropertyDecorator as LitPropertyDecorator } from '@lit/reactive-element/decorators/property.js';
|
|
2
|
+
import type { PropertyDeclaration } from '@lit/reactive-element';
|
|
3
|
+
export { html, svg, nothing } from 'lit';
|
|
4
|
+
export type { TemplateResult, SVGTemplateResult } from 'lit';
|
|
5
|
+
/**
|
|
6
|
+
* Converter for `type: Boolean` properties, replacing Lit's presence-based default.
|
|
7
|
+
*
|
|
8
|
+
* Lit's default is `fromAttribute: (value) => value !== null`, so *any* attribute that is present is true —
|
|
9
|
+
* including `disabled="false"`. Frameworks that render a non-boolean attribute name by stringifying its value
|
|
10
|
+
* (Svelte 5 does this for every name outside the HTML boolean list, and so does any server renderer) therefore
|
|
11
|
+
* turn the flag **on** when the application asked for it to be off, silently.
|
|
12
|
+
*
|
|
13
|
+
* The literal strings `"false"` and `"0"` are read as false; everything else, the empty string included, stays
|
|
14
|
+
* true, so `<c2-button disabled>` and `disabled=""` are unchanged. Reflection matches Lit exactly: true writes
|
|
15
|
+
* an empty attribute, false removes it.
|
|
16
|
+
*/
|
|
17
|
+
export declare const booleanPropertyConverter: {
|
|
18
|
+
toAttribute: (value: unknown) => "" | null;
|
|
19
|
+
fromAttribute: (value: string | null) => boolean;
|
|
20
|
+
};
|
|
1
21
|
export declare const arrayPropertyConverter: {
|
|
2
22
|
toAttribute: (value: string[]) => string;
|
|
3
23
|
fromAttribute: (value: string) => string[];
|
|
24
|
+
fromProperty: (value: unknown) => unknown;
|
|
4
25
|
};
|
|
5
26
|
/**
|
|
6
27
|
* Converter for properties whose value is a plain object or array and whose attribute is JSON, so data-driven
|
|
7
28
|
* components (a table's rows and columns, for instance) can be authored in markup as well as from script.
|
|
8
29
|
* Invalid JSON parses to `undefined` rather than throwing, and never round-trips back to the attribute.
|
|
30
|
+
*
|
|
31
|
+
* A JSON **string assigned to the property** is parsed as well, which is what makes such a property survive
|
|
32
|
+
* server rendering. A server writes attributes only, so the application hands the component
|
|
33
|
+
* `JSON.stringify(rows)`; on the client the same binding usually lands as a property assignment instead, and
|
|
34
|
+
* without `fromProperty` that string would simply be stored. A string that is not valid JSON is left alone.
|
|
9
35
|
*/
|
|
10
36
|
export declare const jsonPropertyConverter: {
|
|
11
37
|
toAttribute: (value: unknown) => string | null;
|
|
12
38
|
fromAttribute: (value: string | null) => any;
|
|
39
|
+
fromProperty: (value: unknown) => any;
|
|
13
40
|
};
|
|
41
|
+
/**
|
|
42
|
+
* `@property`, but with the two conversions a component library needs and Lit's defaults do not provide.
|
|
43
|
+
*
|
|
44
|
+
* - `type: Boolean` gets {@link booleanPropertyConverter}, so `disabled="false"` is false rather than true.
|
|
45
|
+
* - A converter that declares `fromProperty` ({@link jsonPropertyConverter}, {@link arrayPropertyConverter})
|
|
46
|
+
* also parses a string assigned directly to the property, so the same value works as an attribute on the
|
|
47
|
+
* server and as a property on the client.
|
|
48
|
+
*
|
|
49
|
+
* An explicit `converter` always wins, so a property that needs Lit's presence-based boolean can still ask for
|
|
50
|
+
* it. Import this instead of `property` from `lit/decorators.js` in every c2n component.
|
|
51
|
+
*/
|
|
52
|
+
export declare function property(options?: PropertyDeclaration): LitPropertyDecorator;
|
|
14
53
|
//# sourceMappingURL=lit-helper.d.ts.map
|
package/dist/lit-helper.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lit-helper.d.ts","sourceRoot":"","sources":["../src/lit-helper.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB;yBACZ,MAAM,EAAE;2BAGN,MAAM;
|
|
1
|
+
{"version":3,"file":"lit-helper.d.ts","sourceRoot":"","sources":["../src/lit-helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,iBAAiB,IAAI,oBAAoB,EAAE,MAAM,8CAA8C,CAAA;AACtI,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAEhE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACxC,YAAY,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,KAAK,CAAA;AAU5D;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,wBAAwB;yBACd,OAAO;2BACL,MAAM,GAAG,IAAI;CACrC,CAAA;AAED,eAAO,MAAM,sBAAsB;yBACZ,MAAM,EAAE;2BAGN,MAAM;0BAGP,OAAO;CAI8B,CAAA;AAE7D;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB;yBACX,OAAO;2BAIL,MAAM,GAAG,IAAI;0BAQd,OAAO;CAQ8B,CAAA;AA8B7D;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,oBAAoB,CAY5E"}
|
package/dist/lit-helper.js
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
import { property as litProperty } from '@lit/reactive-element/decorators/property.js';
|
|
2
|
+
export { html, svg, nothing } from 'lit';
|
|
3
|
+
/**
|
|
4
|
+
* Converter for `type: Boolean` properties, replacing Lit's presence-based default.
|
|
5
|
+
*
|
|
6
|
+
* Lit's default is `fromAttribute: (value) => value !== null`, so *any* attribute that is present is true —
|
|
7
|
+
* including `disabled="false"`. Frameworks that render a non-boolean attribute name by stringifying its value
|
|
8
|
+
* (Svelte 5 does this for every name outside the HTML boolean list, and so does any server renderer) therefore
|
|
9
|
+
* turn the flag **on** when the application asked for it to be off, silently.
|
|
10
|
+
*
|
|
11
|
+
* The literal strings `"false"` and `"0"` are read as false; everything else, the empty string included, stays
|
|
12
|
+
* true, so `<c2-button disabled>` and `disabled=""` are unchanged. Reflection matches Lit exactly: true writes
|
|
13
|
+
* an empty attribute, false removes it.
|
|
14
|
+
*/
|
|
15
|
+
export const booleanPropertyConverter = {
|
|
16
|
+
toAttribute: (value) => (value ? '' : null),
|
|
17
|
+
fromAttribute: (value) => value !== null && value !== 'false' && value !== '0',
|
|
18
|
+
};
|
|
1
19
|
export const arrayPropertyConverter = {
|
|
2
20
|
toAttribute: (value) => {
|
|
3
21
|
return Array.isArray(value) ? value.join(';') : '';
|
|
@@ -5,11 +23,21 @@ export const arrayPropertyConverter = {
|
|
|
5
23
|
fromAttribute: (value) => {
|
|
6
24
|
return value ? value.split(';') : [];
|
|
7
25
|
},
|
|
26
|
+
fromProperty: (value) => {
|
|
27
|
+
if (typeof value !== 'string')
|
|
28
|
+
return value;
|
|
29
|
+
return value ? value.split(';') : [];
|
|
30
|
+
},
|
|
8
31
|
};
|
|
9
32
|
/**
|
|
10
33
|
* Converter for properties whose value is a plain object or array and whose attribute is JSON, so data-driven
|
|
11
34
|
* components (a table's rows and columns, for instance) can be authored in markup as well as from script.
|
|
12
35
|
* Invalid JSON parses to `undefined` rather than throwing, and never round-trips back to the attribute.
|
|
36
|
+
*
|
|
37
|
+
* A JSON **string assigned to the property** is parsed as well, which is what makes such a property survive
|
|
38
|
+
* server rendering. A server writes attributes only, so the application hands the component
|
|
39
|
+
* `JSON.stringify(rows)`; on the client the same binding usually lands as a property assignment instead, and
|
|
40
|
+
* without `fromProperty` that string would simply be stored. A string that is not valid JSON is left alone.
|
|
13
41
|
*/
|
|
14
42
|
export const jsonPropertyConverter = {
|
|
15
43
|
toAttribute: (value) => {
|
|
@@ -27,5 +55,68 @@ export const jsonPropertyConverter = {
|
|
|
27
55
|
return undefined;
|
|
28
56
|
}
|
|
29
57
|
},
|
|
58
|
+
fromProperty: (value) => {
|
|
59
|
+
if (typeof value !== 'string')
|
|
60
|
+
return value;
|
|
61
|
+
try {
|
|
62
|
+
return JSON.parse(value);
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return value;
|
|
66
|
+
}
|
|
67
|
+
},
|
|
30
68
|
};
|
|
69
|
+
/** The `fromProperty` of a declaration's converter, when it has one. */
|
|
70
|
+
function propertyCoercion(options) {
|
|
71
|
+
const converter = options?.converter;
|
|
72
|
+
if (!converter || typeof converter === 'function')
|
|
73
|
+
return undefined;
|
|
74
|
+
return converter.fromProperty;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Wraps the accessor Lit installed so the value is coerced before Lit's setter records it and requests an
|
|
78
|
+
* update. Lit's own setter stays the one that calls `requestUpdate`, so reflection and change detection are
|
|
79
|
+
* untouched.
|
|
80
|
+
*
|
|
81
|
+
* Only reachable under experimental decorators, where `createProperty` has already defined the accessor on the
|
|
82
|
+
* prototype by the time the decorator returns. Under standard decorators the accessor does not exist yet and
|
|
83
|
+
* the coercion is skipped; this repository compiles with `experimentalDecorators`.
|
|
84
|
+
*/
|
|
85
|
+
function wrapPropertySetter(prototype, name, coerce) {
|
|
86
|
+
const descriptor = Object.getOwnPropertyDescriptor(prototype, name);
|
|
87
|
+
const set = descriptor?.set;
|
|
88
|
+
if (!set)
|
|
89
|
+
return;
|
|
90
|
+
Object.defineProperty(prototype, name, {
|
|
91
|
+
...descriptor,
|
|
92
|
+
set(value) {
|
|
93
|
+
set.call(this, coerce(value));
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* `@property`, but with the two conversions a component library needs and Lit's defaults do not provide.
|
|
99
|
+
*
|
|
100
|
+
* - `type: Boolean` gets {@link booleanPropertyConverter}, so `disabled="false"` is false rather than true.
|
|
101
|
+
* - A converter that declares `fromProperty` ({@link jsonPropertyConverter}, {@link arrayPropertyConverter})
|
|
102
|
+
* also parses a string assigned directly to the property, so the same value works as an attribute on the
|
|
103
|
+
* server and as a property on the client.
|
|
104
|
+
*
|
|
105
|
+
* An explicit `converter` always wins, so a property that needs Lit's presence-based boolean can still ask for
|
|
106
|
+
* it. Import this instead of `property` from `lit/decorators.js` in every c2n component.
|
|
107
|
+
*/
|
|
108
|
+
export function property(options) {
|
|
109
|
+
const declaration = options?.type === Boolean && options.converter === undefined ? { ...options, converter: booleanPropertyConverter } : options;
|
|
110
|
+
const decorate = litProperty(declaration);
|
|
111
|
+
const coerce = propertyCoercion(declaration);
|
|
112
|
+
if (!coerce)
|
|
113
|
+
return decorate;
|
|
114
|
+
const legacyDecorate = decorate;
|
|
115
|
+
return ((prototype, name, descriptor) => {
|
|
116
|
+
const result = legacyDecorate(prototype, name, descriptor);
|
|
117
|
+
if (typeof name !== 'object')
|
|
118
|
+
wrapPropertySetter(prototype, name, coerce);
|
|
119
|
+
return result;
|
|
120
|
+
});
|
|
121
|
+
}
|
|
31
122
|
//# sourceMappingURL=lit-helper.js.map
|
package/dist/lit-helper.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lit-helper.js","sourceRoot":"","sources":["../src/lit-helper.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,WAAW,EAAE,CAAC,KAAe,EAAE,EAAE;QAC/B,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IACpD,CAAC;IACD,aAAa,EAAE,CAAC,KAAa,EAAE,EAAE;QAC/B,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IACtC,CAAC;
|
|
1
|
+
{"version":3,"file":"lit-helper.js","sourceRoot":"","sources":["../src/lit-helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,WAAW,EAAkD,MAAM,8CAA8C,CAAA;AAGtI,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AAWxC;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,WAAW,EAAE,CAAC,KAAc,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACpD,aAAa,EAAE,CAAC,KAAoB,EAAE,EA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GAAG,gBAAgB,CAAC,WAAW,CAAC,CAAA;IAC5C,IAAI,CAAC,MAAM;QAAE,OAAO,QAAQ,CAAA;IAE5B,MAAM,cAAc,GAAG,QAA8F,CAAA;IACrH,OAAO,CAAC,CAAC,SAAiB,EAAE,IAAiB,EAAE,UAA+B,EAAE,EAAE;QAChF,MAAM,MAAM,GAAG,cAAc,CAAC,SAAS,EAAE,IAAI,EAAE,UAAU,CAAC,CAAA;QAC1D,IAAI,OAAO,IAAI,KAAK,QAAQ;YAAE,kBAAkB,CAAC,SAAS,EAAE,IAAI,EAAE,MAAM,CAAC,CAAA;QACzE,OAAO,MAAM,CAAA;IACf,CAAC,CAAyB,CAAA;AAC5B,CAAC","sourcesContent":["import { property as litProperty, type PropertyDecorator as LitPropertyDecorator } from '@lit/reactive-element/decorators/property.js'\nimport type { PropertyDeclaration } from '@lit/reactive-element'\n\nexport { html, svg, nothing } from 'lit'\nexport type { TemplateResult, SVGTemplateResult } from 'lit'\n\n/**\n * A converter that also understands the value being assigned straight to the property rather than parsed out of\n * the attribute. `fromProperty` is what {@link property} installs a setter for; see its documentation for why.\n */\ninterface StringTolerantConverter {\n fromProperty: (value: unknown) => unknown\n}\n\n/**\n * Converter for `type: Boolean` properties, replacing Lit's presence-based default.\n *\n * Lit's default is `fromAttribute: (value) => value !== null`, so *any* attribute that is present is true —\n * including `disabled=\"false\"`. Frameworks that render a non-boolean attribute name by stringifying its value\n * (Svelte 5 does this for every name outside the HTML boolean list, and so does any server renderer) therefore\n * turn the flag **on** when the application asked for it to be off, silently.\n *\n * The literal strings `\"false\"` and `\"0\"` are read as false; everything else, the empty string included, stays\n * true, so `<c2-button disabled>` and `disabled=\"\"` are unchanged. Reflection matches Lit exactly: true writes\n * an empty attribute, false removes it.\n */\nexport const booleanPropertyConverter = {\n toAttribute: (value: unknown) => (value ? '' : null),\n fromAttribute: (value: string | null) => value !== null && value !== 'false' && value !== '0',\n}\n\nexport const arrayPropertyConverter = {\n toAttribute: (value: string[]) => {\n return Array.isArray(value) ? value.join(';') : ''\n },\n fromAttribute: (value: string) => {\n return value ? value.split(';') : []\n },\n fromProperty: (value: unknown) => {\n if (typeof value !== 'string') return value\n return value ? value.split(';') : []\n },\n} satisfies StringTolerantConverter & Record<string, unknown>\n\n/**\n * Converter for properties whose value is a plain object or array and whose attribute is JSON, so data-driven\n * components (a table's rows and columns, for instance) can be authored in markup as well as from script.\n * Invalid JSON parses to `undefined` rather than throwing, and never round-trips back to the attribute.\n *\n * A JSON **string assigned to the property** is parsed as well, which is what makes such a property survive\n * server rendering. A server writes attributes only, so the application hands the component\n * `JSON.stringify(rows)`; on the client the same binding usually lands as a property assignment instead, and\n * without `fromProperty` that string would simply be stored. A string that is not valid JSON is left alone.\n */\nexport const jsonPropertyConverter = {\n toAttribute: (value: unknown) => {\n if (value === undefined || value === null) return null\n return JSON.stringify(value)\n },\n fromAttribute: (value: string | null) => {\n if (!value) return undefined\n try {\n return JSON.parse(value)\n } catch {\n return undefined\n }\n },\n fromProperty: (value: unknown) => {\n if (typeof value !== 'string') return value\n try {\n return JSON.parse(value)\n } catch {\n return value\n }\n },\n} satisfies StringTolerantConverter & Record<string, unknown>\n\n/** The `fromProperty` of a declaration's converter, when it has one. */\nfunction propertyCoercion(options?: PropertyDeclaration): ((value: unknown) => unknown) | undefined {\n const converter = options?.converter\n if (!converter || typeof converter === 'function') return undefined\n return (converter as Partial<StringTolerantConverter>).fromProperty\n}\n\n/**\n * Wraps the accessor Lit installed so the value is coerced before Lit's setter records it and requests an\n * update. Lit's own setter stays the one that calls `requestUpdate`, so reflection and change detection are\n * untouched.\n *\n * Only reachable under experimental decorators, where `createProperty` has already defined the accessor on the\n * prototype by the time the decorator returns. Under standard decorators the accessor does not exist yet and\n * the coercion is skipped; this repository compiles with `experimentalDecorators`.\n */\nfunction wrapPropertySetter(prototype: object, name: PropertyKey, coerce: (value: unknown) => unknown): void {\n const descriptor = Object.getOwnPropertyDescriptor(prototype, name)\n const set = descriptor?.set\n if (!set) return\n Object.defineProperty(prototype, name, {\n ...descriptor,\n set(this: object, value: unknown) {\n set.call(this, coerce(value))\n },\n })\n}\n\n/**\n * `@property`, but with the two conversions a component library needs and Lit's defaults do not provide.\n *\n * - `type: Boolean` gets {@link booleanPropertyConverter}, so `disabled=\"false\"` is false rather than true.\n * - A converter that declares `fromProperty` ({@link jsonPropertyConverter}, {@link arrayPropertyConverter})\n * also parses a string assigned directly to the property, so the same value works as an attribute on the\n * server and as a property on the client.\n *\n * An explicit `converter` always wins, so a property that needs Lit's presence-based boolean can still ask for\n * it. Import this instead of `property` from `lit/decorators.js` in every c2n component.\n */\nexport function property(options?: PropertyDeclaration): LitPropertyDecorator {\n const declaration = options?.type === Boolean && options.converter === undefined ? { ...options, converter: booleanPropertyConverter } : options\n const decorate = litProperty(declaration)\n const coerce = propertyCoercion(declaration)\n if (!coerce) return decorate\n\n const legacyDecorate = decorate as (prototype: object, name: PropertyKey, descriptor?: PropertyDescriptor) => unknown\n return ((prototype: object, name: PropertyKey, descriptor?: PropertyDescriptor) => {\n const result = legacyDecorate(prototype, name, descriptor)\n if (typeof name !== 'object') wrapPropertySetter(prototype, name, coerce)\n return result\n }) as LitPropertyDecorator\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@c2n/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "tsc -p tsconfig.json -w",
|
|
6
6
|
"build": "tsc -p tsconfig.json"
|
|
@@ -62,10 +62,11 @@
|
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@lit/context": "1.1.6",
|
|
65
|
-
"@lit/reactive-element": "2.1.2"
|
|
65
|
+
"@lit/reactive-element": "2.1.2",
|
|
66
|
+
"lit": "3.3.3"
|
|
66
67
|
},
|
|
67
68
|
"devDependencies": {
|
|
68
69
|
"@c2n/config": "*"
|
|
69
70
|
},
|
|
70
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "0261bfceaaa9f710a54e8f36cb57f946c0b83e53"
|
|
71
72
|
}
|