@stryke/hooks 0.4.24 → 0.4.31
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/CHANGELOG.md +342 -0
- package/README.md +18 -10
- package/dist/index.cjs +1 -192
- package/dist/index.d.cts +18 -0
- package/dist/index.d.mts +18 -0
- package/dist/index.mjs +1 -1
- package/dist/is-function-BhD7GXOO.cjs +1 -0
- package/dist/is-function-md4Ym3I0.mjs +2 -0
- package/dist/is-function-md4Ym3I0.mjs.map +1 -0
- package/dist/navigator-CY6InfsZ.d.cts +23 -0
- package/dist/navigator-CY6InfsZ.d.cts.map +1 -0
- package/dist/navigator-DUOlrD-4.d.mts +23 -0
- package/dist/navigator-DUOlrD-4.d.mts.map +1 -0
- package/dist/use-battery-BkRIfbJz.d.mts +11 -0
- package/dist/use-battery-BkRIfbJz.d.mts.map +1 -0
- package/dist/use-battery-DZZDx003.cjs +1 -0
- package/dist/use-battery-DaA7I4_x.mjs +2 -0
- package/dist/use-battery-DaA7I4_x.mjs.map +1 -0
- package/dist/use-battery-DpuF7GMz.d.cts +11 -0
- package/dist/use-battery-DpuF7GMz.d.cts.map +1 -0
- package/dist/use-battery.cjs +1 -46
- package/dist/use-battery.d.cts +2 -0
- package/dist/use-battery.d.mts +2 -0
- package/dist/use-battery.mjs +1 -1
- package/dist/use-callback-ref-B-95d49K.d.mts +9 -0
- package/dist/use-callback-ref-B-95d49K.d.mts.map +1 -0
- package/dist/use-callback-ref-CloM-Kqk.cjs +1 -0
- package/dist/use-callback-ref-ctiFnQn4.d.cts +9 -0
- package/dist/use-callback-ref-ctiFnQn4.d.cts.map +1 -0
- package/dist/use-callback-ref-otlhGzUu.mjs +2 -0
- package/dist/use-callback-ref-otlhGzUu.mjs.map +1 -0
- package/dist/use-callback-ref.cjs +1 -13
- package/dist/use-callback-ref.d.cts +2 -0
- package/dist/use-callback-ref.d.mts +2 -0
- package/dist/use-callback-ref.mjs +1 -1
- package/dist/use-callback-stable-C3QZzhdC.mjs +2 -0
- package/dist/use-callback-stable-C3QZzhdC.mjs.map +1 -0
- package/dist/use-callback-stable-C5X8ySnU.d.mts +55 -0
- package/dist/use-callback-stable-C5X8ySnU.d.mts.map +1 -0
- package/dist/use-callback-stable-CvXmYtWT.cjs +1 -0
- package/dist/use-callback-stable-D_wCU4yv.d.cts +55 -0
- package/dist/use-callback-stable-D_wCU4yv.d.cts.map +1 -0
- package/dist/use-callback-stable.cjs +1 -10
- package/dist/use-callback-stable.d.cts +2 -0
- package/dist/use-callback-stable.d.mts +2 -0
- package/dist/use-callback-stable.mjs +1 -1
- package/dist/use-click-away-Bpl7sh5j.cjs +1 -0
- package/dist/use-click-away-D-DKaD9B.mjs +2 -0
- package/dist/use-click-away-D-DKaD9B.mjs.map +1 -0
- package/dist/use-click-away-DG8ULjSN.d.cts +14 -0
- package/dist/use-click-away-DG8ULjSN.d.cts.map +1 -0
- package/dist/use-click-away-kc61inYs.d.mts +14 -0
- package/dist/use-click-away-kc61inYs.d.mts.map +1 -0
- package/dist/use-click-away.cjs +1 -22
- package/dist/use-click-away.d.cts +2 -0
- package/dist/use-click-away.d.mts +2 -0
- package/dist/use-click-away.mjs +1 -1
- package/dist/use-compose-refs-BUwJN8zY.cjs +1 -0
- package/dist/use-compose-refs-BysZtFy1.mjs +2 -0
- package/dist/use-compose-refs-BysZtFy1.mjs.map +1 -0
- package/dist/{use-compose-refs.d.ts → use-compose-refs-D1nHM35F.d.cts} +10 -4
- package/dist/use-compose-refs-D1nHM35F.d.cts.map +1 -0
- package/dist/use-compose-refs-Dy3epP6l.d.mts +31 -0
- package/dist/use-compose-refs-Dy3epP6l.d.mts.map +1 -0
- package/dist/use-compose-refs.cjs +1 -21
- package/dist/use-compose-refs.d.cts +2 -0
- package/dist/use-compose-refs.d.mts +2 -0
- package/dist/use-compose-refs.mjs +1 -1
- package/dist/use-copy-to-clipboard-Cls03hBs.mjs +2 -0
- package/dist/use-copy-to-clipboard-Cls03hBs.mjs.map +1 -0
- package/dist/use-copy-to-clipboard-D3QmuRQ2.d.mts +10 -0
- package/dist/use-copy-to-clipboard-D3QmuRQ2.d.mts.map +1 -0
- package/dist/use-copy-to-clipboard-DFTtZkv7.cjs +1 -0
- package/dist/use-copy-to-clipboard-DzccpceW.d.cts +10 -0
- package/dist/use-copy-to-clipboard-DzccpceW.d.cts.map +1 -0
- package/dist/use-copy-to-clipboard.cjs +1 -25
- package/dist/use-copy-to-clipboard.d.cts +2 -0
- package/dist/use-copy-to-clipboard.d.mts +2 -0
- package/dist/use-copy-to-clipboard.mjs +1 -1
- package/dist/use-debounce-B07BBb1-.d.mts +17 -0
- package/dist/use-debounce-B07BBb1-.d.mts.map +1 -0
- package/dist/use-debounce-Bh6vyN-1.d.cts +17 -0
- package/dist/use-debounce-Bh6vyN-1.d.cts.map +1 -0
- package/dist/use-debounce-Cto2Ny5z.mjs +2 -0
- package/dist/use-debounce-Cto2Ny5z.mjs.map +1 -0
- package/dist/use-debounce-DWeScEkQ.cjs +1 -0
- package/dist/use-debounce.cjs +1 -26
- package/dist/use-debounce.d.cts +2 -0
- package/dist/use-debounce.d.mts +2 -0
- package/dist/use-debounce.mjs +1 -1
- package/dist/use-did-finish-ssr-B6M_wlP4.mjs +2 -0
- package/dist/use-did-finish-ssr-B6M_wlP4.mjs.map +1 -0
- package/dist/use-did-finish-ssr-BbXffDj5.cjs +1 -0
- package/dist/use-did-finish-ssr-CBz5xeHc.d.mts +10 -0
- package/dist/use-did-finish-ssr-CBz5xeHc.d.mts.map +1 -0
- package/dist/use-did-finish-ssr-D3CpAwOz.d.cts +10 -0
- package/dist/use-did-finish-ssr-D3CpAwOz.d.cts.map +1 -0
- package/dist/use-did-finish-ssr.cjs +1 -28
- package/dist/use-did-finish-ssr.d.cts +2 -0
- package/dist/use-did-finish-ssr.d.mts +2 -0
- package/dist/use-did-finish-ssr.mjs +1 -1
- package/dist/use-escape-keydown-BsJYLp1N.d.cts +8 -0
- package/dist/use-escape-keydown-BsJYLp1N.d.cts.map +1 -0
- package/dist/use-escape-keydown-CFy25Wk6.mjs +2 -0
- package/dist/use-escape-keydown-CFy25Wk6.mjs.map +1 -0
- package/dist/use-escape-keydown-DgPvPpzz.d.mts +8 -0
- package/dist/use-escape-keydown-DgPvPpzz.d.mts.map +1 -0
- package/dist/use-escape-keydown-ITaT9SqI.cjs +1 -0
- package/dist/use-escape-keydown.cjs +1 -19
- package/dist/use-escape-keydown.d.cts +2 -0
- package/dist/use-escape-keydown.d.mts +2 -0
- package/dist/use-escape-keydown.mjs +1 -1
- package/dist/use-event-CBTGhPhg.mjs +2 -0
- package/dist/use-event-CBTGhPhg.mjs.map +1 -0
- package/dist/use-event-DG39UVbo.cjs +1 -0
- package/dist/{use-event.d.ts → use-event-DHFCg8sl.d.cts} +5 -2
- package/dist/use-event-DHFCg8sl.d.cts.map +1 -0
- package/dist/use-event-DQyUWk4T.d.mts +12 -0
- package/dist/use-event-DQyUWk4T.d.mts.map +1 -0
- package/dist/use-event.cjs +1 -20
- package/dist/use-event.d.cts +2 -0
- package/dist/use-event.d.mts +2 -0
- package/dist/use-event.mjs +1 -1
- package/dist/{use-hover.d.ts → use-hover-CPJ3UcMM.d.mts} +5 -1
- package/dist/use-hover-CPJ3UcMM.d.mts.map +1 -0
- package/dist/use-hover-DCP1g7QG.mjs +2 -0
- package/dist/use-hover-DCP1g7QG.mjs.map +1 -0
- package/dist/use-hover-DeFTY9RX.d.cts +10 -0
- package/dist/use-hover-DeFTY9RX.d.cts.map +1 -0
- package/dist/use-hover-SNRrnUoI.cjs +1 -0
- package/dist/use-hover.cjs +1 -21
- package/dist/use-hover.d.cts +2 -0
- package/dist/use-hover.d.mts +2 -0
- package/dist/use-hover.mjs +1 -1
- package/dist/{use-idle.d.ts → use-idle-Car_0ThE.d.cts} +5 -1
- package/dist/use-idle-Car_0ThE.d.cts.map +1 -0
- package/dist/use-idle-CrCoMyLz.cjs +1 -0
- package/dist/use-idle-DrgoS1jh.mjs +2 -0
- package/dist/use-idle-DrgoS1jh.mjs.map +1 -0
- package/dist/use-idle-DwhHMDDp.d.mts +11 -0
- package/dist/use-idle-DwhHMDDp.d.mts.map +1 -0
- package/dist/use-idle.cjs +1 -27
- package/dist/use-idle.d.cts +2 -0
- package/dist/use-idle.d.mts +2 -0
- package/dist/use-idle.mjs +1 -1
- package/dist/use-isomorphic-layout-effect-Br2hUBEM.cjs +1 -0
- package/dist/use-isomorphic-layout-effect-CwRlvm9E.d.cts +13 -0
- package/dist/use-isomorphic-layout-effect-CwRlvm9E.d.cts.map +1 -0
- package/dist/use-isomorphic-layout-effect-D7uazny2.mjs +2 -0
- package/dist/use-isomorphic-layout-effect-D7uazny2.mjs.map +1 -0
- package/dist/use-isomorphic-layout-effect-IWX2e-IS.d.mts +13 -0
- package/dist/use-isomorphic-layout-effect-IWX2e-IS.d.mts.map +1 -0
- package/dist/use-isomorphic-layout-effect.cjs +1 -9
- package/dist/use-isomorphic-layout-effect.d.cts +2 -0
- package/dist/use-isomorphic-layout-effect.d.mts +2 -0
- package/dist/use-isomorphic-layout-effect.mjs +1 -1
- package/dist/use-keyboard-visible-83MQ2ogF.mjs +2 -0
- package/dist/use-keyboard-visible-83MQ2ogF.mjs.map +1 -0
- package/dist/use-keyboard-visible-BHYBoMGb.cjs +1 -0
- package/dist/use-keyboard-visible-BPIMSGQ1.d.cts +5 -0
- package/dist/use-keyboard-visible-BPIMSGQ1.d.cts.map +1 -0
- package/dist/use-keyboard-visible-iH9veUTt.d.mts +5 -0
- package/dist/use-keyboard-visible-iH9veUTt.d.mts.map +1 -0
- package/dist/use-keyboard-visible.cjs +1 -23
- package/dist/use-keyboard-visible.d.cts +2 -0
- package/dist/use-keyboard-visible.d.mts +2 -0
- package/dist/use-keyboard-visible.mjs +1 -1
- package/dist/{use-memo-stable.d.ts → use-memo-stable-Aqx3eZTS.d.mts} +5 -1
- package/dist/use-memo-stable-Aqx3eZTS.d.mts.map +1 -0
- package/dist/use-memo-stable-DKI3Fj07.mjs +2 -0
- package/dist/use-memo-stable-DKI3Fj07.mjs.map +1 -0
- package/dist/use-memo-stable-DKW_L41q.cjs +1 -0
- package/dist/{use-callback-stable.d.ts → use-memo-stable-i9UN2iWi.d.cts} +7 -7
- package/dist/use-memo-stable-i9UN2iWi.d.cts.map +1 -0
- package/dist/use-memo-stable.cjs +1 -28
- package/dist/use-memo-stable.d.cts +2 -0
- package/dist/use-memo-stable.d.mts +2 -0
- package/dist/use-memo-stable.mjs +1 -1
- package/dist/use-network-state-Bce55hBv.cjs +1 -0
- package/dist/use-network-state-CtGu_gfo.mjs +2 -0
- package/dist/use-network-state-CtGu_gfo.mjs.map +1 -0
- package/dist/use-network-state-DPhNT5_N.d.mts +20 -0
- package/dist/use-network-state-DPhNT5_N.d.mts.map +1 -0
- package/dist/use-network-state-DQegmILl.d.cts +20 -0
- package/dist/use-network-state-DQegmILl.d.cts.map +1 -0
- package/dist/use-network-state.cjs +1 -44
- package/dist/use-network-state.d.cts +2 -0
- package/dist/use-network-state.d.mts +2 -0
- package/dist/use-network-state.mjs +1 -1
- package/dist/use-previous-BNZSuZUn.cjs +1 -0
- package/dist/use-previous-BvOs-yn-.d.cts +5 -0
- package/dist/use-previous-BvOs-yn-.d.cts.map +1 -0
- package/dist/use-previous-ChmuSO8b.d.mts +5 -0
- package/dist/use-previous-ChmuSO8b.d.mts.map +1 -0
- package/dist/use-previous-vtWmTmEN.mjs +2 -0
- package/dist/use-previous-vtWmTmEN.mjs.map +1 -0
- package/dist/use-previous.cjs +1 -14
- package/dist/use-previous.d.cts +2 -0
- package/dist/use-previous.d.mts +2 -0
- package/dist/use-previous.mjs +1 -1
- package/package.json +79 -309
- package/dist/index.d.ts +0 -25
- package/dist/use-battery.d.ts +0 -4
- package/dist/use-callback-ref.d.ts +0 -5
- package/dist/use-click-away.d.ts +0 -7
- package/dist/use-copy-to-clipboard.d.ts +0 -6
- package/dist/use-debounce.d.ts +0 -9
- package/dist/use-did-finish-ssr.d.ts +0 -7
- package/dist/use-escape-keydown.d.ts +0 -4
- package/dist/use-isomorphic-layout-effect.d.ts +0 -7
- package/dist/use-keyboard-visible.d.ts +0 -1
- package/dist/use-network-state.d.ts +0 -13
- package/dist/use-previous.d.ts +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{n as e,r as t,t as n}from"./use-compose-refs-BysZtFy1.mjs";export{n as composeRefs,e as setRef,t as useComposedRefs};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{useCallback as e,useState as t}from"react";function n(e){let t=document.createElement(`textarea`);t.value=e,document.body.append(t),t.select(),document.execCommand(`copy`),t.remove()}function r(){let[r,i]=t(null);return[r,e(async e=>{await(async()=>{try{if(navigator?.clipboard?.writeText)await navigator.clipboard.writeText(e??``),i(e??``);else throw Error(`writeText not supported`)}catch{n(e??``),i(e??``)}})()},[])]}export{r as t};
|
|
2
|
+
//# sourceMappingURL=use-copy-to-clipboard-Cls03hBs.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-copy-to-clipboard-Cls03hBs.mjs","names":[],"sources":["../../types/src/base.ts","../src/use-copy-to-clipboard.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { TypedArray } from \"./array\";\n\nexport type SerializablePrimitive =\n | null\n | undefined\n | string\n | number\n | boolean\n | bigint;\nexport type Primitive = SerializablePrimitive | symbol;\n\n/**\n * Matches any primitive, `void`, `Date`, or `RegExp` value.\n */\nexport type BuiltIns = Primitive | void | Date | RegExp;\n\n/**\n * Matches any non-primitive object\n */\n// eslint-disable-next-line ts/no-unsafe-function-type\nexport type AtomicObject = Function | Promise<any> | Date | RegExp;\n\n/** Determines if the passed value is of a specific type */\nexport type TypeTester = (value: any) => boolean;\n\n/**\n * The interface for a type mapping (key =\\> function) to use for {@link getType}.\n * export * The key represents the name of the type. The function represents the {@link TypeTester | test method}.\n * The map should be ordered by testing preference, with more specific tests first.\n * If a test returns true, it is selected, and the key is returned as the type.\n */\nexport type TypeMap = Record<string, TypeTester>;\n\ndeclare const emptyObjectSymbol: unique symbol;\n\nexport type FunctionOrValue<Value> = Value extends () => infer X ? X : Value;\n\n/**\n * A [[List]]\n *\n * @example\n * ```ts\n * type list0 = [1, 2, 3]\n * type list1 = number[]\n * ```\n *\n * @param A - its type\n * @returns [[List]]\n */\nexport type List<A = any> = ReadonlyArray<A>;\n\n/**\n * Alias to create a [[Function]]\n *\n * @example\n * ```ts\n * import { FunctionLike } from '@stryke/types'\n *\n * type test0 = FunctionLike<[string, number], boolean>\n * /// (args_0: string, args_1: number) => boolean\n * ```\n *\n * @param P - parameters\n * @param R - return type\n * @returns [[Function]]\n */\nexport type FunctionLike<P extends List = any, R = any> = (...args: P) => R;\n\nexport type AnyFunction = FunctionLike<any, any>;\nexport type Nullish = undefined | null;\nexport type Nullishable<T> = T | Nullish;\nexport type NonNullishObject = object; // not null/undefined which are Object\nexport type NativeClass = abstract new (...args: any) => any;\nexport type AnyNumber = number | number;\nexport type AnyString = string | string;\nexport type AnyBoolean = boolean | boolean;\nexport type AnyArray = any[];\nexport type PlainObject = Record<any, object>; // https://stackoverflow.com/a/75052315/130638\nexport type AnyMap = Map<any, any>;\nexport type AnyWeakMap = WeakMap<WeakKey, any>;\nexport type EmptyArray = [];\nexport interface EmptyObject {\n [emptyObjectSymbol]?: never;\n}\n\nexport type Any =\n | boolean\n | number\n | bigint\n | string\n | null\n | undefined\n | void\n | symbol\n | object\n | PlainObject\n | AnyArray\n | AnyMap\n | AnyWeakMap;\n\n/**\n * The valid types of the index for an `Indexable` type object\n */\nexport type IndexType = string | number | symbol;\n\n/**\n * The declaration of a ***dictionary-type*** object with a specific type\n *\n * @see {@link Indexable}\n * @see {@link IndexType}\n * @see {@link Dictionary}\n */\nexport type TypedIndexable<T> = Record<IndexType, T>;\n\n/**\n * The declaration of a ***dictionary-type*** object\n *\n * @see {@link TypedIndexable}\n * @see {@link IndexType}\n * @see {@link Dictionary}\n */\nexport type Indexable = TypedIndexable<any>;\n\n/**\n * The declaration of a ***dictionary-type*** object with a specific type\n *\n * @see {@link Indexable}\n * @see {@link IndexType}\n * @see {@link TypedIndexable}\n */\nexport type Dictionary<T> = Record<string, T>;\n\nexport const EMPTY_STRING = \"\";\nexport const NEWLINE_STRING = \"\\r\\n\";\nexport const EMPTY_OBJECT = {};\n\nexport type AnyCase<T extends IndexType> = string extends T\n ? string\n : T extends `${infer F1}${infer F2}${infer R}`\n ? `${Uppercase<F1> | Lowercase<F1>}${Uppercase<F2> | Lowercase<F2>}${AnyCase<R>}`\n : T extends `${infer F}${infer R}`\n ? `${Uppercase<F> | Lowercase<F>}${AnyCase<R>}`\n : typeof EMPTY_STRING;\n\nexport type Newable<T> = new (..._args: never[]) => T;\n\nexport interface Abstract<T> {\n prototype: T;\n}\n\nexport interface Clonable<T> {\n clone: () => T;\n}\n\nexport type MaybePromise<T> = T | Promise<T>;\n\nexport type ReducerFunction<TState, TAction> = (\n state: TState,\n action: TAction\n) => TState;\n\n// NOTE: for the file size optimization\nexport const TYPE_ARGUMENTS = \"Arguments\";\nexport const TYPE_ARRAY = \"Array\";\nexport const TYPE_OBJECT = \"Object\";\nexport const TYPE_MAP = \"Map\";\nexport const TYPE_SET = \"Set\";\n\nexport type Collection =\n | IArguments\n | unknown[]\n | Map<unknown, unknown>\n | Record<string | number | symbol, unknown>\n | Set<unknown>;\n\nexport type NonUndefined<T> = T extends undefined ? never : T;\n\nexport type BrowserNativeObject = Date | File;\n\nexport type DeepPartial<T> = T extends BrowserNativeObject | NestedValue\n ? T\n : {\n [K in keyof T]?: DeepPartial<T[K]>;\n };\n\nexport type Rollback = Record<\n string,\n (initialValue: any, currentValue: any) => any\n>;\n\n/**\n * Extract all required keys from the given type.\n *\n * @remarks\n * This is useful when you want to create a new type that contains different type values for the required keys only or use the list of keys for validation purposes, etc...\n */\nexport type RequiredKeysOf<BaseType extends object> = Exclude<\n {\n [Key in keyof BaseType]: BaseType extends Record<Key, BaseType[Key]>\n ? Key\n : never;\n }[keyof BaseType],\n undefined\n>;\n\n/**\n * Returns a boolean for whether the two given types are equal.\n *\n * @remarks\n * Use-cases: If you want to make a conditional branch based on the result of a comparison of two types.\n *\n * @see https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650\n * @see https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796\n */\nexport type IsEqual<A, B> =\n (<G>() => G extends A ? 1 : 2) extends <G>() => G extends B ? 1 : 2\n ? true\n : false;\n\nexport type Filter<KeyType, ExcludeType> =\n IsEqual<KeyType, ExcludeType> extends true\n ? never\n : KeyType extends ExcludeType\n ? never\n : KeyType;\n\ninterface ExceptOptions {\n /**\n Disallow assigning non-specified properties.\n\n Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.\n\n @defaultValue false\n */\n requireExactProps?: boolean;\n}\n\n/**\n * Create a type from an object type without certain keys.\n *\n * @remarks\n * We recommend setting the `requireExactProps` option to `true`.\n *\n * This type is a stricter version of [`Omit`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-5.html#the-omit-helper-type). The `Omit` type does not restrict the omitted keys to be keys present on the given type, while `Except` does. The benefits of a stricter type are avoiding typos and allowing the compiler to pick up on rename refactors automatically.\n *\n * This type was proposed to the TypeScript team, which declined it, saying they prefer that libraries implement stricter versions of the built-in types ([microsoft/TypeScript#30825](https://github.com/microsoft/TypeScript/issues/30825#issuecomment-523668235)).\n */\nexport type Except<\n ObjectType,\n KeysType extends keyof ObjectType,\n Options extends ExceptOptions = { requireExactProps: false }\n> = {\n [KeyType in keyof ObjectType as Filter<\n KeyType,\n KeysType\n >]: ObjectType[KeyType];\n} & (Options[\"requireExactProps\"] extends true\n ? Partial<Record<KeysType, never>>\n : Record<string, never>);\n\n/**\n * Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.\n *\n * @remarks\n * Sometimes it is desired to pass a value as a function argument that has a different type. At first inspection it may seem assignable, and then you discover it is not because the `value`'s type definition was defined as an interface. In the following example, `fn` requires an argument of type `Record<string, unknown>`. If the value is defined as a literal, then it is assignable. And if the `value` is defined as type using the `Simplify` utility the value is assignable. But if the `value` is defined as an interface, it is not assignable because the interface is not sealed and elsewhere a non-string property could be added to the interface.\n *\n * If the type definition must be an interface (perhaps it was defined in a third-party npm package), then the `value` can be defined as `const value: Simplify<SomeInterface> = ...`. Then `value` will be assignable to the `fn` argument. Or the `value` can be cast as `Simplify<SomeInterface>` if you can't re-declare the `value`.\n *\n * @see https://github.com/microsoft/TypeScript/issues/15300\n */\nexport type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};\n\n/**\n * Create a type that makes the given keys required. The remaining keys are kept as is. The sister of the `SetOptional` type.\n *\n * @remarks\n * Use-case: You want to define a single model where the only thing that changes is whether or not some of the keys are required.\n */\nexport type SetRequired<\n BaseType,\n Keys extends keyof BaseType\n> = BaseType extends unknown // type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types). // union into a [distributive conditional // `extends unknown` is always going to be the case and is used to convert any\n ? Simplify<\n // Pick just the keys that are optional from the base type.\n Except<BaseType, Keys> &\n // Pick the keys that should be required from the base type and make them required.\n Required<Pick<BaseType, Keys>>\n >\n : never;\n\nexport const $NestedValue: unique symbol = Symbol(\"NestedValue\");\n\nexport type NestedValue<TValue extends object = object> = {\n [$NestedValue]: never;\n} & TValue;\n\nexport interface RefObject<T> {\n current: T;\n}\n\nexport interface Identity<T = string> {\n id: T;\n}\n\nexport interface Versioned {\n version: number;\n}\n\nexport interface Sequenced {\n /**\n * The sequence number (version, or event counter, etc.) of the record\n */\n sequence: number;\n}\n\nexport interface Typed {\n /**\n * The type of the record\n */\n __type: string;\n}\n\nexport interface ClassTypeCheckable<T> extends Typed {\n /**\n * Run type check on the given value\n * @param value - The value to check\n * @returns True if the value is of the type of the class\n */\n isTypeOf: (value: unknown) => value is T;\n}\n\n/**\n * Matches non-recursive types.\n */\nexport type NonRecursiveType =\n | BuiltIns\n // eslint-disable-next-line ts/no-unsafe-function-type\n | Function\n | (new (...arguments_: any[]) => unknown);\n\nexport type IsPrimitive<T> = [T] extends [Primitive] ? true : false;\nexport type IsNever<T> = [T] extends [never] ? true : false;\nexport type IsAny<T> = 0 extends 1 & T ? true : false;\nexport type IsNull<T> = [T] extends [null] ? true : false;\nexport type IsUndefined<T> = T extends undefined ? true : false;\nexport type IsUnknown<T> = unknown extends T // `T` can be `unknown` or `any`\n ? IsNull<T> extends false // `any` can be `null`, but `unknown` can't be\n ? true\n : false\n : false;\nexport type IsNullish<T> = IsNull<T> & IsUndefined<T>;\nexport type IsFunction<T> = T extends AnyFunction ? true : false;\n\n/**\n * Declare locally scoped properties on `globalThis`.\n *\n * When defining a global variable in a declaration file is inappropriate, it can be helpful to define a `type` or `interface` (say `ExtraGlobals`) with the global variable and then cast `globalThis` via code like `globalThis as unknown as ExtraGlobals`.\n *\n * Instead of casting through `unknown`, you can update your `type` or `interface` to extend `GlobalThis` and then directly cast `globalThis`.\n *\n * @example\n * ```\n * import type { GlobalThis } from '@stryke/types';\n *\n * type ExtraGlobals = GlobalThis & {\n * readonly GLOBAL_TOKEN: string;\n * };\n *\n * (globalThis as ExtraGlobals).GLOBAL_TOKEN;\n * ```\n */\nexport type GlobalThis = typeof globalThis;\n\n/**\n * Matches a [`class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).\n */\nexport interface Class<T, Arguments extends unknown[] = any[]> {\n prototype: Pick<T, keyof T>;\n new (...arguments_: Arguments): T;\n}\n\n/**\n * Matches a [`class` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).\n */\nexport type Constructor<T, Arguments extends unknown[] = any[]> = new (\n ...arguments_: Arguments\n) => T;\n\n/**\n * Matches an [`abstract class`](https://www.typescriptlang.org/docs/handbook/classes.html#abstract-classes).\n *\n * @privateRemarks\n * We cannot use a `type` here because TypeScript throws: 'abstract' modifier cannot appear on a type member. (1070)\n */\n\nexport interface AbstractClass<\n T,\n Arguments extends unknown[] = any[]\n> extends AbstractConstructor<T, Arguments> {\n prototype: Pick<T, keyof T>;\n}\n\n/**\n * Matches an [`abstract class`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-2.html#abstract-construct-signatures) constructor.\n */\nexport type AbstractConstructor<\n T,\n Arguments extends unknown[] = any[]\n> = abstract new (...arguments_: Arguments) => T;\n\n/**\n * Create a tuple type of the given length `<L>` and fill it with the given type `<Fill>`.\n *\n * If `<Fill>` is not provided, it will default to `unknown`.\n *\n * @see https://itnext.io/implementing-arithmetic-within-typescripts-type-system-a1ef140a6f6f\n */\nexport type BuildTuple<\n L extends number,\n Fill = unknown,\n T extends readonly unknown[] = []\n> = T[\"length\"] extends L ? T : BuildTuple<L, Fill, [...T, Fill]>;\n\n/**\n * Test if the given function has multiple call signatures.\n *\n * Needed to handle the case of a single call signature with properties.\n *\n * Multiple call signatures cannot currently be supported due to a TypeScript limitation.\n * @see https://github.com/microsoft/TypeScript/issues/29732\n */\nexport type HasMultipleCallSignatures<\n T extends (...arguments_: any[]) => unknown\n> = T extends {\n (...arguments_: infer A): unknown;\n (...arguments_: infer B): unknown;\n}\n ? B extends A\n ? A extends B\n ? false\n : true\n : true\n : false;\n\ntype StructuredCloneablePrimitive =\n | string\n | number\n | bigint\n | boolean\n | null\n | undefined\n | boolean\n | number\n | string;\n\ntype StructuredCloneableData =\n | ArrayBuffer\n | DataView\n | Date\n | Error\n | RegExp\n | TypedArray\n | Blob\n | File;\n\n// DOM exclusive types\n// | AudioData\n// | CropTarget\n// | CryptoKey\n// | DOMException\n// | DOMMatrix\n// | DOMMatrixReadOnly\n// | DOMPoint\n// | DOMPointReadOnly\n// | DOMQuad\n// | DOMRect\n// | DOMRectReadOnly\n// | FileList\n// | FileSystemDirectoryHandle\n// | FileSystemFileHandle\n// | FileSystemHandle\n// | GPUCompilationInfo\n// | GPUCompilationMessage\n// | ImageBitmap\n// | ImageData\n// | RTCCertificate\n// | VideoFrame\n\ntype StructuredCloneableCollection =\n | readonly StructuredCloneable[]\n | {\n readonly [key: string]: StructuredCloneable;\n readonly [key: number]: StructuredCloneable;\n }\n | ReadonlyMap<StructuredCloneable, StructuredCloneable>\n | ReadonlySet<StructuredCloneable>;\n\n/**\n * Matches a value that can be losslessly cloned using `structuredClone`.\n *\n * Note:\n * - Custom error types will be cloned as the base `Error` type\n * - This type doesn't include types exclusive to the TypeScript DOM library (e.g. `DOMRect` and `VideoFrame`)\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm\n *\n * @example\n * ```\n * import type { StructuredCloneable } from '@stryke/types';\n *\n * class CustomClass {}\n *\n * // @ts-expect-error\n * const error: StructuredCloneable = {\n * custom: new CustomClass(),\n * };\n *\n * structuredClone(error);\n * //=> {custom: {}}\n *\n * const good: StructuredCloneable = {\n * number: 3,\n * date: new Date(),\n * map: new Map<string, number>(),\n * }\n *\n * good.map.set('key', 1);\n *\n * structuredClone(good);\n * //=> {number: 3, date: Date(2022-10-17 22:22:35.920), map: Map {'key' -> 1}}\n * ```\n */\nexport type StructuredCloneable =\n | StructuredCloneablePrimitive\n | StructuredCloneableData\n | StructuredCloneableCollection;\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { EMPTY_STRING } from \"@stryke/types/base\";\nimport { useCallback, useState } from \"react\";\n\nfunction oldSchoolCopy(text: string) {\n const tempTextArea = document.createElement(\"textarea\");\n tempTextArea.value = text;\n document.body.append(tempTextArea);\n tempTextArea.select();\n document.execCommand(\"copy\");\n tempTextArea.remove();\n}\n\n/**\n * Copies a value to the clipboard\n *\n * @returns A tuple with the copied value and a function to copy a value to the clipboard\n */\nexport function useCopyToClipboard() {\n const [state, setState] = useState<string | null>(null);\n\n const copyToClipboard = useCallback(async (value: string | null) => {\n const handleCopy = async () => {\n try {\n if (navigator?.clipboard?.writeText) {\n await navigator.clipboard.writeText(value ?? EMPTY_STRING);\n setState(value ?? EMPTY_STRING);\n } else {\n throw new Error(\"writeText not supported\");\n }\n } catch {\n oldSchoolCopy(value ?? EMPTY_STRING);\n setState(value ?? EMPTY_STRING);\n }\n };\n\n await handleCopy();\n }, []);\n\n return [state, copyToClipboard];\n}\n"],"mappings":"kDCqBA,SAAS,EAAc,EAAc,CACnC,IAAM,EAAe,SAAS,cAAc,WAAW,CACvD,EAAa,MAAQ,EACrB,SAAS,KAAK,OAAO,EAAa,CAClC,EAAa,QAAQ,CACrB,SAAS,YAAY,OAAO,CAC5B,EAAa,QAAQ,CAQvB,SAAgB,GAAqB,CACnC,GAAM,CAAC,EAAO,GAAY,EAAwB,KAAK,CAoBvD,MAAO,CAAC,EAlBgB,EAAY,KAAO,IAAyB,CAelE,MAdmB,SAAY,CAC7B,GAAI,CACF,GAAI,WAAW,WAAW,UACxB,MAAM,UAAU,UAAU,UAAU,GAAS,GAAa,CAC1D,EAAS,GAAS,GAAa,MAE/B,MAAU,MAAM,0BAA0B,MAEtC,CACN,EAAc,GAAS,GAAa,CACpC,EAAS,GAAS,GAAa,KAIjB,EACjB,EAAE,CAAC,CAEyB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/use-copy-to-clipboard.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Copies a value to the clipboard
|
|
4
|
+
*
|
|
5
|
+
* @returns A tuple with the copied value and a function to copy a value to the clipboard
|
|
6
|
+
*/
|
|
7
|
+
declare function useCopyToClipboard(): (string | ((value: string | null) => Promise<void>) | null)[];
|
|
8
|
+
//#endregion
|
|
9
|
+
export { useCopyToClipboard as t };
|
|
10
|
+
//# sourceMappingURL=use-copy-to-clipboard-D3QmuRQ2.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-copy-to-clipboard-D3QmuRQ2.d.mts","names":[],"sources":["../src/use-copy-to-clipboard.ts"],"sourcesContent":[],"mappings":";;AAmCA;;;;iBAAgB,kBAAA,CAAA,wCAGiD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./use-battery-DZZDx003.cjs`);let t=require(`react`);const n=``;function r(e){let t=document.createElement(`textarea`);t.value=e,document.body.append(t),t.select(),document.execCommand(`copy`),t.remove()}function i(){let[e,n]=(0,t.useState)(null);return[e,(0,t.useCallback)(async e=>{await(async()=>{try{if(navigator?.clipboard?.writeText)await navigator.clipboard.writeText(e??``),n(e??``);else throw Error(`writeText not supported`)}catch{r(e??``),n(e??``)}})()},[])]}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return i}});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/use-copy-to-clipboard.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Copies a value to the clipboard
|
|
4
|
+
*
|
|
5
|
+
* @returns A tuple with the copied value and a function to copy a value to the clipboard
|
|
6
|
+
*/
|
|
7
|
+
declare function useCopyToClipboard(): (string | ((value: string | null) => Promise<void>) | null)[];
|
|
8
|
+
//#endregion
|
|
9
|
+
export { useCopyToClipboard as t };
|
|
10
|
+
//# sourceMappingURL=use-copy-to-clipboard-DzccpceW.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-copy-to-clipboard-DzccpceW.d.cts","names":[],"sources":["../src/use-copy-to-clipboard.ts"],"sourcesContent":[],"mappings":";;AAmCA;;;;iBAAgB,kBAAA,CAAA,wCAGiD"}
|
|
@@ -1,25 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.useCopyToClipboard = useCopyToClipboard;
|
|
7
|
-
var _base = require("@stryke/types/base");
|
|
8
|
-
var _react = require("react");
|
|
9
|
-
function i(n) {
|
|
10
|
-
const t = document.createElement("textarea");
|
|
11
|
-
t.value = n, document.body.append(t), t.select(), document.execCommand("copy"), t.remove();
|
|
12
|
-
}
|
|
13
|
-
function useCopyToClipboard() {
|
|
14
|
-
const [n, t] = (0, _react.useState)(null),
|
|
15
|
-
r = (0, _react.useCallback)(async e => {
|
|
16
|
-
await (async () => {
|
|
17
|
-
try {
|
|
18
|
-
if (navigator?.clipboard?.writeText) await navigator.clipboard.writeText(e ?? _base.EMPTY_STRING), t(e ?? _base.EMPTY_STRING);else throw new Error("writeText not supported");
|
|
19
|
-
} catch {
|
|
20
|
-
i(e ?? _base.EMPTY_STRING), t(e ?? _base.EMPTY_STRING);
|
|
21
|
-
}
|
|
22
|
-
})();
|
|
23
|
-
}, []);
|
|
24
|
-
return [n, r];
|
|
25
|
-
}
|
|
1
|
+
const e=require(`./use-copy-to-clipboard-DFTtZkv7.cjs`);exports.useCopyToClipboard=e.t;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{t as e}from"./use-copy-to-clipboard-Cls03hBs.mjs";export{e as useCopyToClipboard};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region ../helpers/src/debounce.d.ts
|
|
2
|
+
interface DebounceOptions {
|
|
3
|
+
signal?: AbortSignal;
|
|
4
|
+
}
|
|
5
|
+
//#endregion
|
|
6
|
+
//#region src/use-debounce.d.ts
|
|
7
|
+
declare function useDebounce<A extends (...args: any) => any | undefined | null, DebouncedFn extends A & {
|
|
8
|
+
cancel: () => void;
|
|
9
|
+
}>(fn: A, wait: number, options?: DebounceOptions): DebouncedFn;
|
|
10
|
+
/**
|
|
11
|
+
* Returns a value once it stops changing after "amt" time.
|
|
12
|
+
* Note: you may need to memo or this will keep re-rendering
|
|
13
|
+
*/
|
|
14
|
+
declare function useDebounceValue<A>(val: A, amt?: number): A;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { useDebounceValue as n, useDebounce as t };
|
|
17
|
+
//# sourceMappingURL=use-debounce-B07BBb1-.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-debounce-B07BBb1-.d.mts","names":[],"sources":["../../helpers/src/debounce.ts","../src/use-debounce.ts"],"sourcesContent":[],"mappings":";UAiBiB,eAAA;EAAA,MAAA,CAAA,EACN,WADqB;;;;AAAf,iBCsCD,WDrCL,CAAA,UAAW,CAAA,GAAA,IAAA,EAAA,GAAA,EAAA,GAAA,GAAA,GAAA,SAAA,GAAA,IAAA,EAAA,oBCuCA,CDvCA,GAAA;;OC0ChB,2BAA0B,kBAAuB;;AALvD;;;AAKgC,iBAmBhB,gBAnBgB,CAAA,CAAA,CAAA,CAAA,GAAA,EAmBS,CAnBT,EAAA,GAAA,CAAA,EAAA,MAAA,CAAA,EAmBsB,CAnBtB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region ../helpers/src/debounce.d.ts
|
|
2
|
+
interface DebounceOptions {
|
|
3
|
+
signal?: AbortSignal;
|
|
4
|
+
}
|
|
5
|
+
//#endregion
|
|
6
|
+
//#region src/use-debounce.d.ts
|
|
7
|
+
declare function useDebounce<A extends (...args: any) => any | undefined | null, DebouncedFn extends A & {
|
|
8
|
+
cancel: () => void;
|
|
9
|
+
}>(fn: A, wait: number, options?: DebounceOptions): DebouncedFn;
|
|
10
|
+
/**
|
|
11
|
+
* Returns a value once it stops changing after "amt" time.
|
|
12
|
+
* Note: you may need to memo or this will keep re-rendering
|
|
13
|
+
*/
|
|
14
|
+
declare function useDebounceValue<A>(val: A, amt?: number): A;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { useDebounceValue as n, useDebounce as t };
|
|
17
|
+
//# sourceMappingURL=use-debounce-Bh6vyN-1.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-debounce-Bh6vyN-1.d.cts","names":[],"sources":["../../helpers/src/debounce.ts","../src/use-debounce.ts"],"sourcesContent":[],"mappings":";UAiBiB,eAAA;EAAA,MAAA,CAAA,EACN,WADqB;;;;AAAf,iBCsCD,WDrCL,CAAA,UAAW,CAAA,GAAA,IAAA,EAAA,GAAA,EAAA,GAAA,GAAA,GAAA,SAAA,GAAA,IAAA,EAAA,oBCuCA,CDvCA,GAAA;;OC0ChB,2BAA0B,kBAAuB;;AALvD;;;AAKgC,iBAmBhB,gBAnBgB,CAAA,CAAA,CAAA,CAAA,GAAA,EAmBS,CAnBT,EAAA,GAAA,CAAA,EAAA,MAAA,CAAA,EAmBsB,CAnBtB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{useEffect as e,useMemo as t,useRef as n,useState as r}from"react";function i(e,t,{signal:n}={}){let r=null,i=((...i)=>{r!==null&&clearTimeout(r),!n?.aborted&&(r=setTimeout(()=>{e(...i),r=null},t))});return i.cancel=()=>{r!==null&&(clearTimeout(r),r=null)},n?.addEventListener(`abort`,()=>{i.cancel()},{once:!0}),i}function a(r,a,o={}){let s=n(null);return e(()=>()=>{s.current?.cancel()},[]),t(()=>(s.current=i(r,a,o),s.current),[r,o,a])}function o(t,n=0){let[i,a]=r(t);return e(()=>{let e=setTimeout(()=>{a(e=>e===t?e:t)},n);return()=>{clearTimeout(e)}},[n,t]),i}export{o as n,a as t};
|
|
2
|
+
//# sourceMappingURL=use-debounce-Cto2Ny5z.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-debounce-Cto2Ny5z.mjs","names":["timeoutId: ReturnType<typeof setTimeout> | null"],"sources":["../../helpers/src/debounce.ts","../src/use-debounce.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 License, and is\n free for commercial and private use. For more information, please visit\n our licensing page.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://stormsoftware.com/projects/stryke/docs\n Contact: https://stormsoftware.com/contact\n License: https://stormsoftware.com/projects/stryke/license\n\n ------------------------------------------------------------------- */\n\nexport interface DebounceOptions {\n signal?: AbortSignal;\n}\n\n/**\n * Creates a debounced function that delays invoking the provided function until after `debounceMs` milliseconds\n * have elapsed since the last time the debounced function was invoked. The debounced function also has a `cancel`\n * method to cancel any pending execution.\n *\n * @example\n * ```typescript\n * const debouncedFunction = debounce(() => {\n * console.log('Function executed');\n * }, 1000);\n *\n * // Will log 'Function executed' after 1 second if not called again in that time\n * debouncedFunction();\n *\n * // Will not log anything as the previous call is canceled\n * debouncedFunction.cancel();\n *\n * // With AbortSignal\n * const controller = new AbortController();\n * const signal = controller.signal;\n * const debouncedWithSignal = debounce(() => {\n * console.log('Function executed');\n * }, 1000, { signal });\n *\n * debouncedWithSignal();\n *\n * // Will cancel the debounced function call\n * controller.abort();\n * ```\n *\n * @param func - The function to debounce.\n * @param debounceMs - The number of milliseconds to delay.\n * @param options - The options object.\n * @returns A new debounced function with a `cancel` method.\n */\nexport function debounce<F extends (...args: any[]) => void>(\n func: F,\n debounceMs: number,\n { signal }: DebounceOptions = {}\n): F & { cancel: () => void } {\n let timeoutId: ReturnType<typeof setTimeout> | null = null;\n\n const debounced = ((...args: Parameters<F>) => {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n }\n\n if (signal?.aborted) {\n return;\n }\n\n timeoutId = setTimeout(() => {\n func(...args);\n timeoutId = null;\n }, debounceMs);\n }) as F & { cancel: () => void };\n\n const onAbort = () => {\n debounced.cancel();\n };\n\n debounced.cancel = () => {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n };\n\n signal?.addEventListener(\"abort\", onAbort, { once: true });\n\n return debounced;\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { DebounceOptions } from \"@stryke/helpers/debounce\";\nimport { debounce } from \"@stryke/helpers/debounce\";\nimport { useEffect, useMemo, useRef, useState } from \"react\";\n\n// export function debounce<A extends Function>(\n// func: A,\n// wait?: number,\n// leading?: boolean\n// ): A & {\n// cancel: () => void;\n// } {\n// let timeout: any;\n// let isCancelled = false;\n\n// function debounced(this: any) {\n// isCancelled = false;\n// const args = arguments;\n// if (leading && !timeout) {\n// func.apply(this, args);\n// }\n// clearTimeout(timeout);\n// timeout = setTimeout(() => {\n// timeout = null;\n// if (!(leading || isCancelled)) {\n// func.apply(this, args);\n// }\n// isCancelled = false;\n// }, wait);\n// }\n\n// debounced.cancel = () => {\n// isCancelled = true;\n// };\n\n// return debounced as any;\n// }\n\nexport function useDebounce<\n A extends (...args: any) => any | undefined | null,\n DebouncedFn extends A & {\n cancel: () => void;\n }\n>(fn: A, wait: number, options: DebounceOptions = {}): DebouncedFn {\n const dbEffect = useRef<DebouncedFn | null>(null);\n\n useEffect(() => {\n return () => {\n dbEffect.current?.cancel();\n };\n }, []);\n\n return useMemo(() => {\n dbEffect.current = debounce(fn, wait, options) as unknown as DebouncedFn;\n return dbEffect.current;\n }, [fn, options, wait]);\n}\n\n/**\n * Returns a value once it stops changing after \"amt\" time.\n * Note: you may need to memo or this will keep re-rendering\n */\nexport function useDebounceValue<A>(val: A, amt = 0): A {\n const [state, setState] = useState(val);\n\n useEffect(() => {\n const tm = setTimeout(() => {\n setState(prev => {\n if (prev === val) return prev;\n return val;\n });\n }, amt);\n\n return () => {\n clearTimeout(tm);\n };\n }, [amt, val]);\n\n return state;\n}\n"],"mappings":"yEAwDA,SAAgB,EACd,EACA,EACA,CAAE,UAA4B,EAAE,CACJ,CAC5B,IAAIA,EAAkD,KAEhD,IAAc,GAAG,IAAwB,CACzC,IAAc,MAChB,aAAa,EAAU,CAGrB,IAAQ,UAIZ,EAAY,eAAiB,CAC3B,EAAK,GAAG,EAAK,CACb,EAAY,MACX,EAAW,IAgBhB,MATA,GAAU,WAAe,CACnB,IAAc,OAChB,aAAa,EAAU,CACvB,EAAY,OAIhB,GAAQ,iBAAiB,YAXH,CACpB,EAAU,QAAQ,EAUuB,CAAE,KAAM,GAAM,CAAC,CAEnD,ECpCT,SAAgB,EAKd,EAAO,EAAc,EAA2B,EAAE,CAAe,CACjE,IAAM,EAAW,EAA2B,KAAK,CAQjD,OANA,UACe,CACX,EAAS,SAAS,QAAQ,EAE3B,EAAE,CAAC,CAEC,OACL,EAAS,QAAU,EAAS,EAAI,EAAM,EAAQ,CACvC,EAAS,SACf,CAAC,EAAI,EAAS,EAAK,CAAC,CAOzB,SAAgB,EAAoB,EAAQ,EAAM,EAAM,CACtD,GAAM,CAAC,EAAO,GAAY,EAAS,EAAI,CAevC,OAbA,MAAgB,CACd,IAAM,EAAK,eAAiB,CAC1B,EAAS,GACH,IAAS,EAAY,EAClB,EACP,EACD,EAAI,CAEP,UAAa,CACX,aAAa,EAAG,GAEjB,CAAC,EAAK,EAAI,CAAC,CAEP"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./use-battery-DZZDx003.cjs`);let t=require(`react`);function n(e,t,{signal:n}={}){let r=null,i=((...i)=>{r!==null&&clearTimeout(r),!n?.aborted&&(r=setTimeout(()=>{e(...i),r=null},t))});return i.cancel=()=>{r!==null&&(clearTimeout(r),r=null)},n?.addEventListener(`abort`,()=>{i.cancel()},{once:!0}),i}function r(e,r,i={}){let a=(0,t.useRef)(null);return(0,t.useEffect)(()=>()=>{a.current?.cancel()},[]),(0,t.useMemo)(()=>(a.current=n(e,r,i),a.current),[e,i,r])}function i(e,n=0){let[r,i]=(0,t.useState)(e);return(0,t.useEffect)(()=>{let t=setTimeout(()=>{i(t=>t===e?t:e)},n);return()=>{clearTimeout(t)}},[n,e]),r}Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return r}});
|
package/dist/use-debounce.cjs
CHANGED
|
@@ -1,26 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.useDebounce = useDebounce;
|
|
7
|
-
exports.useDebounceValue = useDebounceValue;
|
|
8
|
-
var _debounce = require("@stryke/helpers/debounce");
|
|
9
|
-
var _react = require("react");
|
|
10
|
-
function useDebounce(e, n, t = {}) {
|
|
11
|
-
const u = (0, _react.useRef)(null);
|
|
12
|
-
return (0, _react.useEffect)(() => () => {
|
|
13
|
-
u.current?.cancel();
|
|
14
|
-
}, []), (0, _react.useMemo)(() => (u.current = (0, _debounce.debounce)(e, n, t), u.current), [e, t, n]);
|
|
15
|
-
}
|
|
16
|
-
function useDebounceValue(e, n = 0) {
|
|
17
|
-
const [t, u] = (0, _react.useState)(e);
|
|
18
|
-
return (0, _react.useEffect)(() => {
|
|
19
|
-
const c = setTimeout(() => {
|
|
20
|
-
u(r => r === e ? r : e);
|
|
21
|
-
}, n);
|
|
22
|
-
return () => {
|
|
23
|
-
clearTimeout(c);
|
|
24
|
-
};
|
|
25
|
-
}, [n, e]), t;
|
|
26
|
-
}
|
|
1
|
+
const e=require(`./use-debounce-DWeScEkQ.cjs`);exports.useDebounce=e.t,exports.useDebounceValue=e.n;
|
package/dist/use-debounce.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{n as e,t}from"./use-debounce-Cto2Ny5z.mjs";export{t as useDebounce,e as useDebounceValue};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{t as e}from"./is-function-md4Ym3I0.mjs";import{useEffect as t,useState as n,useSyncExternalStore as r}from"react";const i=()=>{},a=()=>i;function o(e,i){if(process.env.TAMAGUI_TARGET===`native`)return e??!0;if(i?.sync)return r(a,()=>e??!0,()=>!1);let[o,s]=n(e);return t(()=>{s(e??!0)},[e]),o??!1}function s(e){return o(e,{sync:!0})}function c(t){return o()?e(t)?t():t:void 0}export{o as n,s as r,c as t};
|
|
2
|
+
//# sourceMappingURL=use-did-finish-ssr-B6M_wlP4.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-did-finish-ssr-B6M_wlP4.mjs","names":[],"sources":["../src/use-did-finish-ssr.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport { useEffect, useState, useSyncExternalStore } from \"react\";\n\nconst emptyFn = () => {};\nconst emptyFnFn = () => emptyFn;\n\nexport function useDidFinishSSR<A = boolean>(\n value?: A,\n options?: {\n sync?: boolean;\n }\n): A | false {\n if (process.env.TAMAGUI_TARGET === \"native\") {\n return (value ?? true) as false | A;\n }\n\n if (options?.sync) {\n return useSyncExternalStore(\n emptyFnFn,\n () => value ?? true,\n () => false as any\n );\n }\n\n const [cur, setCur] = useState<any>(value);\n useEffect(() => {\n setCur(value ?? true);\n }, [value]);\n return cur ?? false;\n}\n\nexport function useDidFinishSSRSync<A = boolean>(value?: A): A | false {\n return useDidFinishSSR(value, {\n sync: true\n });\n}\n\ntype FunctionOrValue<Value> = Value extends () => infer X ? X : Value;\n\nexport function useClientValue<Value>(\n value?: Value\n): FunctionOrValue<Value> | undefined {\n const done = useDidFinishSSR();\n\n return done\n ? isFunction(value)\n ? value()\n : (value as FunctionOrValue<Value>)\n : undefined;\n}\n"],"mappings":"yHAqBA,MAAM,MAAgB,GAChB,MAAkB,EAExB,SAAgB,EACd,EACA,EAGW,CACX,GAAI,QAAQ,IAAI,iBAAmB,SACjC,OAAQ,GAAS,GAGnB,GAAI,GAAS,KACX,OAAO,EACL,MACM,GAAS,OACT,GACP,CAGH,GAAM,CAAC,EAAK,GAAU,EAAc,EAAM,CAI1C,OAHA,MAAgB,CACd,EAAO,GAAS,GAAK,EACpB,CAAC,EAAM,CAAC,CACJ,GAAO,GAGhB,SAAgB,EAAiC,EAAsB,CACrE,OAAO,EAAgB,EAAO,CAC5B,KAAM,GACP,CAAC,CAKJ,SAAgB,EACd,EACoC,CAGpC,OAFa,GAAiB,CAG1B,EAAW,EAAM,CACf,GAAO,CACN,EACH,IAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./use-battery-DZZDx003.cjs`),t=require(`./is-function-BhD7GXOO.cjs`);let n=require(`react`);const r=()=>{},i=()=>r;function a(e,t){if(process.env.TAMAGUI_TARGET===`native`)return e??!0;if(t?.sync)return(0,n.useSyncExternalStore)(i,()=>e??!0,()=>!1);let[r,a]=(0,n.useState)(e);return(0,n.useEffect)(()=>{a(e??!0)},[e]),r??!1}function o(e){return a(e,{sync:!0})}function s(e){return a()?t.t(e)?e():e:void 0}Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return s}});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/use-did-finish-ssr.d.ts
|
|
2
|
+
declare function useDidFinishSSR<A = boolean>(value?: A, options?: {
|
|
3
|
+
sync?: boolean;
|
|
4
|
+
}): A | false;
|
|
5
|
+
declare function useDidFinishSSRSync<A = boolean>(value?: A): A | false;
|
|
6
|
+
type FunctionOrValue<Value> = Value extends (() => infer X) ? X : Value;
|
|
7
|
+
declare function useClientValue<Value>(value?: Value): FunctionOrValue<Value> | undefined;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { useDidFinishSSR as n, useDidFinishSSRSync as r, useClientValue as t };
|
|
10
|
+
//# sourceMappingURL=use-did-finish-ssr-CBz5xeHc.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-did-finish-ssr-CBz5xeHc.d.mts","names":[],"sources":["../src/use-did-finish-ssr.ts"],"sourcesContent":[],"mappings":";iBAwBgB,qCACN,UAwBV;EAzBgB,IAAA,CAAA,EAAA,OAAA;AAyBhB,CAAA,CAAA,EApBG,CAoBa,GAAA,KAAA;AAMX,iBANW,mBAMc,CAAA,IAAkC,OAAK,CAAA,CAAA,KAAA,CAAA,EANZ,CAMY,CAAA,EANR,CAMQ,GAAA,KAAA;AAErE,KAFK,eAEW,CAAc,KAAA,CAAA,GAFA,KAEA,UAAA,GAAA,GAAA,KAAA,EAAA,IAAA,CAAA,GAFkC,KAElC;AACpB,iBADM,cACN,CAAA,KAAA,CAAA,CAAA,KAAA,CAAA,EAAA,KAAA,CAAA,EACP,eADO,CACS,KADT,CAAA,GAAA,SAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/use-did-finish-ssr.d.ts
|
|
2
|
+
declare function useDidFinishSSR<A = boolean>(value?: A, options?: {
|
|
3
|
+
sync?: boolean;
|
|
4
|
+
}): A | false;
|
|
5
|
+
declare function useDidFinishSSRSync<A = boolean>(value?: A): A | false;
|
|
6
|
+
type FunctionOrValue<Value> = Value extends (() => infer X) ? X : Value;
|
|
7
|
+
declare function useClientValue<Value>(value?: Value): FunctionOrValue<Value> | undefined;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { useDidFinishSSR as n, useDidFinishSSRSync as r, useClientValue as t };
|
|
10
|
+
//# sourceMappingURL=use-did-finish-ssr-D3CpAwOz.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-did-finish-ssr-D3CpAwOz.d.cts","names":[],"sources":["../src/use-did-finish-ssr.ts"],"sourcesContent":[],"mappings":";iBAwBgB,qCACN,UAwBV;EAzBgB,IAAA,CAAA,EAAA,OAAA;AAyBhB,CAAA,CAAA,EApBG,CAoBa,GAAA,KAAA;AAMX,iBANW,mBAMc,CAAA,IAAkC,OAAK,CAAA,CAAA,KAAA,CAAA,EANZ,CAMY,CAAA,EANR,CAMQ,GAAA,KAAA;AAErE,KAFK,eAEW,CAAc,KAAA,CAAA,GAFA,KAEA,UAAA,GAAA,GAAA,KAAA,EAAA,IAAA,CAAA,GAFkC,KAElC;AACpB,iBADM,cACN,CAAA,KAAA,CAAA,CAAA,KAAA,CAAA,EAAA,KAAA,CAAA,EACP,eADO,CACS,KADT,CAAA,GAAA,SAAA"}
|
|
@@ -1,28 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.useClientValue = useClientValue;
|
|
7
|
-
exports.useDidFinishSSR = useDidFinishSSR;
|
|
8
|
-
exports.useDidFinishSSRSync = useDidFinishSSRSync;
|
|
9
|
-
var _isFunction = require("@stryke/type-checks/is-function");
|
|
10
|
-
var _react = require("react");
|
|
11
|
-
const a = () => {},
|
|
12
|
-
c = () => a;
|
|
13
|
-
function useDidFinishSSR(e, n) {
|
|
14
|
-
if (process.env.TAMAGUI_TARGET === "native") return e ?? !0;
|
|
15
|
-
if (n?.sync) return (0, _react.useSyncExternalStore)(c, () => e ?? !0, () => !1);
|
|
16
|
-
const [t, u] = (0, _react.useState)(e);
|
|
17
|
-
return (0, _react.useEffect)(() => {
|
|
18
|
-
u(e ?? !0);
|
|
19
|
-
}, [e]), t ?? !1;
|
|
20
|
-
}
|
|
21
|
-
function useDidFinishSSRSync(e) {
|
|
22
|
-
return useDidFinishSSR(e, {
|
|
23
|
-
sync: !0
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
function useClientValue(e) {
|
|
27
|
-
return useDidFinishSSR() ? (0, _isFunction.isFunction)(e) ? e() : e : void 0;
|
|
28
|
-
}
|
|
1
|
+
const e=require(`./use-did-finish-ssr-BbXffDj5.cjs`);exports.useClientValue=e.t,exports.useDidFinishSSR=e.n,exports.useDidFinishSSRSync=e.r;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{n as e,r as t,t as n}from"./use-did-finish-ssr-B6M_wlP4.mjs";export{n as useClientValue,e as useDidFinishSSR,t as useDidFinishSSRSync};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/use-escape-keydown.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Listens for when the escape key is down
|
|
4
|
+
*/
|
|
5
|
+
declare function useEscapeKeydown(onEscapeKeyDownProp?: (event: KeyboardEvent) => void, ownerDocument?: Document): void;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { useEscapeKeydown as t };
|
|
8
|
+
//# sourceMappingURL=use-escape-keydown-BsJYLp1N.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-escape-keydown-BsJYLp1N.d.cts","names":[],"sources":["../src/use-escape-keydown.ts"],"sourcesContent":[],"mappings":";;AAwBA;;iBAAgB,gBAAA,+BACgB,wCACf"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{t as e}from"./use-callback-ref-otlhGzUu.mjs";import{useEffect as t}from"react";function n(n,r=globalThis?.document){let i=e(n);t(()=>{let e=e=>{e.key===`Escape`&&i(e)};return r.addEventListener(`keydown`,e),()=>{r.removeEventListener(`keydown`,e)}},[i,r])}export{n as t};
|
|
2
|
+
//# sourceMappingURL=use-escape-keydown-CFy25Wk6.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-escape-keydown-CFy25Wk6.mjs","names":[],"sources":["../src/use-escape-keydown.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { useEffect } from \"react\";\nimport { useCallbackRef } from \"./use-callback-ref\";\n\n/**\n * Listens for when the escape key is down\n */\nexport function useEscapeKeydown(\n onEscapeKeyDownProp?: (event: KeyboardEvent) => void,\n ownerDocument: Document = globalThis?.document\n) {\n const onEscapeKeyDown = useCallbackRef(onEscapeKeyDownProp);\n\n useEffect(() => {\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === \"Escape\") {\n onEscapeKeyDown(event);\n }\n };\n\n ownerDocument.addEventListener(\"keydown\", handleKeyDown);\n\n return () => {\n ownerDocument.removeEventListener(\"keydown\", handleKeyDown);\n };\n }, [onEscapeKeyDown, ownerDocument]);\n}\n"],"mappings":"sFAwBA,SAAgB,EACd,EACA,EAA0B,YAAY,SACtC,CACA,IAAM,EAAkB,EAAe,EAAoB,CAE3D,MAAgB,CACd,IAAM,EAAiB,GAAyB,CAC1C,EAAM,MAAQ,UAChB,EAAgB,EAAM,EAM1B,OAFA,EAAc,iBAAiB,UAAW,EAAc,KAE3C,CACX,EAAc,oBAAoB,UAAW,EAAc,GAE5D,CAAC,EAAiB,EAAc,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/use-escape-keydown.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Listens for when the escape key is down
|
|
4
|
+
*/
|
|
5
|
+
declare function useEscapeKeydown(onEscapeKeyDownProp?: (event: KeyboardEvent) => void, ownerDocument?: Document): void;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { useEscapeKeydown as t };
|
|
8
|
+
//# sourceMappingURL=use-escape-keydown-DgPvPpzz.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-escape-keydown-DgPvPpzz.d.mts","names":[],"sources":["../src/use-escape-keydown.ts"],"sourcesContent":[],"mappings":";;AAwBA;;iBAAgB,gBAAA,+BACgB,wCACf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./use-battery-DZZDx003.cjs`),t=require(`./use-callback-ref-CloM-Kqk.cjs`);let n=require(`react`);function r(e,r=globalThis?.document){let i=t.t(e);(0,n.useEffect)(()=>{let e=e=>{e.key===`Escape`&&i(e)};return r.addEventListener(`keydown`,e),()=>{r.removeEventListener(`keydown`,e)}},[i,r])}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return r}});
|
|
@@ -1,19 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.useEscapeKeydown = useEscapeKeydown;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
var _useCallbackRef = require("./use-callback-ref.cjs");
|
|
9
|
-
function useEscapeKeydown(s, e = globalThis?.document) {
|
|
10
|
-
const o = (0, _useCallbackRef.useCallbackRef)(s);
|
|
11
|
-
(0, _react.useEffect)(() => {
|
|
12
|
-
const n = t => {
|
|
13
|
-
t.key === "Escape" && o(t);
|
|
14
|
-
};
|
|
15
|
-
return e.addEventListener("keydown", n), () => {
|
|
16
|
-
e.removeEventListener("keydown", n);
|
|
17
|
-
};
|
|
18
|
-
}, [o, e]);
|
|
19
|
-
}
|
|
1
|
+
require(`./use-callback-ref-CloM-Kqk.cjs`);const e=require(`./use-escape-keydown-ITaT9SqI.cjs`);exports.useEscapeKeydown=e.t;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import"./use-callback-ref-otlhGzUu.mjs";import{t as e}from"./use-escape-keydown-CFy25Wk6.mjs";export{e as useEscapeKeydown};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{t as e}from"./use-isomorphic-layout-effect-D7uazny2.mjs";import{useCallback as t,useRef as n}from"react";const r=()=>{throw Error(`Cannot call an event handler while rendering.`)};function i(e){return a(e,r,!0)}function a(r,i,a){let o=n(i??r);return e(()=>{o.current=r}),t(a?(...e)=>o.current?.apply(null,e):()=>o.current,[])}export{i as t};
|
|
2
|
+
//# sourceMappingURL=use-event-CBTGhPhg.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-event-CBTGhPhg.mjs","names":[],"sources":["../src/use-event.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { useCallback, useRef } from \"react\";\nimport { useIsomorphicLayoutEffect } from \"./use-isomorphic-layout-effect\";\n\ntype AnyFunction = (...args: any[]) => any;\n\nconst defaultValue = () => {\n throw new Error(\"Cannot call an event handler while rendering.\");\n};\n\n/**\n * The function returns a memoized event handler.\n *\n * @param callback - The event handler to memoize.\n * @returns A memoized event handler.\n */\nexport function useEvent<T extends AnyFunction>(callback?: T): T {\n return useGet(callback, defaultValue, true) as T;\n}\n\n// keeps a reference to the current value easily\nfunction useGet<A>(\n currentValue: A,\n initialValue?: any,\n forwardToFunction?: boolean\n): () => A {\n const curRef = useRef<any>(initialValue ?? currentValue);\n useIsomorphicLayoutEffect(() => {\n curRef.current = currentValue;\n });\n\n return useCallback(\n forwardToFunction\n ? // eslint-disable-next-line ts/no-unsafe-call\n (...args) => curRef.current?.apply(null, args)\n : () => curRef.current,\n []\n );\n}\n"],"mappings":"gHAuBA,MAAM,MAAqB,CACzB,MAAU,MAAM,gDAAgD,EASlE,SAAgB,EAAgC,EAAiB,CAC/D,OAAO,EAAO,EAAU,EAAc,GAAK,CAI7C,SAAS,EACP,EACA,EACA,EACS,CACT,IAAM,EAAS,EAAY,GAAgB,EAAa,CAKxD,OAJA,MAAgC,CAC9B,EAAO,QAAU,GACjB,CAEK,EACL,GAEK,GAAG,IAAS,EAAO,SAAS,MAAM,KAAM,EAAK,KACxC,EAAO,QACjB,EAAE,CACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./use-battery-DZZDx003.cjs`),t=require(`./use-isomorphic-layout-effect-Br2hUBEM.cjs`);let n=require(`react`);const r=()=>{throw Error(`Cannot call an event handler while rendering.`)};function i(e){return a(e,r,!0)}function a(e,r,i){let a=(0,n.useRef)(r??e);return t.t(()=>{a.current=e}),(0,n.useCallback)(i?(...e)=>a.current?.apply(null,e):()=>a.current,[])}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return i}});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/use-event.d.ts
|
|
1
2
|
type AnyFunction = (...args: any[]) => any;
|
|
2
3
|
/**
|
|
3
4
|
* The function returns a memoized event handler.
|
|
@@ -5,5 +6,7 @@ type AnyFunction = (...args: any[]) => any;
|
|
|
5
6
|
* @param callback - The event handler to memoize.
|
|
6
7
|
* @returns A memoized event handler.
|
|
7
8
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
declare function useEvent<T extends AnyFunction>(callback?: T): T;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { useEvent as t };
|
|
12
|
+
//# sourceMappingURL=use-event-DHFCg8sl.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-event-DHFCg8sl.d.cts","names":[],"sources":["../src/use-event.ts"],"sourcesContent":[],"mappings":";KAqBK,WAAA;;AAYL;;;;;iBAAgB,mBAAmB,wBAAwB,IAAI"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/use-event.d.ts
|
|
2
|
+
type AnyFunction = (...args: any[]) => any;
|
|
3
|
+
/**
|
|
4
|
+
* The function returns a memoized event handler.
|
|
5
|
+
*
|
|
6
|
+
* @param callback - The event handler to memoize.
|
|
7
|
+
* @returns A memoized event handler.
|
|
8
|
+
*/
|
|
9
|
+
declare function useEvent<T extends AnyFunction>(callback?: T): T;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { useEvent as t };
|
|
12
|
+
//# sourceMappingURL=use-event-DQyUWk4T.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-event-DQyUWk4T.d.mts","names":[],"sources":["../src/use-event.ts"],"sourcesContent":[],"mappings":";KAqBK,WAAA;;AAYL;;;;;iBAAgB,mBAAmB,wBAAwB,IAAI"}
|
package/dist/use-event.cjs
CHANGED
|
@@ -1,20 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.useEvent = useEvent;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
var _useIsomorphicLayoutEffect = require("./use-isomorphic-layout-effect.cjs");
|
|
9
|
-
const l = () => {
|
|
10
|
-
throw new Error("Cannot call an event handler while rendering.");
|
|
11
|
-
};
|
|
12
|
-
function useEvent(n) {
|
|
13
|
-
return s(n, l, !0);
|
|
14
|
-
}
|
|
15
|
-
function s(n, r, t) {
|
|
16
|
-
const e = (0, _react.useRef)(r ?? n);
|
|
17
|
-
return (0, _useIsomorphicLayoutEffect.useIsomorphicLayoutEffect)(() => {
|
|
18
|
-
e.current = n;
|
|
19
|
-
}), (0, _react.useCallback)(t ? (...o) => e.current?.apply(null, o) : () => e.current, []);
|
|
20
|
-
}
|
|
1
|
+
require(`./use-isomorphic-layout-effect-Br2hUBEM.cjs`);const e=require(`./use-event-DG39UVbo.cjs`);exports.useEvent=e.t;
|
package/dist/use-event.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import"./use-isomorphic-layout-effect-D7uazny2.mjs";import{t as e}from"./use-event-CBTGhPhg.mjs";export{e as useEvent};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
//#region src/use-hover.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* A hook that returns tuple containing a ref and a boolean indicating if the element (referenced by the ref) is being hovered.
|
|
3
4
|
*
|
|
4
5
|
* @returns A tuple containing a ref and a boolean indicating if the element is being hovered
|
|
5
6
|
*/
|
|
6
|
-
|
|
7
|
+
declare const useHover: () => [(node: HTMLElement) => void, boolean];
|
|
8
|
+
//#endregion
|
|
9
|
+
export { useHover as t };
|
|
10
|
+
//# sourceMappingURL=use-hover-CPJ3UcMM.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-hover-CPJ3UcMM.d.mts","names":[],"sources":["../src/use-hover.ts"],"sourcesContent":[],"mappings":";;AAyBA;;;;cAAa,wBAAuB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{useCallback as e,useRef as t,useState as n}from"react";const r=()=>{let[r,i]=n(!1),a=t(null),o=e(()=>{i(!0)},[]),s=e(()=>{i(!1)},[]);return[e(e=>{a.current?.nodeType===Node.ELEMENT_NODE&&(a.current.removeEventListener(`mouseenter`,o),a.current.removeEventListener(`mouseleave`,s)),e?.nodeType===Node.ELEMENT_NODE&&(e.addEventListener(`mouseenter`,o),e.addEventListener(`mouseleave`,s)),a.current=e},[o,s]),r]};export{r as t};
|
|
2
|
+
//# sourceMappingURL=use-hover-DCP1g7QG.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-hover-DCP1g7QG.mjs","names":[],"sources":["../src/use-hover.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { useCallback, useRef, useState } from \"react\";\n\n/**\n * A hook that returns tuple containing a ref and a boolean indicating if the element (referenced by the ref) is being hovered.\n *\n * @returns A tuple containing a ref and a boolean indicating if the element is being hovered\n */\nexport const useHover = (): [(node: HTMLElement) => void, boolean] => {\n const [hovering, setHovering] = useState(false);\n const previousNode = useRef<HTMLElement | null>(null);\n\n const handleMouseEnter = useCallback(() => {\n setHovering(true);\n }, []);\n const handleMouseLeave = useCallback(() => {\n setHovering(false);\n }, []);\n\n const customRef = useCallback(\n (node: HTMLElement) => {\n if (previousNode.current?.nodeType === Node.ELEMENT_NODE) {\n previousNode.current.removeEventListener(\n \"mouseenter\",\n handleMouseEnter\n );\n previousNode.current.removeEventListener(\n \"mouseleave\",\n handleMouseLeave\n );\n }\n\n if (node?.nodeType === Node.ELEMENT_NODE) {\n node.addEventListener(\"mouseenter\", handleMouseEnter);\n node.addEventListener(\"mouseleave\", handleMouseLeave);\n }\n\n previousNode.current = node;\n },\n [handleMouseEnter, handleMouseLeave]\n );\n\n return [customRef, hovering];\n};\n"],"mappings":"8DAyBA,MAAa,MAAyD,CACpE,GAAM,CAAC,EAAU,GAAe,EAAS,GAAM,CACzC,EAAe,EAA2B,KAAK,CAE/C,EAAmB,MAAkB,CACzC,EAAY,GAAK,EAChB,EAAE,CAAC,CACA,EAAmB,MAAkB,CACzC,EAAY,GAAM,EACjB,EAAE,CAAC,CAyBN,MAAO,CAvBW,EACf,GAAsB,CACjB,EAAa,SAAS,WAAa,KAAK,eAC1C,EAAa,QAAQ,oBACnB,aACA,EACD,CACD,EAAa,QAAQ,oBACnB,aACA,EACD,EAGC,GAAM,WAAa,KAAK,eAC1B,EAAK,iBAAiB,aAAc,EAAiB,CACrD,EAAK,iBAAiB,aAAc,EAAiB,EAGvD,EAAa,QAAU,GAEzB,CAAC,EAAkB,EAAiB,CACrC,CAEkB,EAAS"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/use-hover.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* A hook that returns tuple containing a ref and a boolean indicating if the element (referenced by the ref) is being hovered.
|
|
4
|
+
*
|
|
5
|
+
* @returns A tuple containing a ref and a boolean indicating if the element is being hovered
|
|
6
|
+
*/
|
|
7
|
+
declare const useHover: () => [(node: HTMLElement) => void, boolean];
|
|
8
|
+
//#endregion
|
|
9
|
+
export { useHover as t };
|
|
10
|
+
//# sourceMappingURL=use-hover-DeFTY9RX.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-hover-DeFTY9RX.d.cts","names":[],"sources":["../src/use-hover.ts"],"sourcesContent":[],"mappings":";;AAyBA;;;;cAAa,wBAAuB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./use-battery-DZZDx003.cjs`);let t=require(`react`);const n=()=>{let[e,n]=(0,t.useState)(!1),r=(0,t.useRef)(null),i=(0,t.useCallback)(()=>{n(!0)},[]),a=(0,t.useCallback)(()=>{n(!1)},[]);return[(0,t.useCallback)(e=>{r.current?.nodeType===Node.ELEMENT_NODE&&(r.current.removeEventListener(`mouseenter`,i),r.current.removeEventListener(`mouseleave`,a)),e?.nodeType===Node.ELEMENT_NODE&&(e.addEventListener(`mouseenter`,i),e.addEventListener(`mouseleave`,a)),r.current=e},[i,a]),e]};Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return n}});
|
package/dist/use-hover.cjs
CHANGED
|
@@ -1,21 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.useHover = void 0;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
const useHover = () => {
|
|
9
|
-
const [u, s] = (0, _react.useState)(!1),
|
|
10
|
-
e = (0, _react.useRef)(null),
|
|
11
|
-
n = (0, _react.useCallback)(() => {
|
|
12
|
-
s(!0);
|
|
13
|
-
}, []),
|
|
14
|
-
o = (0, _react.useCallback)(() => {
|
|
15
|
-
s(!1);
|
|
16
|
-
}, []);
|
|
17
|
-
return [(0, _react.useCallback)(t => {
|
|
18
|
-
e.current?.nodeType === Node.ELEMENT_NODE && (e.current.removeEventListener("mouseenter", n), e.current.removeEventListener("mouseleave", o)), t?.nodeType === Node.ELEMENT_NODE && (t.addEventListener("mouseenter", n), t.addEventListener("mouseleave", o)), e.current = t;
|
|
19
|
-
}, [n, o]), u];
|
|
20
|
-
};
|
|
21
|
-
exports.useHover = useHover;
|
|
1
|
+
const e=require(`./use-hover-SNRrnUoI.cjs`);exports.useHover=e.t;
|