@primereact/core 11.0.0-alpha.9 → 11.0.0-rc.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/LICENSE.md +45 -0
- package/README.md +43 -0
- package/api/{index.d.mts → FilterMatchMode.d.ts} +2 -10
- package/api/FilterOperator.d.ts +5 -0
- package/api/index.d.ts +2 -0
- package/api/index.mjs +0 -1
- package/base/index.d.ts +1 -0
- package/base/index.mjs +1 -2
- package/base/{index.d.mts → useBase.d.ts} +3 -6
- package/component/Component.d.ts +11 -0
- package/component/Component.props.d.ts +3 -0
- package/component/Component.utils.d.ts +12 -0
- package/component/index.d.ts +4 -0
- package/component/index.mjs +1 -2
- package/component/useComponent.d.ts +30 -0
- package/component/useComponentPT.d.ts +9 -0
- package/component/useComponentStyle.d.ts +10 -0
- package/component/useComponentStyleHandler.d.ts +51 -0
- package/component/withComponent.d.ts +22 -0
- package/config/PrimeReact.context.d.ts +4 -0
- package/config/PrimeReact.props.d.ts +2 -0
- package/config/index.d.ts +3 -0
- package/config/index.mjs +3 -2
- package/config/usePrimeReact.d.ts +6 -0
- package/dnd/announcements.d.ts +5 -0
- package/dnd/collision.d.ts +39 -0
- package/dnd/createDnd.d.ts +15 -0
- package/dnd/index.d.ts +3 -0
- package/dnd/index.mjs +1 -0
- package/dnd/sortable.d.ts +56 -0
- package/dnd/utils.d.ts +21 -0
- package/headless/index.d.ts +2 -0
- package/headless/index.mjs +1 -2
- package/headless/useHeadless.d.ts +9 -0
- package/headless/withHeadless.d.ts +15 -0
- package/icon/Icon.d.ts +2 -0
- package/icon/Icon.props.d.ts +2 -0
- package/icon/Icon.style.d.ts +2 -0
- package/icon/index.d.ts +5 -0
- package/icon/index.mjs +2 -46
- package/icon/useIcon.d.ts +6 -0
- package/icon/withIcon.d.ts +22 -0
- package/{index.d.mts → index.d.ts} +4 -0
- package/index.mjs +1 -2
- package/license/index.d.ts +1 -0
- package/license/index.mjs +1 -0
- package/license/licensebanner.d.ts +20 -0
- package/locale/Locale.context.d.ts +4 -0
- package/locale/Locale.props.d.ts +2 -0
- package/locale/defaultLocale.d.ts +125 -0
- package/locale/index.d.ts +5 -0
- package/locale/index.mjs +3 -2
- package/locale/useLocale.d.ts +6 -0
- package/motion/Motion.context.d.ts +5 -0
- package/motion/Motion.d.ts +2 -0
- package/motion/Motion.props.d.ts +2 -0
- package/motion/Motion.utils.d.ts +4 -0
- package/motion/index.d.ts +5 -0
- package/motion/index.mjs +3 -2
- package/motion/useMotion.d.ts +23 -0
- package/motion/useMotion.props.d.ts +2 -0
- package/overlay-manager/OverlayManager.d.ts +81 -0
- package/overlay-manager/index.d.ts +1 -0
- package/overlay-manager/index.mjs +1 -0
- package/package.json +19 -18
- package/passthrough/PassThrough.context.d.ts +4 -0
- package/passthrough/PassThrough.props.d.ts +2 -0
- package/passthrough/index.d.ts +3 -0
- package/passthrough/index.mjs +3 -2
- package/passthrough/usePassThrough.d.ts +1 -0
- package/stylesheet/PrimeReactStyleSheet.d.ts +7 -0
- package/stylesheet/index.d.ts +1 -0
- package/stylesheet/index.mjs +1 -2
- package/theme/Theme.context.d.ts +4 -0
- package/theme/Theme.props.d.ts +2 -0
- package/theme/index.d.ts +3 -0
- package/theme/index.mjs +3 -2
- package/theme/useTheme.d.ts +1 -0
- package/umd/index.js +9 -213
- package/use-style/index.d.ts +2 -0
- package/use-style/index.mjs +1 -2
- package/use-style/useStyle.d.ts +2 -0
- package/use-style/useStyle.props.d.ts +1 -0
- package/utils/ConnectedOverlayScrollHandler.d.ts +10 -0
- package/utils/combinedRefs.d.ts +2 -0
- package/utils/createContext.d.ts +9 -0
- package/utils/env.d.ts +1 -0
- package/utils/index.d.ts +10 -0
- package/utils/index.mjs +3 -2
- package/utils/mergeRefs.d.ts +11 -0
- package/utils/overlayEventBus.d.ts +9 -0
- package/utils/stylePreloadRegistry.d.ts +33 -0
- package/utils/styleRegistry.d.ts +19 -0
- package/LICENSE +0 -21
- package/api/index.mjs.map +0 -1
- package/base/index.mjs.map +0 -1
- package/component/index.d.mts +0 -69
- package/component/index.mjs.map +0 -1
- package/config/index.d.mts +0 -17
- package/config/index.mjs.map +0 -1
- package/headless/index.d.mts +0 -28
- package/headless/index.mjs.map +0 -1
- package/icon/index.d.mts +0 -40
- package/icon/index.mjs.map +0 -1
- package/index.mjs.map +0 -1
- package/locale/index.d.mts +0 -12
- package/locale/index.mjs.map +0 -1
- package/motion/index.d.mts +0 -28
- package/motion/index.mjs.map +0 -1
- package/passthrough/index.d.mts +0 -12
- package/passthrough/index.mjs.map +0 -1
- package/stylesheet/index.d.mts +0 -10
- package/stylesheet/index.mjs.map +0 -1
- package/theme/index.d.mts +0 -12
- package/theme/index.mjs.map +0 -1
- package/umd/index.js.map +0 -1
- package/use-style/index.d.mts +0 -7
- package/use-style/index.mjs.map +0 -1
- package/utils/index.d.mts +0 -35
- package/utils/index.mjs.map +0 -1
package/LICENSE.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# PrimeUI License
|
|
2
|
+
|
|
3
|
+
This package is part of **PrimeUI**, a family of commercial UI libraries by PrimeTek Informatics.
|
|
4
|
+
|
|
5
|
+
## How PrimeUI May Be Used
|
|
6
|
+
|
|
7
|
+
PrimeUI may be used under one of two licenses. You choose the one that applies to you based on eligibility.
|
|
8
|
+
|
|
9
|
+
### Community License (Free)
|
|
10
|
+
|
|
11
|
+
Free for organizations that meet all of the following criteria:
|
|
12
|
+
|
|
13
|
+
- Less than $1,000,000 USD in annual gross revenue
|
|
14
|
+
- Fewer than 5 developers
|
|
15
|
+
- Fewer than 10 employees
|
|
16
|
+
- Less than $3,000,000 USD in venture capital or outside funding
|
|
17
|
+
|
|
18
|
+
Individuals, students, non-profits, and non-commercial open source projects also qualify.
|
|
19
|
+
|
|
20
|
+
The Community License provides full access to the core libraries and supports up to 4 developers. It requires annual renewal by confirming continued eligibility.
|
|
21
|
+
|
|
22
|
+
### Commercial License (Paid)
|
|
23
|
+
|
|
24
|
+
For organizations that do not qualify for the Community License.
|
|
25
|
+
|
|
26
|
+
Licensed per developer, perpetual, with one year of updates included. Renewal is optional and extends access to new versions. The Commercial Suite also includes PrimeBlocks, Theme Designer, all PrimeUI Pro components, and Premium Support.
|
|
27
|
+
|
|
28
|
+
## License Key
|
|
29
|
+
|
|
30
|
+
A valid license key is required to use this software. License verification is performed offline, with no telemetry and no remote connection. A missing, invalid, or expired key may cause the software to display a license notice.
|
|
31
|
+
|
|
32
|
+
## Full Terms
|
|
33
|
+
|
|
34
|
+
The complete license terms, eligibility details, and renewal information are available at:
|
|
35
|
+
|
|
36
|
+
- Community License: https://primeui.dev/licenses/community
|
|
37
|
+
- Commercial License: https://primeui.dev/licenses/commercial
|
|
38
|
+
|
|
39
|
+
## Restrictions
|
|
40
|
+
|
|
41
|
+
This software is distributed as a compiled package. You may not reverse-engineer, decompile, or extract its source code, redistribute it as a component library or development tool, or remove its license mechanisms. Redistributing the software so that third parties can develop with it requires a separate OEM License. See the full terms for details.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
© 2026 PrimeTek Informatics. All rights reserved.
|
package/README.md
CHANGED
|
@@ -1 +1,44 @@
|
|
|
1
1
|
# PrimeReact Core
|
|
2
|
+
|
|
3
|
+
Shared infrastructure for PrimeReact components. Every component in the library depends on this package for configuration, theming, Pass Through (PT), and styling.
|
|
4
|
+
|
|
5
|
+
## Configuration
|
|
6
|
+
|
|
7
|
+
`PrimeReactProvider` and the `usePrimeReact()` hook expose global settings (theme, locale, ripple, PT defaults) through React context. Wrap the application once and every component reads from the same config.
|
|
8
|
+
|
|
9
|
+
## Base component system
|
|
10
|
+
|
|
11
|
+
`useBase()` and `useComponent()` are the foundation every PrimeReact component is built on. They handle prop resolution, attribute selection, style injection, and PT application so component authors don't repeat that logic.
|
|
12
|
+
|
|
13
|
+
## Pass Through (PT)
|
|
14
|
+
|
|
15
|
+
The PT system lets consumers override any internal DOM attribute or class on any element inside a component without forking it. PT values can be objects or functions receiving the current instance and state.
|
|
16
|
+
|
|
17
|
+
## Styling
|
|
18
|
+
|
|
19
|
+
Dynamic stylesheet loading and `useStyle()` for injecting scoped CSS at runtime. Integrates with `@primeuix/styled` for design token resolution.
|
|
20
|
+
|
|
21
|
+
## Utilities
|
|
22
|
+
|
|
23
|
+
Locale management, license verification, overlay positioning, DnD helpers, and re-exports of common utilities from `@primeuix/utils`.
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
import { PrimeReactProvider } from '@primereact/core';
|
|
29
|
+
import Aura from '@primeuix/themes/aura';
|
|
30
|
+
|
|
31
|
+
export default function App() {
|
|
32
|
+
return <PrimeReactProvider value={{ theme: { preset: Aura } }}>{/* components */}</PrimeReactProvider>;
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import { usePrimeReact } from '@primereact/core';
|
|
38
|
+
|
|
39
|
+
const { config, locale } = usePrimeReact();
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## License
|
|
43
|
+
|
|
44
|
+
Licensed under the [PrimeUI License](https://primeui.dev/licenses) - Copyright (c) [PrimeTek Informatics](https://www.primetek.com.tr)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare const FilterMatchMode: Readonly<{
|
|
1
|
+
export declare const FilterMatchMode: Readonly<{
|
|
2
2
|
readonly STARTS_WITH: "startsWith";
|
|
3
3
|
readonly CONTAINS: "contains";
|
|
4
4
|
readonly NOT_CONTAINS: "notContains";
|
|
@@ -17,12 +17,4 @@ declare const FilterMatchMode: Readonly<{
|
|
|
17
17
|
readonly DATE_AFTER: "dateAfter";
|
|
18
18
|
readonly CUSTOM: "custom";
|
|
19
19
|
}>;
|
|
20
|
-
declare type FilterMatchModeType = (typeof FilterMatchMode)[keyof typeof FilterMatchMode];
|
|
21
|
-
|
|
22
|
-
declare const FilterOperator: Readonly<{
|
|
23
|
-
AND: "and";
|
|
24
|
-
OR: "or";
|
|
25
|
-
}>;
|
|
26
|
-
declare type FilterOperatorType = (typeof FilterOperator)[keyof typeof FilterOperator];
|
|
27
|
-
|
|
28
|
-
export { FilterMatchMode, type FilterMatchModeType, FilterOperator, type FilterOperatorType };
|
|
20
|
+
export declare type FilterMatchModeType = (typeof FilterMatchMode)[keyof typeof FilterMatchMode];
|
package/api/index.d.ts
ADDED
package/api/index.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
1
|
var e=Object.freeze({STARTS_WITH:"startsWith",CONTAINS:"contains",NOT_CONTAINS:"notContains",ENDS_WITH:"endsWith",EQUALS:"equals",NOT_EQUALS:"notEquals",IN:"in",LESS_THAN:"lt",LESS_THAN_OR_EQUAL_TO:"lte",GREATER_THAN:"gt",GREATER_THAN_OR_EQUAL_TO:"gte",BETWEEN:"between",DATE_IS:"dateIs",DATE_IS_NOT:"dateIsNot",DATE_BEFORE:"dateBefore",DATE_AFTER:"dateAfter",CUSTOM:"custom"});var o=Object.freeze({AND:"and",OR:"or"});export{e as FilterMatchMode,o as FilterOperator};
|
|
2
|
-
//# sourceMappingURL=index.mjs.map
|
package/base/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useBase';
|
package/base/index.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=index.mjs.map
|
|
1
|
+
import{usePrimeReact as M}from"@primereact/core/config";import{useAttrSelector as b,useId as w,useProps as C}from"@primereact/hooks";import{resolve as I,toKebabCase as S}from"@primeuix/utils";import*as e from"react";var K=(s="UnknownBase",y)=>{let n=M(),{type:u,inProps:t,defaultProps:f,setup:x}=y||{},i=w(t?.id),m=b("pc_"),[B,D]=e.useMemo(()=>s.toLowerCase().split("."),[s]),d=e.useRef(null),R=e.useRef(void 0),r=e.useMemo(()=>({ref:d,elementRef:R,id:i,name:s,type:u,scope:B,part:S(D),inProps:t,$attrSelector:m,$primereact:n}),[i,t,m,n,s,u]),p=n.config?.defaults,E=e.useMemo(()=>{let g=I(p?.[s]||p?.[s.toLowerCase()],r);return{...f,...g?.props}},[f,p,s]),{props:l,attrs:P}=C(E,t),a=e.useMemo(()=>({...r,props:l,attrs:P}),[r,l,P]),o=I(x,a),c=e.useMemo(()=>({state:{},$computedSetup:o,...o,...a,elementRef:o?.elementRef??R}),[o,a]);return e.useImperativeHandle(d,()=>c,[c]),c};export{K as useBase};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Instance, useBaseOptions } from '@primereact/types/core';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
|
|
4
3
|
/**
|
|
5
4
|
* A custom hook for creating a base instance.
|
|
6
5
|
* This hook is used to initialize a base instance with common properties and methods.
|
|
@@ -9,9 +8,7 @@ import * as React from 'react';
|
|
|
9
8
|
* @param options The options for the base instance.
|
|
10
9
|
* @returns The base instance.
|
|
11
10
|
*/
|
|
12
|
-
declare const useBase: <IProps extends {
|
|
11
|
+
export declare const useBase: <IProps extends {
|
|
13
12
|
id?: string;
|
|
14
13
|
ref?: React.Ref<unknown>;
|
|
15
|
-
}, DProps, Exposes extends Record<PropertyKey, unknown>>(name: string | undefined, options: useBaseOptions<IProps, DProps, Exposes>) => Instance<Pick<
|
|
16
|
-
|
|
17
|
-
export { useBase };
|
|
14
|
+
}, DProps, Exposes extends Record<PropertyKey, unknown>>(name: string | undefined, options: useBaseOptions<IProps, DProps, Exposes>) => Instance<Pick<DProps & IProps, keyof DProps>, IProps, Record<PropertyKey, unknown>, Exposes>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ComponentInstance, ComponentProps } from '@primereact/types/core';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* A component wrapper for rendering elements with additional props and attributes.
|
|
5
|
+
* @param inProps The properties to pass to the component.
|
|
6
|
+
* @returns A React element or null if `pIf` is false.
|
|
7
|
+
*/
|
|
8
|
+
export declare function Component<I extends ComponentInstance = ComponentInstance>(inProps?: ComponentProps<I>): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<React.ReactNode> | React.JSX.Element | null | undefined;
|
|
9
|
+
export declare namespace Component {
|
|
10
|
+
var displayName: string;
|
|
11
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Merges props based on the merge function or merge flag.
|
|
3
|
+
*/
|
|
4
|
+
export declare function mergeProps<T extends unknown[], R = Record<PropertyKey, unknown>>(fn: ((...args: T) => R | undefined) | boolean, ...args: T): R;
|
|
5
|
+
/**
|
|
6
|
+
* Resolves a PT class value — wraps string/array values in { className }.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getPTClassValue(obj?: Record<string, unknown>, key?: string, params?: Record<string, unknown>): unknown;
|
|
9
|
+
/**
|
|
10
|
+
* Extracts pass-through value for a given component name from the PT object.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getPT<Fn extends (...args: unknown[]) => unknown>(pt: Record<string, unknown> | undefined, key: string | undefined, name: string | undefined, fn?: Fn): Record<string, unknown>;
|
package/component/index.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
var Ce=Object.defineProperty,Pe=Object.defineProperties;var Se=Object.getOwnPropertyDescriptors;var J=Object.getOwnPropertySymbols;var pe=Object.prototype.hasOwnProperty,ue=Object.prototype.propertyIsEnumerable;var ce=(p,u,l)=>u in p?Ce(p,u,{enumerable:!0,configurable:!0,writable:!0,value:l}):p[u]=l,s=(p,u)=>{for(var l in u||(u={}))pe.call(u,l)&&ce(p,l,u[l]);if(J)for(var l of J(u))ue.call(u,l)&&ce(p,l,u[l]);return p},I=(p,u)=>Pe(p,Se(u));var $=(p,u)=>{var l={};for(var r in p)pe.call(p,r)&&u.indexOf(r)<0&&(l[r]=p[r]);if(p!=null&&J)for(var r of J(p))u.indexOf(r)<0&&ue.call(p,r)&&(l[r]=p[r]);return l};import{isValidElement as he}from"@primereact/core/utils";import{cn as be,resolve as Q}from"@primeuix/utils";import*as U from"react";function we(p={}){var d,h,T,k;let A=p,{pIf:u=!0,style:l,className:r,as:a,asChild:R,instance:n}=A,e=$(A,["pIf","style","className","as","asChild","instance"]);if(u===!1)return null;let m=a||((d=n==null?void 0:n.props)==null?void 0:d.as)||U.Fragment,i=R||((h=n==null?void 0:n.props)==null?void 0:h.asChild),P=m===U.Fragment,w=e,{ref:C=n==null?void 0:n.elementRef,children:f,attrs:O}=w,M=$(w,["ref","children","attrs"]),N=s(s({},O),M),j=Q(f,n,N),D=Q(l||((T=n==null?void 0:n.props)==null?void 0:T.style),n),B=Q(r||((k=n==null?void 0:n.props)==null?void 0:k.className),n);return i||P?U.createElement(U.Fragment,null,j):he(m)?Q(m,n):U.createElement(m,I(s({},N),{ref:C,style:s(s({},N.style),D),className:be(N.className,B)}),j)}we.displayName="PrimeReact.Component";import{omit as ke}from"@primeuix/utils";var ee={ref:void 0,pIf:!0,style:void 0,className:void 0,as:void 0,asChild:!1,pt:void 0,ptOptions:void 0,unstyled:void 0,dt:void 0,children:void 0},He=I(s({},ke(ee,"pt","ptOptions","dt","styles")),{instance:void 0,attrs:void 0});import{useBase as je}from"@primereact/core/base";import*as W from"react";import{useMountEffect as Te,useUnmountEffect as Ie,useUpdateEffect as xe}from"@primereact/hooks";import{mergeProps as ne}from"@primeuix/utils/mergeprops";import{getKeyValue as X,isArray as Oe,isFunction as _e,isNotEmpty as Ee,isString as te,resolve as le,toFlatCase as q}from"@primeuix/utils/object";import*as g from"react";function me(p,u){var F,G,z;let{id:l,name:r,props:a,attrs:R,$primereact:n,$attrSelector:e}=p||{},m=g.useCallback(t=>{let o=M(O(a.pt,r),X,`hooks.${t}`),c=h(X,`hooks.${t}`);o==null||o(),c==null||c()},[a.pt,r]),i=g.useCallback((t,...o)=>_e(t)?t(...o):t?ne(...o):Object.assign({},...o),[]),P=g.useCallback((t={},o="",c={},y=!0)=>{var ae;let b=/./g.test(o)&&!!c[o.split(".")[0]],{mergeSections:v=!0,mergeProps:S=!1}=(a==null?void 0:a.ptOptions)||((ae=n.passthrough)==null?void 0:ae.options)||{},L=y?b?d(f,o,c):h(f,o,c):void 0,_=b?void 0:A(t,f,o,I(s({},c),{global:L||{}})),E=C(o);return v||!v&&_?i(S,L,_,E):s(s({},_),E)},[a.ptOptions,i]),C=g.useCallback((t="")=>{var y,b;let o="data-pc-",c=t==="root"&&Ee((y=a==null?void 0:a.pt)==null?void 0:y["data-pc-section"]);return t!=="transition"&&I(s({},t==="root"&&I(s({[`${o}name`]:q(c?(b=a.pt)==null?void 0:b["data-pc-section"]:r)},c&&{[`${o}extend`]:q(r)}),{[`${e}`]:""})),{[`${o}section`]:q(t)})},[a.pt,e]),f=g.useCallback((t={},o="",c)=>{let y=X(t,o,c);return te(y)||Oe(y)?{className:y}:y},[]),O=g.useCallback((t,o="",c)=>{let y=(b,v=!1)=>{var E;let S=c?c(b):b,L=q(o),_=q(r);return(E=v?L!==_?S==null?void 0:S[L]:void 0:S==null?void 0:S[L])!=null?E:S};return t&&Object.hasOwn(t,"_usept")?{_usept:t._usept,originalValue:y(t.originalValue),value:y(t.value)}:y(t,!0)},[]),M=g.useCallback((t,o,c="",y)=>{var v;let b=S=>o(S,c,y);if(t&&Object.hasOwn(t,"_usept")){let{mergeSections:S=!0,mergeProps:L=!1}=t._usept||((v=n.passthrough)==null?void 0:v.options)||{},_=b(t.originalValue),E=b(t.value);return _===void 0&&E===void 0?void 0:te(E)?E:te(_)?_:S||!S&&E?i(L,_,E):E}return b(t)},[(F=n.passthrough)==null?void 0:F.options,i]),N=g.useMemo(()=>{var t;return O((t=n==null?void 0:n.passthrough)==null?void 0:t.value,void 0,o=>le(o,p))},[(G=n==null?void 0:n.passthrough)==null?void 0:G.value]),j=g.useMemo(()=>{var t;return O((t=n==null?void 0:n.passthrough)==null?void 0:t.value,void 0,o=>X(o,r,p)||le(o,p))},[(z=n==null?void 0:n.passthrough)==null?void 0:z.value]),D=g.useMemo(()=>Object.entries(R||{}).filter(([t])=>t==null?void 0:t.startsWith("pt-")).reduce((t,[o,c])=>{let[,y,...b]=o.split("-");return[y,b==null?void 0:b.join("-")].filter(Boolean).reduce((v,S,L,_)=>(v[S]||(v[S]=L===_.length-1?c:{}),v[S]),t),t},{}),[R]),B=g.useMemo(()=>Object.entries(R||{}).filter(([t])=>!(t!=null&&t.startsWith("pt-"))).reduce((t,[o,c])=>(t[o]=c,t),{}),[R]),A=g.useCallback((t={},o,c="",y)=>ne(M(O(t,r),o,c,y),M(D,o,c,y)),[D]),d=g.useCallback((t,o="",c)=>M(N,t,o,c),[N]),h=g.useCallback((t,o,c)=>M(j,t,o,c),[j]),w=g.useCallback((t="",o={})=>P(a.pt,t,s(s({},u),o)),[a.pt,u]),T=g.useCallback((t="",o={})=>{var y;let c=ne(B,w(t,o));return c&&Object.hasOwn(c,"id")&&((y=c.id)!=null||(c.id=l)),c},[w,l,B]),k=g.useCallback((t={},o="",c={})=>P(t,o,s(s({},u),c),!1),[u]);return Te(()=>m("onMounted")),xe(()=>m("onUpdated")),Ie(()=>m("onUnmounted")),g.useMemo(()=>({ptm:w,ptmi:T,ptmo:k}),[w,T,k])}import{StyleRegistry as Y}from"@primereact/core/utils";import{Theme as H,ThemeService as Le}from"@primeuix/styled";import{cn as Ke,getKeyValue as re}from"@primeuix/utils";import*as x from"react";import{ThemeContext as Me}from"@primereact/core/theme";import{useStyle as Ne}from"@primereact/core/use-style";import{css as oe,dt as ie,Theme as K}from"@primeuix/styled";import{isNotEmpty as ve,minifyCSS as se,resolve as de,toElement as Fe}from"@primeuix/utils";import*as V from"react";function fe(p,u){let l=V.useContext(Me),[r]=Ne(),a=V.useCallback((R,n)=>r({name:n==null?void 0:n.name,css:R,element:Fe(u),options:n}),[r,u]);return V.useMemo(()=>{let R=I(s({name:"base"},p),{load(n="",e={},m="",i=!1){let P=e.name||R.name,C=oe`${n}${m}`,f=i?K.transformCSS(P,C):C;return ve(f)?a(se(f),s({name:P},e)):{}},loadCSS(n){return this.load(this.css,n)},loadStyle(n,e=""){return this.load(this.style,n,e,!0)},getCommonTheme(n){return K.getCommon(this.name,n)},getComponentTheme(n){return K.getComponent(this.name,n)},getPresetTheme(n,e,m){return K.getCustomPreset(this.name,n,e,m)},getLayerOrderThemeCSS(){return K.getLayerOrderCSS(this.name)},getStyleSheet(n="",e={}){if(this.css){let m=de(this.css,{dt:ie}),i=se(oe`${m}${n}`),P=Object.entries(e).reduce((C,[f,O])=>(C.push(`${f}="${O}"`),C),[]).join(" ");return`<style type="text/css" data-primereact-style-id="${this.name}" ${P}>${i}</style>`}return""},getCommonThemeStyleSheet(n,e={}){return K.getCommonStyleSheet(this.name,n,e)},getThemeStyleSheet(n,e={}){let m=[K.getStyleSheet(this.name,n,e)];if(l){let i=this.name==="base"?"global-style":`${this.name}-style`,P=oe`${de(l,{dt:ie})}`,C=se(K.transformCSS(this.name,P)),f=Object.entries(e).reduce((O,[M,N])=>(O.push(`${M}="${N}"`),O),[]).join(" ");m.push(`<style type="text/css" data-primereact-style-id="${i}" ${f}>${C}</style>`)}return m.join("")}});return R},[p,l,a])}function ye(p,u,l){var A;let{props:r={unstyled:!1,dt:void 0},$primereact:a,$attrSelector:R,elementRef:n}=p||{},e=fe(u,n),m=x.useRef(null),i=x.useCallback(()=>{if(!Y.isStyleNameLoaded("base")){let{css:d}=e.baseStyles||{};e.load(d,s({name:"base"},f)),Y.setLoadedStyleName("base")}M()},[e]),P=x.useCallback(()=>{i(),j(i)},[i]),C=x.useMemo(()=>{var d;return r.unstyled!==void 0?r.unstyled:(d=a==null?void 0:a.config)==null?void 0:d.unstyled},[r,a==null?void 0:a.config]),f=x.useMemo(()=>{var d,h;return{nonce:(h=(d=a==null?void 0:a.config)==null?void 0:d.csp)==null?void 0:h.nonce}},[a==null?void 0:a.config]),O=x.useCallback(()=>{if(!Y.isStyleNameLoaded(e==null?void 0:e.name)&&(e!=null&&e.name)){let d=e.name==="global"?"base":e.name;e.loadCSS(s({name:d},f)),Y.setLoadedStyleName(e.name)}},[e,f]),M=x.useCallback(()=>{var d,h,w,T;if(!(C||(a==null?void 0:a.theme)==="none")){if(!H.isStyleNameLoaded("common")){let{primitive:k,semantic:F,global:G,style:z}=((d=e==null?void 0:e.getCommonTheme)==null?void 0:d.call(e))||{};e.load(k==null?void 0:k.css,s({name:"primitive-variables"},f)),e.load(F==null?void 0:F.css,s({name:"semantic-variables"},f)),e.load(G==null?void 0:G.css,s({name:"global-variables"},f)),e.load((h=e.baseStyles)==null?void 0:h.style,s({name:"global-style"},f),z,!0),H.setLoadedStyleName("common")}if(!H.isStyleNameLoaded(e==null?void 0:e.name)&&(e!=null&&e.name)){let{css:k,style:F}=((w=e==null?void 0:e.getComponentTheme)==null?void 0:w.call(e))||{};e.load(k,s({name:`${e.name}-variables`},f)),e.loadStyle(s({name:`${e.name}-style`},f),F),H.setLoadedStyleName(e.name)}if(!H.isStyleNameLoaded("layer-order")){let k=(T=e==null?void 0:e.getLayerOrderThemeCSS)==null?void 0:T.call(e);e.load(k,s({name:"layer-order",first:!0},f)),H.setLoadedStyleName("layer-order")}}},[C,e,f]),N=d=>{var T;let{css:h}=((T=e==null?void 0:e.getPresetTheme)==null?void 0:T.call(e,d,`[${R}]`))||{},w=e==null?void 0:e.load(h,s({name:`${R}-${e.name}`},f));m.current=w},j=x.useCallback((d=()=>{})=>{Le.on("theme:change",d)},[]),D=x.useCallback((d="",h={})=>C?void 0:Ke(re(e.classes,d,I(s({},l),{context:h}))),[C,p,e.classes]),B=x.useCallback((d="",h=!0,w={})=>{var T;if(h){let k=re(e.inlineStyles,d,I(s({},l),{context:w})),F=re((T=e.baseStyles)==null?void 0:T.inlineStyles,d,I(s({},l),{context:w}));return s(s({},F),k)}},[e.inlineStyles,(A=e.baseStyles)==null?void 0:A.inlineStyles,p]);return C||(O(),P(),N(r.dt)),x.useMemo(()=>({cx:D,sx:B,isUnstyled:C,$style:e}),[D,B,C,e])}function Re(p="UnknownComponent",u={}){let l=W.useMemo(()=>s(s({},ee),u.defaultProps),[u.defaultProps]),r=je(p,{inProps:u.inProps,defaultProps:l,setup:u.setup}),{ref:a,props:R}=r,n=W.useMemo(()=>({instance:r,props:r.props,attrs:r.attrs,state:r.state}),[r.props,r.attrs,r.state]),e=me(r,n),m=ye(r,R.styles||u.styles,n),i=W.useMemo(()=>s(s(s({},r),e),m),[r,e,m]);return W.useImperativeHandle(a,()=>i,[i]),i}import{isObject as ge}from"@primeuix/utils";import*as Z from"react";function Pn({name:p="UnknownComponent",defaultProps:u,styles:l,components:r,setup:a,render:R}){let e=Z.memo(m=>{let i=Re(p,{inProps:m,defaultProps:u,styles:l,setup:a}),P=R!=null?R:(()=>null);return i.props.pIf?Z.createElement(P,s({},i)):null},(m,i)=>!ge(m)||!ge(i)?!1:m===i&&Object.keys(u||{}).every(P=>m[P]===i[P]));return e.displayName=`PrimeReact.${p}`,Object.entries(r||{}).forEach(([m,i])=>{e[m]=i}),e}export{we as Component,He as defaultComponentProps,ee as globalProps,Re as useComponent,Pn as withComponent};
|
|
2
|
-
//# sourceMappingURL=index.mjs.map
|
|
1
|
+
import{isValidElement as de,mergeRefs as fe}from"@primereact/core/utils";import{cn as ye,resolve as W}from"@primeuix/utils";import*as K from"react";function Re(c={}){let{pIf:u=!0,style:g,className:t,as:i,asChild:P,instance:n,render:e,...r}=c;if(u===!1)return null;let s=i||n?.props?.as||K.Fragment,d=e||P||n?.props?.asChild,m=s===K.Fragment,{ref:f,children:y,attrs:k,...b}=r,S={...k,...b},E=W(e??y,n,S),O=W(g||n?.props?.style,n),V=W(t||n?.props?.className,n);if(d||m)return K.createElement(K.Fragment,null,E);if(de(s))return W(s,n);{let _={...S,style:{...S.style,...O},className:ye(S.className,V)},l=fe(n?.elementRef,S.ref,f,n?.props?.ref);return _.children?K.createElement(s,{..._,ref:l}):K.createElement(s,{..._,ref:l},E)}}Re.displayName="PrimeReact.Component";import{omit as ge}from"@primeuix/utils";var Q=Object.freeze({ref:void 0,pIf:!0,style:void 0,className:void 0,as:void 0,asChild:!1,instance:void 0,pt:void 0,ptOptions:void 0,unstyled:void 0,dt:void 0,styles:void 0,render:void 0,children:void 0}),Ve=Object.freeze({...ge(Q,"pt","ptOptions","dt","styles"),attrs:void 0});import{useBase as Ne}from"@primereact/core/base";import*as U from"react";import{useMountEffect as be,useUnmountEffect as we,useUpdateEffect as Te}from"@primereact/hooks";import{mergeProps as xe}from"@primeuix/utils/mergeprops";import{getKeyValue as X,isNotEmpty as Ie,isString as se,resolve as oe}from"@primeuix/utils/object";import*as h from"react";import{mergeProps as Ce}from"@primeuix/utils/mergeprops";import{getKeyValue as Pe,isArray as Se,isFunction as he,isString as ke,toFlatCase as ne}from"@primeuix/utils/object";function z(c,...u){return he(c)?c(...u):c?Ce(...u):Object.assign({},...u)}function q(c={},u="",g){let t=Pe(c,u,g);return ke(t)||Se(t)?{className:t}:t}function A(c,u,g,t){let i=(P,n=!1)=>{let e=t?t(P):P,r=ne(u??""),s=ne(g??"");return(n?r!==s?e?.[r]:void 0:e?.[r])??e};return c&&Object.hasOwn(c,"_usept")?{_usept:c._usept,originalValue:i(c.originalValue),value:i(c.value)}:i(c,!0)}function re(c,u){let{id:g,name:t,scope:i,part:P,props:n,attrs:e,$primereact:r,$attrSelector:s}=c||{},d=r?.passthrough,m=d?.value,f=d?.options,y=h.useCallback((o,a,p="",N)=>{let $=w=>a(w,p,N);if(o&&Object.hasOwn(o,"_usept")){let{mergeSections:w=!0,mergeProps:H=!1}=o._usept||f||{},M=$(o.originalValue),x=$(o.value);return M===void 0&&x===void 0?void 0:se(x)?x:se(M)?M:w||!w&&x?z(H,M,x):x}return $(o)},[f]),k=h.useCallback(o=>{let a=y(A(n.pt,t,t),X,`hooks.${o}`),p=y(A(m,void 0,t),X,`hooks.${o}`);a?.(),p?.()},[n.pt,t,y,m]),b=h.useMemo(()=>A(m,void 0,t,o=>oe(o,c)),[m,t]),S=h.useMemo(()=>A(m,void 0,t,o=>X(o,t,c)||oe(o,c)),[m,t]),E=h.useMemo(()=>Object.entries(e||{}).filter(([o])=>o?.startsWith("pt-")).reduce((o,[a,p])=>{let[,N,...$]=a.split("-");return[N,$?.join("-")].filter(Boolean).reduce((w,H,M,x)=>(w[H]||(w[H]=M===x.length-1?p:{}),w[H]),o),o},{}),[e]),O=h.useMemo(()=>Object.entries(e||{}).filter(([o])=>!o?.startsWith("pt-")).reduce((o,[a,p])=>(o[a]=p,o),{}),[e]),V=h.useCallback((o="")=>{let a="data-";return o==="root"&&Ie(e?.["data-scope"])?{[`${a}extend`]:i,[`${a}styled`]:i}:{[`${a}scope`]:i,...o==="root"&&{[`${a}part`]:P,[`${a}id`]:s,[`${a}styled`]:i},[`${a}slot`]:o}},[i,P,s,e]),_=h.useCallback((o={},a,p="",N)=>{let $=y(A(o,t,t),a,p,N),w=y(E,a,p,N);return z(!0,$??{},w??{})},[E,y,t]),l=h.useCallback((o,a="",p)=>y(b,o,a,p),[b,y]),C=h.useCallback((o,a,p)=>y(S,o,a,p),[S,y]),T=h.useCallback((o={},a="",p={},N=!0)=>{let $=a.includes(".")&&!!p[a.split(".")[0]],{mergeSections:w=!0,mergeProps:H=!1}=n?.ptOptions||f||{},M=N?$?l(q,a,p):C(q,a,p):void 0,x=$?void 0:_(o,q,a,{...p,global:M||{}}),te=V(a);return w||!w&&x?z(H,M,x,te):{...x,...te}},[n.ptOptions,l,C,_,V]),I=h.useCallback((o="",a={})=>T(n.pt,o,{...u,...a}),[n.pt,u,T]),v=h.useCallback((o="",a={})=>{let p=xe(O,I(o,a));return p&&Object.hasOwn(p,"id")&&(p.id??=g),p},[I,g,O]),D=h.useCallback((o={},a="",p={})=>T(o,a,{...u,...p},!1),[u,T]);return be(()=>k("onMounted")),Te(()=>k("onUpdated")),we(()=>k("onUnmounted")),h.useMemo(()=>({ptm:I,ptmi:v,ptmo:D}),[I,v,D])}import{isDev as ve,StyleRegistry as G}from"@primereact/core/utils";import{Theme as L,ThemeService as ie}from"@primeuix/styled";import{cn as Me,getKeyValue as ee,isClient as j}from"@primeuix/utils";import*as R from"react";import{ThemeContext as Oe}from"@primereact/core/theme";import{useStyle as $e}from"@primereact/core/use-style";import{css as Y,dt as ae,Theme as F}from"@primeuix/styled";import{isNotEmpty as Ee,minifyCSS as Z,resolve as ce,toElement as _e}from"@primeuix/utils";import*as B from"react";function ue(c,u){let g=B.useContext(Oe),[t]=$e(),i=B.useCallback((P,n)=>t({name:n?.name,css:P,element:_e(u),options:n}),[t,u]);return B.useMemo(()=>{let P={name:"base",...c,load(n="",e={},r="",s=!1){let d=e.name||P.name,m=Y`${n}${r}`,f=s?F.transformCSS(d,m):m;return Ee(f)?i(Z(f),{name:d,...e}):void 0},loadCSS(n){return this.load(this.css,n)},loadStyle(n,e=""){return this.load(this.style,n,e,!0)},getCommonTheme(n){return F.getCommon(this.name,n)},getComponentTheme(n){return F.getComponent(this.name,n)},getPresetTheme(n,e,r){return F.getCustomPreset(this.name,n,e,r)},getLayerOrderThemeCSS(){return F.getLayerOrderCSS(this.name)},getStyleSheet(n="",e={}){if(this.css){let r=ce(this.css,{dt:ae}),s=Z(Y`${r}${n}`),d=Object.entries(e).reduce((m,[f,y])=>(m.push(`${f}="${y}"`),m),[]).join(" ");return`<style type="text/css" data-primereact-style-id="${this.name}" ${d}>${s}</style>`}return""},getCommonThemeStyleSheet(n,e={}){return F.getCommonStyleSheet(this.name,n,e)},getThemeStyleSheet(n,e={}){let r=[F.getStyleSheet(this.name,n,e)];if(g){let s=this.name==="base"?"global-style":`${this.name}-style`,d=Y`${ce(g,{dt:ae})}`,m=Z(F.transformCSS(this.name,d)),f=Object.entries(e).reduce((y,[k,b])=>(y.push(`${k}="${b}"`),y),[]).join(" ");r.push(`<style type="text/css" data-primereact-style-id="${s}" ${f}>${m}</style>`)}return r.join("")}};return P},[c,g,i])}function le(c,u,g){let{props:t={unstyled:!1,dt:void 0},$primereact:i,$attrSelector:P,elementRef:n}=c||{},e=ue(u,n),r=R.useMemo(()=>t.unstyled!==void 0?t.unstyled:i?.config?.unstyled,[t.unstyled,i?.config?.unstyled]),s=R.useMemo(()=>({nonce:i?.config?.csp?.nonce}),[i?.config?.csp?.nonce]),d=R.useRef(null),m=R.useRef(!1),f=R.useRef(null),y=R.useRef(null),k=R.useRef(!1);if(ve){let l=u?.style,C=typeof l=="string"?l:null;C!==null&&y.current!==C&&(y.current=C,k.current=!0)}let b=R.useCallback(()=>{if(!e?.name)return;let l=e.name==="global"?"base":e.name;if(!j()){e.loadCSS({name:l,...s});return}f.current&&f.current!==e.name&&(G.releaseStyleName(f.current),f.current=null);let C=k.current;(C||!f.current)&&((C||G.retainStyleName(e.name))&&e.loadCSS({name:l,...s}),f.current=e.name)},[e,s]),S=R.useCallback(()=>{if(r||i?.theme==="none")return;let l=()=>{let{primitive:v,semantic:D,global:o,style:a}=e?.getCommonTheme?.()||{};e.load(v?.css,{name:"primitive-variables",...s}),e.load(D?.css,{name:"semantic-variables",...s}),e.load(o?.css,{name:"global-variables",...s}),e.load(e.baseStyles?.style,{name:"global-style",...s},a,!0)},C=()=>{let{css:v,style:D}=e?.getComponentTheme?.()||{};e.load(v,{name:`${e.name}-variables`,...s}),e.loadStyle({name:`${e.name}-style`,...s},D)},T=()=>{let v=e?.getLayerOrderThemeCSS?.();e.load(v,{name:"layer-order",first:!0,...s})};if(!j()){l(),e?.name&&C(),T();return}let I=k.current;(I||!L.isStyleNameLoaded("common"))&&(l(),L.setLoadedStyleName("common")),(I||!L.isStyleNameLoaded(e?.name))&&e?.name&&(C(),L.setLoadedStyleName(e.name)),(I||!L.isStyleNameLoaded("layer-order"))&&(T(),L.setLoadedStyleName("layer-order"))},[r,e,s]),E=R.useCallback(()=>{let{css:l}=e.baseStyles||{};if(!j()){e.load(l,{name:"base",...s}),S();return}let C=k.current;(C||!m.current)&&(m.current=!0,(C||G.retainStyleName("base"))&&e.load(l,{name:"base",...s})),S(),k.current=!1},[e,s,S]),O=R.useCallback(l=>{i?.theme?.options?.cssVariables===!1&&e?.name&&L.addScopedToken({[e.name]:l})&&(L.deleteLoadedStyleName(e.name),S());let{css:C}=e?.getPresetTheme?.(l,`[${P}]`)||{},T=e?.load(C,{name:`${P}-${e.name}`,...s});d.current=T||null},[e,P,s,S,i?.theme]),V=R.useCallback((l="",C={})=>r?void 0:Me(ee(e.classes,l,{...g,context:C})),[r,g,e.classes]),_=R.useCallback((l="",C=!0,T={})=>{if(C){let I=ee(e.inlineStyles,l,{...g,context:T});return{...ee(e.baseStyles?.inlineStyles,l,{...g,context:T}),...I}}},[e.inlineStyles,e.baseStyles?.inlineStyles,g]);return!j()&&!r&&(b(),E(),O(t.dt)),R.useInsertionEffect(()=>{!j()||r||(b(),E())},[r,b,E]),R.useEffect(()=>{if(!j()||r||i?.theme==="none")return;let l=()=>{S(),O(t.dt)};return ie.on("theme:change",l),()=>{ie.off("theme:change",l)}},[r,i?.theme,S,O,t.dt]),R.useInsertionEffect(()=>{if(!(!j()||r))return d.current?.remove(),d.current=null,O(t.dt),()=>{d.current?.remove(),d.current=null}},[r,t.dt,O]),R.useEffect(()=>{if(j())return()=>{m.current&&(G.releaseStyleName("base"),m.current=!1),f.current&&(G.releaseStyleName(f.current),f.current=null)}},[]),R.useMemo(()=>({cx:V,sx:_,isUnstyled:r,$style:e}),[V,_,r,e])}function pe(c="UnknownComponent",u={}){let g=U.useMemo(()=>({...Q,...u.defaultProps}),[u.defaultProps]),t=Ne(c,{type:u.type,inProps:u.inProps,defaultProps:g,setup:u.setup}),{ref:i,props:P}=t,n=U.useMemo(()=>({instance:t,props:t.props,attrs:t.attrs,state:t.state}),[t.props,t.attrs,t.state]),e=re(t,n),r=le(t,P.styles||u.styles,n),s=U.useMemo(()=>({...t,...e,...r}),[t,e,r]);return U.useImperativeHandle(i,()=>s,[s]),s}import{isObject as me}from"@primeuix/utils";import*as J from"react";function dt({name:c="UnknownComponent",type:u="primitive",defaultProps:g,styles:t,components:i,setup:P,render:n}){let r=J.memo(s=>{let d=pe(c,{type:u,inProps:s,defaultProps:g,styles:t,setup:P}),m=n??(()=>null);return d.props.pIf?J.createElement(m,{...d}):null},(s,d)=>{if(!me(s)||!me(d))return!1;let m=s,f=d,y=Object.keys(m);if(y.length!==Object.keys(f).length)return!1;for(let k of y){let b=m[k],S=f[k];if(typeof b=="function"||typeof S=="function"){if(b!==S)return!1;continue}if(!Object.is(b,S))return!1}return!0});return r.displayName=`PrimeReact.${c}`,Object.entries(i||{}).forEach(([s,d])=>{r[s]=d}),r}export{Re as Component,Ve as defaultComponentProps,Q as globalProps,pe as useComponent,dt as withComponent};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { InComponentInstance, useComponentOptions } from '@primereact/types/core';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* A hook for creating a component instance.
|
|
5
|
+
* This hook initializes a component with properties, attributes, and styles, and provides methods for handling pass-through options and styles.
|
|
6
|
+
* It also supports custom setup functions for additional configuration.
|
|
7
|
+
*
|
|
8
|
+
* @param name The name of the component, used for debugging and identification.
|
|
9
|
+
* @param options The options to customize the component instance.
|
|
10
|
+
* @returns The component instance.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useComponent<IProps, DProps, Exposes extends Record<PropertyKey, unknown>, Styles>(name?: string, options?: useComponentOptions<IProps, DProps, Exposes, Styles>): InComponentInstance<import("@primereact/types").SafeRecord<Pick<{
|
|
13
|
+
ref?: React.Ref<unknown> | undefined;
|
|
14
|
+
pIf?: boolean | undefined;
|
|
15
|
+
style?: React.CSSProperties | ((instance?: import("@primereact/types/core").ComponentInstance<Record<PropertyKey, unknown>, Record<PropertyKey, unknown>, Record<PropertyKey, unknown>> | undefined) => React.CSSProperties | undefined) | undefined;
|
|
16
|
+
className?: string | ((instance?: import("@primereact/types/core").ComponentInstance<Record<PropertyKey, unknown>, Record<PropertyKey, unknown>, Record<PropertyKey, unknown>> | undefined) => string | undefined) | undefined;
|
|
17
|
+
as?: string | number | bigint | boolean | React.ComponentClass<any, any> | React.FunctionComponent<any> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | null | undefined;
|
|
18
|
+
asChild?: boolean | undefined;
|
|
19
|
+
instance?: import("@primereact/types/core").ComponentInstance<Record<PropertyKey, unknown>, Record<PropertyKey, unknown>, Record<PropertyKey, unknown>> | undefined;
|
|
20
|
+
pt?: Record<PropertyKey, unknown> | undefined;
|
|
21
|
+
ptOptions?: import("@primereact/types/core").PassThroughOptions | undefined;
|
|
22
|
+
unstyled?: boolean | undefined;
|
|
23
|
+
dt?: unknown;
|
|
24
|
+
styles?: import("@primereact/types/styles").StylesOptions | undefined;
|
|
25
|
+
render?: ((instance: import("@primereact/types/core").ComponentInstance<Record<PropertyKey, unknown>, Record<PropertyKey, unknown>, Record<PropertyKey, unknown>>) => React.ReactNode) | undefined;
|
|
26
|
+
children?: any;
|
|
27
|
+
} & IProps & {
|
|
28
|
+
id?: string;
|
|
29
|
+
ref?: React.Ref<unknown>;
|
|
30
|
+
}, "dt" | "style" | "ref" | "pIf" | "className" | "as" | "asChild" | "instance" | "pt" | "ptOptions" | "unstyled" | "styles" | "render" | "children">>, IProps, Record<PropertyKey, unknown>, Exposes>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { GlobalComponentProps, Instance, useComponentPTReturnType } from '@primereact/types/core';
|
|
2
|
+
/**
|
|
3
|
+
* A hook for managing pass-through options for a component.
|
|
4
|
+
*
|
|
5
|
+
* @param instance The instance of the component.
|
|
6
|
+
* @param $params Additional parameters for the hook.
|
|
7
|
+
* @returns An object containing the pass-through options.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useComponentPT<Props extends GlobalComponentProps, IProps, Params>(instance: Instance<Props, IProps>, $params?: Params): useComponentPTReturnType;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { GlobalComponentProps, Instance, useComponentStyleReturnType } from '@primereact/types/core';
|
|
2
|
+
/**
|
|
3
|
+
* A hook for managing component styles.
|
|
4
|
+
*
|
|
5
|
+
* @param instance The instance of the component.
|
|
6
|
+
* @param styles The styles to apply to the component.
|
|
7
|
+
* @param $params Additional parameters for the hook.
|
|
8
|
+
* @returns An object containing the component styles.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useComponentStyle<Props extends GlobalComponentProps, IProps, Styles, Params>(instance: Instance<Props, IProps>, styles?: Styles, $params?: Params): useComponentStyleReturnType;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Preset, StylesOptions, StyleType } from '@primereact/types/styles';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* A custom hook for managing component styles.
|
|
5
|
+
*
|
|
6
|
+
* @param styles The styles to apply to the component.
|
|
7
|
+
* @param elementRef A reference to the HTML element.
|
|
8
|
+
* @returns An object containing methods to load and manage styles.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useComponentStyleHandler<Styles>(styles?: Styles, elementRef?: React.Ref<HTMLElement>): {
|
|
11
|
+
load(style?: StyleType, options?: Record<PropertyKey, unknown> & {
|
|
12
|
+
name?: string;
|
|
13
|
+
}, extendedStyle?: string, enableThemeTransform?: boolean): void | Element;
|
|
14
|
+
loadCSS(options?: Record<PropertyKey, unknown>): void | Element;
|
|
15
|
+
loadStyle(options?: Record<PropertyKey, unknown>, extendedStyle?: string): void | Element;
|
|
16
|
+
getCommonTheme(params?: Record<PropertyKey, unknown>): {
|
|
17
|
+
primitive: {
|
|
18
|
+
css: string | undefined;
|
|
19
|
+
tokens: string[] | undefined;
|
|
20
|
+
};
|
|
21
|
+
semantic: {
|
|
22
|
+
css: string | undefined;
|
|
23
|
+
tokens: string[] | undefined;
|
|
24
|
+
};
|
|
25
|
+
global: {
|
|
26
|
+
css: string | undefined;
|
|
27
|
+
tokens: string[] | undefined;
|
|
28
|
+
};
|
|
29
|
+
style: string | undefined;
|
|
30
|
+
};
|
|
31
|
+
getComponentTheme(params?: Record<PropertyKey, unknown>): {
|
|
32
|
+
css: string | undefined;
|
|
33
|
+
tokens: string[] | undefined;
|
|
34
|
+
style: string | undefined;
|
|
35
|
+
};
|
|
36
|
+
getPresetTheme(preset: Preset, selector: string, params?: Record<PropertyKey, unknown>): {
|
|
37
|
+
css: string | undefined;
|
|
38
|
+
tokens: string[] | undefined;
|
|
39
|
+
style: string | undefined;
|
|
40
|
+
};
|
|
41
|
+
getLayerOrderThemeCSS(): string;
|
|
42
|
+
getStyleSheet(extendedCSS?: string, props?: {}): string;
|
|
43
|
+
getCommonThemeStyleSheet(params?: Record<PropertyKey, unknown>, props?: Record<PropertyKey, unknown>): string;
|
|
44
|
+
getThemeStyleSheet(params?: Record<PropertyKey, unknown>, props?: Record<PropertyKey, unknown>): string;
|
|
45
|
+
name: string;
|
|
46
|
+
css?: StyleType | undefined;
|
|
47
|
+
style?: StyleType | undefined;
|
|
48
|
+
classes?: import("@primereact/types/styles").ClassesType<import("@primereact/types/core").ComponentInstance> | undefined;
|
|
49
|
+
inlineStyles?: import("@primereact/types/styles").InlineStylesType<import("@primereact/types/core").ComponentInstance> | undefined;
|
|
50
|
+
baseStyles?: StylesOptions<import("@primereact/types/core").ComponentInstance> | undefined;
|
|
51
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ComponentInstance, withComponentOptions } from '@primereact/types/core';
|
|
2
|
+
import type { StylesOptions } from '@primereact/types/styles';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
/**
|
|
5
|
+
* A higher-order component for enhancing a component with additional features.
|
|
6
|
+
*
|
|
7
|
+
* @template IProps The interface for the component's input properties.
|
|
8
|
+
* @template DProps The interface for the component's default properties.
|
|
9
|
+
* @template Exposes The interface for the properties that the component exposes.
|
|
10
|
+
* @template Styles The styles options for the component.
|
|
11
|
+
* @template CData Additional data to expose on the component.
|
|
12
|
+
*
|
|
13
|
+
* @param options The options for the component.
|
|
14
|
+
* @param options.name The name of the component, used for debugging and identification.
|
|
15
|
+
* @param options.defaultProps The default properties for the component.
|
|
16
|
+
* @param options.styles The styles to apply to the component.
|
|
17
|
+
* @param options.components Additional components to include in the component.
|
|
18
|
+
* @param options.setup A setup function for additional configuration of the component.
|
|
19
|
+
* @param options.render A render function for the component.
|
|
20
|
+
* @returns A React component wrapped with the specified options.
|
|
21
|
+
*/
|
|
22
|
+
export declare function withComponent<IProps, DProps, Exposes extends Record<PropertyKey, unknown> = Record<PropertyKey, unknown>, Styles = StylesOptions, CData = Record<string, unknown>>({ name, type, defaultProps, styles, components, setup, render }: withComponentOptions<IProps, DProps, Exposes, Styles, CData>): (<I extends ComponentInstance, T extends React.ElementType>(inProps?: IProps & import("@primereact/types/core").GlobalComponentProps<I, unknown, T, unknown, unknown> & {} & {} & Omit<import("@primereact/types").ExtractProps<T>, keyof import("@primereact/types/core").GlobalComponentProps<I_1, P, T_1, unknown, unknown> | keyof IProps> & DProps) => React.JSX.Element | null) & CData & React.FC<{}>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { PrimeReactProps } from '@primereact/types/core';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
export declare const PrimeReactContext: React.Context<PrimeReactProps | undefined>;
|
|
4
|
+
export declare function PrimeReactProvider(inProps?: React.PropsWithChildren<PrimeReactProps>): React.JSX.Element;
|
package/config/index.mjs
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import{showInvalidLicenseBanner as T}from"@primereact/core/license";import{LocaleProvider as h}from"@primereact/core/locale";import{PassThroughProvider as E}from"@primereact/core/passthrough";import{ThemeProvider as x}from"@primereact/core/theme";import{useProps as A}from"@primereact/hooks";import{registerLicense as _,verifyLicense as v}from"@primeui/license-manager";import{resolve as S}from"@primeuix/utils";import*as t from"react";import{FilterMatchMode as e}from"@primereact/core/api";var f={csp:{nonce:void 0},defaults:void 0,filterMatchModeOptions:{text:[e.STARTS_WITH,e.CONTAINS,e.NOT_CONTAINS,e.ENDS_WITH,e.EQUALS,e.NOT_EQUALS],numeric:[e.EQUALS,e.NOT_EQUALS,e.LESS_THAN,e.LESS_THAN_OR_EQUAL_TO,e.GREATER_THAN,e.GREATER_THAN_OR_EQUAL_TO],date:[e.DATE_IS,e.DATE_IS_NOT,e.DATE_BEFORE,e.DATE_AFTER]},inputVariant:void 0,locale:"en",pt:void 0,ptOptions:{mergeSections:!0,mergeProps:!1},ripple:!1,theme:void 0,stylesheet:void 0,unstyled:!1,zIndex:{modal:1100,overlay:1e3,menu:1e3,tooltip:1100},license:void 0};var C="2026-06-28",c=t.createContext(void 0);function W(i={}){let{props:r,attrs:n}=A(f,i),[s,u]=t.useState(r.inputVariant),[m,l]=t.useState(r.defaults),[p,R]=t.useState(r.zIndex);t.useEffect(()=>{r.license&&_({primeui:r.license}),v("primeui",{releaseDate:C}).then(d=>{d.valid||(console.warn(`[PrimeUI] ${d.message}`),T())})},[]);let a=t.useMemo(()=>({inputVariant:s,setInputVariant:u,defaults:m,setDefaults:l,zIndex:p,setZIndex:R}),[s,m,p]),P=t.useMemo(()=>S(n.children,a),[n.children,a]);return t.createElement(c.Provider,{value:a},t.createElement(h,{lang:r.locale},t.createElement(E,{value:r.pt,...r.ptOptions},t.createElement(x,{preset:r.theme?.preset,stylesheet:r.stylesheet,...r.theme?.options},P))))}import{LocaleContext as L}from"@primereact/core/locale";import{PassThroughContext as N}from"@primereact/core/passthrough";import{ThemeContext as O}from"@primereact/core/theme";import*as o from"react";function Z(){let i=o.useContext(c),r=o.useContext(L),n=o.useContext(N),s=o.useContext(O);if(i===void 0)throw new Error("[PrimeReact] PrimeReactProvider not found. Wrap your application in <PrimeReactProvider> before using PrimeReact components.");return o.useMemo(()=>({config:i,locale:r,passthrough:n,theme:s}),[i,r,n,s])}export{c as PrimeReactContext,W as PrimeReactProvider,f as defaultConfigProps,Z as usePrimeReact};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function usePrimeReact(): {
|
|
2
|
+
config: import("@primereact/types/core").PrimeReactProps;
|
|
3
|
+
locale: import("@primereact/types/core").LocaleContextValue | undefined;
|
|
4
|
+
passthrough: import("@primereact/types/core").PassThroughProps | undefined;
|
|
5
|
+
theme: import("@primereact/types/core").ThemeProps | null;
|
|
6
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collision detection strategies for createDnd.
|
|
3
|
+
*/
|
|
4
|
+
import type { CollisionResult, DragData, Point, Rect, UniqueId } from '@primereact/types/primitive/dnd';
|
|
5
|
+
export interface CollisionInput {
|
|
6
|
+
position: Point;
|
|
7
|
+
activeRect: Rect | null;
|
|
8
|
+
droppables: Array<{
|
|
9
|
+
id: UniqueId;
|
|
10
|
+
rect: Rect;
|
|
11
|
+
data: DragData;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
}>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Returns droppables whose rect contains the pointer.
|
|
17
|
+
* Smallest (innermost) droppable wins for nested scenarios.
|
|
18
|
+
*/
|
|
19
|
+
declare function pointerWithin(input: CollisionInput): CollisionResult[];
|
|
20
|
+
/**
|
|
21
|
+
* Returns droppables overlapping the active drag rect, sorted by overlap %.
|
|
22
|
+
*/
|
|
23
|
+
declare function rectIntersection(input: CollisionInput): CollisionResult[];
|
|
24
|
+
/**
|
|
25
|
+
* Returns droppables sorted by center-to-center distance (closest first).
|
|
26
|
+
*/
|
|
27
|
+
declare function closestCenter(input: CollisionInput): CollisionResult[];
|
|
28
|
+
/**
|
|
29
|
+
* Returns droppables sorted by average corner-to-corner distance (closest first).
|
|
30
|
+
*/
|
|
31
|
+
declare function closestCorners(input: CollisionInput): CollisionResult[];
|
|
32
|
+
/** All built-in collision strategies. */
|
|
33
|
+
export declare const collisionStrategies: {
|
|
34
|
+
readonly pointerWithin: typeof pointerWithin;
|
|
35
|
+
readonly rectIntersection: typeof rectIntersection;
|
|
36
|
+
readonly closestCenter: typeof closestCenter;
|
|
37
|
+
readonly closestCorners: typeof closestCorners;
|
|
38
|
+
};
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* createDnd — Framework-Agnostic Drag & Drop Core
|
|
3
|
+
*
|
|
4
|
+
* Pure JavaScript implementation following the createMotion pattern.
|
|
5
|
+
* Can be wrapped by React, Angular, Vue, Lit, Svelte, Solid etc.
|
|
6
|
+
*
|
|
7
|
+
* - SSR-safe: No DOM access at module level or during creation.
|
|
8
|
+
* - Zero memory leaks: destroy() cleans every listener, timer, observer.
|
|
9
|
+
* - Cross-browser: Uses only standard, well-supported APIs.
|
|
10
|
+
* - Performance: RAF-throttled pointer, zero-reflow scroll pattern, rect caching.
|
|
11
|
+
*/
|
|
12
|
+
import type { CreateDndOptions, DndInstance } from '@primereact/types/primitive/dnd';
|
|
13
|
+
export { collisionStrategies } from './collision';
|
|
14
|
+
export { arrayMove, arrayTransfer } from './sortable';
|
|
15
|
+
export declare function createDnd(options?: CreateDndOptions): DndInstance;
|
package/dnd/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { createDnd, collisionStrategies, arrayMove, arrayTransfer } from './createDnd';
|
|
2
|
+
export type { UniqueId, Point, Rect, DragData, Transform, CollisionStrategy, SortDirection, DraggableRegistration, DroppableRegistration, SortableContainerRegistration, DragStartEvent, DragMoveEvent, DragOverEvent, DragEndEvent, DragCancelEvent, SortEvent, TransferEvent, DragOperation, SortableOperationState, CollisionResult, DndState, PointerSensorOptions, KeyboardSensorOptions, AutoScrollOptions, DndAnnouncements, CreateDndOptions, DndEventMap, DndInstance } from '@primereact/types/primitive/dnd';
|
|
3
|
+
export type { CollisionInput } from './collision';
|
package/dnd/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var xe={onDragStart:i=>`Picked up ${i.active.data?.label??"item"}. Use Arrow keys to move, Space or Enter to drop, Escape to cancel.`,onDragOver:i=>i.over?`Over ${i.over.data?.label??"drop zone"}.`:"Not over a drop zone.",onDragEnd:i=>i.cancelled?"Drag cancelled. Item returned to original position.":i.over?`Dropped on ${i.over.data?.label??"drop zone"}.`:"Dropped.",onDragCancel:()=>"Drag cancelled. Item returned to original position.",onSortOver:i=>`Moved to position ${i.index+1} of ${i.total}${i.containerId?` in ${String(i.containerId)}`:""}.`};function Y(){return typeof window<"u"&&typeof document<"u"}function Z(i){let n=i.getBoundingClientRect();return{x:n.x,y:n.y,width:n.width,height:n.height,top:n.top,right:n.right,bottom:n.bottom,left:n.left}}function de(i,n,a,e){return{x:i,y:n,width:a,height:e,top:n,right:i+a,bottom:n+e,left:i}}function he(i,n){return de(i.x-n.x,i.y-n.y,i.width,i.height)}function B(i,n){return Math.sqrt((i.x-n.x)**2+(i.y-n.y)**2)}function H(i){return{x:i.x+i.width/2,y:i.y+i.height/2}}function oe(i,n){return i.x>=n.left&&i.x<=n.right&&i.y>=n.top&&i.y<=n.bottom}function ue(i){return i.width*i.height}function Re(i,n){let a=Math.max(i.left,n.left),e=Math.max(i.top,n.top),d=Math.min(i.right,n.right)-a,b=Math.min(i.bottom,n.bottom)-e;return d>0&&b>0?d*b:0}function De(i){if(!Y())return null;let n=i.parentElement;for(;n&&n!==document.documentElement;){let a=getComputedStyle(n),e=(a.overflowY==="auto"||a.overflowY==="scroll")&&n.scrollHeight>n.clientHeight,d=(a.overflowX==="auto"||a.overflowX==="scroll")&&n.scrollWidth>n.clientWidth;if(e||d)return n;n=n.parentElement}return document.documentElement.scrollHeight>document.documentElement.clientHeight?document.documentElement:null}function fe(i){return i===document.documentElement?{x:window.scrollX,y:window.scrollY}:{x:i.scrollLeft,y:i.scrollTop}}function Ce(i,n,a){i===document.documentElement?window.scrollBy(n,a):i.scrollBy(n,a)}function pe(i,n){let a=null;return{call(){a!==null&&clearTimeout(a),a=setTimeout(()=>{a=null,i()},n)},cancel(){a!==null&&(clearTimeout(a),a=null)}}}function We(i){let n=[];for(let a of i.droppables)if(!a.disabled&&oe(i.position,a.rect)){let e=ue(a.rect);e>0&&n.push({id:a.id,data:a.data,ratio:1/e})}return n.sort((a,e)=>(e.ratio??0)-(a.ratio??0)),n}function $e(i){if(!i.activeRect)return[];let n=[];for(let a of i.droppables){if(a.disabled)continue;let e=Re(i.activeRect,a.rect);if(e>0){let d=ue(a.rect);n.push({id:a.id,data:a.data,ratio:d>0?e/d:0})}}return n.sort((a,e)=>(e.ratio??0)-(a.ratio??0)),n}function _e(i){if(!i.activeRect)return[];let n=H(i.activeRect),a=[];for(let e of i.droppables)e.disabled||a.push({id:e.id,data:e.data,distance:B(n,H(e.rect))});return a.sort((e,d)=>(e.distance??1/0)-(d.distance??1/0)),a}function Ve(i){if(!i.activeRect)return[];let n=i.activeRect,a=[{x:n.left,y:n.top},{x:n.right,y:n.top},{x:n.left,y:n.bottom},{x:n.right,y:n.bottom}],e=[];for(let d of i.droppables){if(d.disabled)continue;let b=d.rect,T=[{x:b.left,y:b.top},{x:b.right,y:b.top},{x:b.left,y:b.bottom},{x:b.right,y:b.bottom}],v=0;for(let E=0;E<4;E++)v+=B(a[E],T[E]);e.push({id:d.id,data:d.data,distance:v/4})}return e.sort((d,b)=>(d.distance??1/0)-(b.distance??1/0)),e}var ee={pointerWithin:We,rectIntersection:$e,closestCenter:_e,closestCorners:Ve};var we=.25;function Ee(i){let{position:n,items:a,direction:e,activeId:d,allowInsideDrop:b=!1}=i,T={index:0,position:"before",targetId:null,dropPosition:"before",targetRect:null};if(a.length===0)return T;let v=a.filter(y=>y.id!==d);if(v.length===0)return T;let E=0,S=1/0;for(let y=0;y<v.length;y++){let G=H(v[y].rect),j=e==="horizontal"?Math.abs(n.x-G.x):e==="vertical"?Math.abs(n.y-G.y):B(n,G);j<S&&(S=j,E=y)}let C=v[E],L=C.rect,m=H(L),P;e==="horizontal"?P=n.x<m.x?"before":"after":e==="vertical"?P=n.y<m.y?"before":"after":P=n.y<m.y?"before":n.y>m.y?"after":n.x<m.x?"before":"after";let U;b?U=Ze(n,L,e):U=P;let I=a.findIndex(y=>y.id===C.id);return{index:P==="after"?I+1:I,position:P,targetId:C.id,dropPosition:U,targetRect:L}}function Ze(i,n,a){if(a==="horizontal"){let d=n.width*we;return i.x<n.left+d?"before":i.x>n.right-d?"after":"inside"}let e=n.height*we;return i.y<n.top+e?"before":i.y>n.bottom-e?"after":"inside"}function Se(i){let{items:n,activeId:a,originalIndex:e,projectedIndex:d,activeRect:b,itemRects:T,direction:v}=i,E=new Map;if(!b||e===d)return E;let S=d>e;if(v==="grid")for(let C=0;C<n.length;C++){let L=n[C];if(L===a||!(S?C>e&&C<=d:C>=d&&C<e))continue;let P=S?C-1:C+1;n[P]===a&&(P=S?P-1:P+1);let U=n[P],I=T.get(L),y=U?T.get(U):null;I&&y&&E.set(L,{x:y.x-I.x,y:y.y-I.y,scaleX:1,scaleY:1})}else{let C=v==="horizontal"?b.width:0,L=v==="vertical"?b.height:0;for(let m=0;m<n.length;m++){let P=n[m];if(P===a)continue;let U=0,I=0;S?m>e&&m<=d&&(U=-C,I=-L):m>=d&&m<e&&(U=C,I=L),(U!==0||I!==0)&&E.set(P,{x:U,y:I,scaleX:1,scaleY:1})}}return E}function Me(i){let{sourceItems:n,targetItems:a,activeId:e,originalIndex:d,projectedIndex:b,activeRect:T,sourceDirection:v,targetDirection:E}=i,S=new Map,C=new Map;if(!T)return{sourceTransforms:S,targetTransforms:C};let L=v==="horizontal"?T.width:0,m=v==="vertical"||v==="grid"?T.height:0;for(let I=0;I<n.length;I++)n[I]!==e&&I>d&&S.set(n[I],{x:-L,y:-m,scaleX:1,scaleY:1});let P=E==="horizontal"?T.width:0,U=E==="vertical"||E==="grid"?T.height:0;for(let I=0;I<a.length;I++)I>=b&&C.set(a[I],{x:P,y:U,scaleX:1,scaleY:1});return{sourceTransforms:S,targetTransforms:C}}function Pe(i,n,a){if(n<0||n>=i.length||a<0||a>i.length)return i.slice();let e=i.slice(),[d]=e.splice(n,1);return e.splice(a,0,d),e}function Te(i,n,a,e){if(a<0||a>=i.length||e<0||e>n.length)return{source:i.slice(),target:n.slice()};let d=i.slice(),[b]=d.splice(a,1),T=n.slice();return T.splice(e,0,b),{source:d,target:T}}function Ge(i){let n=!1;function a(){if(n)throw new Error("createDnd: instance has been destroyed.")}let e={operation:null,draggables:new Map,droppables:new Map,sortableContainers:new Map,collisions:[],sortable:null},d=new Set,b=!1;function T(){if(!b){b=!0;try{for(let t of d)t()}finally{b=!1}}}function v(t){let o=t(e);o!==e&&(e=o,T())}let E=new Map;function S(t,o){let r=E.get(t);if(r)for(let s of r)s(o)}let C=i?.collisionDetection??"pointerWithin";function L(){return ee[C]??ee.pointerWithin}let m=null,P=i?.autoScroll!==!1,U=typeof i?.autoScroll=="object"?i.autoScroll:{},I=null,y={x:0,y:0},G={...xe,...i?.announcements},j=new Map;function ie(){if(Y()){j.clear();for(let[t,o]of e.draggables)o.node&&j.set(t,Z(o.node));for(let[t,o]of e.droppables)o.node&&j.set(t,Z(o.node));for(let[t,o]of e.sortableContainers)o.node&&j.set(t,Z(o.node))}}function z(t,o){let r=j.get(t);return r?he(r,o):null}function ge(){e.operation&&(ie(),y={x:0,y:0},ne(e.operation.current))}let J=pe(ge,50),re=pe(ge,100),F=null,te=null,ae=null,se=null;function Ae(){if(!(!Y()||typeof ResizeObserver>"u")){F=new ResizeObserver(()=>J.call());for(let[,t]of e.sortableContainers)t.node&&F.observe(t.node)}}function Ue(){if(!Y())return;let t=()=>re.call();window.addEventListener("resize",t,{passive:!0}),se=()=>{window.removeEventListener("resize",t),re.cancel()}}function Oe(){if(!Y())return;if(typeof MutationObserver<"u"){te=new MutationObserver(()=>J.call());for(let[,r]of e.sortableContainers)r.node&&te.observe(r.node,{childList:!0})}let t=m??window,o=()=>J.call();t.addEventListener("scroll",o,{passive:!0}),ae=()=>t.removeEventListener("scroll",o)}function me(){te?.disconnect(),te=null,ae?.(),ae=null,J.cancel()}function qe(t){let o=[],r=e.operation;if(!r)return o;let s=e.draggables.get(r.activeId);for(let[u,c]of e.droppables){if(c.disabled)continue;let p=z(u,t);if(!p)continue;let M=!c.accept||s?.scope!=null&&c.accept.includes(s.scope),x=c.canDrop?c.canDrop(r.data):!0;M&&x&&o.push({id:u,rect:p,data:c.data??{},disabled:!1})}for(let[u,c]of e.sortableContainers){if(c.disabled)continue;let p=z(u,t);if(!p)continue;(!c.accept||s?.scope!=null&&c.accept.includes(s.scope))&&o.push({id:u,rect:p,data:{},disabled:!1})}return o}function Le(t,o){if(t.length!==o.length)return!1;for(let r=0;r<t.length;r++)if(t[r].id!==o[r].id)return!1;return!0}function ne(t,o){let r=e.operation;if(!r)return;let s=o??y,u=qe(s),c=z(r.activeId,s),p=L()({position:t,activeRect:c,droppables:u});if(!Le(e.collisions,p)){let x=e.collisions[0]??null,R=p[0]??null;v(O=>({...O,collisions:p})),x?.id!==R?.id&&S("dragOver",{active:{id:r.activeId,data:r.data},over:R?{id:R.id,data:R.data}:null})}Ke(t,s)}let Q=null;function ke(t){if(Q){let o=e.sortableContainers.get(Q.containerId);if(o){let r=o.items.indexOf(t);if(r!==-1)return{container:o,index:r}}Q=null}for(let[,o]of e.sortableContainers){let r=o.items.indexOf(t);if(r!==-1)return Q={containerId:o.id,index:r},{container:o,index:r}}return null}function ze(t,o){if(t.size!==o.size)return!1;for(let[r,s]of t){let u=o.get(r);if(!u||s.x!==u.x||s.y!==u.y)return!1}return!0}function Ke(t,o){let r=e.operation;if(!r)return;let s=ke(r.activeId);if(!s){e.sortable!==null&&v(f=>({...f,sortable:null}));return}let u=e.draggables.get(r.activeId),c=null;for(let[,f]of e.sortableContainers){let g=z(f.id,o);if(!g||!oe(t,g))continue;if(!f.accept||u?.scope!=null&&f.accept.includes(u.scope)||f.id===s.container.id){c=f;break}}c||(c=s.container);let p=[];for(let f of c.items){let g=z(f,o);g&&p.push({id:f,rect:g})}let M=Ee({position:t,items:p,direction:c.direction,activeId:r.activeId,allowInsideDrop:c.allowInsideDrop}),x=M.index,R=c.id!==s.container.id,O;if(R){let{sourceTransforms:f,targetTransforms:g}=Me({sourceItems:s.container.items,targetItems:c.items,activeId:r.activeId,originalIndex:s.index,projectedIndex:x,activeRect:z(r.activeId,o),sourceDirection:s.container.direction,targetDirection:c.direction});O=new Map([...f,...g])}else O=Se({items:s.container.items,activeId:r.activeId,originalIndex:s.index,projectedIndex:x,activeRect:z(r.activeId,o),itemRects:j,direction:s.container.direction});let q=M.targetId!=null?{targetId:M.targetId,position:M.dropPosition,targetRect:M.targetRect}:null,l={sourceContainerId:s.container.id,currentContainerId:c.id,originalIndex:s.index,projectedIndex:x,transforms:O,dropIndicator:q},h=e.sortable;(!h||h.currentContainerId!==l.currentContainerId||h.projectedIndex!==l.projectedIndex||!ze(h.transforms,l.transforms)||h.dropIndicator?.targetId!==l.dropIndicator?.targetId||h.dropIndicator?.position!==l.dropIndicator?.position)&&v(f=>({...f,sortable:l}))}function He(){if(!(!P||!Y())){if(!m){let t=e.draggables.get(e.operation.activeId);t?.node&&(m=De(t.node))}m&&(y={x:0,y:0},be())}}function ve(){I!==null&&(cancelAnimationFrame(I),I=null),y={x:0,y:0}}function be(){let t=e.operation;if(!t||!m)return;let o=U.threshold??50,r=U.speed??15,s=U.direction??"both",u=t.current,c=m===document.documentElement?de(0,0,window.innerWidth,window.innerHeight):Z(m),p=0,M=0;if(s!=="horizontal"){let x=u.y-c.top,R=c.bottom-u.y;x>=0&&x<o?M=-r*(1-x/o):R>=0&&R<o&&(M=r*(1-R/o))}if(s!=="vertical"){let x=u.x-c.left,R=c.right-u.x;x>=0&&x<o?p=-r*(1-x/o):R>=0&&R<o&&(p=r*(1-R/o))}if(p!==0||M!==0){let x=fe(m);Ce(m,p,M);let R=fe(m),O=R.x-x.x,q=R.y-x.y;(O!==0||q!==0)&&(y={x:y.x+O,y:y.y+q},ne(t.current,y))}I=requestAnimationFrame(be)}function ce(t,o){if(a(),e.operation)return;let r=e.draggables.get(o);if(!r||r.disabled)return;let s={...r.data},u;if("clientX"in t){let c=t;u={x:c.clientX,y:c.clientY}}else{let c=r.node?Z(r.node):null;u=c?H(c):{x:0,y:0}}v(c=>({...c,operation:{activeId:o,origin:u,current:{...u},delta:{x:0,y:0},data:s},collisions:[],sortable:null})),ie(),Oe(),He(),S("dragStart",{active:{id:o,data:s,node:r.node},event:t}),ne(u)}function $(t,o){a();let r=e.operation;if(!r)return;let s={x:o.x-r.origin.x,y:o.y-r.origin.y};v(c=>({...c,operation:c.operation?{...c.operation,current:o,delta:s}:null})),ne(o);let u=e.draggables.get(r.activeId);S("dragMove",{active:{id:r.activeId,data:r.data,node:u?.node??null},position:o,delta:s,event:t})}function le(t){a();let o=e.operation;if(!o)return;let r=e.collisions[0]??null,s=e.sortable;s&&(s.sourceContainerId!==s.currentContainerId?S("transfer",{activeId:o.activeId,from:{containerId:s.sourceContainerId,index:s.originalIndex},to:{containerId:s.currentContainerId,index:s.projectedIndex},event:t}):s.originalIndex!==s.projectedIndex&&S("sort",{containerId:s.sourceContainerId,activeId:o.activeId,fromIndex:s.originalIndex,toIndex:s.projectedIndex,event:t})),S("dragEnd",{active:{id:o.activeId,data:o.data},over:r?{id:r.id,data:r.data}:null,cancelled:!1,event:t}),Ie()}function W(t){a();let o=e.operation;o&&(S("dragCancel",{active:{id:o.activeId,data:o.data},event:t}),S("dragEnd",{active:{id:o.activeId,data:o.data},over:null,cancelled:!0,event:t}),Ie())}function Ie(){ve(),me(),j.clear(),y={x:0,y:0},Q=null,m=null,v(t=>({...t,operation:null,collisions:[],sortable:null}))}let _=new Set;function je(t,o,r){if(a(),!Y())return()=>{};let s=r?.activationDistance??5,u=r?.activationDelay??0,c=!1,p=!1,M=null,x=null,R=u===0,O=null,q=null,l=null;function h(){c=!1,p=!1,M=null,R=u===0,x!==null&&(clearTimeout(x),x=null),O!==null&&(cancelAnimationFrame(O),O=null),q=null,l=null,document.removeEventListener("pointermove",w),document.removeEventListener("pointerup",K),document.removeEventListener("pointercancel",A),document.removeEventListener("keydown",k),document.removeEventListener("contextmenu",X)}function f(){q&&l&&p&&($(l,q),q=null,l=null),O=null}function g(D){if(!(D.button!==0||e.operation||e.draggables.get(o)?.disabled)){c=!0,M={x:D.clientX,y:D.clientY},R=u===0;try{t.setPointerCapture(D.pointerId)}catch{}u>0&&(x=setTimeout(()=>{R=!0,x=null},u)),document.addEventListener("pointermove",w),document.addEventListener("pointerup",K),document.addEventListener("pointercancel",A),document.addEventListener("keydown",k),document.addEventListener("contextmenu",X)}}function w(D){if(!c&&!p||!M)return;let V={x:D.clientX,y:D.clientY};if(!p){let ye=B(M,V);if(!R){ye>s&&h();return}if(ye<s)return;p=!0,c=!1,ce(D,o);return}q=V,l=D,O===null&&(O=requestAnimationFrame(f))}function K(D){p&&(q&&$(D,q),le(D));try{t.releasePointerCapture(D.pointerId)}catch{}h()}function A(D){p&&W(D);try{t.releasePointerCapture(D.pointerId)}catch{}h()}function k(D){D.key==="Escape"&&p&&(W(D),h())}function X(D){(p||c)&&D.preventDefault()}t.addEventListener("pointerdown",g);let N=()=>{h(),t.removeEventListener("pointerdown",g),_.delete(N)};return _.add(N),N}function Xe(t,o,r){if(a(),!Y())return()=>{};let s=r?.step??25,u=r?.fastStep??s*5,c=!1;function p(l){if(!e.draggables.get(o)?.disabled){if(!c){(l.key===" "||l.key==="Enter")&&(l.preventDefault(),c=!0,ce(l,o));return}switch(l.preventDefault(),l.key){case"Escape":c=!1,W(l);break;case"Tab":c=!1,W(l);break;case" ":case"Enter":c=!1,le(l);break;case"ArrowUp":case"ArrowDown":case"ArrowLeft":case"ArrowRight":if(!e.operation)break;if(e.sortable!==null)M(l);else{let f=l.shiftKey?u:s,g=e.operation.current,w={x:g.x,y:g.y};l.key==="ArrowUp"&&(w.y-=f),l.key==="ArrowDown"&&(w.y+=f),l.key==="ArrowLeft"&&(w.x-=f),l.key==="ArrowRight"&&(w.x+=f),$(l,w)}break;case"Home":case"End":e.sortable&&x(l);break}}}function M(l){if(!e.operation||!e.sortable)return;let{currentContainerId:h,projectedIndex:f}=e.sortable,g=e.sortableContainers.get(h);if(!g)return;let w=g.direction==="vertical"||g.direction==="grid",K=g.direction==="horizontal"||g.direction==="grid",A=f,k=h;if(l.key==="ArrowUp"&&w||l.key==="ArrowLeft"&&K)A>0&&A--;else if(l.key==="ArrowDown"&&w||l.key==="ArrowRight"&&K){let X=g.items.filter(N=>N!==e.operation.activeId).length;A<X&&A++}else if(l.key==="ArrowLeft"||l.key==="ArrowRight"){let X=O(h,l.key==="ArrowRight"?"right":"left");X&&(k=X.id,A=0)}(A!==f||k!==h)&&R(k,A,l)}function x(l){if(!e.operation||!e.sortable)return;let h=e.sortableContainers.get(e.sortable.currentContainerId);if(!h)return;let f=h.items.filter(w=>w!==e.operation.activeId),g=l.key==="Home"?f[0]:f[f.length-1];if(g!=null){let w=z(g,y);w&&$(l,H(w))}}function R(l,h,f){let g=e.sortableContainers.get(l);if(!g)return;let w=g.items.filter(A=>A!==e.operation.activeId),K=w[Math.min(h,w.length-1)];if(K!=null){let A=z(K,y);if(A){$(f,H(A));let k=e.draggables.get(K);k?.node&&k.node.scrollIntoView({block:"nearest",inline:"nearest",behavior:"smooth"})}}}function O(l,h){let f=z(l,y);if(!f)return null;let g=H(f),w=null,K=1/0;for(let[A,k]of e.sortableContainers){if(A===l)continue;let X=z(A,y);if(!X)continue;let N=H(X);if(h==="right"&&N.x<=g.x||h==="left"&&N.x>=g.x)continue;let D=e.draggables.get(e.operation.activeId);if(k.accept&&D?.scope!=null&&!k.accept.includes(D.scope))continue;let V=B(g,N);V<K&&(K=V,w=k)}return w}t.addEventListener("keydown",p);let q=()=>{c&&(c=!1,W()),t.removeEventListener("keydown",p),_.delete(q)};return _.add(q),q}function Ye(t){return a(),v(o=>{let r=new Map(o.draggables);return r.set(t.id,t),{...o,draggables:r}}),()=>{e.operation?.activeId===t.id&&W(),v(o=>{let r=new Map(o.draggables);return r.delete(t.id),{...o,draggables:r}})}}function Ne(t){return a(),v(o=>{let r=new Map(o.droppables);return r.set(t.id,t),{...o,droppables:r}}),()=>{v(o=>{let r=new Map(o.droppables);return r.delete(t.id),{...o,droppables:r}})}}function Fe(t){return a(),v(o=>{let r=new Map(o.sortableContainers);return r.set(t.id,t),{...o,sortableContainers:r}}),t.node&&F&&F.observe(t.node),()=>{t.node&&F&&F.unobserve(t.node),v(o=>{let r=new Map(o.sortableContainers);return r.delete(t.id),{...o,sortableContainers:r}})}}function Be(t,o){let r=G[t];return r?r(o):""}return Y()&&(Ae(),Ue()),{getState:()=>e,subscribe(t){return a(),d.add(t),()=>{d.delete(t)}},registerDraggable:Ye,registerDroppable:Ne,registerSortableContainer:Fe,startDrag:ce,updateDrag:$,endDrag:le,cancelDrag:W,on(t,o){a(),E.has(t)||E.set(t,new Set);let r=E.get(t),s=o;return r.add(s),()=>{r.delete(s)}},attachPointerSensor:je,attachKeyboardSensor:Xe,setScrollableElement(t){m=t},setCollisionDetection(t){C=t},measureRects:ie,getAdjustedRect:z,getAnnouncement:Be,destroy(){if(!n){n=!0,e.operation&&(S("dragCancel",{active:{id:e.operation.activeId,data:e.operation.data}}),S("dragEnd",{active:{id:e.operation.activeId,data:e.operation.data},over:null,cancelled:!0}),ve(),me());for(let t of _)t();_.clear(),F?.disconnect(),F=null,se?.(),se=null,J.cancel(),re.cancel(),E.clear(),d.clear(),j.clear(),e={operation:null,draggables:new Map,droppables:new Map,sortableContainers:new Map,collisions:[],sortable:null}}}}}export{Pe as arrayMove,Te as arrayTransfer,ee as collisionStrategies,Ge as createDnd};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sortable collision detection and transform computation for createDnd.
|
|
3
|
+
*/
|
|
4
|
+
import type { DropPosition, Point, Rect, SortDirection, Transform, UniqueId } from '@primereact/types/primitive/dnd';
|
|
5
|
+
export interface SortableCollisionInput {
|
|
6
|
+
position: Point;
|
|
7
|
+
items: Array<{
|
|
8
|
+
id: UniqueId;
|
|
9
|
+
rect: Rect;
|
|
10
|
+
}>;
|
|
11
|
+
direction: SortDirection;
|
|
12
|
+
activeId: UniqueId;
|
|
13
|
+
/** When true, the middle zone returns 'inside' (for Tree-like nested drops). */
|
|
14
|
+
allowInsideDrop?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface SortableCollisionResult {
|
|
17
|
+
index: number;
|
|
18
|
+
position: 'before' | 'after';
|
|
19
|
+
/** Drop indicator info for visual feedback. */
|
|
20
|
+
targetId: UniqueId | null;
|
|
21
|
+
/** Three-zone position: 'before' | 'after' | 'inside'. Only 'inside' when allowInsideDrop is true. */
|
|
22
|
+
dropPosition: DropPosition;
|
|
23
|
+
/** Rect of the closest target item. */
|
|
24
|
+
targetRect: Rect | null;
|
|
25
|
+
}
|
|
26
|
+
export declare function sortableCollision(input: SortableCollisionInput): SortableCollisionResult;
|
|
27
|
+
export interface ComputeTransformsInput {
|
|
28
|
+
items: UniqueId[];
|
|
29
|
+
activeId: UniqueId;
|
|
30
|
+
originalIndex: number;
|
|
31
|
+
projectedIndex: number;
|
|
32
|
+
activeRect: Rect | null;
|
|
33
|
+
itemRects: Map<UniqueId, Rect>;
|
|
34
|
+
direction: SortDirection;
|
|
35
|
+
}
|
|
36
|
+
export declare function computeShiftTransforms(input: ComputeTransformsInput): Map<UniqueId, Transform>;
|
|
37
|
+
export declare function computeCrossContainerTransforms(input: {
|
|
38
|
+
sourceItems: UniqueId[];
|
|
39
|
+
targetItems: UniqueId[];
|
|
40
|
+
activeId: UniqueId;
|
|
41
|
+
originalIndex: number;
|
|
42
|
+
projectedIndex: number;
|
|
43
|
+
activeRect: Rect | null;
|
|
44
|
+
sourceDirection: SortDirection;
|
|
45
|
+
targetDirection: SortDirection;
|
|
46
|
+
}): {
|
|
47
|
+
sourceTransforms: Map<UniqueId, Transform>;
|
|
48
|
+
targetTransforms: Map<UniqueId, Transform>;
|
|
49
|
+
};
|
|
50
|
+
/** Immutably moves an item within an array. Returns original array if indices are out of bounds. */
|
|
51
|
+
export declare function arrayMove<T>(arr: readonly T[], fromIndex: number, toIndex: number): T[];
|
|
52
|
+
/** Immutably transfers an item between two arrays. Returns originals if indices are out of bounds. */
|
|
53
|
+
export declare function arrayTransfer<T>(source: readonly T[], target: readonly T[], fromIndex: number, toIndex: number): {
|
|
54
|
+
source: T[];
|
|
55
|
+
target: T[];
|
|
56
|
+
};
|