UNPKG

@zywave/zui-bundle

Version:

ZUI, out of the box, provides ES modules with bare path modifiers (e.g. `import '@zywave/zui-foo-bar'`). This is great as that's the way browsers are _going_, but they aren't there quite yet. Tooling exists to help solve this problem like webpack or rollu

60 lines (56 loc) 1.55 kB
import { d as desc } from './_ab875545.js'; /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ /** * A property decorator that converts a class property into a getter that * returns the `assignedNodes` of the given `slot`. * * Can be passed an optional {@linkcode QueryAssignedNodesOptions} object. * * Example usage: * ```ts * class MyElement { * @queryAssignedNodes({slot: 'list', flatten: true}) * listItems!: Array<Node>; * * render() { * return html` * <slot name="list"></slot> * `; * } * } * ``` * * Note the type of this property should be annotated as `Array<Node>`. Use the * queryAssignedElements decorator to list only elements, and optionally filter * the element list using a CSS selector. * * @category Decorator */ function queryAssignedNodes(options) { // eslint-disable-next-line @typescript-eslint/no-explicit-any return (obj, name) => { const { slot } = options ?? {}; const slotSelector = `slot${slot ? `[name=${slot}]` : ':not([name])'}`; return desc(obj, name, { get() { const slotEl = this.renderRoot?.querySelector(slotSelector); return slotEl?.assignedNodes(options) ?? []; } }); }; } const screenBreakpoints = { xxsmall: '30em' /* 480 / 16 */, xsmall: '45em' /* 720 / 16 */, small: '60em' /* 960 / 16 */, medium: '64em' /* 1024 / 16 */, large: '80em' /* 1280 / 16 */, xlarge: '120em' /* 1920 / 16 */ }; export { queryAssignedNodes as q, screenBreakpoints as s };