@workos-inc/widgets 1.20.2-next.1792700156145 → 1.20.2
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 +4 -10
- package/dist/cjs/admin-portal-audit-log-streaming.client.cjs +2 -1
- package/dist/cjs/admin-portal-audit-log-streaming.client.cjs.map +1 -1
- package/dist/cjs/admin-portal-domain-verification.client.cjs +3 -2
- package/dist/cjs/admin-portal-domain-verification.client.cjs.map +1 -1
- package/dist/cjs/admin-portal-sso-connection.client.cjs +2 -1
- package/dist/cjs/admin-portal-sso-connection.client.cjs.map +1 -1
- package/dist/cjs/api/api-provider.cjs +23 -1
- package/dist/cjs/api/api-provider.cjs.map +1 -1
- package/dist/cjs/api/api-provider.d.cts.map +1 -1
- package/dist/cjs/api/claims.cjs.map +1 -1
- package/dist/cjs/api/claims.d.cts +2 -1
- package/dist/cjs/api/claims.d.cts.map +1 -1
- package/dist/cjs/api/client-graphql/client.cjs +3 -2
- package/dist/cjs/api/client-graphql/client.cjs.map +1 -1
- package/dist/cjs/api/client-graphql/hooks.cjs +3 -20
- package/dist/cjs/api/client-graphql/hooks.cjs.map +1 -1
- package/dist/cjs/api/client-graphql/hooks.d.cts +3 -12
- package/dist/cjs/api/client-graphql/hooks.d.cts.map +1 -1
- package/dist/cjs/api/client-graphql/query-keys.cjs +25 -0
- package/dist/cjs/api/client-graphql/query-keys.cjs.map +1 -0
- package/dist/cjs/api/client-graphql/query-keys.d.cts +16 -0
- package/dist/cjs/api/client-graphql/query-keys.d.cts.map +1 -0
- package/dist/cjs/components/copy-text.cjs +1 -1
- package/dist/cjs/components/copy-text.cjs.map +1 -1
- package/dist/cjs/components/form.cjs +9 -13
- package/dist/cjs/components/form.cjs.map +1 -1
- package/dist/cjs/components/form.d.cts.map +1 -1
- package/dist/cjs/components/otp-input.cjs +1 -0
- package/dist/cjs/components/otp-input.cjs.map +1 -1
- package/dist/cjs/directory-sync.client.cjs +2 -1
- package/dist/cjs/directory-sync.client.cjs.map +1 -1
- package/dist/cjs/lib/api/api-key.cjs +4 -3
- package/dist/cjs/lib/api/api-key.cjs.map +1 -1
- package/dist/cjs/lib/api/me.cjs +2 -1
- package/dist/cjs/lib/api/me.cjs.map +1 -1
- package/dist/cjs/lib/api/pipes.cjs +7 -6
- package/dist/cjs/lib/api/pipes.cjs.map +1 -1
- package/dist/cjs/lib/api/user-api-key.cjs +3 -2
- package/dist/cjs/lib/api/user-api-key.cjs.map +1 -1
- package/dist/cjs/lib/i18n/intl-context.cjs.map +1 -1
- package/dist/cjs/lib/i18n/intl-context.d.cts +1 -0
- package/dist/cjs/lib/i18n/intl-context.d.cts.map +1 -1
- package/dist/cjs/lib/i18n/use-translation.cjs +2 -2
- package/dist/cjs/lib/i18n/use-translation.cjs.map +1 -1
- package/dist/cjs/lib/use-composed-event-handlers.cjs +15 -0
- package/dist/cjs/lib/use-composed-event-handlers.cjs.map +1 -0
- package/dist/cjs/lib/use-composed-event-handlers.d.cts +6 -0
- package/dist/cjs/lib/use-composed-event-handlers.d.cts.map +1 -0
- package/dist/cjs/lib/use-debounce.cjs +124 -116
- package/dist/cjs/lib/use-debounce.cjs.map +1 -1
- package/dist/cjs/lib/use-debounce.d.cts +53 -48
- package/dist/cjs/lib/use-debounce.d.cts.map +1 -1
- package/dist/cjs/lib/use-widgets-invalidator.cjs +3 -3
- package/dist/cjs/lib/use-widgets-invalidator.cjs.map +1 -1
- package/dist/cjs/lib/use-widgets-invalidator.d.cts.map +1 -1
- package/dist/cjs/lib/utils.cjs +0 -7
- package/dist/cjs/lib/utils.cjs.map +1 -1
- package/dist/cjs/lib/utils.d.cts +0 -3
- package/dist/cjs/lib/utils.d.cts.map +1 -1
- package/dist/cjs/organization-switcher.client.cjs +2 -1
- package/dist/cjs/organization-switcher.client.cjs.map +1 -1
- package/dist/cjs/pipes-admin.client.cjs +2 -1
- package/dist/cjs/pipes-admin.client.cjs.map +1 -1
- package/dist/cjs/pipes.client.cjs +2 -1
- package/dist/cjs/pipes.client.cjs.map +1 -1
- package/dist/cjs/user-security.client.cjs +2 -1
- package/dist/cjs/user-security.client.cjs.map +1 -1
- package/dist/cjs/user-sessions.client.cjs +2 -1
- package/dist/cjs/user-sessions.client.cjs.map +1 -1
- package/dist/cjs/widgets/api-keys/api-keys-search.cjs +1 -1
- package/dist/cjs/widgets/api-keys/api-keys-search.cjs.map +1 -1
- package/dist/cjs/widgets/api-keys/user-api-keys-search.cjs +1 -1
- package/dist/cjs/widgets/api-keys/user-api-keys-search.cjs.map +1 -1
- package/dist/cjs/widgets/organization-switcher/organization-switcher.cjs +19 -5
- package/dist/cjs/widgets/organization-switcher/organization-switcher.cjs.map +1 -1
- package/dist/cjs/widgets/organization-switcher/organization-switcher.d.cts +2 -1
- package/dist/cjs/widgets/organization-switcher/organization-switcher.d.cts.map +1 -1
- package/dist/cjs/widgets/pipes/pipes.cjs +3 -2
- package/dist/cjs/widgets/pipes/pipes.cjs.map +1 -1
- package/dist/cjs/widgets/user-sessions/logout-all-sessions-dialog.cjs +2 -1
- package/dist/cjs/widgets/user-sessions/logout-all-sessions-dialog.cjs.map +1 -1
- package/dist/cjs/widgets/user-sessions/logout-dialog.cjs +2 -1
- package/dist/cjs/widgets/user-sessions/logout-dialog.cjs.map +1 -1
- package/dist/cjs/widgets/users-management/invite-user-dialog.cjs +5 -6
- package/dist/cjs/widgets/users-management/invite-user-dialog.cjs.map +1 -1
- package/dist/cjs/widgets/users-management/users-management-utils.cjs +4 -3
- package/dist/cjs/widgets/users-management/users-management-utils.cjs.map +1 -1
- package/dist/cjs/widgets/users-management/users-management.cjs.map +1 -1
- package/dist/cjs/widgets/users-management/users-search.cjs +1 -1
- package/dist/cjs/widgets/users-management/users-search.cjs.map +1 -1
- package/dist/esm/admin-portal-audit-log-streaming.client.js +2 -1
- package/dist/esm/admin-portal-audit-log-streaming.client.js.map +1 -1
- package/dist/esm/admin-portal-domain-verification.client.js +2 -1
- package/dist/esm/admin-portal-domain-verification.client.js.map +1 -1
- package/dist/esm/admin-portal-sso-connection.client.js +2 -1
- package/dist/esm/admin-portal-sso-connection.client.js.map +1 -1
- package/dist/esm/api/api-provider.d.ts.map +1 -1
- package/dist/esm/api/api-provider.js +23 -1
- package/dist/esm/api/api-provider.js.map +1 -1
- package/dist/esm/api/claims.d.ts +2 -1
- package/dist/esm/api/claims.d.ts.map +1 -1
- package/dist/esm/api/claims.js.map +1 -1
- package/dist/esm/api/client-graphql/client.js +3 -2
- package/dist/esm/api/client-graphql/client.js.map +1 -1
- package/dist/esm/api/client-graphql/hooks.d.ts +3 -12
- package/dist/esm/api/client-graphql/hooks.d.ts.map +1 -1
- package/dist/esm/api/client-graphql/hooks.js +1 -18
- package/dist/esm/api/client-graphql/hooks.js.map +1 -1
- package/dist/esm/api/client-graphql/query-keys.d.ts +16 -0
- package/dist/esm/api/client-graphql/query-keys.d.ts.map +1 -0
- package/dist/esm/api/client-graphql/query-keys.js +23 -0
- package/dist/esm/api/client-graphql/query-keys.js.map +1 -0
- package/dist/esm/components/copy-text.js +1 -1
- package/dist/esm/components/copy-text.js.map +1 -1
- package/dist/esm/components/form.d.ts.map +1 -1
- package/dist/esm/components/form.js +9 -13
- package/dist/esm/components/form.js.map +1 -1
- package/dist/esm/components/otp-input.js +1 -0
- package/dist/esm/components/otp-input.js.map +1 -1
- package/dist/esm/directory-sync.client.js +2 -1
- package/dist/esm/directory-sync.client.js.map +1 -1
- package/dist/esm/lib/api/api-key.js +2 -1
- package/dist/esm/lib/api/api-key.js.map +1 -1
- package/dist/esm/lib/api/me.js +2 -1
- package/dist/esm/lib/api/me.js.map +1 -1
- package/dist/esm/lib/api/pipes.js +2 -1
- package/dist/esm/lib/api/pipes.js.map +1 -1
- package/dist/esm/lib/api/user-api-key.js +2 -1
- package/dist/esm/lib/api/user-api-key.js.map +1 -1
- package/dist/esm/lib/i18n/intl-context.d.ts +1 -0
- package/dist/esm/lib/i18n/intl-context.d.ts.map +1 -1
- package/dist/esm/lib/i18n/intl-context.js.map +1 -1
- package/dist/esm/lib/i18n/use-translation.js +2 -2
- package/dist/esm/lib/i18n/use-translation.js.map +1 -1
- package/dist/esm/lib/use-composed-event-handlers.d.ts +6 -0
- package/dist/esm/lib/use-composed-event-handlers.d.ts.map +1 -0
- package/dist/esm/lib/use-composed-event-handlers.js +12 -0
- package/dist/esm/lib/use-composed-event-handlers.js.map +1 -0
- package/dist/esm/lib/use-debounce.d.ts +53 -48
- package/dist/esm/lib/use-debounce.d.ts.map +1 -1
- package/dist/esm/lib/use-debounce.js +124 -116
- package/dist/esm/lib/use-debounce.js.map +1 -1
- package/dist/esm/lib/use-widgets-invalidator.d.ts.map +1 -1
- package/dist/esm/lib/use-widgets-invalidator.js +2 -2
- package/dist/esm/lib/use-widgets-invalidator.js.map +1 -1
- package/dist/esm/lib/utils.d.ts +0 -3
- package/dist/esm/lib/utils.d.ts.map +1 -1
- package/dist/esm/lib/utils.js +1 -7
- package/dist/esm/lib/utils.js.map +1 -1
- package/dist/esm/organization-switcher.client.js +2 -1
- package/dist/esm/organization-switcher.client.js.map +1 -1
- package/dist/esm/pipes-admin.client.js +2 -1
- package/dist/esm/pipes-admin.client.js.map +1 -1
- package/dist/esm/pipes.client.js +2 -1
- package/dist/esm/pipes.client.js.map +1 -1
- package/dist/esm/user-security.client.js +2 -1
- package/dist/esm/user-security.client.js.map +1 -1
- package/dist/esm/user-sessions.client.js +2 -1
- package/dist/esm/user-sessions.client.js.map +1 -1
- package/dist/esm/widgets/api-keys/api-keys-search.js +1 -1
- package/dist/esm/widgets/api-keys/api-keys-search.js.map +1 -1
- package/dist/esm/widgets/api-keys/user-api-keys-search.js +1 -1
- package/dist/esm/widgets/api-keys/user-api-keys-search.js.map +1 -1
- package/dist/esm/widgets/organization-switcher/organization-switcher.d.ts +2 -1
- package/dist/esm/widgets/organization-switcher/organization-switcher.d.ts.map +1 -1
- package/dist/esm/widgets/organization-switcher/organization-switcher.js +19 -5
- package/dist/esm/widgets/organization-switcher/organization-switcher.js.map +1 -1
- package/dist/esm/widgets/pipes/pipes.js +2 -1
- package/dist/esm/widgets/pipes/pipes.js.map +1 -1
- package/dist/esm/widgets/user-sessions/logout-all-sessions-dialog.js +2 -1
- package/dist/esm/widgets/user-sessions/logout-all-sessions-dialog.js.map +1 -1
- package/dist/esm/widgets/user-sessions/logout-dialog.js +2 -1
- package/dist/esm/widgets/user-sessions/logout-dialog.js.map +1 -1
- package/dist/esm/widgets/users-management/invite-user-dialog.js +5 -6
- package/dist/esm/widgets/users-management/invite-user-dialog.js.map +1 -1
- package/dist/esm/widgets/users-management/users-management-utils.js +2 -1
- package/dist/esm/widgets/users-management/users-management-utils.js.map +1 -1
- package/dist/esm/widgets/users-management/users-management.js.map +1 -1
- package/dist/esm/widgets/users-management/users-search.js +1 -1
- package/dist/esm/widgets/users-management/users-search.js.map +1 -1
- package/package.json +1 -1
- package/src/api/api-provider.tsx +39 -1
- package/src/api/claims.ts +2 -1
- package/src/api/client-graphql/client.ts +8 -2
- package/src/api/client-graphql/hooks.ts +8 -27
- package/src/api/client-graphql/query-keys.ts +29 -0
- package/src/components/copy-text.tsx +1 -1
- package/src/components/form.tsx +33 -29
- package/src/components/otp-input.tsx +2 -0
- package/src/lib/i18n/intl-context.tsx +4 -0
- package/src/lib/i18n/use-translation.ts +1 -4
- package/src/lib/use-composed-event-handlers.ts +25 -0
- package/src/lib/use-debounce.ts +289 -237
- package/src/lib/use-widgets-invalidator.ts +0 -4
- package/src/lib/utils.ts +0 -12
- package/src/widgets/api-keys/api-keys-search.tsx +6 -3
- package/src/widgets/api-keys/user-api-keys-search.tsx +6 -3
- package/src/widgets/organization-switcher/organization-switcher.tsx +32 -8
- package/src/widgets/users-management/invite-user-dialog.tsx +9 -11
- package/src/widgets/users-management/users-management.tsx +1 -1
- package/src/widgets/users-management/users-search.tsx +6 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-debounce.cjs","names":["React","canUseDOM"],"sources":["../../../src/lib/use-debounce.ts"],"sourcesContent":["// Fork of https://github.com/xnimorz/use-debounce\n// MIT License, Copyright (c) 2018 Nikita Mostovoy\nimport * as React from \"react\";\nimport { canUseDOM } from \"./utils.js\";\n\n/**\n * Creates a debounced function that delays invoking `func` until after `wait`\n * milliseconds have elapsed since the last time the debounced function was\n * invoked, or until the next browser frame is drawn.\n *\n * The debounced function comes with a `cancel` method to cancel delayed `func`\n * invocations and a `flush` method to immediately invoke them.\n *\n * Provide `options` to indicate whether `func` should be invoked on the leading\n * and/or trailing edge of the `wait` timeout. The `func` is invoked with the\n * last arguments provided to the debounced function.\n *\n * Subsequent calls to the debounced function return the result of the last\n * `func` invocation.\n *\n * **Note:** If `leading` and `trailing` options are `true`, `func` is invoked\n * on the trailing edge of the timeout only if the debounced function is invoked\n * more than once during the `wait` timeout.\n *\n * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred\n * until the next tick, similar to `setTimeout` with a timeout of `0`.\n *\n * If `wait` is omitted in an environment with `requestAnimationFrame`, `func`\n * invocation will be deferred until the next frame is drawn (typically about\n * 16ms).\n *\n * See [David Corbacho's\n * article](https://css-tricks.com/debouncing-throttling-explained-examples/)\n * for details over the differences between `debounce` and `throttle`.\n *\n * @category Function\n * @param {Function} func The function to debounce.\n * @param {number} [wait=0] The number of milliseconds to delay; if omitted,\n * `requestAnimationFrame` is used (if available, otherwise it will be\n * setTimeout(...,0)).\n * @param {Object} [options={}] The options object. Controls if `func` should be\n * invoked on the leading edge of the timeout.\n * @param {boolean} [options.leading=false] The maximum time `func` is allowed\n * to be delayed before it's invoked.\n * @param {number} [options.maxWait] Controls if `func` should be invoked the\n * trailing edge of the timeout.\n * @param {boolean} [options.trailing=true]\n * @returns {Function} Returns the new debounced function.\n * @example\n * ```tsx\n * // Avoid costly calculations while the window size is in flux.\n * const resizeHandler = useDebouncedCallback(calculateLayout, 150);\n * window.addEventListener('resize', resizeHandler)\n *\n * // Invoke `sendMail` when clicked, debouncing subsequent calls.\n * const clickHandler = useDebouncedCallback(sendMail, 300, {\n * leading: true,\n * trailing: false,\n * })\n * <button onClick={clickHandler}>click me</button>\n *\n * // Ensure `batchLog` is invoked once after 1 second of debounced calls.\n * const debounced = useDebouncedCallback(batchLog, 250, { 'maxWait': 1000 })\n * const source = new EventSource('/stream')\n * source.addEventListener('message', debounced)\n *\n * // Cancel the trailing debounced invocation.\n * window.addEventListener('popstate', debounced.cancel)\n *\n * // Check for pending invocations.\n * const status = debounced.isPending() ? \"Pending...\" : \"Ready\"\n * ```\n */\nfunction useDebouncedCallback<T extends (...args: any) => ReturnType<T>>(\n this: unknown,\n func: T,\n wait?: number,\n options?: Options,\n): DebouncedState<T> {\n const lastCallTime = React.useRef<number>(null);\n const lastInvokeTime = React.useRef(0);\n const timerId = React.useRef<number>(null);\n const lastArgs = React.useRef<unknown[]>(null);\n const lastThis = React.useRef<unknown>(undefined);\n const result = React.useRef<ReturnType<T>>(undefined);\n const funcRef = React.useRef(func);\n const mounted = React.useRef(true);\n const visibilityListener = React.useRef<VoidFunction>(null);\n const debouncedRef = React.useRef<DebouncedState<T>>(undefined);\n // Always keep the latest version of debounce callback, with no wait time.\n // TODO: Fix this!\n // eslint-disable-next-line react-hooks/exhaustive-deps\n funcRef.current = func;\n\n // Bypass `requestAnimationFrame` by explicitly setting `wait=0`.\n const useRAF = !wait && wait !== 0 && canUseDOM;\n\n if (typeof func !== \"function\") {\n throw new TypeError(\"Expected a function\");\n }\n\n wait = +(wait || 0);\n options = options || {};\n\n const leading = !!options.leading;\n const trailing = \"trailing\" in options ? !!options.trailing : true; // `true` by default\n const flushOnExit = !!options.flushOnExit && trailing;\n const maxing = \"maxWait\" in options;\n const debounceOnServer =\n \"debounceOnServer\" in options ? !!options.debounceOnServer : false; // `false` by default\n const maxWait = maxing ? Math.max(+(options.maxWait || 0), wait) : null;\n\n // You may have a question, why we have so many code under the useMemo definition.\n //\n // This was made as we want to escape from useCallback hell and\n // not to initialize a number of functions each time useDebouncedCallback is called.\n //\n // It means that we have less garbage for our GC calls which improves performance.\n // Also, it makes this library smaller.\n //\n // And the last reason, that the code without lots of useCallback with deps is easier to read.\n // You have only one place for that.\n const debounced = React.useMemo(() => {\n const invokeFunc = (time: number) => {\n const args = lastArgs.current;\n const thisArg = lastThis.current;\n lastArgs.current = lastThis.current = null;\n lastInvokeTime.current = time;\n\n return (result.current = funcRef.current.apply(thisArg, args || []));\n };\n\n const startTimer = (pendingFunc: () => void, wait: number) => {\n if (useRAF) {\n cancelAnimationFrame(timerId.current!);\n }\n timerId.current = useRAF\n ? requestAnimationFrame(pendingFunc)\n : (setTimeout(pendingFunc, wait) as unknown as number);\n };\n\n const shouldInvoke = (time: number) => {\n if (!mounted.current) return false;\n\n const timeSinceLastCall = time - (lastCallTime.current || 0);\n const timeSinceLastInvoke = time - lastInvokeTime.current;\n\n // Either this is the first call, activity has stopped and we're at the\n // trailing edge, the system time has gone backwards and we're treating\n // it as the trailing edge, or we've hit the `maxWait` limit.\n return (\n !lastCallTime.current ||\n timeSinceLastCall >= wait ||\n timeSinceLastCall < 0 ||\n (maxing && timeSinceLastInvoke >= (maxWait || 0))\n );\n };\n\n const trailingEdge = (time: number) => {\n timerId.current = null;\n\n // Only invoke if we have `lastArgs` which means `func` has been\n // debounced at least once.\n if (trailing && lastArgs.current) {\n return invokeFunc(time);\n }\n\n lastArgs.current = lastThis.current = null;\n return result.current;\n };\n\n const timerExpired = () => {\n const time = Date.now();\n\n if (shouldInvoke(time)) {\n return trailingEdge(time);\n }\n // https://github.com/xnimorz/use-debounce/issues/97\n if (!mounted.current) {\n return;\n }\n // Remaining wait calculation\n const timeSinceLastCall = time - (lastCallTime.current || 0);\n const timeSinceLastInvoke = time - lastInvokeTime.current;\n const timeWaiting = wait - timeSinceLastCall;\n const remainingWait = maxing\n ? Math.min(timeWaiting, (maxWait || 0) - timeSinceLastInvoke)\n : timeWaiting;\n\n // Restart the timer\n startTimer(timerExpired, remainingWait);\n };\n\n const func: DebouncedState<T> = (...args: Parameters<T>): ReturnType<T> => {\n if (!canUseDOM && !debounceOnServer) {\n // TODO: Fixme\n return undefined!;\n }\n\n const time = Date.now();\n const isInvoking = shouldInvoke(time);\n\n lastArgs.current = args;\n lastThis.current = this;\n lastCallTime.current = time;\n\n if (flushOnExit && !visibilityListener.current) {\n visibilityListener.current = () => {\n if (globalThis.document?.visibilityState === \"hidden\") {\n debouncedRef.current?.flush();\n }\n };\n globalThis.document?.addEventListener?.(\n \"visibilitychange\",\n visibilityListener.current,\n );\n }\n if (isInvoking) {\n if (!timerId.current && mounted.current) {\n // Reset any `maxWait` timer.\n lastInvokeTime.current = lastCallTime.current;\n // Start the timer for the trailing edge.\n startTimer(timerExpired, wait);\n // Invoke the leading edge.\n return leading ? invokeFunc(lastCallTime.current) : result.current!;\n }\n if (maxing) {\n // Handle invocations in a tight loop.\n startTimer(timerExpired, wait);\n return invokeFunc(lastCallTime.current);\n }\n }\n if (!timerId.current) {\n startTimer(timerExpired, wait);\n }\n return result.current!;\n };\n\n func.cancel = () => {\n if (timerId.current) {\n useRAF\n ? cancelAnimationFrame(timerId.current!)\n : clearTimeout(timerId.current!);\n }\n lastInvokeTime.current = 0;\n lastArgs.current =\n lastCallTime.current =\n lastThis.current =\n timerId.current =\n null;\n };\n\n func.isPending = () => {\n return !!timerId.current;\n };\n\n func.flush = () => {\n return !timerId.current ? result.current : trailingEdge(Date.now());\n };\n\n return func;\n }, [\n leading,\n maxing,\n wait,\n maxWait,\n trailing,\n flushOnExit,\n useRAF,\n debounceOnServer,\n ]);\n\n // Store reference to debounced function for cleanup\n debouncedRef.current = debounced;\n\n React.useEffect(() => {\n mounted.current = true;\n return () => {\n if (flushOnExit) {\n debouncedRef.current?.flush();\n }\n if (visibilityListener.current) {\n globalThis.document?.removeEventListener?.(\n \"visibilitychange\",\n visibilityListener.current,\n );\n visibilityListener.current = null;\n }\n mounted.current = false;\n };\n }, [flushOnExit]);\n\n return debounced;\n}\n\ninterface CallOptions {\n /**\n * Controls if the function should be invoked on the leading edge of the timeout.\n */\n leading?: boolean;\n /**\n * Controls if the function should be invoked on the trailing edge of the timeout.\n */\n trailing?: boolean;\n /**\n * Controls if the function should be invoked when the React component unmounts or\n * the page is closed. This is usually desirable whenever `func` has persistent side-effects\n * such as persists data.\n *\n * NOTE: If the callback calls `fetch()`, you usually also want to specify the `keepalive=true`\n * option for `fetch()` so it can finish in the background after the page is closed.\n *\n * This option has no effect if `trailing == false`.\n */\n flushOnExit?: boolean;\n}\n\ninterface Options extends CallOptions {\n /**\n * The maximum time the given function is allowed to be delayed before it's invoked.\n */\n maxWait?: number;\n /**\n * If the setting is set to true, all debouncing and timers will happen on the server side as well\n */\n debounceOnServer?: boolean;\n}\n\ninterface ControlFunctions<ReturnT> {\n /**\n * Cancel pending function invocations\n */\n cancel: () => void;\n /**\n * Immediately invoke pending function invocations\n */\n flush: () => ReturnT | undefined;\n /**\n * Returns `true` if there are any pending function invocations\n */\n isPending: () => boolean;\n}\n\n/**\n * Subsequent calls to the debounced function return the result of the last func invocation.\n * Note, that if there are no previous invocations you will get undefined. You should check it in your code properly.\n */\ninterface DebouncedState<\n T extends (...args: any) => ReturnType<T>,\n> extends ControlFunctions<ReturnType<T>> {\n (...args: Parameters<T>): ReturnType<T> | undefined;\n}\n\nexport { useDebouncedCallback };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyEA,SAAS,qBAEP,MACA,MACA,SACmB;CACnB,MAAM,eAAeA,MAAM,OAAe,IAAI;CAC9C,MAAM,iBAAiBA,MAAM,OAAO,CAAC;CACrC,MAAM,UAAUA,MAAM,OAAe,IAAI;CACzC,MAAM,WAAWA,MAAM,OAAkB,IAAI;CAC7C,MAAM,WAAWA,MAAM,OAAgB,MAAS;CAChD,MAAM,SAASA,MAAM,OAAsB,MAAS;CACpD,MAAM,UAAUA,MAAM,OAAO,IAAI;CACjC,MAAM,UAAUA,MAAM,OAAO,IAAI;CAC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,SAAS,UACP,aAAa,UACb,SAAS,UACT,QAAQ,UACN;EACN;EAEA,KAAK,kBAAkB;GACrB,OAAO,CAAC,CAAC,QAAQ;EACnB;EAEA,KAAK,cAAc;GACjB,OAAO,CAAC,QAAQ,UAAU,OAAO,UAAU,aAAa,KAAK,IAAI,CAAC;EACpE;EAEA,OAAO;CACT,GAAG;EACD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CAGD,aAAa,UAAU;CAEvB,MAAM,gBAAgB;EACpB,QAAQ,UAAU;EAClB,aAAa;GACX,IAAI,aACF,aAAa,SAAS,MAAM;GAE9B,IAAI,mBAAmB,SAAS;IAC9B,WAAW,UAAU,sBACnB,oBACA,mBAAmB,OACrB;IACA,mBAAmB,UAAU;GAC/B;GACA,QAAQ,UAAU;EACpB;CACF,GAAG,CAAC,WAAW,CAAC;CAEhB,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"use-debounce.cjs","names":["canUseDOM","React"],"sources":["../../../src/lib/use-debounce.ts"],"sourcesContent":["// Fork of https://github.com/xnimorz/use-debounce\n// MIT License, Copyright (c) 2018 Nikita Mostovoy\nimport * as React from \"react\";\nimport { useLayoutEffect } from \"./use-layout-effect.js\";\nimport { canUseDOM } from \"./utils.js\";\n\ninterface Options {\n /**\n * The number of milliseconds to delay. if omitted, invocation is deferred to\n * the next animation frame (or the next tick where that's unavailable).\n */\n wait?: number;\n /**\n * Controls if the function should be invoked on the leading edge of the\n * timeout.\n * @default false\n */\n leading?: boolean;\n /**\n * Controls if the function should be invoked on the trailing edge of the\n * timeout.\n * @default true\n */\n trailing?: boolean;\n /**\n * Controls if the function should be invoked when the React component\n * unmounts or the page is closed. This is usually desirable whenever `func`\n * has persistent side-effects such as persists data.\n *\n * NOTE: If the callback calls `fetch()`, you usually also want to specify the\n * `keepalive=true` option for `fetch()` so it can finish in the background\n * after the page is closed.\n *\n * This option has no effect if `trailing == false`.\n *\n * @default false\n */\n flushOnExit?: boolean;\n /**\n * The maximum time the given function is allowed to be delayed before it's\n * invoked. Pass `null` and the maximum wait time is equal to the `wait` time.\n */\n maxWait?: number | null;\n /**\n * If the setting is set to true, all debouncing and timers will happen on the\n * server side as well.\n *\n * @default false\n */\n debounceOnServer?: boolean;\n}\n\n/**\n * Creates a debounced function that delays invoking `func` until after `wait`\n * milliseconds have elapsed since the last time the debounced function was\n * invoked, or until the next browser frame is drawn.\n *\n * The debounced function comes with a `cancel` method to cancel delayed `func`\n * invocations and a `flush` method to immediately invoke them.\n *\n * Provide `options` to indicate whether `func` should be invoked on the leading\n * and/or trailing edge of the `wait` timeout. The `func` is invoked with the\n * last arguments provided to the debounced function.\n *\n * Subsequent calls to the debounced function return the result of the last\n * `func` invocation.\n *\n * **Note:** If `leading` and `trailing` options are `true`, `func` is invoked\n * on the trailing edge of the timeout only if the debounced function is invoked\n * more than once during the `wait` timeout.\n *\n * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred\n * until the next tick, similar to `setTimeout` with a timeout of `0`.\n *\n * If `wait` is omitted in an environment with `requestAnimationFrame`, `func`\n * invocation will be deferred until the next frame is drawn (typically about\n * 16ms).\n *\n * See [David Corbacho's\n * article](https://css-tricks.com/debouncing-throttling-explained-examples/)\n * for details over the differences between `debounce` and `throttle`.\n *\n * @param func The function to debounce\n * @param options The options object\n * @returns Returns the new debounced function.\n * @example\n * ```tsx\n * // Avoid costly calculations while the window size is in flux.\n * const resizeHandler = useDebouncedCallback(calculateLayout, { wait: 150 });\n * window.addEventListener('resize', resizeHandler)\n *\n * // Invoke `sendMail` when clicked, debouncing subsequent calls.\n * const clickHandler = useDebouncedCallback(sendMail, {\n * wait: 300,\n * leading: true,\n * trailing: false,\n * })\n * <button onClick={clickHandler}>click me</button>\n *\n * // Ensure `batchLog` is invoked once after 1 second of debounced calls.\n * const debounced = useDebouncedCallback(batchLog, { wait: 250, maxWait: 1000 })\n * const source = new EventSource('/stream')\n * source.addEventListener('message', debounced)\n *\n * // Cancel the trailing debounced invocation.\n * window.addEventListener('popstate', debounced.cancel)\n *\n * // Check for pending invocations.\n * const status = debounced.isPending() ? \"Pending...\" : \"Ready\"\n * ```\n */\nfunction useDebouncedCallback<T extends (...args: any) => ReturnType<T>>(\n func: T,\n options: Options = {},\n): DebouncedState<T> {\n const {\n wait = 0,\n leading = false,\n trailing = true,\n maxWait: maxWaitOption,\n debounceOnServer = false,\n } = options;\n // Bypass `requestAnimationFrame` by explicitly setting `wait: 0`.\n const useRAF = options.wait === undefined && canUseDOM;\n const flushOnExit = !!options.flushOnExit && trailing;\n const maxWait =\n maxWaitOption === undefined ? null : Math.max(maxWaitOption ?? 0, wait);\n\n const stateRef = React.useRef<DebounceState<T>>({\n func,\n lastCallTime: null,\n lastInvokeTime: 0,\n timerId: null,\n lastArgs: null,\n lastThis: undefined,\n result: undefined,\n mounted: true,\n visibilityListener: null,\n debounced: undefined,\n });\n\n const debounced = React.useMemo(() => {\n const config: DebounceConfig = {\n wait,\n maxWait,\n leading,\n trailing,\n flushOnExit,\n useRAF,\n debounceOnServer,\n };\n const debounced: DebouncedState<T> = function (\n this: unknown,\n ...args: Parameters<T>\n ) {\n return debounce(stateRef.current, config, this, args);\n };\n debounced.cancel = () => cancel(stateRef.current, config);\n debounced.isPending = () => !!stateRef.current.timerId;\n debounced.flush = () => flush(stateRef.current, config);\n return debounced;\n }, [wait, maxWait, leading, trailing, flushOnExit, useRAF, debounceOnServer]);\n\n useLayoutEffect(() => {\n stateRef.current.func = func;\n stateRef.current.debounced = debounced;\n });\n\n React.useEffect(() => {\n const state = stateRef.current;\n state.mounted = true;\n return () => {\n if (flushOnExit) {\n state.debounced?.flush();\n }\n if (state.visibilityListener) {\n globalThis.document?.removeEventListener?.(\n \"visibilitychange\",\n state.visibilityListener,\n );\n state.visibilityListener = null;\n }\n state.mounted = false;\n };\n }, [flushOnExit]);\n\n return debounced;\n}\n\n/**\n * Mutable timer state for a hook instance. It outlives any single debounced\n * function, so changing options doesn't drop pending invocations.\n */\ninterface DebounceState<T extends (...args: any) => ReturnType<T>> {\n func: T;\n lastCallTime: number | null;\n lastInvokeTime: number;\n timerId: number | null;\n lastArgs: Parameters<T> | null;\n lastThis: unknown;\n result: ReturnType<T> | undefined;\n mounted: boolean;\n visibilityListener: VoidFunction | null;\n debounced: DebouncedState<T> | undefined;\n}\n\ninterface DebounceConfig {\n wait: number;\n maxWait: number | null;\n leading: boolean;\n trailing: boolean;\n flushOnExit: boolean;\n useRAF: boolean;\n debounceOnServer: boolean;\n}\n\nfunction invokeFunc<T extends (...args: any) => ReturnType<T>>(\n state: DebounceState<T>,\n time: number,\n) {\n const args = state.lastArgs;\n const thisArg = state.lastThis;\n state.lastArgs = state.lastThis = null;\n state.lastInvokeTime = time;\n\n return (state.result = state.func.apply(thisArg, args || []));\n}\n\nfunction startTimer<T extends (...args: any) => ReturnType<T>>(\n state: DebounceState<T>,\n config: DebounceConfig,\n wait: number,\n) {\n const onTimer = () => timerExpired(state, config);\n if (config.useRAF) {\n cancelAnimationFrame(state.timerId!);\n }\n state.timerId = config.useRAF\n ? requestAnimationFrame(onTimer)\n : (setTimeout(onTimer, wait) as unknown as number);\n}\n\nfunction shouldInvoke<T extends (...args: any) => ReturnType<T>>(\n state: DebounceState<T>,\n { wait, maxWait }: DebounceConfig,\n time: number,\n) {\n if (!state.mounted) return false;\n\n const timeSinceLastCall = time - (state.lastCallTime || 0);\n const timeSinceLastInvoke = time - state.lastInvokeTime;\n\n // Either this is the first call, activity has stopped and we're at the\n // trailing edge, the system time has gone backwards and we're treating\n // it as the trailing edge, or we've hit the `maxWait` limit.\n return (\n !state.lastCallTime ||\n timeSinceLastCall >= wait ||\n timeSinceLastCall < 0 ||\n (maxWait !== null && timeSinceLastInvoke >= maxWait)\n );\n}\n\nfunction trailingEdge<T extends (...args: any) => ReturnType<T>>(\n state: DebounceState<T>,\n config: DebounceConfig,\n time: number,\n) {\n state.timerId = null;\n\n // Only invoke if we have `lastArgs` which means `func` has been\n // debounced at least once.\n if (config.trailing && state.lastArgs) {\n return invokeFunc(state, time);\n }\n\n state.lastArgs = state.lastThis = null;\n return state.result;\n}\n\nfunction timerExpired<T extends (...args: any) => ReturnType<T>>(\n state: DebounceState<T>,\n config: DebounceConfig,\n) {\n const time = Date.now();\n\n if (shouldInvoke(state, config, time)) {\n trailingEdge(state, config, time);\n return;\n }\n // https://github.com/xnimorz/use-debounce/issues/97\n if (!state.mounted) {\n return;\n }\n // Remaining wait calculation\n const timeSinceLastCall = time - (state.lastCallTime || 0);\n const timeSinceLastInvoke = time - state.lastInvokeTime;\n const timeWaiting = config.wait - timeSinceLastCall;\n const remainingWait =\n config.maxWait !== null\n ? Math.min(timeWaiting, config.maxWait - timeSinceLastInvoke)\n : timeWaiting;\n\n // Restart the timer\n startTimer(state, config, remainingWait);\n}\n\nfunction debounce<T extends (...args: any) => ReturnType<T>>(\n state: DebounceState<T>,\n config: DebounceConfig,\n thisArg: unknown,\n args: Parameters<T>,\n): ReturnType<T> | undefined {\n if (!canUseDOM && !config.debounceOnServer) {\n return undefined;\n }\n\n const time = Date.now();\n const isInvoking = shouldInvoke(state, config, time);\n\n state.lastArgs = args;\n state.lastThis = thisArg;\n state.lastCallTime = time;\n\n if (config.flushOnExit && !state.visibilityListener) {\n state.visibilityListener = () => {\n if (globalThis.document?.visibilityState === \"hidden\") {\n state.debounced?.flush();\n }\n };\n globalThis.document?.addEventListener?.(\n \"visibilitychange\",\n state.visibilityListener,\n );\n }\n if (isInvoking) {\n if (!state.timerId && state.mounted) {\n // Reset any `maxWait` timer.\n state.lastInvokeTime = time;\n // Start the timer for the trailing edge.\n startTimer(state, config, config.wait);\n // Invoke the leading edge.\n return config.leading ? invokeFunc(state, time) : state.result;\n }\n if (config.maxWait !== null) {\n // Handle invocations in a tight loop.\n startTimer(state, config, config.wait);\n return invokeFunc(state, time);\n }\n }\n if (!state.timerId) {\n startTimer(state, config, config.wait);\n }\n return state.result;\n}\n\nfunction cancel<T extends (...args: any) => ReturnType<T>>(\n state: DebounceState<T>,\n config: DebounceConfig,\n) {\n if (state.timerId) {\n if (config.useRAF) {\n cancelAnimationFrame(state.timerId);\n } else {\n clearTimeout(state.timerId);\n }\n }\n state.lastInvokeTime = 0;\n state.lastArgs = state.lastCallTime = state.lastThis = state.timerId = null;\n}\n\nfunction flush<T extends (...args: any) => ReturnType<T>>(\n state: DebounceState<T>,\n config: DebounceConfig,\n) {\n return !state.timerId\n ? state.result\n : trailingEdge(state, config, Date.now());\n}\n\ninterface ControlFunctions<ReturnT> {\n /**\n * Cancel pending function invocations\n */\n cancel: () => void;\n /**\n * Immediately invoke pending function invocations\n */\n flush: () => ReturnT | undefined;\n /**\n * Returns `true` if there are any pending function invocations\n */\n isPending: () => boolean;\n}\n\n/**\n * Subsequent calls to the debounced function return the result of the last func invocation.\n * Note, that if there are no previous invocations you will get undefined. You should check it in your code properly.\n */\ninterface DebouncedState<\n T extends (...args: any) => ReturnType<T>,\n> extends ControlFunctions<ReturnType<T>> {\n (...args: Parameters<T>): ReturnType<T> | undefined;\n}\n\nexport { useDebouncedCallback };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+GA,SAAS,qBACP,MACA,UAAmB,CAAC,GACD;CACnB,MAAM,EACJ,OAAO,GACP,UAAU,OACV,WAAW,MACX,SAAS,eACT,mBAAmB,UACjB;CAEJ,MAAM,SAAS,QAAQ,SAAS,UAAaA,kBAAAA;CAC7C,MAAM,cAAc,CAAC,CAAC,QAAQ,eAAe;CAC7C,MAAM,UACJ,kBAAkB,SAAY,OAAO,KAAK,IAAI,iBAAiB,GAAG,IAAI;CAExE,MAAM,WAAWC,MAAM,OAAyB;EAC9C;EACA,cAAc;EACd,gBAAgB;EAChB,SAAS;EACT,UAAU;EACV,UAAU;EACV,QAAQ;EACR,SAAS;EACT,oBAAoB;EACpB,WAAW;CACb,CAAC;CAED,MAAM,YAAYA,MAAM,cAAc;EACpC,MAAM,SAAyB;GAC7B;GACA;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AY,MAAM;GAE3B,WAAW,OAAO,QAAQ,OAAO,IAAI;GACrC,OAAO,WAAW,OAAO,IAAI;EAC/B;CACF;CACA,IAAI,CAAC,MAAM,SACT,WAAW,OAAO,QAAQ,OAAO,IAAI;CAEvC,OAAO,MAAM;AACf;AAEA,SAAS,OACP,OACA,QACA;CACA,IAAI,MAAM,SAAS;EACjB,IAAI,OAAO,QACT,qBAAqB,MAAM,OAAO;OAElC,aAAa,MAAM,OAAO;CAE9B;CACA,MAAM,iBAAiB;CACvB,MAAM,WAAW,MAAM,eAAe,MAAM,WAAW,MAAM,UAAU;AACzE;AAEA,SAAS,MACP,OACA,QACA;CACA,OAAO,CAAC,MAAM,UACV,MAAM,SACN,aAAa,OAAO,QAAQ,KAAK,IAAI,CAAC;AAC5C"}
|
|
@@ -1,4 +1,49 @@
|
|
|
1
1
|
//#region src/lib/use-debounce.d.ts
|
|
2
|
+
interface Options {
|
|
3
|
+
/**
|
|
4
|
+
* The number of milliseconds to delay. if omitted, invocation is deferred to
|
|
5
|
+
* the next animation frame (or the next tick where that's unavailable).
|
|
6
|
+
*/
|
|
7
|
+
wait?: number;
|
|
8
|
+
/**
|
|
9
|
+
* Controls if the function should be invoked on the leading edge of the
|
|
10
|
+
* timeout.
|
|
11
|
+
* @default false
|
|
12
|
+
*/
|
|
13
|
+
leading?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Controls if the function should be invoked on the trailing edge of the
|
|
16
|
+
* timeout.
|
|
17
|
+
* @default true
|
|
18
|
+
*/
|
|
19
|
+
trailing?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Controls if the function should be invoked when the React component
|
|
22
|
+
* unmounts or the page is closed. This is usually desirable whenever `func`
|
|
23
|
+
* has persistent side-effects such as persists data.
|
|
24
|
+
*
|
|
25
|
+
* NOTE: If the callback calls `fetch()`, you usually also want to specify the
|
|
26
|
+
* `keepalive=true` option for `fetch()` so it can finish in the background
|
|
27
|
+
* after the page is closed.
|
|
28
|
+
*
|
|
29
|
+
* This option has no effect if `trailing == false`.
|
|
30
|
+
*
|
|
31
|
+
* @default false
|
|
32
|
+
*/
|
|
33
|
+
flushOnExit?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* The maximum time the given function is allowed to be delayed before it's
|
|
36
|
+
* invoked. Pass `null` and the maximum wait time is equal to the `wait` time.
|
|
37
|
+
*/
|
|
38
|
+
maxWait?: number | null;
|
|
39
|
+
/**
|
|
40
|
+
* If the setting is set to true, all debouncing and timers will happen on the
|
|
41
|
+
* server side as well.
|
|
42
|
+
*
|
|
43
|
+
* @default false
|
|
44
|
+
*/
|
|
45
|
+
debounceOnServer?: boolean;
|
|
46
|
+
}
|
|
2
47
|
/**
|
|
3
48
|
* Creates a debounced function that delays invoking `func` until after `wait`
|
|
4
49
|
* milliseconds have elapsed since the last time the debounced function was
|
|
@@ -29,34 +74,25 @@
|
|
|
29
74
|
* article](https://css-tricks.com/debouncing-throttling-explained-examples/)
|
|
30
75
|
* for details over the differences between `debounce` and `throttle`.
|
|
31
76
|
*
|
|
32
|
-
* @
|
|
33
|
-
* @param
|
|
34
|
-
* @
|
|
35
|
-
* `requestAnimationFrame` is used (if available, otherwise it will be
|
|
36
|
-
* setTimeout(...,0)).
|
|
37
|
-
* @param {Object} [options={}] The options object. Controls if `func` should be
|
|
38
|
-
* invoked on the leading edge of the timeout.
|
|
39
|
-
* @param {boolean} [options.leading=false] The maximum time `func` is allowed
|
|
40
|
-
* to be delayed before it's invoked.
|
|
41
|
-
* @param {number} [options.maxWait] Controls if `func` should be invoked the
|
|
42
|
-
* trailing edge of the timeout.
|
|
43
|
-
* @param {boolean} [options.trailing=true]
|
|
44
|
-
* @returns {Function} Returns the new debounced function.
|
|
77
|
+
* @param func The function to debounce
|
|
78
|
+
* @param options The options object
|
|
79
|
+
* @returns Returns the new debounced function.
|
|
45
80
|
* @example
|
|
46
81
|
* ```tsx
|
|
47
82
|
* // Avoid costly calculations while the window size is in flux.
|
|
48
|
-
* const resizeHandler = useDebouncedCallback(calculateLayout, 150);
|
|
83
|
+
* const resizeHandler = useDebouncedCallback(calculateLayout, { wait: 150 });
|
|
49
84
|
* window.addEventListener('resize', resizeHandler)
|
|
50
85
|
*
|
|
51
86
|
* // Invoke `sendMail` when clicked, debouncing subsequent calls.
|
|
52
|
-
* const clickHandler = useDebouncedCallback(sendMail,
|
|
87
|
+
* const clickHandler = useDebouncedCallback(sendMail, {
|
|
88
|
+
* wait: 300,
|
|
53
89
|
* leading: true,
|
|
54
90
|
* trailing: false,
|
|
55
91
|
* })
|
|
56
92
|
* <button onClick={clickHandler}>click me</button>
|
|
57
93
|
*
|
|
58
94
|
* // Ensure `batchLog` is invoked once after 1 second of debounced calls.
|
|
59
|
-
* const debounced = useDebouncedCallback(batchLog, 250,
|
|
95
|
+
* const debounced = useDebouncedCallback(batchLog, { wait: 250, maxWait: 1000 })
|
|
60
96
|
* const source = new EventSource('/stream')
|
|
61
97
|
* source.addEventListener('message', debounced)
|
|
62
98
|
*
|
|
@@ -67,38 +103,7 @@
|
|
|
67
103
|
* const status = debounced.isPending() ? "Pending..." : "Ready"
|
|
68
104
|
* ```
|
|
69
105
|
*/
|
|
70
|
-
declare function useDebouncedCallback<T extends (...args: any) => ReturnType<T>>(
|
|
71
|
-
interface CallOptions {
|
|
72
|
-
/**
|
|
73
|
-
* Controls if the function should be invoked on the leading edge of the timeout.
|
|
74
|
-
*/
|
|
75
|
-
leading?: boolean;
|
|
76
|
-
/**
|
|
77
|
-
* Controls if the function should be invoked on the trailing edge of the timeout.
|
|
78
|
-
*/
|
|
79
|
-
trailing?: boolean;
|
|
80
|
-
/**
|
|
81
|
-
* Controls if the function should be invoked when the React component unmounts or
|
|
82
|
-
* the page is closed. This is usually desirable whenever `func` has persistent side-effects
|
|
83
|
-
* such as persists data.
|
|
84
|
-
*
|
|
85
|
-
* NOTE: If the callback calls `fetch()`, you usually also want to specify the `keepalive=true`
|
|
86
|
-
* option for `fetch()` so it can finish in the background after the page is closed.
|
|
87
|
-
*
|
|
88
|
-
* This option has no effect if `trailing == false`.
|
|
89
|
-
*/
|
|
90
|
-
flushOnExit?: boolean;
|
|
91
|
-
}
|
|
92
|
-
interface Options extends CallOptions {
|
|
93
|
-
/**
|
|
94
|
-
* The maximum time the given function is allowed to be delayed before it's invoked.
|
|
95
|
-
*/
|
|
96
|
-
maxWait?: number;
|
|
97
|
-
/**
|
|
98
|
-
* If the setting is set to true, all debouncing and timers will happen on the server side as well
|
|
99
|
-
*/
|
|
100
|
-
debounceOnServer?: boolean;
|
|
101
|
-
}
|
|
106
|
+
declare function useDebouncedCallback<T extends (...args: any) => ReturnType<T>>(func: T, options?: Options): DebouncedState<T>;
|
|
102
107
|
interface ControlFunctions<ReturnT> {
|
|
103
108
|
/**
|
|
104
109
|
* Cancel pending function invocations
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-debounce.d.cts","names":[],"sources":["../../../src/lib/use-debounce.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-debounce.d.cts","names":[],"sources":["../../../src/lib/use-debounce.ts"],"mappings":";UAMU;;;;;EAKR;;;;;;EAMA;;;;;;EAMA;;;;;;;;;;;;;;EAcA;;;;;EAKA;;;;;;;EAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA8DO,qBAAqB,cAAc,cAAc,WAAW,IACnE,MAAM,GACN,UAAS,UACR,eAAe;UA0QR,iBAAiB;;;;EAIzB;;;;EAIA,aAAa;;;;EAIb;;;;;;UAOQ,eACR,cAAc,cAAc,WAAW,YAC/B,iBAAiB,WAAW;MAChC,MAAM,WAAW,KAAK,WAAW"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
3
|
-
const
|
|
3
|
+
const require_api_client_graphql_query_keys = require("../api/client-graphql/query-keys.cjs");
|
|
4
|
+
require("../api/client-graphql/hooks.cjs");
|
|
4
5
|
let _tanstack_react_query = require("@tanstack/react-query");
|
|
5
6
|
let react = require("react");
|
|
6
7
|
react = require_runtime.__toESM(react, 1);
|
|
@@ -9,8 +10,7 @@ function useWidgetsInvalidatorImpl() {
|
|
|
9
10
|
const queryClient = (0, _tanstack_react_query.useQueryClient)();
|
|
10
11
|
return react.useCallback(async () => {
|
|
11
12
|
await queryClient.invalidateQueries({ queryKey: ["authToken"] });
|
|
12
|
-
|
|
13
|
-
return queryClient.invalidateQueries({ predicate: (query) => require_api_client_graphql_hooks.isClientGraphqlQueryKey(query.queryKey) });
|
|
13
|
+
return queryClient.invalidateQueries({ predicate: (query) => require_api_client_graphql_query_keys.isClientGraphqlQueryKey(query.queryKey) });
|
|
14
14
|
}, [queryClient]);
|
|
15
15
|
}
|
|
16
16
|
function useWidgetsInvalidator() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-widgets-invalidator.cjs","names":["useQueryClient","React","isClientGraphqlQueryKey"],"sources":["../../../src/lib/use-widgets-invalidator.ts"],"sourcesContent":["import { useQueryClient } from \"@tanstack/react-query\";\nimport * as React from \"react\";\nimport { isClientGraphqlQueryKey } from \"../api/client-graphql/hooks.js\";\n\nfunction useWidgetsInvalidatorImpl() {\n const queryClient = useQueryClient();\n\n return React.useCallback(async () => {\n await queryClient.invalidateQueries({ queryKey: [\"authToken\"] });\n
|
|
1
|
+
{"version":3,"file":"use-widgets-invalidator.cjs","names":["useQueryClient","React","isClientGraphqlQueryKey"],"sources":["../../../src/lib/use-widgets-invalidator.ts"],"sourcesContent":["import { useQueryClient } from \"@tanstack/react-query\";\nimport * as React from \"react\";\nimport { isClientGraphqlQueryKey } from \"../api/client-graphql/hooks.js\";\n\nfunction useWidgetsInvalidatorImpl() {\n const queryClient = useQueryClient();\n\n return React.useCallback(async () => {\n await queryClient.invalidateQueries({ queryKey: [\"authToken\"] });\n return queryClient.invalidateQueries({\n predicate: (query) => isClientGraphqlQueryKey(query.queryKey),\n });\n }, [queryClient]);\n}\n\nfunction useWidgetsInvalidator() {\n try {\n // oxlint-disable-next-line react-hooks/rules-of-hooks\n return useWidgetsInvalidatorImpl();\n } catch {\n throw Error(\n \"useWidgetsInvalidation must be used within the `WorkOsWidgets` provider component\",\n );\n }\n}\n\nexport { useWidgetsInvalidator };\n"],"mappings":";;;;;;;;AAIA,SAAS,4BAA4B;CACnC,MAAM,eAAA,GAAcA,sBAAAA,eAAAA,CAAe;CAEnC,OAAOC,MAAM,YAAY,YAAY;EACnC,MAAM,YAAY,kBAAkB,EAAE,UAAU,CAAC,WAAW,EAAE,CAAC;EAC/D,OAAO,YAAY,kBAAkB,EACnC,YAAY,UAAUC,sCAAAA,wBAAwB,MAAM,QAAQ,EAC9D,CAAC;CACH,GAAG,CAAC,WAAW,CAAC;AAClB;AAEA,SAAS,wBAAwB;CAC/B,IAAI;EAEF,OAAO,0BAA0B;CACnC,QAAQ;EACN,MAAM,MACJ,mFACF;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-widgets-invalidator.d.cts","names":[],"sources":["../../../src/lib/use-widgets-invalidator.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"use-widgets-invalidator.d.cts","names":[],"sources":["../../../src/lib/use-widgets-invalidator.ts"],"mappings":";iBAeS,+BAAqB"}
|
package/dist/cjs/lib/utils.cjs
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
//#region src/lib/utils.ts
|
|
3
3
|
const canUseDOM = !!(typeof window !== "undefined" && window.document && window.document.createElement);
|
|
4
|
-
function composeEventHandlers(originalEventHandler, ourEventHandler) {
|
|
5
|
-
return function handleEvent(event) {
|
|
6
|
-
originalEventHandler?.(event);
|
|
7
|
-
if (!event || !event.defaultPrevented) return ourEventHandler?.(event);
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
4
|
function getBestName({ firstName, lastName }) {
|
|
11
5
|
return [firstName, lastName].filter(Boolean).join(" ") || null;
|
|
12
6
|
}
|
|
@@ -55,7 +49,6 @@ function openUrlViaForm(href, options) {
|
|
|
55
49
|
}
|
|
56
50
|
//#endregion
|
|
57
51
|
exports.canUseDOM = canUseDOM;
|
|
58
|
-
exports.composeEventHandlers = composeEventHandlers;
|
|
59
52
|
exports.getBestName = getBestName;
|
|
60
53
|
exports.isErrorLike = isErrorLike;
|
|
61
54
|
exports.isObjectLike = isObjectLike;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.cjs","names":[],"sources":["../../../src/lib/utils.ts"],"sourcesContent":["export const canUseDOM = !!(\n typeof window !== \"undefined\" &&\n window.document &&\n window.document.createElement\n);\n\nexport function
|
|
1
|
+
{"version":3,"file":"utils.cjs","names":[],"sources":["../../../src/lib/utils.ts"],"sourcesContent":["export const canUseDOM = !!(\n typeof window !== \"undefined\" &&\n window.document &&\n window.document.createElement\n);\n\nexport function getBestName({\n firstName,\n lastName,\n}: {\n firstName?: string | null | undefined;\n lastName?: string | null | undefined;\n}) {\n return [firstName, lastName].filter(Boolean).join(\" \") || null;\n}\n\nexport function isObjectLike(value: unknown): value is object {\n return typeof value === \"object\" && value !== null;\n}\n\nexport function isErrorLike(value: unknown): value is Error {\n return (\n isObjectLike(value) &&\n \"message\" in value &&\n typeof value.message === \"string\" &&\n \"name\" in value &&\n typeof value.name === \"string\" &&\n (!(\"stack\" in value && value.stack) || typeof value.stack === \"string\")\n );\n}\n\nexport function isPromiseLike(value: unknown): value is PromiseLike<unknown> {\n return (\n isObjectLike(value) && \"then\" in value && typeof value.then === \"function\"\n );\n}\n\n/**\n * Opens links via form submission instead of URL query parameters. This keeps\n * sensitive parameters in the request body rather than the URL, reducing\n * exposure in server logs, browser history, and referrer headers.\n */\nexport function openUrlViaForm(\n href: string,\n options: { sensitiveParams?: string[]; target?: string; rel?: string },\n): void {\n let url: URL;\n try {\n url = new URL(href);\n } catch {\n throw new TypeError(\"Invalid URL\");\n }\n\n let { target, rel, sensitiveParams = [] } = options;\n\n // API tokens are always treated as sensitive parameters\n sensitiveParams = [...sensitiveParams, \"apiToken\"];\n\n const form = document.createElement(\"form\");\n form.method = \"POST\";\n if (target) {\n form.target = target;\n }\n\n if (!rel && target === \"_blank\") {\n rel = \"noopener noreferrer\";\n }\n\n if (rel) {\n form.rel = rel;\n }\n\n for (const paramName of sensitiveParams) {\n const paramValue = url.searchParams.get(paramName);\n if (paramValue === null) {\n continue;\n }\n\n url.searchParams.delete(paramName);\n const fieldInput = document.createElement(\"input\");\n fieldInput.type = \"hidden\";\n fieldInput.name = paramName;\n fieldInput.value = paramValue;\n form.appendChild(fieldInput);\n }\n\n const formAction = url.toString();\n form.action = formAction;\n document.body.appendChild(form);\n form.submit();\n document.body.removeChild(form);\n}\n"],"mappings":";;AAAA,MAAa,YAAY,CAAC,EACxB,OAAO,WAAW,eAClB,OAAO,YACP,OAAO,SAAS;AAGlB,SAAgB,YAAY,EAC1B,WACA,YAIC;CACD,OAAO,CAAC,WAAW,QAAQ,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,KAAK;AAC5D;AAEA,SAAgB,aAAa,OAAiC;CAC5D,OAAO,OAAO,UAAU,YAAY,UAAU;AAChD;AAEA,SAAgB,YAAY,OAAgC;CAC1D,OACE,aAAa,KAAK,KAClB,aAAa,SACb,OAAO,MAAM,YAAY,YACzB,UAAU,SACV,OAAO,MAAM,SAAS,aACrB,EAAE,WAAW,SAAS,MAAM,UAAU,OAAO,MAAM,UAAU;AAElE;AAEA,SAAgB,cAAc,OAA+C;CAC3E,OACE,aAAa,KAAK,KAAK,UAAU,SAAS,OAAO,MAAM,SAAS;AAEpE;;;;;;AAOA,SAAgB,eACd,MACA,SACM;CACN,IAAI;CACJ,IAAI;EACF,MAAM,IAAI,IAAI,IAAI;CACpB,QAAQ;EACN,MAAM,IAAI,UAAU,aAAa;CACnC;CAEA,IAAI,EAAE,QAAQ,KAAK,kBAAkB,CAAC,MAAM;CAG5C,kBAAkB,CAAC,GAAG,iBAAiB,UAAU;CAEjD,MAAM,OAAO,SAAS,cAAc,MAAM;CAC1C,KAAK,SAAS;CACd,IAAI,QACF,KAAK,SAAS;CAGhB,IAAI,CAAC,OAAO,WAAW,UACrB,MAAM;CAGR,IAAI,KACF,KAAK,MAAM;CAGb,KAAK,MAAM,aAAa,iBAAiB;EACvC,MAAM,aAAa,IAAI,aAAa,IAAI,SAAS;EACjD,IAAI,eAAe,MACjB;EAGF,IAAI,aAAa,OAAO,SAAS;EACjC,MAAM,aAAa,SAAS,cAAc,OAAO;EACjD,WAAW,OAAO;EAClB,WAAW,OAAO;EAClB,WAAW,QAAQ;EACnB,KAAK,YAAY,UAAU;CAC7B;CAGA,KAAK,SADc,IAAI,SACT;CACd,SAAS,KAAK,YAAY,IAAI;CAC9B,KAAK,OAAO;CACZ,SAAS,KAAK,YAAY,IAAI;AAChC"}
|
package/dist/cjs/lib/utils.d.cts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
//#region src/lib/utils.d.ts
|
|
2
2
|
export declare const canUseDOM: boolean;
|
|
3
|
-
export declare function composeEventHandlers<E extends {
|
|
4
|
-
defaultPrevented: boolean;
|
|
5
|
-
}>(originalEventHandler?: (event: E) => void, ourEventHandler?: (event: E) => void): (event: E) => void;
|
|
6
3
|
export declare function getBestName({ firstName, lastName }: {
|
|
7
4
|
firstName?: string | null | undefined;
|
|
8
5
|
lastName?: string | null | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.cts","names":[],"sources":["../../../src/lib/utils.ts"],"mappings":";qBAAa;wBAMG,
|
|
1
|
+
{"version":3,"file":"utils.d.cts","names":[],"sources":["../../../src/lib/utils.ts"],"mappings":";qBAAa;wBAMG,cACd,WACA;EAEA;EACA;;wBAKc,aAAa,iBAAiB;wBAI9B,YAAY,iBAAiB,SAAS;wBAWtC,cAAc,iBAAiB,SAAS;;;;;;wBAWxC,eACd,cACA;EAAW;EAA4B;EAAiB"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
|
|
4
4
|
const require_lib_widgets_context = require("./lib/widgets-context.cjs");
|
|
5
|
+
const require_api_client_graphql_query_keys = require("./api/client-graphql/query-keys.cjs");
|
|
5
6
|
const require_api_api_provider = require("./api/api-provider.cjs");
|
|
6
7
|
const require_api_client_graphql_hooks = require("./api/client-graphql/hooks.cjs");
|
|
7
8
|
const require_components_error_boundary = require("./components/error-boundary.cjs");
|
|
@@ -37,7 +38,7 @@ const emptyOrganizations = [];
|
|
|
37
38
|
const OrganizationSwitcherImpl = ({ variant, switchToOrganization, organizationLabel, truncateBehavior, children, ...domProps }) => {
|
|
38
39
|
const isApiReady = require_api_api_provider.useApiReady();
|
|
39
40
|
const organizationsQuery = require_api_client_graphql_hooks.useClientGraphqlQuery({
|
|
40
|
-
queryKey:
|
|
41
|
+
queryKey: require_api_client_graphql_query_keys.clientGraphqlQueryKey("ListUserOrganizations"),
|
|
41
42
|
queryFn: (sdk) => sdk.ListUserOrganizations(),
|
|
42
43
|
select: (data) => data.organizations,
|
|
43
44
|
placeholderData: _tanstack_react_query.keepPreviousData
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organization-switcher.client.cjs","names":["useWorkOsApiUrl","ErrorBoundary","OrganizationSwitcherError","ApiProvider","useApiReady","useClientGraphqlQuery","clientGraphqlQueryKey","keepPreviousData","OrganizationSwitcherLoading","OrganizationSwitcherPresentational"],"sources":["../../src/organization-switcher.client.tsx"],"sourcesContent":["\"use client\";\n\nimport { keepPreviousData } from \"@tanstack/react-query\";\nimport * as React from \"react\";\nimport type { AuthToken } from \"./api/api-provider.js\";\nimport { ApiProvider, useApiReady } from \"./api/api-provider.js\";\nimport {\n clientGraphqlQueryKey,\n useClientGraphqlQuery,\n} from \"./api/client-graphql/hooks.js\";\nimport { ErrorBoundary } from \"./components/error-boundary.js\";\nimport { useWorkOsApiUrl } from \"./lib/widgets-context.js\";\nimport type {\n OrganizationSwitcherErrorProps,\n OrganizationSwitcherLoadingProps,\n OrganizationSwitcherPassthroughProps,\n UserOrganization,\n} from \"./widgets/organization-switcher/organization-switcher.js\";\nimport {\n OrganizationSwitcherError,\n OrganizationSwitcherLoading,\n OrganizationSwitcher as OrganizationSwitcherPresentational,\n} from \"./widgets/organization-switcher/organization-switcher.js\";\n\ninterface OrganizationSwitcherProps extends OrganizationSwitcherPassthroughProps {\n authToken: AuthToken;\n}\n\nconst OrganizationSwitcher: React.FC<OrganizationSwitcherProps> = ({\n authToken,\n organizationLabel,\n switchToOrganization,\n truncateBehavior,\n variant,\n ...domProps\n}) => {\n const baseUrl = useWorkOsApiUrl();\n\n return (\n <ErrorBoundary\n fallbackRender={({ error }) => (\n <OrganizationSwitcherError\n error={error}\n variant={variant}\n {...domProps}\n />\n )}\n >\n <ApiProvider\n widgetType=\"organization-switcher\"\n authToken={authToken}\n baseUrl={baseUrl}\n >\n <OrganizationSwitcherImpl\n switchToOrganization={switchToOrganization}\n organizationLabel={organizationLabel}\n truncateBehavior={truncateBehavior}\n variant={variant}\n {...domProps}\n />\n </ApiProvider>\n </ErrorBoundary>\n );\n};\n\n// Constant reference to avoid unnecessary prop changes\nconst emptyOrganizations: UserOrganization[] = [];\n\ninterface OrganizationSwitcherImplProps extends OrganizationSwitcherPassthroughProps {}\n\nconst OrganizationSwitcherImpl: React.FC<OrganizationSwitcherImplProps> = ({\n variant,\n switchToOrganization,\n organizationLabel,\n truncateBehavior,\n children,\n ...domProps\n}) => {\n const isApiReady = useApiReady();\n const organizationsQuery = useClientGraphqlQuery({\n queryKey: clientGraphqlQueryKey(\"ListUserOrganizations\"),\n queryFn: (sdk) => sdk.ListUserOrganizations(),\n select: (data) => data.organizations,\n placeholderData: keepPreviousData,\n });\n\n const organizations = organizationsQuery.data ?? emptyOrganizations;\n\n if (organizationsQuery.isLoading || !isApiReady) {\n return <OrganizationSwitcherLoading variant={variant} {...domProps} />;\n }\n\n if (organizationsQuery.isError) {\n return (\n <OrganizationSwitcherError\n error={organizationsQuery.error}\n variant={variant}\n {...domProps}\n />\n );\n }\n\n return (\n <ErrorBoundary\n fallbackRender={({ error }) => (\n <OrganizationSwitcherError\n error={error}\n variant={variant}\n {...domProps}\n />\n )}\n >\n <OrganizationSwitcherPresentational\n organizations={organizations}\n switchToOrganization={switchToOrganization}\n variant={variant}\n organizationLabel={organizationLabel}\n truncateBehavior={truncateBehavior}\n {...domProps}\n >\n {children}\n </OrganizationSwitcherPresentational>\n </ErrorBoundary>\n );\n};\n\nexport type {\n OrganizationSwitcherProps,\n OrganizationSwitcherLoadingProps,\n OrganizationSwitcherErrorProps,\n};\nexport {\n OrganizationSwitcher,\n OrganizationSwitcherLoading,\n OrganizationSwitcherError,\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"organization-switcher.client.cjs","names":["useWorkOsApiUrl","ErrorBoundary","OrganizationSwitcherError","ApiProvider","useApiReady","useClientGraphqlQuery","clientGraphqlQueryKey","keepPreviousData","OrganizationSwitcherLoading","OrganizationSwitcherPresentational"],"sources":["../../src/organization-switcher.client.tsx"],"sourcesContent":["\"use client\";\n\nimport { keepPreviousData } from \"@tanstack/react-query\";\nimport * as React from \"react\";\nimport type { AuthToken } from \"./api/api-provider.js\";\nimport { ApiProvider, useApiReady } from \"./api/api-provider.js\";\nimport {\n clientGraphqlQueryKey,\n useClientGraphqlQuery,\n} from \"./api/client-graphql/hooks.js\";\nimport { ErrorBoundary } from \"./components/error-boundary.js\";\nimport { useWorkOsApiUrl } from \"./lib/widgets-context.js\";\nimport type {\n OrganizationSwitcherErrorProps,\n OrganizationSwitcherLoadingProps,\n OrganizationSwitcherPassthroughProps,\n UserOrganization,\n} from \"./widgets/organization-switcher/organization-switcher.js\";\nimport {\n OrganizationSwitcherError,\n OrganizationSwitcherLoading,\n OrganizationSwitcher as OrganizationSwitcherPresentational,\n} from \"./widgets/organization-switcher/organization-switcher.js\";\n\ninterface OrganizationSwitcherProps extends OrganizationSwitcherPassthroughProps {\n authToken: AuthToken;\n}\n\nconst OrganizationSwitcher: React.FC<OrganizationSwitcherProps> = ({\n authToken,\n organizationLabel,\n switchToOrganization,\n truncateBehavior,\n variant,\n ...domProps\n}) => {\n const baseUrl = useWorkOsApiUrl();\n\n return (\n <ErrorBoundary\n fallbackRender={({ error }) => (\n <OrganizationSwitcherError\n error={error}\n variant={variant}\n {...domProps}\n />\n )}\n >\n <ApiProvider\n widgetType=\"organization-switcher\"\n authToken={authToken}\n baseUrl={baseUrl}\n >\n <OrganizationSwitcherImpl\n switchToOrganization={switchToOrganization}\n organizationLabel={organizationLabel}\n truncateBehavior={truncateBehavior}\n variant={variant}\n {...domProps}\n />\n </ApiProvider>\n </ErrorBoundary>\n );\n};\n\n// Constant reference to avoid unnecessary prop changes\nconst emptyOrganizations: UserOrganization[] = [];\n\ninterface OrganizationSwitcherImplProps extends OrganizationSwitcherPassthroughProps {}\n\nconst OrganizationSwitcherImpl: React.FC<OrganizationSwitcherImplProps> = ({\n variant,\n switchToOrganization,\n organizationLabel,\n truncateBehavior,\n children,\n ...domProps\n}) => {\n const isApiReady = useApiReady();\n const organizationsQuery = useClientGraphqlQuery({\n queryKey: clientGraphqlQueryKey(\"ListUserOrganizations\"),\n queryFn: (sdk) => sdk.ListUserOrganizations(),\n select: (data) => data.organizations,\n placeholderData: keepPreviousData,\n });\n\n const organizations = organizationsQuery.data ?? emptyOrganizations;\n\n if (organizationsQuery.isLoading || !isApiReady) {\n return <OrganizationSwitcherLoading variant={variant} {...domProps} />;\n }\n\n if (organizationsQuery.isError) {\n return (\n <OrganizationSwitcherError\n error={organizationsQuery.error}\n variant={variant}\n {...domProps}\n />\n );\n }\n\n return (\n <ErrorBoundary\n fallbackRender={({ error }) => (\n <OrganizationSwitcherError\n error={error}\n variant={variant}\n {...domProps}\n />\n )}\n >\n <OrganizationSwitcherPresentational\n organizations={organizations}\n switchToOrganization={switchToOrganization}\n variant={variant}\n organizationLabel={organizationLabel}\n truncateBehavior={truncateBehavior}\n {...domProps}\n >\n {children}\n </OrganizationSwitcherPresentational>\n </ErrorBoundary>\n );\n};\n\nexport type {\n OrganizationSwitcherProps,\n OrganizationSwitcherLoadingProps,\n OrganizationSwitcherErrorProps,\n};\nexport {\n OrganizationSwitcher,\n OrganizationSwitcherLoading,\n OrganizationSwitcherError,\n};\n"],"mappings":";;;;;;;;;;;;;;AA4BA,MAAM,wBAA6D,EACjE,WACA,mBACA,sBACA,kBACA,SACA,GAAG,eACC;CACJ,MAAM,UAAUA,4BAAAA,gBAAgB;CAEhC,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,kCAAAA,eAAD;EACE,iBAAiB,EAAE,YACjB,iBAAA,GAAA,kBAAA,IAAA,CAACC,4DAAAA,2BAAD;GACS;GACE;GACT,GAAI;EACL,CAAA;EAGH,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACC,yBAAAA,aAAD;GACE,YAAW;GACA;GACF;GAET,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,0BAAD;IACwB;IACH;IACD;IACT;IACT,GAAI;GACL,CAAA;EACU,CAAA;CACA,CAAA;AAEnB;AAGA,MAAM,qBAAyC,CAAC;AAIhD,MAAM,4BAAqE,EACzE,SACA,sBACA,mBACA,kBACA,UACA,GAAG,eACC;CACJ,MAAM,aAAaC,yBAAAA,YAAY;CAC/B,MAAM,qBAAqBC,iCAAAA,sBAAsB;EAC/C,UAAUC,sCAAAA,sBAAsB,uBAAuB;EACvD,UAAU,QAAQ,IAAI,sBAAsB;EAC5C,SAAS,SAAS,KAAK;EACvB,iBAAiBC,sBAAAA;CACnB,CAAC;CAED,MAAM,gBAAgB,mBAAmB,QAAQ;CAEjD,IAAI,mBAAmB,aAAa,CAAC,YACnC,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACC,4DAAAA,6BAAD;EAAsC;EAAS,GAAI;CAAW,CAAA;CAGvE,IAAI,mBAAmB,SACrB,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACN,4DAAAA,2BAAD;EACE,OAAO,mBAAmB;EACjB;EACT,GAAI;CACL,CAAA;CAIL,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACD,kCAAAA,eAAD;EACE,iBAAiB,EAAE,YACjB,iBAAA,GAAA,kBAAA,IAAA,CAACC,4DAAAA,2BAAD;GACS;GACE;GACT,GAAI;EACL,CAAA;EAGH,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACO,4DAAAA,sBAAD;GACiB;GACO;GACb;GACU;GACD;GAClB,GAAI;GAEH;EACiC,CAAA;CACvB,CAAA;AAEnB"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const require_lib_widgets_context = require("./lib/widgets-context.cjs");
|
|
4
4
|
const require_lib_use_is_hydrated = require("./lib/use-is-hydrated.cjs");
|
|
5
|
+
const require_api_client_graphql_query_keys = require("./api/client-graphql/query-keys.cjs");
|
|
5
6
|
const require_api_api_provider = require("./api/api-provider.cjs");
|
|
6
7
|
const require_api_client_graphql_hooks = require("./api/client-graphql/hooks.cjs");
|
|
7
8
|
const require_components_error_boundary = require("./components/error-boundary.cjs");
|
|
@@ -54,7 +55,7 @@ const PipesAdminSectionsImpl = (props) => {
|
|
|
54
55
|
const integrations = require_widgets_pipes_admin_pipes_admin.useManageableIntegrations();
|
|
55
56
|
const shared = require_widgets_pipes_admin_pipes_admin.useOrganizationOwnedIntegrations();
|
|
56
57
|
const organizationName = require_api_client_graphql_hooks.useClientGraphqlQuery({
|
|
57
|
-
queryKey:
|
|
58
|
+
queryKey: require_api_client_graphql_query_keys.clientGraphqlQueryKey("ListUserOrganizations"),
|
|
58
59
|
queryFn: (sdk) => sdk.ListUserOrganizations()
|
|
59
60
|
}).data?.organizations.find((organization) => organization.isCurrent)?.name;
|
|
60
61
|
if (!isHydrated || integrations.isLoading) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_widgets_pipes_admin_pipes_admin.PipesAdminLoading, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipes-admin.client.cjs","names":["useWorkOsApiUrl","ErrorBoundary","PipesAdminError","ApiProvider","PipesCredentialUserIdContext","useIsHydrated","useManageableIntegrations","PipesAdminLoading","PipesAdminPresentational","useOrganizationOwnedIntegrations","useClientGraphqlQuery","clientGraphqlQueryKey","PipesAdminSectionsPresentational"],"sources":["../../src/pipes-admin.client.tsx"],"sourcesContent":["\"use client\";\nimport type { AuthToken } from \"./api/api-provider.js\";\nimport { ApiProvider } from \"./api/api-provider.js\";\nimport {\n clientGraphqlQueryKey,\n useClientGraphqlQuery,\n} from \"./api/client-graphql/hooks.js\";\nimport { ErrorBoundary } from \"./components/error-boundary.js\";\nimport { useIsHydrated } from \"./lib/use-is-hydrated.js\";\nimport type { WidgetRootDomProps } from \"./lib/widget-types.js\";\nimport { useWorkOsApiUrl } from \"./lib/widgets-context.js\";\nimport {\n PipesAdminError,\n PipesAdminLoading,\n PipesAdmin as PipesAdminPresentational,\n PipesAdminSections as PipesAdminSectionsPresentational,\n useManageableIntegrations,\n useOrganizationOwnedIntegrations,\n} from \"./widgets/pipes-admin/pipes-admin.js\";\nimport type {\n PipesAdminErrorProps,\n PipesAdminLoadingProps,\n} from \"./widgets/pipes-admin/pipes-admin.js\";\nimport { PipesCredentialUserIdContext } from \"./widgets/pipes/pipes-credential-attribution.js\";\n\ninterface PipesAdminProps extends WidgetRootDomProps {\n authToken: AuthToken;\n /**\n * The acting person's WorkOS user ID for shared API-key and client-credentials\n * writes with an application credential token. Required for those writes only.\n * User-backed sessions use the authenticated user; a different ID is rejected.\n * This prop is not rendered and does not grant authorization. The API validates\n * identity and organization membership.\n */\n userId?: string;\n /**\n * Opt in to the sectioned administrator experience: the connections the\n * organization owns and shares with everyone (which the administrator can\n * configure, connect, reauthorize and disconnect), followed by the provider\n * settings that govern what members may connect to on their own.\n *\n * The two sections are fetched separately, so provider settings render as\n * soon as they resolve regardless of the shared section.\n *\n * Defaults to `false`, which renders the single unsectioned provider\n * settings list and never requests organization-owned connections.\n */\n enableSharedConnections?: boolean;\n}\n\nconst PipesAdmin: React.FC<PipesAdminProps> = ({\n authToken,\n userId,\n enableSharedConnections,\n ...domProps\n}) => {\n const baseUrl = useWorkOsApiUrl();\n\n return (\n <ErrorBoundary\n fallbackRender={({ error }) => (\n <PipesAdminError {...domProps} error={error} />\n )}\n >\n <ApiProvider\n widgetType=\"pipes-admin\"\n authToken={authToken}\n baseUrl={baseUrl}\n >\n <PipesCredentialUserIdContext.Provider value={userId}>\n <PipesAdminImpl\n enableSharedConnections={enableSharedConnections}\n {...domProps}\n />\n </PipesCredentialUserIdContext.Provider>\n </ApiProvider>\n </ErrorBoundary>\n );\n};\n\ninterface PipesAdminImplProps extends Omit<\n PipesAdminProps,\n \"authToken\" | \"userId\"\n> {}\n\n// The two experiences are separate components so the opt-out path mounts no\n// organization-owned hook at all, and therefore issues exactly the requests it\n// always has.\nconst PipesAdminImpl: React.FC<PipesAdminImplProps> = ({\n enableSharedConnections,\n ...props\n}) => {\n return enableSharedConnections ? (\n <PipesAdminSectionsImpl {...props} />\n ) : (\n <PipesAdminProviderSettingsImpl {...props} />\n );\n};\n\ninterface PipesAdminProviderSettingsImplProps extends Omit<\n PipesAdminImplProps,\n \"enableSharedConnections\"\n> {}\n\nconst PipesAdminProviderSettingsImpl: React.FC<\n PipesAdminProviderSettingsImplProps\n> = (props) => {\n const isHydrated = useIsHydrated();\n const integrations = useManageableIntegrations();\n\n if (!isHydrated || integrations.isLoading) {\n return <PipesAdminLoading count={6} {...props} />;\n }\n\n if (integrations.isError) {\n return <PipesAdminError error={integrations.error} {...props} />;\n }\n\n return (\n <PipesAdminPresentational integrations={integrations.data} {...props} />\n );\n};\n\ninterface PipesAdminSectionsImplProps extends Omit<\n PipesAdminImplProps,\n \"enableSharedConnections\"\n> {}\n\nconst PipesAdminSectionsImpl: React.FC<PipesAdminSectionsImplProps> = (\n props,\n) => {\n const isHydrated = useIsHydrated();\n const integrations = useManageableIntegrations();\n // Both sections have their own cache entry and resolve independently:\n // provider settings render as soon as they arrive, and a slow or failing\n // organization request only affects the shared section.\n const shared = useOrganizationOwnedIntegrations();\n const organizations = useClientGraphqlQuery({\n queryKey: clientGraphqlQueryKey(\"ListUserOrganizations\"),\n queryFn: (sdk) => sdk.ListUserOrganizations(),\n });\n const organizationName = organizations.data?.organizations.find(\n (organization) => organization.isCurrent,\n )?.name;\n\n if (!isHydrated || integrations.isLoading) {\n return <PipesAdminLoading count={6} {...props} />;\n }\n\n if (integrations.isError) {\n return <PipesAdminError error={integrations.error} {...props} />;\n }\n\n return (\n <PipesAdminSectionsPresentational\n integrations={integrations.data}\n sharedIntegrations={shared.data}\n isSharedLoading={shared.isLoading}\n organizationName={organizationName}\n {...props}\n />\n );\n};\n\nexport type { PipesAdminProps, PipesAdminLoadingProps, PipesAdminErrorProps };\nexport { PipesAdmin, PipesAdminLoading, PipesAdminError };\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"pipes-admin.client.cjs","names":["useWorkOsApiUrl","ErrorBoundary","PipesAdminError","ApiProvider","PipesCredentialUserIdContext","useIsHydrated","useManageableIntegrations","PipesAdminLoading","PipesAdminPresentational","useOrganizationOwnedIntegrations","useClientGraphqlQuery","clientGraphqlQueryKey","PipesAdminSectionsPresentational"],"sources":["../../src/pipes-admin.client.tsx"],"sourcesContent":["\"use client\";\nimport type { AuthToken } from \"./api/api-provider.js\";\nimport { ApiProvider } from \"./api/api-provider.js\";\nimport {\n clientGraphqlQueryKey,\n useClientGraphqlQuery,\n} from \"./api/client-graphql/hooks.js\";\nimport { ErrorBoundary } from \"./components/error-boundary.js\";\nimport { useIsHydrated } from \"./lib/use-is-hydrated.js\";\nimport type { WidgetRootDomProps } from \"./lib/widget-types.js\";\nimport { useWorkOsApiUrl } from \"./lib/widgets-context.js\";\nimport {\n PipesAdminError,\n PipesAdminLoading,\n PipesAdmin as PipesAdminPresentational,\n PipesAdminSections as PipesAdminSectionsPresentational,\n useManageableIntegrations,\n useOrganizationOwnedIntegrations,\n} from \"./widgets/pipes-admin/pipes-admin.js\";\nimport type {\n PipesAdminErrorProps,\n PipesAdminLoadingProps,\n} from \"./widgets/pipes-admin/pipes-admin.js\";\nimport { PipesCredentialUserIdContext } from \"./widgets/pipes/pipes-credential-attribution.js\";\n\ninterface PipesAdminProps extends WidgetRootDomProps {\n authToken: AuthToken;\n /**\n * The acting person's WorkOS user ID for shared API-key and client-credentials\n * writes with an application credential token. Required for those writes only.\n * User-backed sessions use the authenticated user; a different ID is rejected.\n * This prop is not rendered and does not grant authorization. The API validates\n * identity and organization membership.\n */\n userId?: string;\n /**\n * Opt in to the sectioned administrator experience: the connections the\n * organization owns and shares with everyone (which the administrator can\n * configure, connect, reauthorize and disconnect), followed by the provider\n * settings that govern what members may connect to on their own.\n *\n * The two sections are fetched separately, so provider settings render as\n * soon as they resolve regardless of the shared section.\n *\n * Defaults to `false`, which renders the single unsectioned provider\n * settings list and never requests organization-owned connections.\n */\n enableSharedConnections?: boolean;\n}\n\nconst PipesAdmin: React.FC<PipesAdminProps> = ({\n authToken,\n userId,\n enableSharedConnections,\n ...domProps\n}) => {\n const baseUrl = useWorkOsApiUrl();\n\n return (\n <ErrorBoundary\n fallbackRender={({ error }) => (\n <PipesAdminError {...domProps} error={error} />\n )}\n >\n <ApiProvider\n widgetType=\"pipes-admin\"\n authToken={authToken}\n baseUrl={baseUrl}\n >\n <PipesCredentialUserIdContext.Provider value={userId}>\n <PipesAdminImpl\n enableSharedConnections={enableSharedConnections}\n {...domProps}\n />\n </PipesCredentialUserIdContext.Provider>\n </ApiProvider>\n </ErrorBoundary>\n );\n};\n\ninterface PipesAdminImplProps extends Omit<\n PipesAdminProps,\n \"authToken\" | \"userId\"\n> {}\n\n// The two experiences are separate components so the opt-out path mounts no\n// organization-owned hook at all, and therefore issues exactly the requests it\n// always has.\nconst PipesAdminImpl: React.FC<PipesAdminImplProps> = ({\n enableSharedConnections,\n ...props\n}) => {\n return enableSharedConnections ? (\n <PipesAdminSectionsImpl {...props} />\n ) : (\n <PipesAdminProviderSettingsImpl {...props} />\n );\n};\n\ninterface PipesAdminProviderSettingsImplProps extends Omit<\n PipesAdminImplProps,\n \"enableSharedConnections\"\n> {}\n\nconst PipesAdminProviderSettingsImpl: React.FC<\n PipesAdminProviderSettingsImplProps\n> = (props) => {\n const isHydrated = useIsHydrated();\n const integrations = useManageableIntegrations();\n\n if (!isHydrated || integrations.isLoading) {\n return <PipesAdminLoading count={6} {...props} />;\n }\n\n if (integrations.isError) {\n return <PipesAdminError error={integrations.error} {...props} />;\n }\n\n return (\n <PipesAdminPresentational integrations={integrations.data} {...props} />\n );\n};\n\ninterface PipesAdminSectionsImplProps extends Omit<\n PipesAdminImplProps,\n \"enableSharedConnections\"\n> {}\n\nconst PipesAdminSectionsImpl: React.FC<PipesAdminSectionsImplProps> = (\n props,\n) => {\n const isHydrated = useIsHydrated();\n const integrations = useManageableIntegrations();\n // Both sections have their own cache entry and resolve independently:\n // provider settings render as soon as they arrive, and a slow or failing\n // organization request only affects the shared section.\n const shared = useOrganizationOwnedIntegrations();\n const organizations = useClientGraphqlQuery({\n queryKey: clientGraphqlQueryKey(\"ListUserOrganizations\"),\n queryFn: (sdk) => sdk.ListUserOrganizations(),\n });\n const organizationName = organizations.data?.organizations.find(\n (organization) => organization.isCurrent,\n )?.name;\n\n if (!isHydrated || integrations.isLoading) {\n return <PipesAdminLoading count={6} {...props} />;\n }\n\n if (integrations.isError) {\n return <PipesAdminError error={integrations.error} {...props} />;\n }\n\n return (\n <PipesAdminSectionsPresentational\n integrations={integrations.data}\n sharedIntegrations={shared.data}\n isSharedLoading={shared.isLoading}\n organizationName={organizationName}\n {...props}\n />\n );\n};\n\nexport type { PipesAdminProps, PipesAdminLoadingProps,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D;EAA0B,cAAc,aAAa;EAAM,GAAI;CAAQ,CAAA;AAE3E;AAOA,MAAM,0BACJ,UACG;CACH,MAAM,aAAaH,4BAAAA,cAAc;CACjC,MAAM,eAAeC,wCAAAA,0BAA0B;CAI/C,MAAM,SAASG,wCAAAA,iCAAiC;CAKhD,MAAM,mBAJgBC,iCAAAA,sBAAsB;EAC1C,UAAUC,sCAAAA,sBAAsB,uBAAuB;EACvD,UAAU,QAAQ,IAAI,sBAAsB;CAC9C,CACyB,CAAA,CAAc,MAAM,cAAc,MACxD,iBAAiB,aAAa,SACjC,CAAC,EAAE;CAEH,IAAI,CAAC,cAAc,aAAa,WAC9B,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACJ,wCAAAA,mBAAD;EAAmB,OAAO;EAAG,GAAI;CAAQ,CAAA;CAGlD,IAAI,aAAa,SACf,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACL,wCAAAA,iBAAD;EAAiB,OAAO,aAAa;EAAO,GAAI;CAAQ,CAAA;CAGjE,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACU,wCAAAA,oBAAD;EACE,cAAc,aAAa;EAC3B,oBAAoB,OAAO;EAC3B,iBAAiB,OAAO;EACN;EAClB,GAAI;CACL,CAAA;AAEL"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const require_lib_widgets_context = require("./lib/widgets-context.cjs");
|
|
4
4
|
const require_lib_use_is_hydrated = require("./lib/use-is-hydrated.cjs");
|
|
5
|
+
const require_api_client_graphql_query_keys = require("./api/client-graphql/query-keys.cjs");
|
|
5
6
|
const require_api_api_provider = require("./api/api-provider.cjs");
|
|
6
7
|
const require_api_client_graphql_hooks = require("./api/client-graphql/hooks.cjs");
|
|
7
8
|
const require_components_error_boundary = require("./components/error-boundary.cjs");
|
|
@@ -90,7 +91,7 @@ const PipesSectionsImpl = (props) => {
|
|
|
90
91
|
const integrations = require_lib_api_pipes.useMyDataIntegrations();
|
|
91
92
|
const shared = require_lib_api_pipes.useSharedDataConnections();
|
|
92
93
|
const organizationName = require_api_client_graphql_hooks.useClientGraphqlQuery({
|
|
93
|
-
queryKey:
|
|
94
|
+
queryKey: require_api_client_graphql_query_keys.clientGraphqlQueryKey("ListUserOrganizations"),
|
|
94
95
|
queryFn: (sdk) => sdk.ListUserOrganizations()
|
|
95
96
|
}).data?.organizations.find((organization) => organization.isCurrent)?.name;
|
|
96
97
|
if (!isHydrated || integrations.isLoading) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_widgets_pipes_pipes.PipesLoading, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipes.client.cjs","names":["useWorkOsApiUrl","ErrorBoundary","PipesError","ApiProvider","useIsHydrated","useMyDataIntegrations","PipesLoading","PipesPresentational","useSharedDataConnections","useClientGraphqlQuery","clientGraphqlQueryKey","PipesSectionsPresentational"],"sources":["../../src/pipes.client.tsx"],"sourcesContent":["\"use client\";\nimport type { AuthToken } from \"./api/api-provider.js\";\nimport { ApiProvider } from \"./api/api-provider.js\";\nimport {\n clientGraphqlQueryKey,\n useClientGraphqlQuery,\n} from \"./api/client-graphql/hooks.js\";\nimport { ErrorBoundary } from \"./components/error-boundary.js\";\nimport {\n useMyDataIntegrations,\n useSharedDataConnections,\n} from \"./lib/api/pipes.js\";\nimport type {\n DataIntegration,\n DataIntegrationWithConnections,\n SharedDataConnection,\n} from \"./lib/api/types.js\";\nimport { useIsHydrated } from \"./lib/use-is-hydrated.js\";\nimport type { WidgetRootDomProps } from \"./lib/widget-types.js\";\nimport { useWorkOsApiUrl } from \"./lib/widgets-context.js\";\nimport {\n PipesError,\n PipesLoading,\n Pipes as PipesPresentational,\n PipesSections as PipesSectionsPresentational,\n} from \"./widgets/pipes/pipes.js\";\nimport type {\n PipesErrorProps,\n PipesLoadingProps,\n} from \"./widgets/pipes/pipes.js\";\n\n/** An auth method a provider advertises (defaults to `oauth` when unset). */\ntype PipesAuthMethod = NonNullable<DataIntegration[\"authMethods\"]>[number];\n\n/**\n * Serializable criteria for narrowing which integrations render. All provided\n * criteria are ANDed; an absent criterion is ignored. Safe to pass from a\n * Server Component, since props cross the server/client boundary.\n */\ninterface PipesFilterCriteria {\n /** Render only integrations whose `slug` is in this list. */\n slugs?: string[];\n /** Render only integrations whose `integrationType` is in this list. */\n integrationTypes?: string[];\n /** Render only integrations that advertise at least one of these methods. */\n authMethods?: PipesAuthMethod[];\n}\n\n/**\n * Narrows which enabled integrations the widget renders. The widget still\n * fetches the full set of integrations the user's organization has enabled\n * (plus any the user is still connected to so they can disconnect); a filter\n * only controls which of those rows are shown, in either of two forms:\n *\n * - **Serializable criteria** (`{ slugs, integrationTypes, authMethods }`),\n * ANDed together. This is the form to use when `<Pipes>` is embedded in a\n * Server Component (the documented token-minting pattern), because props must\n * be serializable across the server/client boundary and plain objects survive\n * it. e.g. `filter={{ slugs: [\"google-drive\"] }}`.\n *\n * - **A predicate** `((integration) => boolean)` for arbitrary filtering by any\n * field on the integration (`authMethods`, `integrationType`,\n * `installation.state`, etc.). A function is **not serializable across the\n * server/client boundary**: the predicate must be defined inside client code\n * and must never be passed in from a Server Component. Concretely, a host\n * using the App Router server-component pattern that needs a predicate must\n * author its own `\"use client\"` wrapper that *owns* the predicate and\n * receives only serializable props (e.g. `authToken`) from the server page.\n *\n * Undefined renders every enabled integration (the default).\n */\ntype PipesFilter =\n | PipesFilterCriteria\n | ((integration: DataIntegration) => boolean);\n\n/** A row the widget renders when `enableSharedConnections` is on. */\ntype PipesConnection = DataIntegrationWithConnections | SharedDataConnection;\n\n/**\n * {@link PipesFilter} as `enableSharedConnections` widens it: the same two\n * forms, except they narrow both sections. The predicate also sees the\n * organization's shared rows, discriminated with `\"integrationType\" in\n * connection` — shared rows carry none of the provider metadata the member's\n * own rows do. Neither `ownership` nor `connected_accounts` discriminates\n * them: the member's own connections can be `\"organization\"` too, and both\n * payloads carry `connected_accounts` (of different element types). Criteria\n * narrow shared rows by `slugs` alone, for the same want of metadata.\n */\ntype PipesConnectionFilter =\n | PipesFilterCriteria\n | ((connection: PipesConnection) => boolean);\n\n/** The unsectioned widget, whose `filter` is what it always was. */\ninterface PipesPersonalProps extends WidgetRootDomProps {\n authToken: AuthToken;\n /**\n * Defaults to `false`, which renders the single unsectioned list of the\n * member's own connections and never requests shared connections.\n */\n enableSharedConnections?: false;\n /** Narrows the member's own connections: {@link PipesFilter}. */\n filter?: PipesFilter;\n}\n\n/**\n * The sectioned widget, whose `filter` also narrows the shared section and so\n * takes the widened predicate.\n */\ninterface PipesSectionsProps extends WidgetRootDomProps {\n authToken: AuthToken;\n /**\n * Opt in to the sectioned member experience: the connections the organization\n * owns and shares with everyone, followed by the member's own connections.\n *\n * Shared connections are read-only for members — they carry no\n * credential-management actions — and are fetched separately from the\n * member's own connections, so the personal section renders as soon as it\n * resolves regardless of the shared one.\n *\n * Typed `boolean` rather than `true` so a host can forward a runtime feature\n * flag: a predicate has to cope with shared rows whenever the flag can be on.\n */\n enableSharedConnections: boolean;\n /** Narrows both sections: {@link PipesConnectionFilter}. */\n filter?: PipesConnectionFilter;\n}\n\ntype PipesProps = PipesPersonalProps | PipesSectionsProps;\n\ntype PipesImplProps =\n | Omit<PipesPersonalProps, \"authToken\">\n | Omit<PipesSectionsProps, \"authToken\">;\n\n/**\n * Overloads rather than one props union, so that opting in widens the\n * predicate's parameter for that host alone while every other host's `filter`\n * stays exactly as it was. A union leaves `enableSharedConnections={false}`\n * satisfying both members — the opt-in one accepts every `boolean` — leaving an\n * inline predicate no single contextual type to draw on (`TS7006`). Overloads\n * are ordered instead: a literal `false` resolves to the personal signature,\n * and anything else, a runtime flag included, to the widened one.\n *\n * The last signature takes the whole union, so that a wrapper forwarding\n * `PipesProps` it hasn't narrowed (`<Pipes {...props} />`) still resolves, and\n * so that `React.ComponentProps<typeof Pipes>` — which reads the last\n * signature — describes the widget rather than only its opted-in half.\n */\ninterface PipesComponent {\n (props: PipesPersonalProps): React.ReactNode;\n (props: PipesSectionsProps): React.ReactNode;\n (props: PipesProps): React.ReactNode;\n}\n\nconst PipesRoot = ({ authToken, ...props }: PipesProps) => {\n const baseUrl = useWorkOsApiUrl();\n\n return (\n <ErrorBoundary\n fallbackRender={({ error }) => <PipesError {...props} error={error} />}\n >\n <ApiProvider widgetType=\"pipes\" authToken={authToken} baseUrl={baseUrl}>\n <PipesImpl {...props} />\n </ApiProvider>\n </ErrorBoundary>\n );\n};\n\n/**\n * Evaluates serializable {@link PipesFilterCriteria} against an integration.\n * Provided criteria are ANDed; an integration with no declared `authMethods`\n * is treated as `oauth` (matching the widget's connect-method defaults).\n */\nfunction matchesPipesFilterCriteria(\n integration: DataIntegration,\n criteria: PipesFilterCriteria,\n): boolean {\n if (criteria.slugs && !criteria.slugs.includes(integration.slug)) {\n return false;\n }\n if (\n criteria.integrationTypes &&\n !criteria.integrationTypes.includes(integration.integrationType)\n ) {\n return false;\n }\n if (criteria.authMethods) {\n const methods = integration.authMethods ?? [\"oauth\"];\n if (!criteria.authMethods.some((method) => methods.includes(method))) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * Narrows shared connections. Criteria match them on `slugs` alone, since their\n * payload carries none of the provider metadata the other criteria read.\n */\nfunction applySharedPipesFilter(\n connections: SharedDataConnection[],\n filter: PipesConnectionFilter | undefined,\n): SharedDataConnection[] {\n if (!filter) {\n return connections;\n }\n\n if (typeof filter === \"function\") {\n return connections.filter(filter);\n }\n\n const { slugs } = filter;\n\n return slugs\n ? connections.filter((connection) => slugs.includes(connection.slug))\n : connections;\n}\n\n/** Applies a {@link PipesFilter} in either of its forms. */\nfunction applyPipesFilter<T extends DataIntegrationWithConnections>(\n integrations: T[],\n filter: PipesFilter | PipesConnectionFilter | undefined,\n): T[] {\n if (!filter) {\n return integrations;\n }\n\n return typeof filter === \"function\"\n ? integrations.filter((integration) => filter(integration))\n : integrations.filter((integration) =>\n matchesPipesFilterCriteria(integration, filter),\n );\n}\n\ninterface PipesSectionsImplProps extends WidgetRootDomProps {\n filter?: PipesConnectionFilter;\n}\n\n// The two experiences are separate components so the opt-out path mounts no\n// shared-connections hook at all, and therefore issues exactly the requests it\n// always has.\nconst PipesImpl: React.FC<PipesImplProps> = (props) => {\n if (props.enableSharedConnections) {\n const { enableSharedConnections, ...sectionsProps } = props;\n return <PipesSectionsImpl {...sectionsProps} />;\n }\n\n const { enableSharedConnections, ...personalProps } = props;\n return <PipesPersonalImpl {...personalProps} />;\n};\n\ninterface PipesPersonalImplProps extends WidgetRootDomProps {\n filter?: PipesFilter | PipesConnectionFilter;\n}\n\nconst PipesPersonalImpl: React.FC<PipesPersonalImplProps> = (props) => {\n const isHydrated = useIsHydrated();\n const integrations = useMyDataIntegrations();\n\n if (!isHydrated || integrations.isLoading) {\n return <PipesLoading count={6} {...props} />;\n }\n\n if (integrations.isError) {\n return <PipesError error={integrations.error} {...props} />;\n }\n\n if (integrations.isSuccess) {\n const visible = applyPipesFilter(integrations.data, props.filter);\n\n return (\n <PipesPresentational\n integrations={visible}\n hasUnfilteredIntegrations={integrations.data.length > 0}\n {...props}\n />\n );\n }\n\n return <PipesError error={integrations.error} {...props} />;\n};\n\nconst PipesSectionsImpl: React.FC<PipesSectionsImplProps> = (props) => {\n const isHydrated = useIsHydrated();\n const integrations = useMyDataIntegrations();\n // Both sections have their own cache entry and resolve independently: the\n // member's own connections render as soon as they arrive, and a slow or\n // failing shared request only affects the shared section.\n const shared = useSharedDataConnections();\n const organizations = useClientGraphqlQuery({\n queryKey: clientGraphqlQueryKey(\"ListUserOrganizations\"),\n queryFn: (sdk) => sdk.ListUserOrganizations(),\n });\n const organizationName = organizations.data?.organizations.find(\n (organization) => organization.isCurrent,\n )?.name;\n\n if (!isHydrated || integrations.isLoading) {\n return <PipesLoading count={6} {...props} />;\n }\n\n if (integrations.isError || !integrations.isSuccess) {\n return <PipesError error={integrations.error} {...props} />;\n }\n\n const visible = applyPipesFilter(integrations.data, props.filter);\n\n return (\n <PipesSectionsPresentational\n integrations={visible}\n hasUnfilteredIntegrations={integrations.data.length > 0}\n sharedConnections={applySharedPipesFilter(shared.data, props.filter)}\n hasUnfilteredSharedConnections={shared.data.length > 0}\n // A failed attempt drops the section rather than leaving skeletons up\n // for the whole retry sequence.\n isSharedLoading={shared.isPending && shared.failureCount === 0}\n organizationName={organizationName}\n {...props}\n />\n );\n};\n\nconst Pipes: PipesComponent = PipesRoot;\n\nexport type {\n PipesProps,\n PipesConnection,\n PipesFilter,\n PipesFilterCriteria,\n PipesConnectionFilter,\n PipesAuthMethod,\n PipesLoadingProps,\n PipesErrorProps,\n};\nexport { Pipes, PipesLoading, PipesError };\n"],"mappings":";;;;;;;;;;;AAyJA,MAAM,aAAa,EAAE,WAAW,GAAG,YAAwB;CACzD,MAAM,UAAUA,4BAAAA,gBAAgB;CAEhC,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,kCAAAA,eAAD;EACE,iBAAiB,EAAE,YAAY,iBAAA,GAAA,kBAAA,IAAA,CAACC,4BAAAA,YAAD;GAAY,GAAI;GAAc;EAAQ,CAAA;EAErE,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACC,yBAAAA,aAAD;GAAa,YAAW;GAAmB;GAAoB;GAC7D,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,WAAD,EAAW,GAAI,MAAQ,CAAA;EACZ,CAAA;CACA,CAAA;AAEnB;;;;;;AAOA,SAAS,2BACP,aACA,UACS;CACT,IAAI,SAAS,SAAS,CAAC,SAAS,MAAM,SAAS,YAAY,IAAI,GAC7D,OAAO;CAET,IACE,SAAS,oBACT,CAAC,SAAS,iBAAiB,SAAS,YAAY,eAAe,GAE/D,OAAO;CAET,IAAI,SAAS,aAAa;EACxB,MAAM,UAAU,YAAY,eAAe,CAAC,OAAO;EACnD,IAAI,CAAC,SAAS,YAAY,MAAM,WAAW,QAAQ,SAAS,MAAM,CAAC,GACjE,OAAO;CAEX;CACA,OAAO;AACT;;;;;AAMA,SAAS,uBACP,aACA,Q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A,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACL,4BAAAA,YAAD;EAAY,OAAO,aAAa;EAAO,GAAI;CAAQ,CAAA;AAC5D;AAEA,MAAM,qBAAuD,UAAU;CACrE,MAAM,aAAaE,4BAAAA,cAAc;CACjC,MAAM,eAAeC,sBAAAA,sBAAsB;CAI3C,MAAM,SAASG,sBAAAA,yBAAyB;CAKxC,MAAM,mBAJgBC,iCAAAA,sBAAsB;EAC1C,UAAUC,iCAAAA,sBAAsB,uBAAuB;EACvD,UAAU,QAAQ,IAAI,sBAAsB;CAC9C,CACyB,CAAA,CAAc,MAAM,cAAc,MACxD,iBAAiB,aAAa,SACjC,CAAC,EAAE;CAEH,IAAI,CAAC,cAAc,aAAa,WAC9B,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACJ,4BAAAA,cAAD;EAAc,OAAO;EAAG,GAAI;CAAQ,CAAA;CAG7C,IAAI,aAAa,WAAW,CAAC,aAAa,WACxC,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACJ,4BAAAA,YAAD;EAAY,OAAO,aAAa;EAAO,GAAI;CAAQ,CAAA;CAG5D,MAAM,UAAU,iBAAiB,aAAa,MAAM,MAAM,MAAM;CAEhE,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACS,4BAAAA,eAAD;EACE,cAAc;EACd,2BAA2B,aAAa,KAAK,SAAS;EACtD,mBAAmB,uBAAuB,OAAO,MAAM,MAAM,MAAM;EACnE,gCAAgC,OAAO,KAAK,SAAS;EAGrD,iBAAiB,OAAO,aAAa,OAAO,iBAAiB;EAC3C;EAClB,GAAI;CACL,CAAA;AAEL;AAEA,MAAM,QAAwB"}
|
|
1
|
+
{"version":3,"file":"pipes.client.cjs","names":["useWorkOsApiUrl","ErrorBoundary","PipesError","ApiProvider","useIsHydrated","useMyDataIntegrations","PipesLoading","PipesPresentational","useSharedDataConnections","useClientGraphqlQuery","clientGraphqlQueryKey","PipesSectionsPresentational"],"sources":["../../src/pipes.client.tsx"],"sourcesContent":["\"use client\";\nimport type { AuthToken } from \"./api/api-provider.js\";\nimport { ApiProvider } from \"./api/api-provider.js\";\nimport {\n clientGraphqlQueryKey,\n useClientGraphqlQuery,\n} from \"./api/client-graphql/hooks.js\";\nimport { ErrorBoundary } from \"./components/error-boundary.js\";\nimport {\n useMyDataIntegrations,\n useSharedDataConnections,\n} from \"./lib/api/pipes.js\";\nimport type {\n DataIntegration,\n DataIntegrationWithConnections,\n SharedDataConnection,\n} from \"./lib/api/types.js\";\nimport { useIsHydrated } from \"./lib/use-is-hydrated.js\";\nimport type { WidgetRootDomProps } from \"./lib/widget-types.js\";\nimport { useWorkOsApiUrl } from \"./lib/widgets-context.js\";\nimport {\n PipesError,\n PipesLoading,\n Pipes as PipesPresentational,\n PipesSections as PipesSectionsPresentational,\n} from \"./widgets/pipes/pipes.js\";\nimport type {\n PipesErrorProps,\n PipesLoadingProps,\n} from \"./widgets/pipes/pipes.js\";\n\n/** An auth method a provider advertises (defaults to `oauth` when unset). */\ntype PipesAuthMethod = NonNullable<DataIntegration[\"authMethods\"]>[number];\n\n/**\n * Serializable criteria for narrowing which integrations render. All provided\n * criteria are ANDed; an absent criterion is ignored. Safe to pass from a\n * Server Component, since props cross the server/client boundary.\n */\ninterface PipesFilterCriteria {\n /** Render only integrations whose `slug` is in this list. */\n slugs?: string[];\n /** Render only integrations whose `integrationType` is in this list. */\n integrationTypes?: string[];\n /** Render only integrations that advertise at least one of these methods. */\n authMethods?: PipesAuthMethod[];\n}\n\n/**\n * Narrows which enabled integrations the widget renders. The widget still\n * fetches the full set of integrations the user's organization has enabled\n * (plus any the user is still connected to so they can disconnect); a filter\n * only controls which of those rows are shown, in either of two forms:\n *\n * - **Serializable criteria** (`{ slugs, integrationTypes, authMethods }`),\n * ANDed together. This is the form to use when `<Pipes>` is embedded in a\n * Server Component (the documented token-minting pattern), because props must\n * be serializable across the server/client boundary and plain objects survive\n * it. e.g. `filter={{ slugs: [\"google-drive\"] }}`.\n *\n * - **A predicate** `((integration) => boolean)` for arbitrary filtering by any\n * field on the integration (`authMethods`, `integrationType`,\n * `installation.state`, etc.). A function is **not serializable across the\n * server/client boundary**: the predicate must be defined inside client code\n * and must never be passed in from a Server Component. Concretely, a host\n * using the App Router server-component pattern that needs a predicate must\n * author its own `\"use client\"` wrapper that *owns* the predicate and\n * receives only serializable props (e.g. `authToken`) from the server page.\n *\n * Undefined renders every enabled integration (the default).\n */\ntype PipesFilter =\n | PipesFilterCriteria\n | ((integration: DataIntegration) => boolean);\n\n/** A row the widget renders when `enableSharedConnections` is on. */\ntype PipesConnection = DataIntegrationWithConnections | SharedDataConnection;\n\n/**\n * {@link PipesFilter} as `enableSharedConnections` widens it: the same two\n * forms, except they narrow both sections. The predicate also sees the\n * organization's shared rows, discriminated with `\"integrationType\" in\n * connection` — shared rows carry none of the provider metadata the member's\n * own rows do. Neither `ownership` nor `connected_accounts` discriminates\n * them: the member's own connections can be `\"organization\"` too, and both\n * payloads carry `connected_accounts` (of different element types). Criteria\n * narrow shared rows by `slugs` alone, for the same want of metadata.\n */\ntype PipesConnectionFilter =\n | PipesFilterCriteria\n | ((connection: PipesConnection) => boolean);\n\n/** The unsectioned widget, whose `filter` is what it always was. */\ninterface PipesPersonalProps extends WidgetRootDomProps {\n authToken: AuthToken;\n /**\n * Defaults to `false`, which renders the single unsectioned list of the\n * member's own connections and never requests shared connections.\n */\n enableSharedConnections?: false;\n /** Narrows the member's own connections: {@link PipesFilter}. */\n filter?: PipesFilter;\n}\n\n/**\n * The sectioned widget, whose `filter` also narrows the shared section and so\n * takes the widened predicate.\n */\ninterface PipesSectionsProps extends WidgetRootDomProps {\n authToken: AuthToken;\n /**\n * Opt in to the sectioned member experience: the connections the organization\n * owns and shares with everyone, followed by the member's own connections.\n *\n * Shared connections are read-only for members — they carry no\n * credential-management actions — and are fetched separately from the\n * member's own connections, so the personal section renders as soon as it\n * resolves regardless of the shared one.\n *\n * Typed `boolean` rather than `true` so a host can forward a runtime feature\n * flag: a predicate has to cope with shared rows whenever the flag can be on.\n */\n enableSharedConnections: boolean;\n /** Narrows both sections: {@link PipesConnectionFilter}. */\n filter?: PipesConnectionFilter;\n}\n\ntype PipesProps = PipesPersonalProps | PipesSectionsProps;\n\ntype PipesImplProps =\n | Omit<PipesPersonalProps, \"authToken\">\n | Omit<PipesSectionsProps, \"authToken\">;\n\n/**\n * Overloads rather than one props union, so that opting in widens the\n * predicate's parameter for that host alone while every other host's `filter`\n * stays exactly as it was. A union leaves `enableSharedConnections={false}`\n * satisfying both members — the opt-in one accepts every `boolean` — leaving an\n * inline predicate no single contextual type to draw on (`TS7006`). Overloads\n * are ordered instead: a literal `false` resolves to the personal signature,\n * and anything else, a runtime flag included, to the widened one.\n *\n * The last signature takes the whole union, so that a wrapper forwarding\n * `PipesProps` it hasn't narrowed (`<Pipes {...props} />`) still resolves, and\n * so that `React.ComponentProps<typeof Pipes>` — which reads the last\n * signature — describes the widget rather than only its opted-in half.\n */\ninterface PipesComponent {\n (props: PipesPersonalProps): React.ReactNode;\n (props: PipesSectionsProps): React.ReactNode;\n (props: PipesProps): React.ReactNode;\n}\n\nconst PipesRoot = ({ authToken, ...props }: PipesProps) => {\n const baseUrl = useWorkOsApiUrl();\n\n return (\n <ErrorBoundary\n fallbackRender={({ error }) => <PipesError {...props} error={error} />}\n >\n <ApiProvider widgetType=\"pipes\" authToken={authToken} baseUrl={baseUrl}>\n <PipesImpl {...props} />\n </ApiProvider>\n </ErrorBoundary>\n );\n};\n\n/**\n * Evaluates serializable {@link PipesFilterCriteria} against an integration.\n * Provided criteria are ANDed; an integration with no declared `authMethods`\n * is treated as `oauth` (matching the widget's connect-method defaults).\n */\nfunction matchesPipesFilterCriteria(\n integration: DataIntegration,\n criteria: PipesFilterCriteria,\n): boolean {\n if (criteria.slugs && !criteria.slugs.includes(integration.slug)) {\n return false;\n }\n if (\n criteria.integrationTypes &&\n !criteria.integrationTypes.includes(integration.integrationType)\n ) {\n return false;\n }\n if (criteria.authMethods) {\n const methods = integration.authMethods ?? [\"oauth\"];\n if (!criteria.authMethods.some((method) => methods.includes(method))) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * Narrows shared connections. Criteria match them on `slugs` alone, since their\n * payload carries none of the provider metadata the other criteria read.\n */\nfunction applySharedPipesFilter(\n connections: SharedDataConnection[],\n filter: PipesConnectionFilter | undefined,\n): SharedDataConnection[] {\n if (!filter) {\n return connections;\n }\n\n if (typeof filter === \"function\") {\n return connections.filter(filter);\n }\n\n const { slugs } = filter;\n\n return slugs\n ? connections.filter((connection) => slugs.includes(connection.slug))\n : connections;\n}\n\n/** Applies a {@link PipesFilter} in either of its forms. */\nfunction applyPipesFilter<T extends DataIntegrationWithConnections>(\n integrations: T[],\n filter: PipesFilter | PipesConnectionFilter | undefined,\n): T[] {\n if (!filter) {\n return integrations;\n }\n\n return typeof filter === \"function\"\n ? integrations.filter((integration) => filter(integration))\n : integrations.filter((integration) =>\n matchesPipesFilterCriteria(integration, filter),\n );\n}\n\ninterface PipesSectionsImplProps extends WidgetRootDomProps {\n filter?: PipesConnectionFilter;\n}\n\n// The two experiences are separate components so the opt-out path mounts no\n// shared-connections hook at all, and therefore issues exactly the requests it\n// always has.\nconst PipesImpl: React.FC<PipesImplProps> = (props) => {\n if (props.enableSharedConnections) {\n const { enableSharedConnections, ...sectionsProps } = props;\n return <PipesSectionsImpl {...sectionsProps} />;\n }\n\n const { enableSharedConnections, ...personalProps } = props;\n return <PipesPersonalImpl {...personalProps} />;\n};\n\ninterface PipesPersonalImplProps extends WidgetRootDomProps {\n filter?: PipesFilter | PipesConnectionFilter;\n}\n\nconst PipesPersonalImpl: React.FC<PipesPersonalImplProps> = (props) => {\n const isHydrated = useIsHydrated();\n const integrations = useMyDataIntegrations();\n\n if (!isHydrated || integrations.isLoading) {\n return <PipesLoading count={6} {...props} />;\n }\n\n if (integrations.isError) {\n return <PipesError error={integrations.error} {...props} />;\n }\n\n if (integrations.isSuccess) {\n const visible = applyPipesFilter(integrations.data, props.filter);\n\n return (\n <PipesPresentational\n integrations={visible}\n hasUnfilteredIntegrations={integrations.data.length > 0}\n {...props}\n />\n );\n }\n\n return <PipesError error={integrations.error} {...props} />;\n};\n\nconst PipesSectionsImpl: React.FC<PipesSectionsImplProps> = (props) => {\n const isHydrated = useIsHydrated();\n const integrations = useMyDataIntegrations();\n // Both sections have their own cache entry and resolve independently: the\n // member's own connections render as soon as they arrive, and a slow or\n // failing shared request only affects the shared section.\n const shared = useSharedDataConnections();\n const organizations = useClientGraphqlQuery({\n queryKey: clientGraphqlQueryKey(\"ListUserOrganizations\"),\n queryFn: (sdk) => sdk.ListUserOrganizations(),\n });\n const organizationName = organizations.data?.organizations.find(\n (organization) => organization.isCurrent,\n )?.name;\n\n if (!isHydrated || integrations.isLoading) {\n return <PipesLoading count={6} {...props} />;\n }\n\n if (integrations.isError || !integrations.isSuccess) {\n return <PipesError error={integrations.error} {...props} />;\n }\n\n const visible = applyPipesFilter(integrations.data, props.filter);\n\n return (\n <PipesSectionsPresentational\n integrations={visible}\n hasUnfilteredIntegrations={integrations.data.length > 0}\n sharedConnections={applySharedPipesFilter(shared.data, props.filter)}\n hasUnfilteredSharedConnections={shared.data.length > 0}\n // A failed attempt drops the section rather than leaving skeletons up\n // for the whole retry sequence.\n isSharedLoading={shared.isPending && shared.failureCount === 0}\n organizationName={organizationName}\n {...props}\n />\n );\n};\n\nconst Pipes: PipesComponent = PipesRoot;\n\nexport type {\n PipesProps,\n PipesConnection,\n PipesFilter,\n PipesFilterCriteria,\n PipesConnectionFilter,\n PipesAuthMethod,\n PipesLoadingProps,\n PipesErrorProps,\n};\nexport { Pipes, PipesLoading, PipesError };\n"],"mappings":";;;;;;;;;;;;AAyJA,MAAM,aAAa,EAAE,WAAW,GAAG,YAAwB;CACzD,MAAM,UAAUA,4BAAAA,gBAAgB;CAEhC,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,kCAAAA,eAAD;EACE,iBAAiB,EAAE,YAAY,iBAAA,GAAA,kBAAA,IAA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,GAAA,kBAAA,IAAA,CAACJ,4BAAAA,YAAD;EAAY,OAAO,aAAa;EAAO,GAAI;CAAQ,CAAA;CAG5D,MAAM,UAAU,iBAAiB,aAAa,MAAM,MAAM,MAAM;CAEhE,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACS,4BAAAA,eAAD;EACE,cAAc;EACd,2BAA2B,aAAa,KAAK,SAAS;EACtD,mBAAmB,uBAAuB,OAAO,MAAM,MAAM,MAAM;EACnE,gCAAgC,OAAO,KAAK,SAAS;EAGrD,iBAAiB,OAAO,aAAa,OAAO,iBAAiB;EAC3C;EAClB,GAAI;CACL,CAAA;AAEL;AAEA,MAAM,QAAwB"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
|
|
4
4
|
const require_lib_widgets_context = require("./lib/widgets-context.cjs");
|
|
5
|
+
const require_api_client_graphql_query_keys = require("./api/client-graphql/query-keys.cjs");
|
|
5
6
|
const require_api_api_provider = require("./api/api-provider.cjs");
|
|
6
7
|
const require_api_client_graphql_hooks = require("./api/client-graphql/hooks.cjs");
|
|
7
8
|
const require_components_error_boundary = require("./components/error-boundary.cjs");
|
|
@@ -30,7 +31,7 @@ const UserSecurityImpl = (props) => {
|
|
|
30
31
|
const isApiReady = require_api_api_provider.useApiReady();
|
|
31
32
|
const meQuery = require_lib_api_me.useMe();
|
|
32
33
|
const settingsQuery = require_api_client_graphql_hooks.useClientGraphqlQuery({
|
|
33
|
-
queryKey:
|
|
34
|
+
queryKey: require_api_client_graphql_query_keys.clientGraphqlQueryKey("AuthenticationSettings"),
|
|
34
35
|
queryFn: (sdk) => sdk.AuthenticationSettings(),
|
|
35
36
|
select: (data) => data.authenticationSettings
|
|
36
37
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-security.client.cjs","names":["useWorkOsApiUrl","ErrorBoundary","UserSecurityError","ApiProvider","useApiReady","useMe","useClientGraphqlQuery","clientGraphqlQueryKey","UserSecurityLoading","UserSecurityPresentational"],"sources":["../../src/user-security.client.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport type { AuthToken } from \"./api/api-provider.js\";\nimport { ApiProvider, useApiReady } from \"./api/api-provider.js\";\nimport {\n clientGraphqlQueryKey,\n useClientGraphqlQuery,\n} from \"./api/client-graphql/hooks.js\";\nimport { ErrorBoundary } from \"./components/error-boundary.js\";\nimport { useMe } from \"./lib/api/me.js\";\nimport type { WidgetRootDomProps } from \"./lib/widget-types.js\";\nimport { useWorkOsApiUrl } from \"./lib/widgets-context.js\";\nimport {\n UserSecurityError,\n UserSecurityLoading,\n UserSecurity as UserSecurityPresentational,\n} from \"./widgets/user-security/user-security.js\";\nimport type {\n UserSecurityErrorProps,\n UserSecurityLoadingProps,\n} from \"./widgets/user-security/user-security.js\";\n\ninterface UserSecurityProps extends WidgetRootDomProps {\n authToken: AuthToken;\n}\n\nconst UserSecurity: React.FC<UserSecurityProps> = ({\n authToken,\n ...domProps\n}) => {\n const baseUrl = useWorkOsApiUrl();\n\n return (\n <ErrorBoundary\n fallbackRender={({ error }) => (\n <UserSecurityError error={error} {...domProps} />\n )}\n >\n <ApiProvider\n widgetType=\"user-security\"\n authToken={authToken}\n baseUrl={baseUrl}\n >\n <UserSecurityImpl {...domProps} />\n </ApiProvider>\n </ErrorBoundary>\n );\n};\n\ninterface UserSecurityImplProps extends WidgetRootDomProps {}\n\nconst UserSecurityImpl: React.FC<UserSecurityImplProps> = (props) => {\n const isApiReady = useApiReady();\n const meQuery = useMe();\n const settingsQuery = useClientGraphqlQuery({\n queryKey: clientGraphqlQueryKey(\"AuthenticationSettings\"),\n queryFn: (sdk) => sdk.AuthenticationSettings(),\n select: (data) => data.authenticationSettings,\n });\n\n if (!isApiReady || meQuery.isLoading || settingsQuery.isLoading) {\n return <UserSecurityLoading {...props} />;\n }\n\n if (!meQuery.isSuccess || !settingsQuery.isSuccess) {\n return (\n <UserSecurityError\n error={meQuery.error ?? settingsQuery.error}\n {...props}\n />\n );\n }\n\n return (\n <ErrorBoundary\n fallbackRender={({ error }) => (\n <UserSecurityError error={error} {...props} />\n )}\n >\n <UserSecurityPresentational\n user={meQuery.data}\n settings={settingsQuery.data}\n {...props}\n />\n </ErrorBoundary>\n );\n};\n\nexport type {\n UserSecurityProps,\n UserSecurityLoadingProps,\n UserSecurityErrorProps,\n};\nexport { UserSecurity, UserSecurityLoading, UserSecurityError };\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"user-security.client.cjs","names":["useWorkOsApiUrl","ErrorBoundary","UserSecurityError","ApiProvider","useApiReady","useMe","useClientGraphqlQuery","clientGraphqlQueryKey","UserSecurityLoading","UserSecurityPresentational"],"sources":["../../src/user-security.client.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport type { AuthToken } from \"./api/api-provider.js\";\nimport { ApiProvider, useApiReady } from \"./api/api-provider.js\";\nimport {\n clientGraphqlQueryKey,\n useClientGraphqlQuery,\n} from \"./api/client-graphql/hooks.js\";\nimport { ErrorBoundary } from \"./components/error-boundary.js\";\nimport { useMe } from \"./lib/api/me.js\";\nimport type { WidgetRootDomProps } from \"./lib/widget-types.js\";\nimport { useWorkOsApiUrl } from \"./lib/widgets-context.js\";\nimport {\n UserSecurityError,\n UserSecurityLoading,\n UserSecurity as UserSecurityPresentational,\n} from \"./widgets/user-security/user-security.js\";\nimport type {\n UserSecurityErrorProps,\n UserSecurityLoadingProps,\n} from \"./widgets/user-security/user-security.js\";\n\ninterface UserSecurityProps extends WidgetRootDomProps {\n authToken: AuthToken;\n}\n\nconst UserSecurity: React.FC<UserSecurityProps> = ({\n authToken,\n ...domProps\n}) => {\n const baseUrl = useWorkOsApiUrl();\n\n return (\n <ErrorBoundary\n fallbackRender={({ error }) => (\n <UserSecurityError error={error} {...domProps} />\n )}\n >\n <ApiProvider\n widgetType=\"user-security\"\n authToken={authToken}\n baseUrl={baseUrl}\n >\n <UserSecurityImpl {...domProps} />\n </ApiProvider>\n </ErrorBoundary>\n );\n};\n\ninterface UserSecurityImplProps extends WidgetRootDomProps {}\n\nconst UserSecurityImpl: React.FC<UserSecurityImplProps> = (props) => {\n const isApiReady = useApiReady();\n const meQuery = useMe();\n const settingsQuery = useClientGraphqlQuery({\n queryKey: clientGraphqlQueryKey(\"AuthenticationSettings\"),\n queryFn: (sdk) => sdk.AuthenticationSettings(),\n select: (data) => data.authenticationSettings,\n });\n\n if (!isApiReady || meQuery.isLoading || settingsQuery.isLoading) {\n return <UserSecurityLoading {...props} />;\n }\n\n if (!meQuery.isSuccess || !settingsQuery.isSuccess) {\n return (\n <UserSecurityError\n error={meQuery.error ?? settingsQuery.error}\n {...props}\n />\n );\n }\n\n return (\n <ErrorBoundary\n fallbackRender={({ error }) => (\n <UserSecurityError error={error} {...props} />\n )}\n >\n <UserSecurityPresentational\n user={meQuery.data}\n settings={settingsQuery.data}\n {...props}\n />\n </ErrorBoundary>\n );\n};\n\nexport type {\n UserSecurityProps,\n UserSecurityLoadingProps,\n UserSecurityErrorProps,\n};\nexport { UserSecurity, UserSecurityLoading, UserSecurityError };\n"],"mappings":";;;;;;;;;;;;;;AA2BA,MAAM,gBAA6C,EACjD,WACA,GAAG,eACC;CACJ,MAAM,UAAUA,4BAAAA,gBAAgB;CAEhC,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,kCAAAA,eAAD;EACE,iBAAiB,EAAE,YACjB,iBAAA,GAAA,kBAAA,IAAA,CAACC,4CAAAA,mBAAD;GAA0B;GAAO,GAAI;EAAW,CAAA;EAGlD,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACC,yBAAAA,aAAD;GACE,YAAW;GACA;GACF;GAET,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,kBAAD,EAAkB,GAAI,SAAW,CAAA;EACtB,CAAA;CACA,CAAA;AAEnB;AAIA,MAAM,oBAAqD,UAAU;CACnE,MAAM,aAAaC,yBAAAA,YAAY;CAC/B,MAAM,UAAUC,mBAAAA,MAAM;CACtB,MAAM,gBAAgBC,iCAAAA,sBAAsB;EAC1C,UAAUC,sCAAAA,sBAAsB,wBAAwB;EACxD,UAAU,QAAQ,IAAI,uBAAuB;EAC7C,SAAS,SAAS,KAAK;CACzB,CAAC;CAED,IAAI,CAAC,cAAc,QAAQ,aAAa,cAAc,WACpD,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACC,4CAAAA,qBAAD,EAAqB,GAAI,MAAQ,CAAA;CAG1C,IAAI,CAAC,QAAQ,aAAa,CAAC,cAAc,WACvC,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACN,4CAAAA,mBAAD;EACE,OAAO,QAAQ,SAAS,cAAc;EACtC,GAAI;CACL,CAAA;CAIL,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACD,kCAAAA,eAAD;EACE,iBAAiB,EAAE,YACjB,iBAAA,GAAA,kBAAA,IAAA,CAACC,4CAAAA,mBAAD;GAA0B;GAAO,GAAI;EAAQ,CAAA;EAG/C,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACO,4CAAAA,cAAD;GACE,MAAM,QAAQ;GACd,UAAU,cAAc;GACxB,GAAI;EACL,CAAA;CACY,CAAA;AAEnB"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
|
|
4
4
|
const require_lib_widgets_context = require("./lib/widgets-context.cjs");
|
|
5
|
+
const require_api_client_graphql_query_keys = require("./api/client-graphql/query-keys.cjs");
|
|
5
6
|
const require_api_api_provider = require("./api/api-provider.cjs");
|
|
6
7
|
const require_api_client_graphql_hooks = require("./api/client-graphql/hooks.cjs");
|
|
7
8
|
const require_components_error_boundary = require("./components/error-boundary.cjs");
|
|
@@ -31,7 +32,7 @@ const UserSessions = ({ authToken, ...passthroughProps }) => {
|
|
|
31
32
|
const UserSessionsImpl = ({ currentSessionId, ...domProps }) => {
|
|
32
33
|
const isApiReady = require_api_api_provider.useApiReady();
|
|
33
34
|
const sessionsQuery = require_api_client_graphql_hooks.useClientGraphqlQuery({
|
|
34
|
-
queryKey:
|
|
35
|
+
queryKey: require_api_client_graphql_query_keys.clientGraphqlQueryKey("Sessions"),
|
|
35
36
|
queryFn: (sdk) => sdk.Sessions(),
|
|
36
37
|
select: (data) => data.sessions
|
|
37
38
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-sessions.client.cjs","names":["useWorkOsApiUrl","ErrorBoundary","UserSessionsError","ApiProvider","useApiReady","useClientGraphqlQuery","clientGraphqlQueryKey","UserSessionsLoading","UserSessionsPresentational"],"sources":["../../src/user-sessions.client.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { ApiProvider, useApiReady } from \"./api/api-provider.js\";\nimport {\n clientGraphqlQueryKey,\n useClientGraphqlQuery,\n} from \"./api/client-graphql/hooks.js\";\nimport { ErrorBoundary } from \"./components/error-boundary.js\";\nimport type { WidgetRootDomProps } from \"./lib/widget-types.js\";\nimport { useWorkOsApiUrl } from \"./lib/widgets-context.js\";\nimport {\n UserSessionsError,\n UserSessionsLoading,\n UserSessions as UserSessionsPresentational,\n} from \"./widgets/user-sessions/user-sessions.js\";\nimport type {\n UserSessionsErrorProps,\n UserSessionsLoadingProps,\n} from \"./widgets/user-sessions/user-sessions.js\";\n\ninterface UserSessionsWithoutCurrentSessionIdProps {\n authToken: () => Promise<string>;\n currentSessionId?: never;\n}\n\ninterface UserSessionsWithCurrentSessionIdProps {\n authToken: string;\n currentSessionId: string;\n}\n\ntype UserSessionsProps = WidgetRootDomProps &\n (\n | UserSessionsWithoutCurrentSessionIdProps\n | UserSessionsWithCurrentSessionIdProps\n );\n\nconst UserSessions: React.FC<UserSessionsProps> = ({\n authToken,\n ...passthroughProps\n}) => {\n const baseUrl = useWorkOsApiUrl();\n return (\n <ErrorBoundary\n fallbackRender={({ error }) => {\n const { currentSessionId, ...domProps } = passthroughProps;\n return <UserSessionsError error={error} {...domProps} />;\n }}\n >\n <ApiProvider\n widgetType=\"user-sessions\"\n authToken={authToken}\n baseUrl={baseUrl}\n >\n <UserSessionsImpl {...passthroughProps} />\n </ApiProvider>\n </ErrorBoundary>\n );\n};\n\ninterface UserSessionsImplProps extends WidgetRootDomProps {\n currentSessionId?: string;\n}\n\nconst UserSessionsImpl: React.FC<UserSessionsImplProps> = ({\n currentSessionId,\n ...domProps\n}) => {\n const isApiReady = useApiReady();\n const sessionsQuery = useClientGraphqlQuery({\n queryKey: clientGraphqlQueryKey(\"Sessions\"),\n queryFn: (sdk) => sdk.Sessions(),\n select: (data) => data.sessions,\n });\n\n if (!isApiReady || sessionsQuery.isLoading) {\n return <UserSessionsLoading {...domProps} />;\n }\n\n if (sessionsQuery.isError) {\n return <UserSessionsError error={sessionsQuery.error} {...domProps} />;\n }\n\n const sessions = sessionsQuery.data ?? [];\n\n return (\n <ErrorBoundary\n fallbackRender={({ error }) => (\n <UserSessionsError error={error} {...domProps} />\n )}\n >\n <UserSessionsPresentational\n sessionsData={sessions}\n currentSessionId={\n currentSessionId ??\n sessions.find((session) => session.isCurrent)?.id ??\n \"\"\n }\n {...domProps}\n />\n </ErrorBoundary>\n );\n};\n\nexport type {\n UserSessionsProps,\n UserSessionsLoadingProps,\n UserSessionsErrorProps,\n};\nexport { UserSessions, UserSessionsLoading, UserSessionsError };\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"user-sessions.client.cjs","names":["useWorkOsApiUrl","ErrorBoundary","UserSessionsError","ApiProvider","useApiReady","useClientGraphqlQuery","clientGraphqlQueryKey","UserSessionsLoading","UserSessionsPresentational"],"sources":["../../src/user-sessions.client.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { ApiProvider, useApiReady } from \"./api/api-provider.js\";\nimport {\n clientGraphqlQueryKey,\n useClientGraphqlQuery,\n} from \"./api/client-graphql/hooks.js\";\nimport { ErrorBoundary } from \"./components/error-boundary.js\";\nimport type { WidgetRootDomProps } from \"./lib/widget-types.js\";\nimport { useWorkOsApiUrl } from \"./lib/widgets-context.js\";\nimport {\n UserSessionsError,\n UserSessionsLoading,\n UserSessions as UserSessionsPresentational,\n} from \"./widgets/user-sessions/user-sessions.js\";\nimport type {\n UserSessionsErrorProps,\n UserSessionsLoadingProps,\n} from \"./widgets/user-sessions/user-sessions.js\";\n\ninterface UserSessionsWithoutCurrentSessionIdProps {\n authToken: () => Promise<string>;\n currentSessionId?: never;\n}\n\ninterface UserSessionsWithCurrentSessionIdProps {\n authToken: string;\n currentSessionId: string;\n}\n\ntype UserSessionsProps = WidgetRootDomProps &\n (\n | UserSessionsWithoutCurrentSessionIdProps\n | UserSessionsWithCurrentSessionIdProps\n );\n\nconst UserSessions: React.FC<UserSessionsProps> = ({\n authToken,\n ...passthroughProps\n}) => {\n const baseUrl = useWorkOsApiUrl();\n return (\n <ErrorBoundary\n fallbackRender={({ error }) => {\n const { currentSessionId, ...domProps } = passthroughProps;\n return <UserSessionsError error={error} {...domProps} />;\n }}\n >\n <ApiProvider\n widgetType=\"user-sessions\"\n authToken={authToken}\n baseUrl={baseUrl}\n >\n <UserSessionsImpl {...passthroughProps} />\n </ApiProvider>\n </ErrorBoundary>\n );\n};\n\ninterface UserSessionsImplProps extends WidgetRootDomProps {\n currentSessionId?: string;\n}\n\nconst UserSessionsImpl: React.FC<UserSessionsImplProps> = ({\n currentSessionId,\n ...domProps\n}) => {\n const isApiReady = useApiReady();\n const sessionsQuery = useClientGraphqlQuery({\n queryKey: clientGraphqlQueryKey(\"Sessions\"),\n queryFn: (sdk) => sdk.Sessions(),\n select: (data) => data.sessions,\n });\n\n if (!isApiReady || sessionsQuery.isLoading) {\n return <UserSessionsLoading {...domProps} />;\n }\n\n if (sessionsQuery.isError) {\n return <UserSessionsError error={sessionsQuery.error} {...domProps} />;\n }\n\n const sessions = sessionsQuery.data ?? [];\n\n return (\n <ErrorBoundary\n fallbackRender={({ error }) => (\n <UserSessionsError error={error} {...domProps} />\n )}\n >\n <UserSessionsPresentational\n sessionsData={sessions}\n currentSessionId={\n currentSessionId ??\n sessions.find((session) => session.isCurrent)?.id ??\n \"\"\n }\n {...domProps}\n />\n </ErrorBoundary>\n );\n};\n\nexport type {\n UserSessionsProps,\n UserSessionsLoadingProps,\n UserSessionsErrorProps,\n};\nexport { UserSessions, UserSessionsLoading, UserSessionsError };\n"],"mappings":";;;;;;;;;;;;;AAqCA,MAAM,gBAA6C,EACjD,WACA,GAAG,uBACC;CACJ,MAAM,UAAUA,4BAAAA,gBAAgB;CAChC,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,kCAAAA,eAAD;EACE,iBAAiB,EAAE,YAAY;GAC7B,MAAM,EAAE,kBAAkB,GAAG,aAAa;GAC1C,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACC,4CAAAA,mBAAD;IAA0B;IAAO,GAAI;GAAW,CAAA;EACzD;EAEA,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACC,yBAAAA,aAAD;GACE,YAAW;GACA;GACF;GAET,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,kBAAD,EAAkB,GAAI,iBAAmB,CAAA;EAC9B,CAAA;CACA,CAAA;AAEnB;AAMA,MAAM,oBAAqD,EACzD,kBACA,GAAG,eACC;CACJ,MAAM,aAAaC,yBAAAA,YAAY;CAC/B,MAAM,gBAAgBC,iCAAAA,sBAAsB;EAC1C,UAAUC,sCAAAA,sBAAsB,UAAU;EAC1C,UAAU,QAAQ,IAAI,SAAS;EAC/B,SAAS,SAAS,KAAK;CACzB,CAAC;CAED,IAAI,CAAC,cAAc,cAAc,WAC/B,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACC,4CAAAA,qBAAD,EAAqB,GAAI,SAAW,CAAA;CAG7C,IAAI,cAAc,SAChB,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACL,4CAAAA,mBAAD;EAAmB,OAAO,c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