@bquery/bquery 1.3.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +546 -501
- package/dist/component/component.d.ts.map +1 -1
- package/dist/component/index.d.ts +2 -0
- package/dist/component/index.d.ts.map +1 -1
- package/dist/component/library.d.ts +34 -0
- package/dist/component/library.d.ts.map +1 -0
- package/dist/component/types.d.ts +10 -6
- package/dist/component/types.d.ts.map +1 -1
- package/dist/component-CY5MVoYN.js +531 -0
- package/dist/component-CY5MVoYN.js.map +1 -0
- package/dist/component.es.mjs +6 -184
- package/dist/config-DRmZZno3.js +40 -0
- package/dist/config-DRmZZno3.js.map +1 -0
- package/dist/core/collection.d.ts +19 -3
- package/dist/core/collection.d.ts.map +1 -1
- package/dist/core/element.d.ts +23 -4
- package/dist/core/element.d.ts.map +1 -1
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/utils/function.d.ts +21 -4
- package/dist/core/utils/function.d.ts.map +1 -1
- package/dist/core-CK2Mfpf4.js +648 -0
- package/dist/core-CK2Mfpf4.js.map +1 -0
- package/dist/core-DPdbItcq.js +112 -0
- package/dist/core-DPdbItcq.js.map +1 -0
- package/dist/core.es.mjs +45 -1218
- package/dist/full.d.ts +6 -6
- package/dist/full.d.ts.map +1 -1
- package/dist/full.es.mjs +98 -92
- package/dist/full.iife.js +173 -3
- package/dist/full.iife.js.map +1 -1
- package/dist/full.umd.js +173 -3
- package/dist/full.umd.js.map +1 -1
- package/dist/index.es.mjs +143 -139
- package/dist/motion/transition.d.ts +1 -1
- package/dist/motion/transition.d.ts.map +1 -1
- package/dist/motion/types.d.ts +11 -1
- package/dist/motion/types.d.ts.map +1 -1
- package/dist/motion-C5DRdPnO.js +415 -0
- package/dist/motion-C5DRdPnO.js.map +1 -0
- package/dist/motion.es.mjs +25 -361
- package/dist/object-qGpWr6-J.js +38 -0
- package/dist/object-qGpWr6-J.js.map +1 -0
- package/dist/platform/announcer.d.ts +59 -0
- package/dist/platform/announcer.d.ts.map +1 -0
- package/dist/platform/config.d.ts +92 -0
- package/dist/platform/config.d.ts.map +1 -0
- package/dist/platform/cookies.d.ts +45 -0
- package/dist/platform/cookies.d.ts.map +1 -0
- package/dist/platform/index.d.ts +8 -0
- package/dist/platform/index.d.ts.map +1 -1
- package/dist/platform/meta.d.ts +62 -0
- package/dist/platform/meta.d.ts.map +1 -0
- package/dist/platform/storage.d.ts.map +1 -1
- package/dist/platform-B7JhGBc7.js +361 -0
- package/dist/platform-B7JhGBc7.js.map +1 -0
- package/dist/platform.es.mjs +11 -243
- package/dist/reactive/async-data.d.ts +114 -0
- package/dist/reactive/async-data.d.ts.map +1 -0
- package/dist/reactive/core.d.ts +12 -0
- package/dist/reactive/core.d.ts.map +1 -1
- package/dist/reactive/effect.d.ts.map +1 -1
- package/dist/reactive/index.d.ts +2 -2
- package/dist/reactive/index.d.ts.map +1 -1
- package/dist/reactive/internals.d.ts +6 -0
- package/dist/reactive/internals.d.ts.map +1 -1
- package/dist/reactive/signal.d.ts +2 -0
- package/dist/reactive/signal.d.ts.map +1 -1
- package/dist/reactive-BDya-ia8.js +253 -0
- package/dist/reactive-BDya-ia8.js.map +1 -0
- package/dist/reactive.es.mjs +18 -34
- package/dist/router-CijiICxt.js +188 -0
- package/dist/router-CijiICxt.js.map +1 -0
- package/dist/router.es.mjs +11 -200
- package/dist/sanitize-jyJ2ryE2.js +302 -0
- package/dist/sanitize-jyJ2ryE2.js.map +1 -0
- package/dist/security/constants.d.ts.map +1 -1
- package/dist/security/sanitize-core.d.ts.map +1 -1
- package/dist/security.es.mjs +10 -56
- package/dist/store-CPK9E62U.js +262 -0
- package/dist/store-CPK9E62U.js.map +1 -0
- package/dist/store.es.mjs +12 -25
- package/dist/view/evaluate.d.ts.map +1 -1
- package/dist/view-Cdi0g-qo.js +396 -0
- package/dist/view-Cdi0g-qo.js.map +1 -0
- package/dist/view.es.mjs +10 -424
- package/package.json +136 -132
- package/src/component/component.ts +319 -289
- package/src/component/index.ts +42 -40
- package/src/component/library.ts +504 -0
- package/src/component/types.ts +91 -85
- package/src/core/collection.ts +44 -4
- package/src/core/element.ts +33 -5
- package/src/core/index.ts +1 -0
- package/src/core/utils/function.ts +56 -15
- package/src/full.ts +223 -187
- package/src/motion/transition.ts +97 -51
- package/src/motion/types.ts +208 -198
- package/src/platform/announcer.ts +208 -0
- package/src/platform/config.ts +163 -0
- package/src/platform/cookies.ts +165 -0
- package/src/platform/index.ts +39 -18
- package/src/platform/meta.ts +168 -0
- package/src/platform/storage.ts +8 -1
- package/src/reactive/async-data.ts +486 -0
- package/src/reactive/core.ts +21 -0
- package/src/reactive/effect.ts +18 -7
- package/src/reactive/index.ts +37 -23
- package/src/reactive/internals.ts +18 -1
- package/src/reactive/signal.ts +29 -20
- package/src/security/constants.ts +211 -209
- package/src/security/sanitize-core.ts +22 -1
- package/src/view/evaluate.ts +29 -13
- package/dist/batch-4LAvfLE7.js +0 -13
- package/dist/batch-4LAvfLE7.js.map +0 -1
- package/dist/component.es.mjs.map +0 -1
- package/dist/core-COenAZjD.js +0 -145
- package/dist/core-COenAZjD.js.map +0 -1
- package/dist/core.es.mjs.map +0 -1
- package/dist/full.es.mjs.map +0 -1
- package/dist/index.es.mjs.map +0 -1
- package/dist/motion.es.mjs.map +0 -1
- package/dist/persisted-Dz_ryNuC.js +0 -278
- package/dist/persisted-Dz_ryNuC.js.map +0 -1
- package/dist/platform.es.mjs.map +0 -1
- package/dist/reactive.es.mjs.map +0 -1
- package/dist/router.es.mjs.map +0 -1
- package/dist/sanitize-1FBEPAFH.js +0 -272
- package/dist/sanitize-1FBEPAFH.js.map +0 -1
- package/dist/security.es.mjs.map +0 -1
- package/dist/store.es.mjs.map +0 -1
- package/dist/type-guards-DRma3-Kc.js +0 -16
- package/dist/type-guards-DRma3-Kc.js.map +0 -1
- package/dist/untrack-BuEQKH7_.js +0 -6
- package/dist/untrack-BuEQKH7_.js.map +0 -1
- package/dist/view.es.mjs.map +0 -1
- package/dist/watch-CXyaBC_9.js +0 -58
- package/dist/watch-CXyaBC_9.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-CY5MVoYN.js","names":[],"sources":["../src/component/props.ts","../src/component/component.ts","../src/component/html.ts","../src/component/library.ts"],"sourcesContent":["/**\n * Prop coercion utilities.\n *\n * @module bquery/component\n */\n\nimport type { PropDefinition } from './types';\n\n/**\n * Coerces a string attribute value into a typed prop value.\n * Supports String, Number, Boolean, Object, Array, and custom converters.\n *\n * @internal\n * @template T - The target type\n * @param rawValue - The raw string value from the attribute\n * @param config - The prop definition with type information\n * @returns The coerced value of type T\n */\nexport const coercePropValue = <T>(rawValue: string, config: PropDefinition<T>): T => {\n const { type } = config;\n\n if (type === String) return rawValue as T;\n\n if (type === Number) {\n return Number(rawValue) as T;\n }\n\n if (type === Boolean) {\n const normalized = rawValue.trim().toLowerCase();\n if (normalized === '' || normalized === 'true' || normalized === '1') {\n return true as T;\n }\n if (normalized === 'false' || normalized === '0') {\n return false as T;\n }\n return Boolean(rawValue) as T;\n }\n\n if (type === Object || type === Array) {\n try {\n return JSON.parse(rawValue) as T;\n } catch {\n return rawValue as T;\n }\n }\n\n if (typeof type === 'function') {\n const callable = type as (value: unknown) => T;\n const constructable = type as new (value: unknown) => T;\n\n // Explicit construct mode takes precedence\n if (config.construct === true) {\n return Reflect.construct(constructable, [rawValue]) as T;\n }\n if (config.construct === false) {\n return callable(rawValue);\n }\n\n // Auto-detect: Check if type is constructable\n // A function is considered constructable if:\n // 1. It has a prototype with properties beyond just constructor, OR\n // 2. Its prototype.constructor is not itself (inherited), OR\n // 3. It's a class (toString starts with \"class\")\n const hasPrototype = type.prototype !== undefined && type.prototype !== null;\n const prototypeProps = hasPrototype ? Object.getOwnPropertyNames(type.prototype) : [];\n const hasPrototypeMethods = prototypeProps.length > 1;\n const hasInheritedConstructor = hasPrototype && type.prototype.constructor !== type;\n const isClassSyntax = /^class\\s/.test(Function.prototype.toString.call(type));\n\n const isConstructable = hasPrototypeMethods || hasInheritedConstructor || isClassSyntax;\n\n // For constructable types (e.g. Date, custom classes), prefer `new` to avoid\n // silent wrong-type returns (Date() returns string, new Date() returns Date)\n if (isConstructable) {\n try {\n return Reflect.construct(constructable, [rawValue]) as T;\n } catch {\n // Fall back to calling as function if construction fails\n return callable(rawValue);\n }\n }\n\n // For non-constructable types (arrow functions, plain functions), call directly\n // but fall back to constructor if result is undefined (common for function constructors)\n try {\n const result = callable(rawValue);\n\n // If calling without `new` returned undefined and the function has a prototype,\n // it's likely a function constructor that should be called with `new`\n if (result === undefined && hasPrototype) {\n try {\n return Reflect.construct(constructable, [rawValue]) as T;\n } catch {\n // Construction also failed, return the undefined\n return result as T;\n }\n }\n\n return result as T;\n } catch (error) {\n // Fall back to constructor if error indicates 'new' is required\n const isNewRequired =\n error instanceof TypeError &&\n /cannot be invoked without 'new'|is not a function/i.test(error.message);\n\n if (isNewRequired) {\n return Reflect.construct(constructable, [rawValue]) as T;\n }\n\n // Rethrow original error for non-constructable converters\n throw error;\n }\n }\n\n return rawValue as T;\n};\n","/**\r\n * Web Component factory and registry.\r\n *\r\n * @module bquery/component\r\n */\r\n\r\nimport { sanitizeHtml } from '../security/sanitize';\r\nimport { coercePropValue } from './props';\r\nimport type { ComponentDefinition, PropDefinition } from './types';\r\n\r\n/**\r\n * Creates a custom element class for a component definition.\r\n *\r\n * This is useful when you want to extend or register the class manually\r\n * (e.g. with different tag names in tests or custom registries).\r\n *\r\n * @template TProps - Type of the component's props\r\n * @param tagName - The custom element tag name (used for diagnostics)\r\n * @param definition - The component configuration\r\n */\r\nexport const defineComponent = <TProps extends Record<string, unknown>>(\r\n tagName: string,\r\n definition: ComponentDefinition<TProps>\r\n): typeof HTMLElement => {\r\n class BQueryComponent extends HTMLElement {\r\n /** Internal state object for the component */\r\n private readonly state = { ...(definition.state ?? {}) };\r\n /** Typed props object populated from attributes */\r\n private props = {} as TProps;\r\n /** Tracks missing required props for validation during connectedCallback */\r\n private missingRequiredProps = new Set<string>();\r\n /** Tracks whether the component has completed its initial mount */\r\n private hasMounted = false;\r\n\r\n constructor() {\r\n super();\r\n this.attachShadow({ mode: 'open' });\r\n this.syncProps();\r\n }\r\n\r\n /**\r\n * Returns the list of attributes to observe for changes.\r\n */\r\n static get observedAttributes(): string[] {\r\n return Object.keys(definition.props ?? {});\r\n }\r\n\r\n /**\r\n * Called when the element is added to the DOM.\r\n */\r\n connectedCallback(): void {\r\n try {\r\n // Defer initial render until all required props are present\r\n // This allows attributes to be set after element creation\r\n if (this.missingRequiredProps.size > 0) {\r\n // Component will mount once all required props are satisfied\r\n // via attributeChangedCallback\r\n return;\r\n }\r\n this.mount();\r\n } catch (error) {\r\n this.handleError(error as Error);\r\n }\r\n }\r\n\r\n /**\r\n * Performs the initial mount of the component.\r\n * Called when the element is connected and all required props are present.\r\n * @internal\r\n */\r\n private mount(): void {\r\n if (this.hasMounted) return;\r\n definition.beforeMount?.call(this);\r\n definition.connected?.call(this);\r\n this.render();\r\n this.hasMounted = true;\r\n }\r\n\r\n /**\r\n * Called when the element is removed from the DOM.\r\n */\r\n disconnectedCallback(): void {\r\n try {\r\n definition.disconnected?.call(this);\r\n } catch (error) {\r\n this.handleError(error as Error);\r\n }\r\n }\r\n\r\n /**\r\n * Called when an observed attribute changes.\r\n */\r\n attributeChangedCallback(\r\n _name: string,\r\n _oldValue: string | null,\r\n _newValue: string | null\r\n ): void {\r\n try {\r\n this.syncProps();\r\n\r\n if (this.hasMounted) {\r\n // Component already mounted - trigger update render\r\n this.render(true);\r\n } else if (this.isConnected && this.missingRequiredProps.size === 0) {\r\n // All required props are now satisfied and element is connected\r\n // Trigger the deferred initial mount\r\n this.mount();\r\n }\r\n } catch (error) {\r\n this.handleError(error as Error);\r\n }\r\n }\r\n\r\n /**\r\n * Handles errors during component lifecycle.\r\n * @internal\r\n */\r\n private handleError(error: Error): void {\r\n if (definition.onError) {\r\n definition.onError.call(this, error);\r\n } else {\r\n console.error(`bQuery component error in <${tagName}>:`, error);\r\n }\r\n }\r\n\r\n /**\r\n * Updates a state property and triggers a re-render.\r\n *\r\n * @param key - The state property key\r\n * @param value - The new value\r\n */\r\n setState(key: string, value: unknown): void {\r\n this.state[key] = value;\r\n this.render(true);\r\n }\r\n\r\n /**\r\n * Gets a state property value.\r\n *\r\n * @param key - The state property key\r\n * @returns The current value\r\n */\r\n getState<T = unknown>(key: string): T {\r\n return this.state[key] as T;\r\n }\r\n\r\n /**\r\n * Synchronizes props from attributes.\r\n * @internal\r\n */\r\n private syncProps(): void {\r\n const props = definition.props ?? {};\r\n for (const [key, config] of Object.entries(props) as [string, PropDefinition][]) {\r\n const attrValue = this.getAttribute(key);\r\n let value: unknown;\r\n\r\n if (attrValue == null) {\r\n if (config.required && config.default === undefined) {\r\n // Mark as missing instead of throwing - validate during connectedCallback\r\n this.missingRequiredProps.add(key);\r\n value = undefined;\r\n } else {\r\n value = config.default ?? undefined;\r\n }\r\n } else {\r\n // Attribute is present, remove from missing set if it was there\r\n if (this.missingRequiredProps.has(key)) {\r\n this.missingRequiredProps.delete(key);\r\n }\r\n value = coercePropValue(attrValue, config);\r\n }\r\n\r\n if (config.validator && value !== undefined) {\r\n const isValid = config.validator(value);\r\n if (!isValid) {\r\n throw new Error(\r\n `bQuery component: validation failed for prop \"${key}\" with value ${JSON.stringify(value)}`\r\n );\r\n }\r\n }\r\n\r\n (this.props as Record<string, unknown>)[key] = value;\r\n }\r\n }\r\n\r\n /**\r\n * Renders the component to its shadow root.\r\n * @internal\r\n */\r\n private render(triggerUpdated = false): void {\r\n try {\r\n if (triggerUpdated && definition.beforeUpdate) {\r\n const shouldUpdate = definition.beforeUpdate.call(this, this.props);\r\n if (shouldUpdate === false) return;\r\n }\r\n\r\n const emit = (event: string, detail?: unknown): void => {\r\n this.dispatchEvent(new CustomEvent(event, { detail, bubbles: true, composed: true }));\r\n };\r\n\r\n if (!this.shadowRoot) return;\r\n\r\n const markup = definition.render({\r\n props: this.props,\r\n state: this.state,\r\n emit,\r\n });\r\n\r\n // Component render output is authored by the component definition itself,\r\n // so we can explicitly preserve shadow-DOM-specific markup such as <slot>,\r\n // the stylistic `part` attribute, and standard form/input attributes without\r\n // relaxing the global DOM sanitization rules.\r\n const sanitizedMarkup = sanitizeHtml(markup, {\r\n allowTags: ['slot'],\r\n allowAttributes: [\r\n 'part',\r\n // Standard form attributes required by interactive shadow DOM content\r\n 'disabled',\r\n 'checked',\r\n 'placeholder',\r\n 'value',\r\n 'rows',\r\n 'cols',\r\n 'readonly',\r\n 'required',\r\n 'maxlength',\r\n 'minlength',\r\n 'max',\r\n 'min',\r\n 'step',\r\n 'pattern',\r\n 'autocomplete',\r\n 'autofocus',\r\n 'for',\r\n 'multiple',\r\n 'selected',\r\n 'wrap',\r\n ],\r\n });\r\n this.shadowRoot.innerHTML = sanitizedMarkup;\r\n\r\n if (definition.styles) {\r\n const styleElement = document.createElement('style');\r\n styleElement.textContent = definition.styles;\r\n this.shadowRoot.prepend(styleElement);\r\n }\r\n\r\n if (triggerUpdated) {\r\n definition.updated?.call(this);\r\n }\r\n } catch (error) {\r\n this.handleError(error as Error);\r\n }\r\n }\r\n }\r\n\r\n return BQueryComponent;\r\n};\r\n\r\n/**\r\n * Defines and registers a custom Web Component.\r\n *\r\n * This function creates a new custom element with the given tag name\r\n * and configuration. The component uses Shadow DOM for encapsulation\r\n * and automatically re-renders when observed attributes change.\r\n *\r\n * @template TProps - Type of the component's props\r\n * @param tagName - The custom element tag name (must contain a hyphen)\r\n * @param definition - The component configuration\r\n *\r\n * @example\r\n * ```ts\r\n * component('counter-button', {\r\n * props: {\r\n * start: { type: Number, default: 0 },\r\n * },\r\n * state: { count: 0 },\r\n * styles: `\r\n * button { padding: 0.5rem 1rem; }\r\n * `,\r\n * connected() {\r\n * // Use event delegation on shadow root so handler survives re-renders\r\n * const handleClick = (event: Event) => {\r\n * const target = event.target as HTMLElement | null;\r\n * if (target?.matches('button')) {\r\n * this.setState('count', (this.getState('count') as number) + 1);\r\n * }\r\n * };\r\n * this.shadowRoot?.addEventListener('click', handleClick);\r\n * // Store handler for cleanup\r\n * (this as any)._handleClick = handleClick;\r\n * },\r\n * disconnected() {\r\n * // Clean up event listener to prevent memory leaks\r\n * const handleClick = (this as any)._handleClick;\r\n * if (handleClick) {\r\n * this.shadowRoot?.removeEventListener('click', handleClick);\r\n * }\r\n * },\r\n * render({ props, state }) {\r\n * return html`\r\n * <button>\r\n * Count: ${state.count}\r\n * </button>\r\n * `;\r\n * },\r\n * });\r\n * ```\r\n */\r\nexport const component = <TProps extends Record<string, unknown>>(\r\n tagName: string,\r\n definition: ComponentDefinition<TProps>\r\n): void => {\r\n const elementClass = defineComponent(tagName, definition);\r\n\r\n if (!customElements.get(tagName)) {\r\n customElements.define(tagName, elementClass);\r\n }\r\n};\r\n","/**\n * Tagged template literal for creating HTML strings.\n *\n * This function handles interpolation of values into HTML templates,\n * converting null/undefined to empty strings.\n *\n * @param strings - Template literal string parts\n * @param values - Interpolated values\n * @returns Combined HTML string\n *\n * @example\n * ```ts\n * const name = 'World';\n * const greeting = html`<h1>Hello, ${name}!</h1>`;\n * // Result: '<h1>Hello, World!</h1>'\n * ```\n */\nexport const html = (strings: TemplateStringsArray, ...values: unknown[]): string => {\n return strings.reduce((acc, part, index) => `${acc}${part}${values[index] ?? ''}`, '');\n};\n\n/**\n * Escapes HTML entities in interpolated values for XSS prevention.\n * Use this when you need to safely embed user content in templates.\n *\n * @param strings - Template literal string parts\n * @param values - Interpolated values to escape\n * @returns Combined HTML string with escaped values\n *\n * @example\n * ```ts\n * const userInput = '<script>alert(\"xss\")</script>';\n * const safe = safeHtml`<div>${userInput}</div>`;\n * // Result: '<div><script>alert(\"xss\")</script></div>'\n * ```\n */\nexport const safeHtml = (strings: TemplateStringsArray, ...values: unknown[]): string => {\n const escapeMap: Record<string, string> = {\n '&': '&',\n '<': '<',\n '>': '>',\n '\"': '"',\n \"'\": ''',\n '`': '`',\n };\n\n const escape = (value: unknown): string => {\n const str = String(value ?? '');\n return str.replace(/[&<>\"'`]/g, (char) => escapeMap[char]);\n };\n\n return strings.reduce((acc, part, index) => `${acc}${part}${escape(values[index])}`, '');\n};\n","/**\r\n * Default component library based on native Web Components.\r\n *\r\n * @module bquery/component\r\n */\r\n\r\nimport { getBqueryConfig } from '../platform/config';\r\nimport { escapeHtml } from '../security';\r\nimport { component } from './component';\r\nimport { html } from './html';\r\n\r\n/** Options for registering the default component library. */\r\nexport interface DefaultComponentLibraryOptions {\r\n /** Prefix used for all registered component tags. Defaults to `bq`. */\r\n prefix?: string;\r\n}\r\n\r\n/** Tag names returned by registerDefaultComponents(). */\r\nexport interface RegisteredDefaultComponents {\r\n /** Button component tag name. */\r\n button: string;\r\n /** Card component tag name. */\r\n card: string;\r\n /** Input component tag name. */\r\n input: string;\r\n /** Textarea component tag name. */\r\n textarea: string;\r\n /** Checkbox component tag name. */\r\n checkbox: string;\r\n}\r\n\r\nconst baseStyles = `\r\n :host {\r\n color: inherit;\r\n font: inherit;\r\n }\r\n`;\r\n\r\nconst controlStyles = `\r\n ${baseStyles}\r\n .field {\r\n display: inline-flex;\r\n flex-direction: column;\r\n gap: 0.375rem;\r\n width: 100%;\r\n }\r\n .label {\r\n color: #334155;\r\n font-size: 0.875rem;\r\n font-weight: 600;\r\n }\r\n .control {\r\n border: 1px solid #cbd5e1;\r\n border-radius: 0.75rem;\r\n box-sizing: border-box;\r\n font: inherit;\r\n min-height: 2.75rem;\r\n outline: none;\r\n padding: 0.75rem 0.875rem;\r\n width: 100%;\r\n background: #fff;\r\n color: #0f172a;\r\n transition: border-color 160ms ease, box-shadow 160ms ease;\r\n }\r\n .control:focus {\r\n border-color: #2563eb;\r\n box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);\r\n }\r\n .control:disabled {\r\n background: #f8fafc;\r\n color: #94a3b8;\r\n cursor: not-allowed;\r\n }\r\n`;\r\n\r\nconst escapeProp = (value: string): string => escapeHtml(value);\r\n\r\nconst handlerStore = new WeakMap<HTMLElement, Record<string, EventListener>>();\r\n\r\nconst readHandler = (element: HTMLElement, key: string): EventListener | undefined => {\r\n return handlerStore.get(element)?.[key];\r\n};\r\n\r\nconst storeHandler = (element: HTMLElement, key: string, value: EventListener): void => {\r\n const handlers = handlerStore.get(element) ?? {};\r\n handlers[key] = value;\r\n handlerStore.set(element, handlers);\r\n};\r\n\r\nconst getShadowLabelText = (element: HTMLElement): string => {\r\n return element.shadowRoot?.querySelector('.label')?.textContent ?? '';\r\n};\r\n\r\n/**\r\n * Detect a value-only input update, patch the live control in place, and\r\n * return whether the component can skip a full shadow DOM re-render.\r\n *\r\n * @param element - The host custom element whose shadow DOM is being updated\r\n * @param props - The next reflected input props for the pending update\r\n */\r\nconst canSkipInputRender = (\r\n element: HTMLElement,\r\n props: {\r\n label: string;\r\n type: string;\r\n value: string;\r\n placeholder: string;\r\n name: string;\r\n disabled: boolean;\r\n }\r\n): boolean => {\r\n const control = element.shadowRoot?.querySelector('input.control') as HTMLInputElement | null;\r\n if (!control) return false;\r\n\r\n if (getShadowLabelText(element) !== props.label) return false;\r\n if ((control.getAttribute('type') ?? 'text') !== props.type) return false;\r\n if ((control.getAttribute('placeholder') ?? '') !== props.placeholder) return false;\r\n if ((control.getAttribute('name') ?? '') !== props.name) return false;\r\n if (control.disabled !== props.disabled) return false;\r\n\r\n if (control.value !== props.value) {\r\n control.value = props.value;\r\n }\r\n\r\n return true;\r\n};\r\n\r\n/**\r\n * Detect a value-only textarea update, patch the live control in place, and\r\n * return whether the component can skip a full shadow DOM re-render.\r\n *\r\n * @param element - The host custom element whose shadow DOM is being updated\r\n * @param props - The next reflected textarea props for the pending update\r\n */\r\nconst canSkipTextareaRender = (\r\n element: HTMLElement,\r\n props: {\r\n label: string;\r\n value: string;\r\n placeholder: string;\r\n name: string;\r\n rows: number;\r\n disabled: boolean;\r\n }\r\n): boolean => {\r\n const control = element.shadowRoot?.querySelector(\r\n 'textarea.control'\r\n ) as HTMLTextAreaElement | null;\r\n if (!control) return false;\r\n\r\n if (getShadowLabelText(element) !== props.label) return false;\r\n if ((control.getAttribute('placeholder') ?? '') !== props.placeholder) return false;\r\n if ((control.getAttribute('name') ?? '') !== props.name) return false;\r\n if (control.getAttribute('rows') !== String(props.rows)) return false;\r\n if (control.disabled !== props.disabled) return false;\r\n\r\n if (control.value !== props.value) {\r\n control.value = props.value;\r\n }\r\n return true;\r\n};\r\n\r\nconst renderTextareaControl = (props: {\r\n value: string;\r\n placeholder: string;\r\n name: string;\r\n rows: number;\r\n disabled: boolean;\r\n}): string => {\r\n return [\r\n '<textarea',\r\n ' part=\"control\"',\r\n ' class=\"control\"',\r\n ` placeholder=\"${escapeProp(props.placeholder)}\"`,\r\n ` name=\"${escapeProp(props.name)}\"`,\r\n ` rows=\"${props.rows}\"`,\r\n props.disabled ? ' disabled' : '',\r\n `>${escapeProp(props.value)}</textarea>`,\r\n ].join('');\r\n};\r\n\r\n/**\r\n * Register a default set of foundational UI components.\r\n *\r\n * The library is intentionally small and dependency-free, providing common\r\n * primitives that can be themed via shadow parts and CSS custom properties.\r\n *\r\n * @param options - Optional registration settings such as a custom tag prefix\r\n * @returns The registered tag names for each component\r\n */\r\nexport const registerDefaultComponents = (\r\n options: DefaultComponentLibraryOptions = {}\r\n): RegisteredDefaultComponents => {\r\n const prefix = options.prefix ?? getBqueryConfig().components?.prefix ?? 'bq';\r\n const tags: RegisteredDefaultComponents = {\r\n button: `${prefix}-button`,\r\n card: `${prefix}-card`,\r\n input: `${prefix}-input`,\r\n textarea: `${prefix}-textarea`,\r\n checkbox: `${prefix}-checkbox`,\r\n };\r\n\r\n component<{\r\n label: string;\r\n variant: string;\r\n size: string;\r\n type: string;\r\n disabled: boolean;\r\n }>(tags.button, {\r\n props: {\r\n label: { type: String, default: '' },\r\n variant: { type: String, default: 'primary' },\r\n size: { type: String, default: 'md' },\r\n type: { type: String, default: 'button' },\r\n disabled: { type: Boolean, default: false },\r\n },\r\n styles: `\r\n ${baseStyles}\r\n button {\r\n appearance: none;\r\n border: 0;\r\n border-radius: 999px;\r\n cursor: pointer;\r\n display: inline-flex;\r\n align-items: center;\r\n justify-content: center;\r\n font: inherit;\r\n font-weight: 600;\r\n gap: 0.5rem;\r\n min-height: 2.5rem;\r\n padding: 0.65rem 1rem;\r\n transition: transform 160ms ease, opacity 160ms ease, background 160ms ease;\r\n background: #2563eb;\r\n color: #fff;\r\n }\r\n button[data-variant='secondary'] {\r\n background: #e2e8f0;\r\n color: #0f172a;\r\n }\r\n button[data-size='sm'] {\r\n min-height: 2.125rem;\r\n padding: 0.5rem 0.875rem;\r\n }\r\n button[data-size='lg'] {\r\n min-height: 3rem;\r\n padding: 0.875rem 1.25rem;\r\n }\r\n button:hover:not(:disabled) {\r\n transform: translateY(-1px);\r\n }\r\n button:disabled {\r\n cursor: not-allowed;\r\n opacity: 0.6;\r\n }\r\n `,\r\n render: ({ props }) => html`\r\n <button\r\n part=\"button\"\r\n type=\"${escapeProp(props.type)}\"\r\n data-variant=\"${escapeProp(props.variant)}\"\r\n data-size=\"${escapeProp(props.size)}\"\r\n ${props.disabled ? 'disabled' : ''}\r\n >\r\n <slot>${escapeProp(props.label)}</slot>\r\n </button>\r\n `,\r\n });\r\n\r\n component<{ title: string; footer: string; elevated: boolean }>(tags.card, {\r\n props: {\r\n title: { type: String, default: '' },\r\n footer: { type: String, default: '' },\r\n elevated: { type: Boolean, default: true },\r\n },\r\n styles: `\r\n ${baseStyles}\r\n article {\r\n background: #fff;\r\n border: 1px solid #e2e8f0;\r\n border-radius: 1rem;\r\n box-shadow: 0 10px 25px rgba(15, 23, 42, 0.08);\r\n color: #0f172a;\r\n display: block;\r\n padding: 1rem;\r\n }\r\n article[data-elevated='false'] {\r\n box-shadow: none;\r\n }\r\n header, footer {\r\n color: #475569;\r\n font-size: 0.95rem;\r\n font-weight: 600;\r\n }\r\n header {\r\n margin-bottom: 0.75rem;\r\n }\r\n footer {\r\n margin-top: 0.75rem;\r\n }\r\n `,\r\n render: ({ props }) => html`\r\n <article part=\"card\" data-elevated=\"${String(props.elevated)}\">\r\n ${props.title ? `<header part=\"header\">${escapeProp(props.title)}</header>` : ''}\r\n <section part=\"body\"><slot></slot></section>\r\n ${props.footer ? `<footer part=\"footer\">${escapeProp(props.footer)}</footer>` : ''}\r\n </article>\r\n `,\r\n });\r\n\r\n component<{\r\n label: string;\r\n type: string;\r\n value: string;\r\n placeholder: string;\r\n name: string;\r\n disabled: boolean;\r\n }>(tags.input, {\r\n props: {\r\n label: { type: String, default: '' },\r\n type: { type: String, default: 'text' },\r\n value: { type: String, default: '' },\r\n placeholder: { type: String, default: '' },\r\n name: { type: String, default: '' },\r\n disabled: { type: Boolean, default: false },\r\n },\r\n styles: controlStyles,\r\n /**\r\n * Skip the full shadow DOM re-render when only the reflected input value\r\n * changed, because the live control has already been patched in place.\r\n */\r\n beforeUpdate(props) {\r\n if (canSkipInputRender(this, props)) {\r\n return false;\r\n }\r\n return true;\r\n },\r\n connected() {\r\n const handleInput = (event: Event) => {\r\n const target = event.target as HTMLInputElement | null;\r\n if (!target?.matches('input')) return;\r\n event.stopPropagation();\r\n this.setAttribute('value', target.value);\r\n this.dispatchEvent(\r\n new CustomEvent('input', {\r\n detail: { value: target.value },\r\n bubbles: true,\r\n composed: true,\r\n })\r\n );\r\n };\r\n storeHandler(this, '__bqueryInputHandler', handleInput);\r\n this.shadowRoot?.addEventListener('input', handleInput);\r\n },\r\n disconnected() {\r\n const handleInput = readHandler(this, '__bqueryInputHandler');\r\n if (handleInput) {\r\n this.shadowRoot?.removeEventListener('input', handleInput);\r\n }\r\n },\r\n render: ({ props }) => html`\r\n <label part=\"field\" class=\"field\">\r\n ${props.label ? `<span part=\"label\" class=\"label\">${escapeProp(props.label)}</span>` : ''}\r\n <input\r\n part=\"control\"\r\n class=\"control\"\r\n type=\"${escapeProp(props.type)}\"\r\n value=\"${escapeProp(props.value)}\"\r\n placeholder=\"${escapeProp(props.placeholder)}\"\r\n name=\"${escapeProp(props.name)}\"\r\n ${props.disabled ? 'disabled' : ''}\r\n />\r\n </label>\r\n `,\r\n });\r\n\r\n component<{\r\n label: string;\r\n value: string;\r\n placeholder: string;\r\n name: string;\r\n rows: number;\r\n disabled: boolean;\r\n }>(tags.textarea, {\r\n props: {\r\n label: { type: String, default: '' },\r\n value: { type: String, default: '' },\r\n placeholder: { type: String, default: '' },\r\n name: { type: String, default: '' },\r\n rows: { type: Number, default: 4 },\r\n disabled: { type: Boolean, default: false },\r\n },\r\n styles: `${controlStyles}\r\n textarea.control {\r\n min-height: 6rem;\r\n resize: vertical;\r\n }\r\n `,\r\n /**\r\n * Skip the full shadow DOM re-render when only the reflected textarea value\r\n * changed, because the live control has already been patched in place.\r\n */\r\n beforeUpdate(props) {\r\n if (canSkipTextareaRender(this, props)) {\r\n return false;\r\n }\r\n return true;\r\n },\r\n connected() {\r\n const handleInput = (event: Event) => {\r\n const target = event.target as HTMLTextAreaElement | null;\r\n if (!target?.matches('textarea')) return;\r\n event.stopPropagation();\r\n this.setAttribute('value', target.value);\r\n this.dispatchEvent(\r\n new CustomEvent('input', {\r\n detail: { value: target.value },\r\n bubbles: true,\r\n composed: true,\r\n })\r\n );\r\n };\r\n storeHandler(this, '__bqueryTextareaHandler', handleInput);\r\n this.shadowRoot?.addEventListener('input', handleInput);\r\n },\r\n disconnected() {\r\n const handleInput = readHandler(this, '__bqueryTextareaHandler');\r\n if (handleInput) {\r\n this.shadowRoot?.removeEventListener('input', handleInput);\r\n }\r\n },\r\n render: ({ props }) => html`\r\n <label part=\"field\" class=\"field\">\r\n ${props.label ? `<span part=\"label\" class=\"label\">${escapeProp(props.label)}</span>` : ''}\r\n ${renderTextareaControl(props)}\r\n </label>\r\n `,\r\n });\r\n\r\n component<{ label: string; checked: boolean; disabled: boolean }>(tags.checkbox, {\r\n props: {\r\n label: { type: String, default: '' },\r\n checked: { type: Boolean, default: false },\r\n disabled: { type: Boolean, default: false },\r\n },\r\n styles: `\r\n ${baseStyles}\r\n label {\r\n align-items: center;\r\n color: #0f172a;\r\n cursor: pointer;\r\n display: inline-flex;\r\n gap: 0.625rem;\r\n }\r\n input {\r\n accent-color: #2563eb;\r\n block-size: 1rem;\r\n inline-size: 1rem;\r\n }\r\n input:disabled {\r\n cursor: not-allowed;\r\n }\r\n `,\r\n connected() {\r\n const handleChange = (event: Event) => {\r\n const target = event.target as HTMLInputElement | null;\r\n if (!target?.matches('input[type=\"checkbox\"]')) return;\r\n event.stopPropagation();\r\n if (target.checked) {\r\n this.setAttribute('checked', 'true');\r\n } else {\r\n this.removeAttribute('checked');\r\n }\r\n this.dispatchEvent(\r\n new CustomEvent('change', {\r\n detail: { checked: target.checked },\r\n bubbles: true,\r\n composed: true,\r\n })\r\n );\r\n };\r\n storeHandler(this, '__bqueryCheckboxHandler', handleChange);\r\n this.shadowRoot?.addEventListener('change', handleChange);\r\n },\r\n disconnected() {\r\n const handleChange = readHandler(this, '__bqueryCheckboxHandler');\r\n if (handleChange) {\r\n this.shadowRoot?.removeEventListener('change', handleChange);\r\n }\r\n },\r\n render: ({ props }) => html`\r\n <label part=\"label\">\r\n <input\r\n part=\"control\"\r\n type=\"checkbox\"\r\n ${props.checked ? 'checked' : ''}\r\n ${props.disabled ? 'disabled' : ''}\r\n />\r\n <span part=\"text\"><slot>${escapeProp(props.label)}</slot></span>\r\n </label>\r\n `,\r\n });\r\n\r\n return tags;\r\n};\r\n"],"mappings":";;AAkBA,IAAa,IAAA,CAAsB,GAAkB,MAAiC;AACpF,QAAM,EAAE,MAAA,EAAA,IAAS;AAEjB,MAAI,MAAS,OAAQ,QAAO;AAE5B,MAAI,MAAS,OACX,QAAO,OAAO,CAAA;AAGhB,MAAI,MAAS,SAAS;AACpB,UAAM,IAAa,EAAS,KAAA,EAAO,YAAA;AACnC,WAAI,MAAe,MAAM,MAAe,UAAU,MAAe,MACxD,KAEL,MAAe,WAAW,MAAe,MACpC,KAEF,EAAQ;AAAA;AAGjB,MAAI,MAAS,UAAU,MAAS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C5B,EAAM,WAAW,aAAa,EAAA;AAAA;AAAA,kCAER,EAAW,EAAM,KAAA,CAAM;AAAA;AAAA;AAAA,GAGtD,GAEM"}
|
package/dist/component.es.mjs
CHANGED
|
@@ -1,186 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const p = (e, r) => {
|
|
3
|
-
const { type: s } = r;
|
|
4
|
-
if (s === String) return e;
|
|
5
|
-
if (s === Number)
|
|
6
|
-
return Number(e);
|
|
7
|
-
if (s === Boolean) {
|
|
8
|
-
const c = e.trim().toLowerCase();
|
|
9
|
-
return c === "" || c === "true" || c === "1" ? !0 : c === "false" || c === "0" ? !1 : !!e;
|
|
10
|
-
}
|
|
11
|
-
if (s === Object || s === Array)
|
|
12
|
-
try {
|
|
13
|
-
return JSON.parse(e);
|
|
14
|
-
} catch {
|
|
15
|
-
return e;
|
|
16
|
-
}
|
|
17
|
-
if (typeof s == "function") {
|
|
18
|
-
const c = s, t = s;
|
|
19
|
-
if (r.construct === !0)
|
|
20
|
-
return Reflect.construct(t, [e]);
|
|
21
|
-
if (r.construct === !1)
|
|
22
|
-
return c(e);
|
|
23
|
-
const o = s.prototype !== void 0 && s.prototype !== null, u = (o ? Object.getOwnPropertyNames(s.prototype) : []).length > 1, n = o && s.prototype.constructor !== s, l = /^class\s/.test(Function.prototype.toString.call(s));
|
|
24
|
-
if (u || n || l)
|
|
25
|
-
try {
|
|
26
|
-
return Reflect.construct(t, [e]);
|
|
27
|
-
} catch {
|
|
28
|
-
return c(e);
|
|
29
|
-
}
|
|
30
|
-
try {
|
|
31
|
-
const a = c(e);
|
|
32
|
-
if (a === void 0 && o)
|
|
33
|
-
try {
|
|
34
|
-
return Reflect.construct(t, [e]);
|
|
35
|
-
} catch {
|
|
36
|
-
return a;
|
|
37
|
-
}
|
|
38
|
-
return a;
|
|
39
|
-
} catch (a) {
|
|
40
|
-
if (a instanceof TypeError && /cannot be invoked without 'new'|is not a function/i.test(a.message))
|
|
41
|
-
return Reflect.construct(t, [e]);
|
|
42
|
-
throw a;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return e;
|
|
46
|
-
}, d = (e, r) => {
|
|
47
|
-
class s extends HTMLElement {
|
|
48
|
-
constructor() {
|
|
49
|
-
super(), this.state = { ...r.state ?? {} }, this.props = {}, this.missingRequiredProps = /* @__PURE__ */ new Set(), this.hasMounted = !1, this.attachShadow({ mode: "open" }), this.syncProps();
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Returns the list of attributes to observe for changes.
|
|
53
|
-
*/
|
|
54
|
-
static get observedAttributes() {
|
|
55
|
-
return Object.keys(r.props ?? {});
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Called when the element is added to the DOM.
|
|
59
|
-
*/
|
|
60
|
-
connectedCallback() {
|
|
61
|
-
try {
|
|
62
|
-
if (this.missingRequiredProps.size > 0)
|
|
63
|
-
return;
|
|
64
|
-
this.mount();
|
|
65
|
-
} catch (t) {
|
|
66
|
-
this.handleError(t);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Performs the initial mount of the component.
|
|
71
|
-
* Called when the element is connected and all required props are present.
|
|
72
|
-
* @internal
|
|
73
|
-
*/
|
|
74
|
-
mount() {
|
|
75
|
-
this.hasMounted || (r.beforeMount?.call(this), r.connected?.call(this), this.render(), this.hasMounted = !0);
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Called when the element is removed from the DOM.
|
|
79
|
-
*/
|
|
80
|
-
disconnectedCallback() {
|
|
81
|
-
try {
|
|
82
|
-
r.disconnected?.call(this);
|
|
83
|
-
} catch (t) {
|
|
84
|
-
this.handleError(t);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Called when an observed attribute changes.
|
|
89
|
-
*/
|
|
90
|
-
attributeChangedCallback(t, o, i) {
|
|
91
|
-
try {
|
|
92
|
-
this.syncProps(), this.hasMounted ? this.render(!0) : this.isConnected && this.missingRequiredProps.size === 0 && this.mount();
|
|
93
|
-
} catch (u) {
|
|
94
|
-
this.handleError(u);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Handles errors during component lifecycle.
|
|
99
|
-
* @internal
|
|
100
|
-
*/
|
|
101
|
-
handleError(t) {
|
|
102
|
-
r.onError ? r.onError.call(this, t) : console.error(`bQuery component error in <${e}>:`, t);
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Updates a state property and triggers a re-render.
|
|
106
|
-
*
|
|
107
|
-
* @param key - The state property key
|
|
108
|
-
* @param value - The new value
|
|
109
|
-
*/
|
|
110
|
-
setState(t, o) {
|
|
111
|
-
this.state[t] = o, this.render(!0);
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Gets a state property value.
|
|
115
|
-
*
|
|
116
|
-
* @param key - The state property key
|
|
117
|
-
* @returns The current value
|
|
118
|
-
*/
|
|
119
|
-
getState(t) {
|
|
120
|
-
return this.state[t];
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Synchronizes props from attributes.
|
|
124
|
-
* @internal
|
|
125
|
-
*/
|
|
126
|
-
syncProps() {
|
|
127
|
-
const t = r.props ?? {};
|
|
128
|
-
for (const [o, i] of Object.entries(t)) {
|
|
129
|
-
const u = this.getAttribute(o);
|
|
130
|
-
let n;
|
|
131
|
-
if (u == null ? i.required && i.default === void 0 ? (this.missingRequiredProps.add(o), n = void 0) : n = i.default ?? void 0 : (this.missingRequiredProps.has(o) && this.missingRequiredProps.delete(o), n = p(u, i)), i.validator && n !== void 0 && !i.validator(n))
|
|
132
|
-
throw new Error(
|
|
133
|
-
`bQuery component: validation failed for prop "${o}" with value ${JSON.stringify(n)}`
|
|
134
|
-
);
|
|
135
|
-
this.props[o] = n;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Renders the component to its shadow root.
|
|
140
|
-
* @internal
|
|
141
|
-
*/
|
|
142
|
-
render(t = !1) {
|
|
143
|
-
try {
|
|
144
|
-
if (t && r.beforeUpdate && r.beforeUpdate.call(this, this.props) === !1)
|
|
145
|
-
return;
|
|
146
|
-
const o = (n, l) => {
|
|
147
|
-
this.dispatchEvent(new CustomEvent(n, { detail: l, bubbles: !0, composed: !0 }));
|
|
148
|
-
};
|
|
149
|
-
if (!this.shadowRoot) return;
|
|
150
|
-
const i = r.render({
|
|
151
|
-
props: this.props,
|
|
152
|
-
state: this.state,
|
|
153
|
-
emit: o
|
|
154
|
-
}), u = h(i);
|
|
155
|
-
if (this.shadowRoot.innerHTML = u, r.styles) {
|
|
156
|
-
const n = document.createElement("style");
|
|
157
|
-
n.textContent = r.styles, this.shadowRoot.prepend(n);
|
|
158
|
-
}
|
|
159
|
-
t && r.updated?.call(this);
|
|
160
|
-
} catch (o) {
|
|
161
|
-
this.handleError(o);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return s;
|
|
166
|
-
}, b = (e, r) => {
|
|
167
|
-
const s = d(e, r);
|
|
168
|
-
customElements.get(e) || customElements.define(e, s);
|
|
169
|
-
}, E = (e, ...r) => e.reduce((s, c, t) => `${s}${c}${r[t] ?? ""}`, ""), g = (e, ...r) => {
|
|
170
|
-
const s = {
|
|
171
|
-
"&": "&",
|
|
172
|
-
"<": "<",
|
|
173
|
-
">": ">",
|
|
174
|
-
'"': """,
|
|
175
|
-
"'": "'",
|
|
176
|
-
"`": "`"
|
|
177
|
-
}, c = (t) => String(t ?? "").replace(/[&<>"'`]/g, (i) => s[i]);
|
|
178
|
-
return e.reduce((t, o, i) => `${t}${o}${c(r[i])}`, "");
|
|
179
|
-
};
|
|
1
|
+
import { a as t, i as o, n as a, r as n, t as s } from "./component-CY5MVoYN.js";
|
|
180
2
|
export {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
3
|
+
o as component,
|
|
4
|
+
t as defineComponent,
|
|
5
|
+
a as html,
|
|
6
|
+
s as registerDefaultComponents,
|
|
7
|
+
n as safeHtml
|
|
185
8
|
};
|
|
186
|
-
//# sourceMappingURL=component.es.mjs.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { i as o, r as f } from "./object-qGpWr6-J.js";
|
|
2
|
+
var s = {
|
|
3
|
+
fetch: {
|
|
4
|
+
headers: {},
|
|
5
|
+
parseAs: "json"
|
|
6
|
+
},
|
|
7
|
+
cookies: {
|
|
8
|
+
path: "/",
|
|
9
|
+
sameSite: "Lax",
|
|
10
|
+
secure: !1
|
|
11
|
+
},
|
|
12
|
+
announcer: {
|
|
13
|
+
politeness: "polite",
|
|
14
|
+
atomic: !0,
|
|
15
|
+
delay: 16,
|
|
16
|
+
clearDelay: 1e3
|
|
17
|
+
},
|
|
18
|
+
pageMeta: {},
|
|
19
|
+
transitions: {
|
|
20
|
+
skipOnReducedMotion: !1,
|
|
21
|
+
classes: [],
|
|
22
|
+
types: []
|
|
23
|
+
},
|
|
24
|
+
components: { prefix: "bq" }
|
|
25
|
+
}, r = (e) => {
|
|
26
|
+
if (typeof Headers < "u" && e instanceof Headers) return new Headers(e);
|
|
27
|
+
if (Array.isArray(e)) return e.map((n) => r(n));
|
|
28
|
+
if (f(e)) {
|
|
29
|
+
const n = {};
|
|
30
|
+
for (const [a, i] of Object.entries(e)) n[a] = r(i);
|
|
31
|
+
return n;
|
|
32
|
+
}
|
|
33
|
+
return e;
|
|
34
|
+
}, t = r(s), d = (e) => (t = r(o(s, t, e)), c()), c = () => r(t);
|
|
35
|
+
export {
|
|
36
|
+
c as n,
|
|
37
|
+
d as t
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=config-DRmZZno3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-DRmZZno3.js","names":[],"sources":["../src/platform/config.ts"],"sourcesContent":["/**\r\n * Global bQuery configuration helpers.\r\n *\r\n * @module bquery/platform\r\n */\r\n\r\nimport { isPlainObject, merge } from '../core/utils/object';\r\n\r\n/** Supported response parsing strategies for fetch composables. */\r\nexport type BqueryFetchParseAs = 'json' | 'text' | 'blob' | 'arrayBuffer' | 'formData' | 'response';\r\n\r\n/** Global fetch defaults used by useFetch(). */\r\nexport interface BqueryFetchConfig {\r\n /** Optional base URL prepended to relative request URLs. */\r\n baseUrl?: string;\r\n /** Default request headers. */\r\n headers?: HeadersInit;\r\n /** Default response parser. */\r\n parseAs?: BqueryFetchParseAs;\r\n}\r\n\r\n/** Global cookie defaults used by useCookie(). */\r\nexport interface BqueryCookieConfig {\r\n /** Default cookie path. */\r\n path?: string;\r\n /** Default SameSite mode. */\r\n sameSite?: 'Strict' | 'Lax' | 'None';\r\n /** Whether cookies should be marked secure by default. */\r\n secure?: boolean;\r\n}\r\n\r\n/** Global announcer defaults used by useAnnouncer(). */\r\nexport interface BqueryAnnouncerConfig {\r\n /** Default politeness level. */\r\n politeness?: 'polite' | 'assertive';\r\n /** Whether announcements should be treated atomically. */\r\n atomic?: boolean;\r\n /** Delay before writing the message into the live region. */\r\n delay?: number;\r\n /** Delay after which the live region is cleared automatically. */\r\n clearDelay?: number;\r\n}\r\n\r\n/** Global page meta defaults used by definePageMeta(). */\r\nexport interface BqueryPageMetaConfig {\r\n /** Optional title template function. */\r\n titleTemplate?: (title: string) => string;\r\n}\r\n\r\n/** Global motion defaults used by transition(). */\r\nexport interface BqueryTransitionConfig {\r\n /** Skip transitions when reduced motion is preferred. */\r\n skipOnReducedMotion?: boolean;\r\n /** Classes applied to the root element during transitions. */\r\n classes?: string[];\r\n /** Transition type identifiers added when supported by the browser. */\r\n types?: string[];\r\n}\r\n\r\n/** Global default component library configuration. */\r\nexport interface BqueryComponentLibraryConfig {\r\n /** Prefix used by registerDefaultComponents(). */\r\n prefix?: string;\r\n}\r\n\r\n/** Complete global bQuery configuration object. */\r\nexport interface BqueryConfig {\r\n /** Fetch composable defaults. */\r\n fetch?: BqueryFetchConfig;\r\n /** Cookie composable defaults. */\r\n cookies?: BqueryCookieConfig;\r\n /** Announcer composable defaults. */\r\n announcer?: BqueryAnnouncerConfig;\r\n /** Page metadata defaults. */\r\n pageMeta?: BqueryPageMetaConfig;\r\n /** View transition defaults. */\r\n transitions?: BqueryTransitionConfig;\r\n /** Default component library options. */\r\n components?: BqueryComponentLibraryConfig;\r\n}\r\n\r\nconst defaultConfig: BqueryConfig = {\r\n fetch: {\r\n headers: {},\r\n parseAs: 'json',\r\n },\r\n cookies: {\r\n path: '/',\r\n sameSite: 'Lax',\r\n secure: false,\r\n },\r\n announcer: {\r\n politeness: 'polite',\r\n atomic: true,\r\n delay: 16,\r\n clearDelay: 1000,\r\n },\r\n pageMeta: {},\r\n transitions: {\r\n skipOnReducedMotion: false,\r\n classes: [],\r\n types: [],\r\n },\r\n components: {\r\n prefix: 'bq',\r\n },\r\n};\r\n\r\nconst cloneConfigValue = <T>(value: T): T => {\r\n if (typeof Headers !== 'undefined' && value instanceof Headers) {\r\n return new Headers(value) as T;\r\n }\r\n\r\n if (Array.isArray(value)) {\r\n return value.map((entry) => cloneConfigValue(entry)) as T;\r\n }\r\n\r\n if (isPlainObject(value)) {\r\n const result: Record<string, unknown> = {};\r\n for (const [key, entry] of Object.entries(value)) {\r\n result[key] = cloneConfigValue(entry);\r\n }\r\n return result as T;\r\n }\r\n\r\n return value;\r\n};\r\n\r\nlet currentConfig: BqueryConfig = cloneConfigValue(defaultConfig);\r\n\r\n/**\r\n * Define or extend the global bQuery configuration.\r\n *\r\n * @param config - Partial configuration values to merge into the current config\r\n * @returns The resolved configuration after merging\r\n *\r\n * @example\r\n * ```ts\r\n * defineBqueryConfig({\r\n * fetch: { baseUrl: 'https://api.example.com' },\r\n * components: { prefix: 'ui' },\r\n * });\r\n * ```\r\n */\r\nexport const defineBqueryConfig = (config: BqueryConfig): BqueryConfig => {\r\n currentConfig = cloneConfigValue(\r\n merge(\r\n defaultConfig as Record<string, unknown>,\r\n currentConfig as Record<string, unknown>,\r\n config as Record<string, unknown>\r\n ) as BqueryConfig\r\n );\r\n return getBqueryConfig();\r\n};\r\n\r\n/**\r\n * Get the currently resolved bQuery configuration.\r\n *\r\n * @returns A cloned snapshot of the active configuration\r\n */\r\nexport const getBqueryConfig = (): BqueryConfig => {\r\n return cloneConfigValue(currentConfig);\r\n};\r\n"],"mappings":";AAiFA,IAAM,IAA8B;AAAA,EAClC,OAAO;AAAA,IACL,SAAS,CAAA;AAAA,IACT,SAAS;AAAA;EAEX,SAAS;AAAA,IACP,MAAM;AAAA,IACN,UAAU;AAAA,IACV,QAAQ;AAAA;EAEV,WAAW;AAAA,IACT,YAAY;AAAA,IACZ,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,YAAY;AAAA;EAEd,UAAU,CAAA;AAAA,EACV,aAAa;AAAA,IACX,qBAAqB;AAAA,IACrB,SAAS,CAAA;AAAA,IACT,OAAO,CAAA;AAAA;EAET,YAAY,EACV,QAAQ,KAAA;GAIN,IAAA,CAAuB,MAAgB;AAC3C,MAAI,OAAO,UAAY,OAAe,aAAiB,QACrD,QAAO,IAAI,QAAQ,CAAA;AAGrB,MAAI,MAAM,QAAQ,CAAA,EAChB,QAAO,EAAM,IAAA,CAAK,MAAU,EAAiB,CAAA,CAAM;AAGrD,MAAI,EAAc,CAAA,GAAQ;AACxB,UAAM,IAAkC,CAAA;AACxC,eAAW,CAAC,GAAK,CAAA,KAAU,OAAO,QAAQ,CAAA,EACxC,CAAA,EAAO,CAAA,IAAO,EAAiB,CAAA;AAEjC,WAAO;AAAA;AAGT,SAAO;GAGL,IAA8B,EAAiB,CAAA,GAgBtC,IAAA,CAAsB,OACjC,IAAgB,EACd,EACE,GACA,GACA,CAAA,CACD,GAEI,EAAA,IAQI,IAAA,MACJ,EAAiB,CAAA"}
|
|
@@ -148,13 +148,16 @@ export declare class BQueryCollection {
|
|
|
148
148
|
/** Insert content after all elements. */
|
|
149
149
|
after(content: InsertableContent): this;
|
|
150
150
|
/**
|
|
151
|
-
*
|
|
151
|
+
* Gets or sets CSS styles on all elements.
|
|
152
|
+
* When getting, returns the computed style value from the first element.
|
|
152
153
|
*
|
|
153
154
|
* @param property - Property name or object of properties
|
|
154
155
|
* @param value - Value when setting single property
|
|
155
|
-
* @returns The instance
|
|
156
|
+
* @returns The computed style value when getting, instance when setting
|
|
156
157
|
*/
|
|
157
|
-
css(property: string
|
|
158
|
+
css(property: string): string;
|
|
159
|
+
css(property: string, value: string): this;
|
|
160
|
+
css(property: Record<string, string>): this;
|
|
158
161
|
/** Wrap each element with a wrapper element or tag. */
|
|
159
162
|
wrap(wrapper: string | Element): this;
|
|
160
163
|
/**
|
|
@@ -262,6 +265,19 @@ export declare class BQueryCollection {
|
|
|
262
265
|
* ```
|
|
263
266
|
*/
|
|
264
267
|
undelegate(event: string, selector: string, handler: (event: Event, target: Element) => void): this;
|
|
268
|
+
/**
|
|
269
|
+
* Finds all descendant elements matching the selector across all elements
|
|
270
|
+
* in the collection. Returns a new BQueryCollection with the results.
|
|
271
|
+
*
|
|
272
|
+
* @param selector - CSS selector to match
|
|
273
|
+
* @returns A new BQueryCollection with all matching descendants
|
|
274
|
+
*
|
|
275
|
+
* @example
|
|
276
|
+
* ```ts
|
|
277
|
+
* $$('.container').find('.item').addClass('highlight');
|
|
278
|
+
* ```
|
|
279
|
+
*/
|
|
280
|
+
find(selector: string): BQueryCollection;
|
|
265
281
|
/**
|
|
266
282
|
* Removes all elements from the DOM.
|
|
267
283
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../../src/core/collection.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAM1C;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,gBAAgB;aAgBC,QAAQ,EAAE,OAAO,EAAE;IAf/C;;;;;OAKG;IACH,OAAO,CAAC,QAAQ,CAAC,iBAAiB,C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,IAAI;IAKjD;;;;;;OAMG;IACH,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,kCAAkC,GAAG,IAAI;IAKrE;;;;;;OAMG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI;IAO9C;;;;;;;;;;;;;;;;;;;OAmBG;IACH,QAAQ,CACN,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,GAC/C,IAAI;IA4BP;;;;;;;;;;;;;;;;OAgBG;IACH,UAAU,CACR,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,GAC/C,IAAI;IA4BP;;;;;;;;;;;OAWG;IACH,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,gBAAgB;IAexC;;;;OAIG;IACH,MAAM,IAAI,IAAI;IAKd;;;;OAIG;IACH,KAAK,IAAI,IAAI;IAOb,gBAAgB;IAChB,OAAO,CAAC,SAAS;CAiBlB"}
|
package/dist/core/element.d.ts
CHANGED
|
@@ -68,18 +68,23 @@ export declare class BQueryElement {
|
|
|
68
68
|
*
|
|
69
69
|
* @param property - A CSS property name or an object of property-value pairs
|
|
70
70
|
* @param value - The value when setting a single property
|
|
71
|
-
* @returns The instance for method chaining
|
|
71
|
+
* @returns The computed style value when getting a single property, or the instance for method chaining when setting
|
|
72
72
|
*
|
|
73
73
|
* @example
|
|
74
74
|
* ```ts
|
|
75
|
-
* //
|
|
75
|
+
* // Get a computed style value
|
|
76
|
+
* const color = $('#box').css('color');
|
|
77
|
+
*
|
|
78
|
+
* // Set a single property
|
|
76
79
|
* $('#box').css('color', 'red');
|
|
77
80
|
*
|
|
78
|
-
* //
|
|
81
|
+
* // Set multiple properties
|
|
79
82
|
* $('#box').css({ color: 'red', 'font-size': '16px' });
|
|
80
83
|
* ```
|
|
81
84
|
*/
|
|
82
|
-
css(property: string
|
|
85
|
+
css(property: string): string;
|
|
86
|
+
css(property: string, value: string): this;
|
|
87
|
+
css(property: Record<string, string>): this;
|
|
83
88
|
/**
|
|
84
89
|
* Appends HTML or elements to the end of the element.
|
|
85
90
|
*
|
|
@@ -313,6 +318,20 @@ export declare class BQueryElement {
|
|
|
313
318
|
* @returns True if the element matches the selector
|
|
314
319
|
*/
|
|
315
320
|
matches(selector: string): boolean;
|
|
321
|
+
/**
|
|
322
|
+
* Alias for `matches()`. Checks if the element matches a CSS selector.
|
|
323
|
+
*
|
|
324
|
+
* @param selector - CSS selector to match against
|
|
325
|
+
* @returns True if the element matches the selector
|
|
326
|
+
*
|
|
327
|
+
* @example
|
|
328
|
+
* ```ts
|
|
329
|
+
* if ($('#el').is('.active')) {
|
|
330
|
+
* console.log('Element is active');
|
|
331
|
+
* }
|
|
332
|
+
* ```
|
|
333
|
+
*/
|
|
334
|
+
is(selector: string): boolean;
|
|
316
335
|
/**
|
|
317
336
|
* Checks if the element has a specific class.
|
|
318
337
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../../src/core/element.ts"],"names":[],"mappings":"AA2BA,qBAAa,aAAa;IAYZ,OAAO,CAAC,QAAQ,CAAC,OAAO;IAXpC;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAA2D;IAE7F;;;OAGG;gBAC0B,OAAO,EAAE,OAAO;IAE7C;;;OAGG;IACH,IAAI,GAAG,IAAI,OAAO,CAEjB;IAED;;;OAGG;IACH,IAAI,IAAI,IAAI,OAAO,CAElB;IAED,+BAA+B;IAC/B,QAAQ,CAAC,GAAG,UAAU,EAAE,MAAM,EAAE,GAAG,IAAI;IAKvC,kCAAkC;IAClC,WAAW,CAAC,GAAG,UAAU,EAAE,MAAM,EAAE,GAAG,IA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IAM7B;;;;OAIG;IACH,KAAK,IAAI,IAAI;IAKb;;;;OAIG;IACH,IAAI,IAAI,IAAI;IAKZ;;;;;OAKG;IACH,GAAG,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IASrC;;;;;;;;;;;;OAYG;IACH,SAAS,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IA4B9C;;;;;;;;;;OAUG;IACH,eAAe,IAAI,MAAM;IAkBzB;;;;OAIG;IACH,IAAI,IAAI,OAAO;IAIf;;;;OAIG;IACH,MAAM,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE;IAUtE;;;OAGG;IACH,OAAO,CAAC,aAAa;CAGtB"}
|
package/dist/core/index.d.ts
CHANGED
|
@@ -3,4 +3,5 @@ export { BQueryElement } from './element';
|
|
|
3
3
|
export { $, $$ } from './selector';
|
|
4
4
|
export { utils } from './utils';
|
|
5
5
|
export { chunk, compact, ensureArray, flatten, unique, debounce, noop, once, throttle, isEmpty, parseJson, sleep, uid, clamp, inRange, randomInt, toNumber, clone, hasOwn, isPlainObject, merge, omit, pick, capitalize, escapeRegExp, slugify, toCamelCase, toKebabCase, truncate, isArray, isBoolean, isCollection, isDate, isElement, isFunction, isNumber, isObject, isPromise, isString, } from './utils';
|
|
6
|
+
export type { DebouncedFn, ThrottledFn } from './utils';
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,EACL,KAAK,EACL,OAAO,EACP,WAAW,EACX,OAAO,EACP,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,SAAS,EACT,KAAK,EACL,GAAG,EACH,KAAK,EACL,OAAO,EACP,SAAS,EACT,QAAQ,EACR,KAAK,EACL,MAAM,EACN,aAAa,EACb,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,UAAU,EACV,YAAY,EACZ,OAAO,EACP,WAAW,EACX,WAAW,EACX,QAAQ,EACR,OAAO,EACP,SAAS,EACT,YAAY,EACZ,MAAM,EACN,SAAS,EACT,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,QAAQ,GACT,MAAM,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,EACL,KAAK,EACL,OAAO,EACP,WAAW,EACX,OAAO,EACP,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,SAAS,EACT,KAAK,EACL,GAAG,EACH,KAAK,EACL,OAAO,EACP,SAAS,EACT,QAAQ,EACR,KAAK,EACL,MAAM,EACN,aAAa,EACb,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,UAAU,EACV,YAAY,EACZ,OAAO,EACP,WAAW,EACX,WAAW,EACX,QAAQ,EACR,OAAO,EACP,SAAS,EACT,YAAY,EACZ,MAAM,EACN,SAAS,EACT,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,QAAQ,GACT,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module bquery/core/utils/function
|
|
5
5
|
*/
|
|
6
|
+
/** A debounced function with a cancel method to clear the pending timeout. */
|
|
7
|
+
export interface DebouncedFn<TArgs extends unknown[]> {
|
|
8
|
+
(...args: TArgs): void;
|
|
9
|
+
/** Cancels the pending debounced invocation. */
|
|
10
|
+
cancel(): void;
|
|
11
|
+
}
|
|
12
|
+
/** A throttled function with a cancel method to reset the throttle timer. */
|
|
13
|
+
export interface ThrottledFn<TArgs extends unknown[]> {
|
|
14
|
+
(...args: TArgs): void;
|
|
15
|
+
/** Resets the throttle timer, allowing the next call to execute immediately. */
|
|
16
|
+
cancel(): void;
|
|
17
|
+
}
|
|
6
18
|
/**
|
|
7
19
|
* Creates a debounced function that delays execution until after
|
|
8
20
|
* the specified delay has elapsed since the last call.
|
|
@@ -10,7 +22,7 @@
|
|
|
10
22
|
* @template TArgs - The argument types of the function
|
|
11
23
|
* @param fn - The function to debounce
|
|
12
24
|
* @param delayMs - Delay in milliseconds
|
|
13
|
-
* @returns A debounced version of the function
|
|
25
|
+
* @returns A debounced version of the function with a `cancel()` method
|
|
14
26
|
*
|
|
15
27
|
* @example
|
|
16
28
|
* ```ts
|
|
@@ -21,16 +33,19 @@
|
|
|
21
33
|
* search('h');
|
|
22
34
|
* search('he');
|
|
23
35
|
* search('hello'); // Only this call executes after 300ms
|
|
36
|
+
*
|
|
37
|
+
* search('cancel me');
|
|
38
|
+
* search.cancel(); // Cancels the pending invocation
|
|
24
39
|
* ```
|
|
25
40
|
*/
|
|
26
|
-
export declare function debounce<TArgs extends unknown[]>(fn: (...args: TArgs) => void, delayMs: number):
|
|
41
|
+
export declare function debounce<TArgs extends unknown[]>(fn: (...args: TArgs) => void, delayMs: number): DebouncedFn<TArgs>;
|
|
27
42
|
/**
|
|
28
43
|
* Creates a throttled function that runs at most once per interval.
|
|
29
44
|
*
|
|
30
45
|
* @template TArgs - The argument types of the function
|
|
31
46
|
* @param fn - The function to throttle
|
|
32
47
|
* @param intervalMs - Minimum interval between calls in milliseconds
|
|
33
|
-
* @returns A throttled version of the function
|
|
48
|
+
* @returns A throttled version of the function with a `cancel()` method
|
|
34
49
|
*
|
|
35
50
|
* @example
|
|
36
51
|
* ```ts
|
|
@@ -39,9 +54,11 @@ export declare function debounce<TArgs extends unknown[]>(fn: (...args: TArgs) =
|
|
|
39
54
|
* }, 100);
|
|
40
55
|
*
|
|
41
56
|
* window.addEventListener('scroll', handleScroll);
|
|
57
|
+
*
|
|
58
|
+
* handleScroll.cancel(); // Resets throttle, next call executes immediately
|
|
42
59
|
* ```
|
|
43
60
|
*/
|
|
44
|
-
export declare function throttle<TArgs extends unknown[]>(fn: (...args: TArgs) => void, intervalMs: number):
|
|
61
|
+
export declare function throttle<TArgs extends unknown[]>(fn: (...args: TArgs) => void, intervalMs: number): ThrottledFn<TArgs>;
|
|
45
62
|
/**
|
|
46
63
|
* Ensures a function only runs once. Subsequent calls return the first result.
|
|
47
64
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function.d.ts","sourceRoot":"","sources":["../../../src/core/utils/function.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH
|
|
1
|
+
{"version":3,"file":"function.d.ts","sourceRoot":"","sources":["../../../src/core/utils/function.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,8EAA8E;AAC9E,MAAM,WAAW,WAAW,CAAC,KAAK,SAAS,OAAO,EAAE;IAClD,CAAC,GAAG,IAAI,EAAE,KAAK,GAAG,IAAI,CAAC;IACvB,gDAAgD;IAChD,MAAM,IAAI,IAAI,CAAC;CAChB;AAED,6EAA6E;AAC7E,MAAM,WAAW,WAAW,CAAC,KAAK,SAAS,OAAO,EAAE;IAClD,CAAC,GAAG,IAAI,EAAE,KAAK,GAAG,IAAI,CAAC;IACvB,gFAAgF;IAChF,MAAM,IAAI,IAAI,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,QAAQ,CAAC,KAAK,SAAS,OAAO,EAAE,EAC9C,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,IAAI,EAC5B,OAAO,EAAE,MAAM,GACd,WAAW,CAAC,KAAK,CAAC,CAsBpB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,QAAQ,CAAC,KAAK,SAAS,OAAO,EAAE,EAC9C,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,IAAI,EAC5B,UAAU,EAAE,MAAM,GACjB,WAAW,CAAC,KAAK,CAAC,CAiBpB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,IAAI,CAAC,KAAK,SAAS,OAAO,EAAE,EAAE,OAAO,EACnD,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,OAAO,GAC9B,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,OAAO,CAU7B;AAED;;;;;;;GAOG;AACH,wBAAgB,IAAI,IAAI,IAAI,CAE3B"}
|