@agnos-ui/core
Advanced tools
Comparing version 0.4.4 to 0.5.0-next.0
import type { TransitionFn } from '../../services/transitions/baseTransitions'; | ||
import type { ConfigValidator, Directive, PropsConfig, Widget, WidgetFactory } from '../../types'; | ||
import type { WidgetsCommonPropsAndState } from '../commonProps'; | ||
/** | ||
* Properties for the Accordion component. | ||
*/ | ||
export interface AccordionProps extends WidgetsCommonPropsAndState { | ||
@@ -92,2 +95,5 @@ /** | ||
} | ||
/** | ||
* Represents the state of an Accordion component. | ||
*/ | ||
export interface AccordionState extends WidgetsCommonPropsAndState { | ||
@@ -99,2 +105,5 @@ /** | ||
} | ||
/** | ||
* Interface representing the API for an accordion component. | ||
*/ | ||
export interface AccordionApi { | ||
@@ -134,2 +143,5 @@ /** | ||
} | ||
/** | ||
* Interface representing the directives used in the Accordion component. | ||
*/ | ||
export interface AccordionDirectives { | ||
@@ -141,9 +153,9 @@ /** | ||
} | ||
export type AccordionWidget = Widget<AccordionProps, AccordionState, AccordionApi, object, AccordionDirectives>; | ||
export interface AccordionItemActions { | ||
/** | ||
* Action to be called when the user clicks on the accordion-item button. If the accordion-item is disabled nothing will happen. | ||
*/ | ||
click(): void; | ||
} | ||
/** | ||
* Represents an Accordion widget with specific properties, state, API, and directives. | ||
*/ | ||
export type AccordionWidget = Widget<AccordionProps, AccordionState, AccordionApi, AccordionDirectives>; | ||
/** | ||
* Interface representing the API for an accordion item. | ||
*/ | ||
export interface AccordionItemApi { | ||
@@ -167,2 +179,5 @@ /** | ||
} | ||
/** | ||
* Interface representing the directives used in an accordion item. | ||
*/ | ||
export interface AccordionItemDirectives { | ||
@@ -202,2 +217,5 @@ /** | ||
} | ||
/** | ||
* Interface representing the common properties and state for an accordion item. | ||
*/ | ||
interface AccordionItemCommonPropsAndState extends WidgetsCommonPropsAndState { | ||
@@ -239,2 +257,5 @@ /** | ||
} | ||
/** | ||
* Properties for an AccordionItem component. | ||
*/ | ||
export interface AccordionItemProps extends AccordionItemCommonPropsAndState { | ||
@@ -268,2 +289,5 @@ /** | ||
} | ||
/** | ||
* Represents the state of an accordion item. | ||
*/ | ||
export interface AccordionItemState extends AccordionItemCommonPropsAndState { | ||
@@ -276,4 +300,7 @@ /** | ||
} | ||
export type AccordionItemWidget = Widget<AccordionItemProps, AccordionItemState, AccordionItemApi, AccordionItemActions, AccordionItemDirectives>; | ||
/** | ||
* Represents a widget for an accordion item. | ||
*/ | ||
export type AccordionItemWidget = Widget<AccordionItemProps, AccordionItemState, AccordionItemApi, AccordionItemDirectives>; | ||
/** | ||
* Retrieve a shallow copy of the default accordion config | ||
@@ -280,0 +307,0 @@ * @returns the default accordion config |
@@ -1,2 +0,2 @@ | ||
import { a, c, f, g } from "../../accordion-BnaSamoQ.js"; | ||
import { a, c, f, g } from "../../accordion-BGv150k9.js"; | ||
export { | ||
@@ -3,0 +3,0 @@ a as createAccordion, |
import type { CommonAlertApi, CommonAlertDirectives, CommonAlertProps, CommonAlertState } from './common'; | ||
import type { Widget, WidgetFactory } from '../../types'; | ||
/** | ||
* Represents the state of an alert component. | ||
*/ | ||
export interface AlertState extends CommonAlertState { | ||
} | ||
/** | ||
* Represents the properties for the alert component. | ||
*/ | ||
export interface AlertProps extends CommonAlertProps { | ||
} | ||
/** | ||
* Represents the API for an alert component. | ||
*/ | ||
export interface AlertApi extends CommonAlertApi { | ||
} | ||
/** | ||
* Represents the directives for an alert component. | ||
*/ | ||
export interface AlertDirectives extends CommonAlertDirectives { | ||
} | ||
export type AlertWidget = Widget<AlertProps, AlertState, AlertApi, object, AlertDirectives>; | ||
/** | ||
* Represents an alert widget with specific properties, state, API, and directives. | ||
*/ | ||
export type AlertWidget = Widget<AlertProps, AlertState, AlertApi, AlertDirectives>; | ||
/** | ||
* Retrieve a shallow copy of the default alert config | ||
@@ -14,0 +29,0 @@ * @returns the default alert config |
import type { TransitionFn } from '../../services/transitions/baseTransitions'; | ||
import type { WidgetsCommonPropsAndState } from '../commonProps'; | ||
import type { Directive, PropsConfig, Widget } from '../../types'; | ||
/** | ||
* Interface representing the common properties and state for an alert component. | ||
*/ | ||
export interface CommonAlertCommonPropsAndState extends WidgetsCommonPropsAndState { | ||
@@ -25,2 +28,5 @@ /** | ||
} | ||
/** | ||
* Represents the state of a common alert component. | ||
*/ | ||
export interface CommonAlertState extends CommonAlertCommonPropsAndState { | ||
@@ -32,2 +38,5 @@ /** | ||
} | ||
/** | ||
* Interface representing the common properties for an alert component. | ||
*/ | ||
export interface CommonAlertProps extends CommonAlertCommonPropsAndState { | ||
@@ -91,2 +100,5 @@ /** | ||
} | ||
/** | ||
* Interface representing the common API for alert components. | ||
*/ | ||
export interface CommonAlertApi { | ||
@@ -102,2 +114,5 @@ /** | ||
} | ||
/** | ||
* Interface representing common alert directives. | ||
*/ | ||
export interface CommonAlertDirectives { | ||
@@ -109,4 +124,7 @@ /** | ||
} | ||
export type CommonAlertWidget = Widget<CommonAlertProps, CommonAlertState, CommonAlertApi, object, CommonAlertDirectives>; | ||
/** | ||
* Represents a common alert widget with specified properties, state, API, and directives. | ||
*/ | ||
export type CommonAlertWidget = Widget<CommonAlertProps, CommonAlertState, CommonAlertApi, CommonAlertDirectives>; | ||
/** | ||
* Retrieve a shallow copy of the default alert config | ||
@@ -113,0 +131,0 @@ * @returns the default alert config |
@@ -1,2 +0,2 @@ | ||
import { c, g } from "../../alert-DdGuK__c.js"; | ||
import { c, g } from "../../alert-DJ2l7bcA.js"; | ||
export { | ||
@@ -3,0 +3,0 @@ c as createAlert, |
@@ -0,1 +1,4 @@ | ||
/** | ||
* Interface representing the common properties and state for widgets. | ||
*/ | ||
export interface WidgetsCommonPropsAndState { | ||
@@ -2,0 +5,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
import { c, g, a, m } from "../../modal-CeTI4jxI.js"; | ||
import { c, g, a, m } from "../../modal-DP-4I7vf.js"; | ||
export { | ||
@@ -3,0 +3,0 @@ c as createModal, |
@@ -197,20 +197,2 @@ import type { WidgetsCommonPropsAndState } from '../commonProps'; | ||
/** | ||
* Actions of the modal widget. | ||
*/ | ||
export interface ModalActions { | ||
/** | ||
* Action to be called when the user clicks on the close button. It closes the modal with the {@link modalCloseButtonClick} result. | ||
* @param event - mouse event | ||
*/ | ||
closeButtonClick(event: Pick<MouseEvent, never>): void; | ||
/** | ||
* Action to be called when the user clicks on the modal DOM element (which is supposed to have the size of the full viewport). | ||
* If the click is not done on a descendant of the modal DOM element, it is considered to be done outside the modal | ||
* and, depending on the value of the {@link ModalProps.closeOnOutsideClick|closeOnOutsideClick} prop, the modal is or isn't closed | ||
* (with the {@link modalOutsideClick} result). | ||
* @param event - mouse event | ||
*/ | ||
modalClick(event: Pick<MouseEvent, 'target' | 'currentTarget'>): void; | ||
} | ||
/** | ||
* Directives of the modal widget. | ||
@@ -240,3 +222,3 @@ */ | ||
/** | ||
* Directive to apply to the dialog element when using the native [HTMLDialogElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement) | ||
* Directive to apply to the dialog element when using the native {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement | HTMLDialogElement} | ||
*/ | ||
@@ -248,3 +230,3 @@ dialogDirective: Directive; | ||
*/ | ||
export type ModalWidget = Widget<ModalProps, ModalState, ModalApi, ModalActions, ModalDirectives>; | ||
export type ModalWidget = Widget<ModalProps, ModalState, ModalApi, ModalDirectives>; | ||
/** | ||
@@ -254,117 +236,3 @@ * Returns a copy of the default modal config. | ||
*/ | ||
export declare function getModalDefaultConfig(): { | ||
/** | ||
* Whether the modal and its backdrop (if present) should be animated when shown or hidden. | ||
* | ||
* @defaultValue `true` | ||
*/ | ||
animated: boolean; | ||
/** | ||
* Whether a backdrop should be created behind the modal. | ||
* | ||
* @defaultValue `true` | ||
*/ | ||
backdrop: boolean; | ||
/** | ||
* The transition to use for the backdrop behind the modal (if present). | ||
* | ||
* @defaultValue | ||
* ```ts | ||
* async () => {} | ||
* ``` | ||
*/ | ||
backdropTransition: TransitionFn; | ||
/** | ||
* Whether the modal should be closed when clicking on the viewport outside the modal. | ||
* | ||
* @defaultValue `true` | ||
*/ | ||
closeOnOutsideClick: boolean; | ||
/** | ||
* The transition to use for the modal. | ||
* | ||
* @defaultValue | ||
* ```ts | ||
* async () => {} | ||
* ``` | ||
*/ | ||
modalTransition: TransitionFn; | ||
/** | ||
* Event to be triggered when the modal is about to be closed (i.e. the {@link ModalApi.close|close} method was called). | ||
* | ||
* @param event - event giving access to the argument given to the {@link ModalApi.close|close} method and allowing | ||
* to cancel the close process. | ||
* | ||
* @defaultValue | ||
* ```ts | ||
* () => {} | ||
* ``` | ||
*/ | ||
onBeforeClose: (event: ModalBeforeCloseEvent) => void; | ||
/** | ||
* Event to be triggered when the visible property changes. | ||
* | ||
* @param visible - new value of the visible propery | ||
* | ||
* @defaultValue | ||
* ```ts | ||
* () => {} | ||
* ``` | ||
*/ | ||
onVisibleChange: (visible: boolean) => void; | ||
/** | ||
* Event to be triggered when the transition is completed and the modal is not visible. | ||
* | ||
* @defaultValue | ||
* ```ts | ||
* () => {} | ||
* ``` | ||
*/ | ||
onHidden: () => void; | ||
/** | ||
* Event to be triggered when the transition is completed and the modal is visible. | ||
* | ||
* @defaultValue | ||
* ```ts | ||
* () => {} | ||
* ``` | ||
*/ | ||
onShown: () => void; | ||
/** | ||
* Value of the aria-label attribute to put on the close button. | ||
* | ||
* @defaultValue `'Close'` | ||
*/ | ||
ariaCloseButtonLabel: string; | ||
/** | ||
* Classes to add on the backdrop DOM element. | ||
* | ||
* @defaultValue `''` | ||
*/ | ||
backdropClass: string; | ||
/** | ||
* Whether to display the close button. | ||
* | ||
* @defaultValue `true` | ||
*/ | ||
closeButton: boolean; | ||
/** | ||
* Which element should contain the modal and backdrop DOM elements. | ||
* If it is not null, the modal and backdrop DOM elements are moved to the specified container. | ||
* Otherwise, they stay where the widget is located. | ||
* | ||
* @defaultValue | ||
* ```ts | ||
* typeof window !== 'undefined' ? document.body : null | ||
* ``` | ||
*/ | ||
container: HTMLElement | null; | ||
/** | ||
* Whether the modal should be visible when the transition is completed. | ||
* | ||
* @defaultValue `false` | ||
*/ | ||
visible: boolean; | ||
className: string; | ||
}; | ||
export declare function getModalDefaultConfig(): ModalProps; | ||
/** | ||
@@ -371,0 +239,0 @@ * Creates a new modal widget instance. |
@@ -1,2 +0,2 @@ | ||
import { c, g } from "../../pagination-BpPHKQsH.js"; | ||
import { c, g } from "../../pagination-DwDRot6q.js"; | ||
export { | ||
@@ -3,0 +3,0 @@ c as createPagination, |
import type { PropsConfig, Widget, Directive } from '../../types'; | ||
import type { WidgetsCommonPropsAndState } from '../commonProps'; | ||
/** | ||
* Interface representing the common properties and state for a pagination component. | ||
*/ | ||
interface PaginationCommonPropsAndState extends WidgetsCommonPropsAndState { | ||
@@ -13,10 +16,2 @@ /** | ||
/** | ||
* The pagination display size. | ||
* | ||
* Bootstrap currently supports small and large sizes. | ||
* | ||
* @defaultValue `null` | ||
*/ | ||
size: 'sm' | 'lg' | null; | ||
/** | ||
* The label for the nav element. | ||
@@ -112,2 +107,5 @@ * | ||
} | ||
/** | ||
* Interface representing the properties for the Pagination component. | ||
*/ | ||
export interface PaginationProps extends PaginationCommonPropsAndState { | ||
@@ -189,3 +187,3 @@ /** | ||
* ```ts | ||
* (currentPage: number, pageCount: number) => `Current page is ${currentPage}` | ||
* (currentPage: number) => `Current page is ${currentPage}` | ||
* ``` | ||
@@ -206,2 +204,5 @@ */ | ||
} | ||
/** | ||
* Interface representing the hrefs for pagination navigation links. | ||
*/ | ||
export interface DirectionsHrefs { | ||
@@ -217,2 +218,5 @@ /** | ||
} | ||
/** | ||
* Represents the state of the pagination component. | ||
*/ | ||
export interface PaginationState extends PaginationCommonPropsAndState { | ||
@@ -246,3 +250,6 @@ /** | ||
} | ||
export interface PaginationActions { | ||
/** | ||
* Interface representing pagination API for navigating through pages. | ||
*/ | ||
export interface PaginationApi { | ||
/** | ||
@@ -252,20 +259,23 @@ * To "go" to a specific page | ||
*/ | ||
select(page: number, event?: MouseEvent): void; | ||
select(page: number): void; | ||
/** | ||
* To "go" to the first page | ||
*/ | ||
first(event?: MouseEvent): void; | ||
first(): void; | ||
/** | ||
* To "go" to the previous page | ||
*/ | ||
previous(event?: MouseEvent): void; | ||
previous(): void; | ||
/** | ||
* To "go" to the next page | ||
*/ | ||
next(event?: MouseEvent): void; | ||
next(): void; | ||
/** | ||
* To "go" to the last page | ||
*/ | ||
last(event?: MouseEvent): void; | ||
last(): void; | ||
} | ||
/** | ||
* Interface representing the directives for pagination components. | ||
*/ | ||
export interface PaginationDirectives { | ||
@@ -296,208 +306,11 @@ /** | ||
} | ||
export interface PaginationApi { | ||
} | ||
export type PaginationWidget = Widget<PaginationProps, PaginationState, PaginationApi, PaginationActions, PaginationDirectives>; | ||
/** | ||
* Represents a pagination widget with specific properties, state, API, actions, and directives. | ||
*/ | ||
export type PaginationWidget = Widget<PaginationProps, PaginationState, PaginationApi, PaginationDirectives>; | ||
/** | ||
* Returns a shallow copy of the default pagination config | ||
* @returns a copy of the default config | ||
*/ | ||
export declare function getPaginationDefaultConfig(): { | ||
/** | ||
* The number of items in your paginated collection. | ||
* | ||
* Note, that this is not the number of pages. Page numbers are calculated dynamically based on | ||
* `collectionSize` and `pageSize`. | ||
* | ||
* Ex. if you have 100 items in your collection and displaying 20 items per page, you'll end up with 5 pages. | ||
* | ||
* Whatever the collectionSize the page number is of minimum 1. | ||
* | ||
* @defaultValue `0` | ||
*/ | ||
collectionSize: number; | ||
/** | ||
* The number of items per page. | ||
* @remarks min value is 1 | ||
* | ||
* @defaultValue `10` | ||
*/ | ||
pageSize: number; | ||
/** | ||
* An event fired when the page is changed. | ||
* | ||
* Event payload is the number of the newly selected page. | ||
* | ||
* Page numbers start with `1`. | ||
* @defaultValue | ||
* ```ts | ||
* () => {} | ||
* ``` | ||
*/ | ||
onPageChange: (page: number) => void; | ||
/** | ||
* pagesFactory returns a function computing the array of pages to be displayed | ||
* as number (-1 are treated as ellipsis). | ||
* Use Page slot to customize the pages view and not this | ||
* @param page - The current page number | ||
* @param pageCount - The total number of pages | ||
* | ||
* @defaultValue | ||
* ```ts | ||
* (_page: number, pageCount: number) => { | ||
* const pages: number[] = []; | ||
* for (let i = 1; i <= pageCount; i++) { | ||
* pages.push(i); | ||
* } | ||
* return pages; | ||
* } | ||
* ``` | ||
*/ | ||
pagesFactory: (page: number, pageCount: number) => number[]; | ||
/** | ||
* Provide the label for each "Page" page button. | ||
* This is used for accessibility purposes. | ||
* for I18n, we suggest to use the global configuration | ||
* override any configuration parameters provided for this | ||
* @param processPage - The current page number | ||
* @param pageCount - The total number of pages | ||
* | ||
* @defaultValue | ||
* ```ts | ||
* (processPage: number, pageCount: number) => `Page ${processPage} of ${pageCount}` | ||
* ``` | ||
*/ | ||
ariaPageLabel: (processPage: number, pageCount: number) => string; | ||
/** | ||
* Provide the label for the aria-live element | ||
* This is used for accessibility purposes. | ||
* for I18n, we suggest to use the global configuration | ||
* override any configuration parameters provided for this | ||
* @param currentPage - The current page number | ||
* @param pageCount - The total number of pages | ||
* | ||
* @defaultValue | ||
* ```ts | ||
* (currentPage: number, pageCount: number) => `Current page is ${currentPage}` | ||
* ``` | ||
*/ | ||
ariaLiveLabel: (currentPage: number, pageCount: number) => string; | ||
/** | ||
* Factory function providing the href for a "Page" page anchor, | ||
* based on the current page number | ||
* @param pageNumber - The index to use in the link | ||
* | ||
* @defaultValue | ||
* ```ts | ||
* (_page: number) => PAGE_LINK_DEFAULT | ||
* ``` | ||
*/ | ||
pageLink: (pageNumber: number) => string; | ||
/** | ||
* The current page. | ||
* | ||
* Page numbers start with `1`. | ||
* | ||
* @defaultValue `1` | ||
*/ | ||
page: number; | ||
/** | ||
* The pagination display size. | ||
* | ||
* Bootstrap currently supports small and large sizes. | ||
* | ||
* @defaultValue `null` | ||
*/ | ||
size: "sm" | "lg" | null; | ||
/** | ||
* The label for the nav element. | ||
* | ||
* for I18n, we suggest to use the global configuration | ||
* override any configuration parameters provided for this | ||
* | ||
* @defaultValue `'Page navigation'` | ||
*/ | ||
ariaLabel: string; | ||
/** | ||
* The label for the "active" page. | ||
* for I18n, we suggest to use the global configuration | ||
* override any configuration parameters provided for this | ||
* | ||
* @defaultValue | ||
* ```ts | ||
* '(current)' | ||
* ``` | ||
*/ | ||
activeLabel: string; | ||
/** | ||
* The label for the "First" page button. | ||
* for I18n, we suggest to use the global configuration | ||
* override any configuration parameters provided for this | ||
* | ||
* @defaultValue | ||
* ```ts | ||
* 'Action link for first page' | ||
* ``` | ||
*/ | ||
ariaFirstLabel: string; | ||
/** | ||
* The label for the "Previous" page button. | ||
* for I18n, we suggest to use the global configuration | ||
* override any configuration parameters provided for this | ||
* | ||
* @defaultValue | ||
* ```ts | ||
* 'Action link for previous page' | ||
* ``` | ||
*/ | ||
ariaPreviousLabel: string; | ||
/** | ||
* The label for the "Next" page button. | ||
* for I18n, we suggest to use the global configuration | ||
* override any configuration parameters provided for this | ||
* | ||
* @defaultValue | ||
* ```ts | ||
* 'Action link for next page' | ||
* ``` | ||
*/ | ||
ariaNextLabel: string; | ||
/** | ||
* The label for the "Last" page button. | ||
* for I18n, we suggest to use the global configuration | ||
* override any configuration parameters provided for this | ||
* | ||
* @defaultValue | ||
* ```ts | ||
* 'Action link for last page' | ||
* ``` | ||
*/ | ||
ariaLastLabel: string; | ||
/** | ||
* The label for the "Ellipsis" page. | ||
* for I18n, we suggest to use the global configuration | ||
* override any configuration parameters provided for this | ||
* | ||
* @defaultValue `'Ellipsis page element'` | ||
*/ | ||
ariaEllipsisLabel: string; | ||
/** | ||
* If `true`, pagination links will be disabled. | ||
* | ||
* @defaultValue `false` | ||
*/ | ||
disabled: boolean; | ||
/** | ||
* If `true`, the "Next" and "Previous" page links are shown. | ||
* | ||
* @defaultValue `true` | ||
*/ | ||
directionLinks: boolean; | ||
/** | ||
* If `true`, the "First" and "Last" page links are shown. | ||
* | ||
* @defaultValue `false` | ||
*/ | ||
boundaryLinks: boolean; | ||
className: string; | ||
}; | ||
export declare function getPaginationDefaultConfig(): PaginationProps; | ||
/** | ||
@@ -504,0 +317,0 @@ * Create a PaginationWidget with given config props |
@@ -1,2 +0,2 @@ | ||
import { c, g } from "../../progressbar-BybOg5FE.js"; | ||
import { c, g } from "../../progressbar-CGmNq0cS.js"; | ||
export { | ||
@@ -3,0 +3,0 @@ c as createProgressbar, |
@@ -29,2 +29,5 @@ import type { Directive, PropsConfig, Widget } from '../../types'; | ||
} | ||
/** | ||
* Interface representing directives for a progress bar component. | ||
*/ | ||
export interface ProgressbarDirectives { | ||
@@ -36,2 +39,5 @@ /** | ||
} | ||
/** | ||
* Represents the state of a progress bar component. | ||
*/ | ||
export interface ProgressbarState extends ProgressbarCommonPropsAndState { | ||
@@ -55,2 +61,5 @@ /** | ||
} | ||
/** | ||
* Interface representing the properties for the Progressbar component. | ||
*/ | ||
export interface ProgressbarProps extends ProgressbarCommonPropsAndState { | ||
@@ -70,6 +79,7 @@ /** | ||
} | ||
export interface ProgressbarApi { | ||
} | ||
export type ProgressbarWidget = Widget<ProgressbarProps, ProgressbarState, ProgressbarApi, object, ProgressbarDirectives>; | ||
/** | ||
* Represents a Progressbar widget with specific properties, state, API, and directives. | ||
*/ | ||
export type ProgressbarWidget = Widget<ProgressbarProps, ProgressbarState, object, ProgressbarDirectives>; | ||
/** | ||
* Retrieve a shallow copy of the default Progressbar config | ||
@@ -76,0 +86,0 @@ * @returns the default Progressbar config |
@@ -1,2 +0,2 @@ | ||
import { c, g } from "../../rating-D6Tv_4Vx.js"; | ||
import { c, g } from "../../rating-Da38uaZz.js"; | ||
export { | ||
@@ -3,0 +3,0 @@ c as createRating, |
import type { Directive, PropsConfig, Widget } from '../../types'; | ||
import type { WidgetsCommonPropsAndState } from '../commonProps'; | ||
/** | ||
* Represents the context for a star in a rating component. | ||
*/ | ||
export interface StarContext { | ||
@@ -66,2 +69,5 @@ /** | ||
} | ||
/** | ||
* Interface representing the properties for the Rating widget. | ||
*/ | ||
export interface RatingProps extends RatingCommonPropsAndState { | ||
@@ -113,2 +119,5 @@ /** | ||
} | ||
/** | ||
* Interface representing directives for a rating component. | ||
*/ | ||
export interface RatingDirectives { | ||
@@ -127,2 +136,5 @@ /** | ||
} | ||
/** | ||
* Represents the state of a rating component. | ||
*/ | ||
export interface RatingState extends RatingCommonPropsAndState { | ||
@@ -146,133 +158,32 @@ /** | ||
} | ||
export interface RatingActions { | ||
/** | ||
* Interface representing the API that can be performed on a rating component. | ||
*/ | ||
export interface RatingApi { | ||
/** | ||
* Method to be used when a star is clicked. | ||
* Sets the rating value. | ||
* | ||
* To be used in the onclick event of a star | ||
* @param index - Star index, starting from 1 | ||
*/ | ||
click(index: number): void; | ||
setRating(index: number): void; | ||
/** | ||
* Method to be used when the mouse enter in a star. | ||
* Sets the hovered rating value. | ||
* | ||
* To be used in the onmouseenter of a star | ||
* @param index - Star index, starting from 1 | ||
*/ | ||
hover(index: number): void; | ||
setHoveredRating(index: number): void; | ||
/** | ||
* Method to be used when the mouse leave the widget. | ||
* | ||
* To be used in the onmouseleave of the rating container | ||
* Leave the rating, resetting the visible rating to the rating value and triggering the onLeave callback | ||
*/ | ||
leave(): void; | ||
/** | ||
* Method to be used to handle the keyboard. | ||
* | ||
* To be used in the onkeydown of the rating container | ||
*/ | ||
handleKey(event: KeyboardEvent): void; | ||
} | ||
export type RatingWidget = Widget<RatingProps, RatingState, object, RatingActions, RatingDirectives>; | ||
/** | ||
* Represents a Rating widget. | ||
*/ | ||
export type RatingWidget = Widget<RatingProps, RatingState, RatingApi, RatingDirectives>; | ||
/** | ||
* Returns a shallow copy of the default rating config. | ||
* @returns a copy of the default config | ||
*/ | ||
export declare function getRatingDefaultConfig(): { | ||
/** | ||
* Return the value for the 'aria-valuetext' attribute. | ||
* @param rating - Current rating value. | ||
* @param maxRating - maxRating value. | ||
* | ||
* @defaultValue | ||
* ```ts | ||
* (rating: number, maxRating: number) => `${rating} out of ${maxRating}` | ||
* ``` | ||
*/ | ||
ariaValueTextFn: (rating: number, maxRating: number) => string; | ||
/** | ||
* An event emitted when the rating is changed. | ||
* | ||
* Event payload is equal to the newly selected rating. | ||
* | ||
* @defaultValue | ||
* ```ts | ||
* () => {} | ||
* ``` | ||
*/ | ||
onRatingChange: (rating: number) => void; | ||
/** | ||
* An event emitted when the user is hovering over a given rating. | ||
* | ||
* Event payload is equal to the rating being hovered over. | ||
* | ||
* @defaultValue | ||
* ```ts | ||
* () => {} | ||
* ``` | ||
*/ | ||
onHover: (rating: number) => void; | ||
/** | ||
* An event emitted when the user stops hovering over a given rating. | ||
* | ||
* Event payload is equal to the rating of the last item being hovered over. | ||
* | ||
* @defaultValue | ||
* ```ts | ||
* () => {} | ||
* ``` | ||
*/ | ||
onLeave: (rating: number) => void; | ||
/** | ||
* The current rating. Could be a decimal value like `3.75`. | ||
* | ||
* @defaultValue `0` | ||
*/ | ||
rating: number; | ||
/** | ||
* The maximum rating that can be given. | ||
* | ||
* @defaultValue `10` | ||
*/ | ||
maxRating: number; | ||
/** | ||
* If `true`, the rating is disabled. | ||
* | ||
* @defaultValue `false` | ||
*/ | ||
disabled: boolean; | ||
/** | ||
* If `true`, the rating can't be changed. | ||
* | ||
* @defaultValue `false` | ||
*/ | ||
readonly: boolean; | ||
/** | ||
* Define if the rating can be reset. | ||
* | ||
* If set to true, the user can 'unset' the rating value by cliking on the current rating value. | ||
* | ||
* @defaultValue `true` | ||
*/ | ||
resettable: boolean; | ||
/** | ||
* Allows setting a custom rating tabindex. | ||
* If the component is disabled, `tabindex` will still be set to `-1`. | ||
* | ||
* @defaultValue `0` | ||
*/ | ||
tabindex: number; | ||
/** | ||
* The aria label | ||
* | ||
* @defaultValue `'Rating'` | ||
*/ | ||
ariaLabel: string; | ||
/** | ||
* The aria labelled by | ||
* | ||
* @defaultValue `''` | ||
*/ | ||
ariaLabelledBy: string; | ||
className: string; | ||
}; | ||
export declare function getRatingDefaultConfig(): RatingProps; | ||
/** | ||
@@ -279,0 +190,0 @@ * Create a RatingWidget with given config props |
@@ -1,2 +0,2 @@ | ||
import { c, g } from "../../select-jUrt_lSn.js"; | ||
import { c, g } from "../../select-CAEPqdz1.js"; | ||
export { | ||
@@ -3,0 +3,0 @@ c as createSelect, |
@@ -66,2 +66,5 @@ import type { Placement } from '@floating-ui/dom'; | ||
} | ||
/** | ||
* Props for the Select component. | ||
*/ | ||
export interface SelectProps<Item> extends SelectCommonPropsAndState<Item> { | ||
@@ -152,2 +155,5 @@ /** | ||
} | ||
/** | ||
* Represents the state of a Select component. | ||
*/ | ||
export interface SelectState<Item> extends SelectCommonPropsAndState<Item> { | ||
@@ -172,2 +178,5 @@ /** | ||
} | ||
/** | ||
* Interface representing the API for a Select component. | ||
*/ | ||
export interface SelectApi<Item> { | ||
@@ -235,2 +244,5 @@ /** | ||
} | ||
/** | ||
* Interface representing the directives used in the Select component. | ||
*/ | ||
export interface SelectDirectives<Item> { | ||
@@ -265,159 +277,20 @@ /** | ||
itemAttributesDirective: Directive<ItemContext<Item>>; | ||
} | ||
export interface SelectActions<Item> { | ||
/** | ||
* Method to be plugged to on the 'input' event. The input text will be used as the filter text. | ||
* A directive to be applied to the input | ||
*/ | ||
onInput: (e: { | ||
target: any; | ||
}) => void; | ||
inputDirective: Directive; | ||
/** | ||
* Method to be attached to the node element to close a badge on click. | ||
* A directive to be applied to a button that closes a badge | ||
*/ | ||
onRemoveBadgeClick: (event: MouseEvent, item: Item) => void; | ||
/** | ||
* Method to be plugged to on an keydown event of the main input, in order to control the keyboard interactions with the highlighted item. | ||
* It manages arrow keys to move the highlighted item, or enter to toggle the item. | ||
*/ | ||
onInputKeydown: (event: KeyboardEvent) => void; | ||
/** | ||
* Method to be plugged to on an keydown event of a badge container, in order to manage main actions on badges. | ||
* | ||
* @param event - keyboard event | ||
* @param item - corresponding item | ||
*/ | ||
onBadgeKeydown: (event: KeyboardEvent, item: Item) => void; | ||
badgeCloseButtonDirective: Directive<ItemContext<Item>>; | ||
} | ||
export type SelectWidget<Item> = Widget<SelectProps<Item>, SelectState<Item>, SelectApi<Item>, SelectActions<Item>, SelectDirectives<Item>>; | ||
/** | ||
* Represents a Select widget component. | ||
*/ | ||
export type SelectWidget<Item> = Widget<SelectProps<Item>, SelectState<Item>, SelectApi<Item>, SelectDirectives<Item>>; | ||
/** | ||
* Returns a shallow copy of the default select config. | ||
* @returns a copy of the default config | ||
*/ | ||
export declare function getSelectDefaultConfig(): { | ||
/** | ||
* List of available items for the dropdown | ||
* | ||
* @defaultValue `[]` | ||
*/ | ||
items: any[]; | ||
/** | ||
* List of allowed placements for the dropdown. | ||
* This refers to the [allowedPlacements from floating UI](https://floating-ui.com/docs/autoPlacement#allowedplacements), given the different [Placement possibilities](https://floating-ui.com/docs/computePosition#placement). | ||
* | ||
* @defaultValue | ||
* ```ts | ||
* ['bottom-start', 'top-start', 'bottom-end', 'top-end'] | ||
* ``` | ||
*/ | ||
allowedPlacements: Placement[]; | ||
/** | ||
* Custom function to get the id of an item | ||
* By default, the item is returned | ||
* | ||
* @defaultValue | ||
* ```ts | ||
* (item: any) => '' + item | ||
* ``` | ||
*/ | ||
itemIdFn(item: any): string; | ||
/** | ||
* Retrieves navigable elements within an HTML element containing badges and the input. | ||
* | ||
* @param node - HTMLElement that contains the badges and the input | ||
* | ||
* @defaultValue | ||
* ```ts | ||
* (node: HTMLElement) => node.querySelectorAll('.au-select-badge,input') | ||
* ``` | ||
*/ | ||
navSelector(node: HTMLElement): NodeListOf<HTMLSpanElement | HTMLInputElement>; | ||
/** | ||
* Callback called dropdown open state change | ||
* @param isOpen - updated open state | ||
* | ||
* @defaultValue | ||
* ```ts | ||
* () => {} | ||
* ``` | ||
*/ | ||
onOpenChange(isOpen: boolean): void; | ||
/** | ||
* Callback called when the text filter change | ||
* @param text - Filtered text | ||
* | ||
* @defaultValue | ||
* ```ts | ||
* () => {} | ||
* ``` | ||
*/ | ||
onFilterTextChange(text: string): void; | ||
/** | ||
* Callback called when the selection change | ||
* | ||
* @defaultValue | ||
* ```ts | ||
* () => {} | ||
* ``` | ||
*/ | ||
onSelectedChange(selected: any[]): void; | ||
/** | ||
* id used for the input inside the select | ||
*/ | ||
id: string | undefined; | ||
/** | ||
* aria-label used for the input inside the select | ||
* | ||
* @defaultValue `'Select'` | ||
*/ | ||
ariaLabel: string | undefined; | ||
/** | ||
* List of selected item ids | ||
* | ||
* @defaultValue `[]` | ||
*/ | ||
selected: any[]; | ||
/** | ||
* Filtered text to be display in the filter input | ||
* | ||
* @defaultValue `''` | ||
*/ | ||
filterText: string; | ||
/** | ||
* true if the select is disabled | ||
* | ||
* @defaultValue `false` | ||
*/ | ||
disabled: boolean; | ||
/** | ||
* true if the select is open | ||
* | ||
* @defaultValue `false` | ||
*/ | ||
open: boolean; | ||
/** | ||
* Class to be added on the dropdown menu container | ||
* | ||
* @defaultValue `''` | ||
*/ | ||
menuClassName: string; | ||
/** | ||
* Class to be added on menu items | ||
* | ||
* @defaultValue `''` | ||
*/ | ||
menuItemClassName: string; | ||
/** | ||
* Class to be added on selected items (displayed in the input zone) | ||
* | ||
* @defaultValue `''` | ||
*/ | ||
badgeClassName: string; | ||
/** | ||
* true if a loading process is being done | ||
* | ||
* @defaultValue `false` | ||
*/ | ||
loading: boolean; | ||
className: string; | ||
}; | ||
export declare function getSelectDefaultConfig(): SelectProps<any>; | ||
/** | ||
@@ -424,0 +297,0 @@ * Create a SelectWidget with given config props |
@@ -1,2 +0,2 @@ | ||
import { c, g } from "../../slider-ByDkbyr1.js"; | ||
import { c, g } from "../../slider-DYrwS7Mv.js"; | ||
export { | ||
@@ -3,0 +3,0 @@ c as createSlider, |
import type { WidgetsCommonPropsAndState } from '../commonProps'; | ||
import type { Directive, PropsConfig, Widget } from '../../types'; | ||
/** | ||
* Options for displaying progress in a slider component. | ||
*/ | ||
export interface ProgressDisplayOptions { | ||
@@ -29,2 +32,5 @@ /** | ||
} | ||
/** | ||
* Options for displaying a handle in a slider component. | ||
*/ | ||
export interface HandleDisplayOptions { | ||
@@ -40,2 +46,5 @@ /** | ||
} | ||
/** | ||
* Represents a handle in a slider component. | ||
*/ | ||
export interface SliderHandle { | ||
@@ -121,2 +130,5 @@ /** | ||
} | ||
/** | ||
* Represents the state of a slider component. | ||
*/ | ||
export interface SliderState extends SliderCommonPropsAndState { | ||
@@ -164,2 +176,5 @@ /** | ||
} | ||
/** | ||
* Interface representing the properties for the Slider component. | ||
*/ | ||
export interface SliderProps extends SliderCommonPropsAndState { | ||
@@ -202,4 +217,5 @@ /** | ||
} | ||
export interface SliderApi { | ||
} | ||
/** | ||
* Interface representing various directives used in the slider component. | ||
*/ | ||
export interface SliderDirectives { | ||
@@ -221,2 +237,10 @@ /** | ||
/** | ||
* Directive to apply handle events handlers | ||
*/ | ||
handleEventsDirective: Directive<{ | ||
item: { | ||
id: number; | ||
}; | ||
}>; | ||
/** | ||
* Directive to apply to the slider handle if any | ||
@@ -246,130 +270,11 @@ */ | ||
} | ||
export interface SliderActions { | ||
/** | ||
* Method to handle click on the slider | ||
* @param event - mouse event | ||
*/ | ||
click(event: MouseEvent): void; | ||
/** | ||
* Method to process the keyboard event | ||
* @param event - keyboard event object | ||
* @param handleNumber - id of the modified handle | ||
*/ | ||
keydown(event: KeyboardEvent, handleNumber: number): void; | ||
/** | ||
* Method describing the behavior of the slider handle on mouse down event | ||
* @param event - mouse event | ||
* @param handleId - numeric id of the handle | ||
*/ | ||
mouseDown(event: MouseEvent, handleId: number): void; | ||
/** | ||
* Method describing the behavior of the slider handle on touch start event | ||
* @param event - touch event | ||
* @param handleId - number id of the handle | ||
*/ | ||
touchStart(event: TouchEvent, handleId: number): void; | ||
} | ||
export type SliderWidget = Widget<SliderProps, SliderState, SliderApi, SliderActions, SliderDirectives>; | ||
/** | ||
* Represents a slider widget component. | ||
*/ | ||
export type SliderWidget = Widget<SliderProps, SliderState, object, SliderDirectives>; | ||
/** | ||
* Returns a shallow copy of the default slider config. | ||
* @returns a copy of the default config | ||
*/ | ||
export declare function getSliderDefaultConfig(): { | ||
/** | ||
* Return the value for the 'aria-label' attribute for the handle | ||
* @param value - value of the handle | ||
* @param sortedIndex - index of the handle in the sorted list | ||
* @param index - index of the handle in the original list | ||
* | ||
* @defaultValue | ||
* ```ts | ||
* (value: number) => '' + value | ||
* ``` | ||
*/ | ||
ariaLabelHandle: (value: number, sortedIndex: number, index: number) => string; | ||
/** | ||
* Return the value for the 'aria-valuetext' attribute for the handle | ||
* @param value - value of the handle | ||
* @param sortedIndex - index of the handle in the sorted list | ||
* @param index - index of the handle in the original list | ||
* | ||
* @defaultValue | ||
* ```ts | ||
* (value: number) => '' + value | ||
* ``` | ||
*/ | ||
ariaValueText: (value: number, sortedIndex: number, index: number) => string; | ||
/** | ||
* An event emitted when slider values are changed | ||
* | ||
* Event payload equals to the updated slider values | ||
* | ||
* @defaultValue | ||
* ```ts | ||
* () => {} | ||
* ``` | ||
*/ | ||
onValuesChange: (values: number[]) => void; | ||
/** | ||
* Minimum value that can be assigned to the slider | ||
* | ||
* @defaultValue `0` | ||
*/ | ||
min: number; | ||
/** | ||
* Maximum value that can be assigned to the slider | ||
* | ||
* @defaultValue `100` | ||
*/ | ||
max: number; | ||
/** | ||
* Unit value between slider steps | ||
* | ||
* @defaultValue `1` | ||
*/ | ||
stepSize: number; | ||
/** | ||
* If `true` slider value cannot be changed but the slider is still focusable | ||
* | ||
* @defaultValue `false` | ||
*/ | ||
readonly: boolean; | ||
/** | ||
* If `true` slider value cannot be changed and the slider cannot be focused | ||
* | ||
* @defaultValue `false` | ||
*/ | ||
disabled: boolean; | ||
/** | ||
* If `true` is vertically positioned otherwise it is horizontal | ||
* | ||
* @defaultValue `false` | ||
*/ | ||
vertical: boolean; | ||
/** | ||
* Current slider values | ||
* | ||
* @defaultValue `[0]` | ||
*/ | ||
values: number[]; | ||
/** | ||
* If `true` the value labels are displayed on the slider | ||
* | ||
* @defaultValue `true` | ||
*/ | ||
showValueLabels: boolean; | ||
/** | ||
* If `true` the min and max labels are displayed on the slider | ||
* | ||
* @defaultValue `true` | ||
*/ | ||
showMinMaxLabels: boolean; | ||
/** | ||
* It `true` slider display is inversed | ||
* | ||
* @defaultValue `false` | ||
*/ | ||
rtl: boolean; | ||
className: string; | ||
}; | ||
export declare function getSliderDefaultConfig(): SliderProps; | ||
/** | ||
@@ -376,0 +281,0 @@ * Create a slider widget with given config props |
@@ -1,2 +0,2 @@ | ||
import { c, g } from "../../toast-BzxextBQ.js"; | ||
import { c, g } from "../../toast-CpvsibAI.js"; | ||
export { | ||
@@ -3,0 +3,0 @@ c as createToast, |
@@ -31,12 +31,27 @@ import type { Directive, PropsConfig, Widget } from '../../types'; | ||
} | ||
/** | ||
* Represents the state of a toast component. | ||
*/ | ||
export interface ToastState extends CommonAlertState, ToastExtraProps { | ||
} | ||
/** | ||
* Represents the properties for the toast component. | ||
*/ | ||
export interface ToastProps extends CommonAlertProps, ToastExtraProps { | ||
} | ||
/** | ||
* Represents the API for the toast component. | ||
*/ | ||
export interface ToastApi extends CommonAlertApi { | ||
} | ||
/** | ||
* Interface representing the directives for a toast component. | ||
*/ | ||
export interface ToastDirectives extends CommonAlertDirectives, ExtraDirectives { | ||
} | ||
export type ToastWidget = Widget<ToastProps, ToastState, ToastApi, object, ToastDirectives>; | ||
/** | ||
* Represents a toast widget with specific properties, state, API, and directives. | ||
*/ | ||
export type ToastWidget = Widget<ToastProps, ToastState, ToastApi, ToastDirectives>; | ||
/** | ||
* Retrieve a shallow copy of the default toast config | ||
@@ -43,0 +58,0 @@ * @returns the default toast config |
@@ -11,5 +11,18 @@ import type { ReadableSignal, WritableSignal } from '@amadeus-it-group/tansu'; | ||
import type { ToastProps } from './components/toast/toast'; | ||
/** | ||
* A utility type that makes all properties of an object type `T` optional, | ||
* and also makes all properties of the nested objects within `T` optional. | ||
* | ||
* @template T - The object type to be transformed. | ||
*/ | ||
export type Partial2Levels<T> = Partial<{ | ||
[Level1 in keyof T]: Partial<T[Level1]>; | ||
}>; | ||
/** | ||
* Represents a store for widget configurations with support for partial updates | ||
* at two levels of depth. This store includes signals for its own state, an optional | ||
* parent state, and an optional adapted parent state. | ||
* | ||
* @template T - The type of the widget configuration. | ||
*/ | ||
export type WidgetsConfigStore<T> = WritableSignal<Partial2Levels<T>> & { | ||
@@ -49,3 +62,6 @@ own$: WritableSignal<Partial2Levels<T>>; | ||
*/ | ||
export declare const createWidgetsConfig: <T>(parent$?: WidgetsConfigStore<T> | undefined, adaptParentConfig?: (config: Partial2Levels<T>) => Partial2Levels<T>) => WidgetsConfigStore<T>; | ||
export declare const createWidgetsConfig: <T>(parent$?: WidgetsConfigStore<T>, adaptParentConfig?: (config: Partial2Levels<T>) => Partial2Levels<T>) => WidgetsConfigStore<T>; | ||
/** | ||
* Configuration for various widgets used in the application. | ||
*/ | ||
export type WidgetsConfig = { | ||
@@ -52,0 +68,0 @@ /** |
30
index.js
@@ -1,11 +0,11 @@ | ||
import { INVALID_VALUE, toSlotContextWidget } from "./types.js"; | ||
import { a, c, f, g } from "./accordion-BnaSamoQ.js"; | ||
import { c as c2, g as g2 } from "./alert-DdGuK__c.js"; | ||
import { c as c3, g as g3, a as a2, m } from "./modal-CeTI4jxI.js"; | ||
import { c as c4, g as g4 } from "./pagination-BpPHKQsH.js"; | ||
import { c as c5, g as g5 } from "./progressbar-BybOg5FE.js"; | ||
import { c as c6, g as g6 } from "./rating-D6Tv_4Vx.js"; | ||
import { c as c7, g as g7 } from "./select-jUrt_lSn.js"; | ||
import { c as c8, g as g8 } from "./slider-ByDkbyr1.js"; | ||
import { c as c9, g as g9 } from "./toast-BzxextBQ.js"; | ||
import { INVALID_VALUE } from "./types.js"; | ||
import { a, c, f, g } from "./accordion-BGv150k9.js"; | ||
import { c as c2, g as g2 } from "./alert-DJ2l7bcA.js"; | ||
import { c as c3, g as g3, a as a2, m } from "./modal-DP-4I7vf.js"; | ||
import { c as c4, g as g4 } from "./pagination-DwDRot6q.js"; | ||
import { c as c5, g as g5 } from "./progressbar-CGmNq0cS.js"; | ||
import { c as c6, g as g6 } from "./rating-Da38uaZz.js"; | ||
import { c as c7, g as g7 } from "./select-CAEPqdz1.js"; | ||
import { c as c8, g as g8 } from "./slider-DYrwS7Mv.js"; | ||
import { c as c9, g as g9 } from "./toast-CpvsibAI.js"; | ||
import { createWidgetsConfig, mergeInto } from "./config.js"; | ||
@@ -20,3 +20,3 @@ import { extendWidgetProps } from "./services/extendWidget.js"; | ||
import { createResizeObserver } from "./services/resizeObserver.js"; | ||
import { sliblingsInert } from "./services/siblingsInert.js"; | ||
import { siblingsInert } from "./services/siblingsInert.js"; | ||
import { hash$ } from "./services/hash.js"; | ||
@@ -26,5 +26,5 @@ import { createTransition, noAnimation } from "./services/transitions/baseTransitions.js"; | ||
import { createSimpleClassTransition } from "./services/transitions/simpleClassTransition.js"; | ||
import { o, a as a3, c as c10, b, p, n, g as g10, j, f as f2, h, q, d, e, i, m as m2, k, l, r, s } from "./directive-3-8yr-ZK.js"; | ||
import { o, a as a3, c as c10, b, p, n, g as g10, j, f as f2, h, q, d, e, i, m as m2, k, l, r, s } from "./directive-CKEccryv.js"; | ||
import { bindableDerived, bindableProp, createPatch, findChangedProperties, isStore, mergeConfigStores, normalizeConfigStores, stateStores, toReadableStore, toWritableStore, writableWithDefault, writablesForProps, writablesWithDefault } from "./utils/stores.js"; | ||
import { t, h as h2, c as c11, d as d2, f as f3, g as g11, a as a4, b as b2, e as e2 } from "./writables-DoU_XYTX.js"; | ||
import { i as i2, t, h as h2, c as c11, d as d2, f as f3, g as g11, a as a4, b as b2, e as e2 } from "./writables-DCiBdIBK.js"; | ||
export { | ||
@@ -65,2 +65,3 @@ INVALID_VALUE, | ||
createTransition, | ||
i2 as createTypeEnum, | ||
createWidgetsConfig, | ||
@@ -100,3 +101,3 @@ q as directiveAttributes, | ||
r as registrationArray, | ||
sliblingsInert, | ||
siblingsInert, | ||
s as ssrAttributes, | ||
@@ -106,3 +107,2 @@ stateStores, | ||
toReadableStore, | ||
toSlotContextWidget, | ||
toWritableStore, | ||
@@ -109,0 +109,0 @@ h2 as typeArray, |
{ | ||
"name": "@agnos-ui/core", | ||
"description": "Framework-agnostic headless widget library.", | ||
"version": "0.4.4", | ||
"description": "Framework-agnostic headless component library.", | ||
"version": "0.5.0-next.0", | ||
"type": "module", | ||
@@ -48,7 +48,7 @@ "main": "./index.cjs", | ||
"@amadeus-it-group/tansu": "^1.0.0", | ||
"@floating-ui/dom": "^1.6.8", | ||
"esm-env": "^1.0.0" | ||
"@floating-ui/dom": "^1.6.11", | ||
"esm-env": "^1.1.4" | ||
}, | ||
"sideEffects": false, | ||
"homepage": "https://amadeusitgroup.github.io/AgnosUI/latest/", | ||
"homepage": "https://www.agnosui.dev/latest/", | ||
"bugs": "https://github.com/AmadeusITGroup/AgnosUI/issues", | ||
@@ -66,2 +66,3 @@ "license": "MIT", | ||
"alert", | ||
"collapse", | ||
"components", | ||
@@ -68,0 +69,0 @@ "modal", |
@@ -5,3 +5,3 @@ # @agnos-ui/core | ||
[AgnosUI](https://amadeusitgroup.github.io/AgnosUI/latest/) is a framework-agnostic widget library with adapters for multiple frameworks, either [Bootstrap](https://getbootstrap.com/)-based or headless: | ||
[AgnosUI](https://www.agnosui.dev/latest/) is a framework-agnostic component library with adapters for multiple frameworks, either [Bootstrap](https://getbootstrap.com/)-based or headless: | ||
@@ -14,4 +14,4 @@ - [Angular bootstrap](https://www.npmjs.com/package/@agnos-ui/angular-bootstrap), [Angular headless](https://www.npmjs.com/package/@agnos-ui/angular-headless) | ||
Please check [our demo site](https://amadeusitgroup.github.io/AgnosUI/latest/) to see all the available widgets and how to use them. | ||
Please check [our demo site](https://www.agnosui.dev/latest/) to see all the available components and how to use them. | ||
Unless you want to develop an adapter for a framework, you probably do not need to use `@agnos-ui/core` directly. Please refer to one of the framework-specific packages. |
import type { ConfigValidator, IsSlotContent, SlotContent, Widget, WidgetFactory, WidgetProps, WidgetSlotContext, WidgetState } from '../types'; | ||
/** | ||
* Type extending the original Widget props and state with ExtraProps | ||
* | ||
* @template W - The base widget type to be extended. | ||
* @template ExtraProps - Additional properties to be added to the widget. | ||
* @template ExtraDirectives - Additional directives to be added to the widget. Defaults to an empty object. | ||
*/ | ||
export type ExtendWidgetProps<W extends Widget, ExtraProps extends object, ExtraDirectives extends object = object> = Widget<ExtendWidgetAdaptSlotWidgetProps<WidgetProps<W>, ExtraProps, ExtraDirectives>, ExtendWidgetAdaptSlotWidgetProps<WidgetState<W>, ExtraProps, ExtraDirectives>, W['api'], W['actions'], ExtendWidgetInterfaces<W['directives'], ExtraDirectives>>; | ||
export type ExtendWidgetProps<W extends Widget, ExtraProps extends object, ExtraDirectives extends object = object> = Widget<ExtendWidgetAdaptSlotWidgetProps<WidgetProps<W>, ExtraProps, ExtraDirectives>, ExtendWidgetAdaptSlotWidgetProps<WidgetState<W>, ExtraProps, ExtraDirectives>, W['api'], ExtendWidgetInterfaces<W['directives'], ExtraDirectives>>; | ||
/** | ||
* Type merging the passed interfaces together | ||
* Combines two interface types into a single type. | ||
* | ||
* @template Interfaces - The base interface type. | ||
* @template ExtraInterfaces - The additional interface type to extend the base interface. | ||
* @typedef {Interfaces & ExtraInterfaces} ExtendWidgetInterfaces - The resulting type that includes properties from both Interfaces and ExtraInterfaces. | ||
*/ | ||
export type ExtendWidgetInterfaces<Interfaces, ExtraInterfaces> = Interfaces & ExtraInterfaces; | ||
/** | ||
* Type replacing the original Props with WidgetSlotContext contaning ExtraProps | ||
* Type to adapt the slot content properties of a widget by extending its props, extra props, and extra directives. | ||
* | ||
* @template Props - The original properties of the widget slot context. | ||
* @template ExtraProps - Additional properties to extend the widget slot context. | ||
* @template ExtraDirectives - Additional directives to extend the widget slot context. | ||
* | ||
* @remarks | ||
* This type conditionally checks if `Props` extends `WidgetSlotContext` and, if so, extends the widget slot context | ||
* with additional properties and directives while omitting the original widget slot context properties. | ||
*/ | ||
export type ExtendWidgetAdaptSlotContentProps<Props extends Record<string, any>, ExtraProps extends object, ExtraDirectives extends object> = Props extends WidgetSlotContext<infer U> ? WidgetSlotContext<ExtendWidgetProps<U, ExtraProps, ExtraDirectives>> & Omit<Props, keyof WidgetSlotContext<any>> : Props; | ||
/** | ||
* Type enriching the original widget slot Props with ExtraProps slots | ||
* Type definition for extending widget properties with additional properties and directives. | ||
* | ||
* This type takes three generic parameters: | ||
* - `Props`: The original properties of the widget. | ||
* - `ExtraProps`: Additional properties to be merged with the original properties. | ||
* - `ExtraDirectives`: Additional directives to be merged with the original properties. | ||
* | ||
* The resulting type combines `ExtraProps` with the original `Props`. For each property in `Props`, | ||
* if the property is of type `SlotContent`, it will be extended with the additional properties and directives. | ||
* | ||
* @template Props - The original properties of the widget. | ||
* @template ExtraProps - Additional properties to be merged with the original properties. | ||
* @template ExtraDirectives - Additional directives to be merged with the original properties. | ||
*/ | ||
@@ -22,2 +50,7 @@ export type ExtendWidgetAdaptSlotWidgetProps<Props, ExtraProps extends object, ExtraDirectives extends object> = ExtraProps & { | ||
* Method to extend the original widget with extra props with validator | ||
* | ||
* @template W - The type of the widget. | ||
* @template ExtraProps - The type of the additional properties. | ||
* @template ExtraDirectives - The type of the additional directives (default is an empty object). | ||
* | ||
* @param factory - original widget factory | ||
@@ -24,0 +57,0 @@ * @param extraPropsDefaults - object containing default value for each extra prop |
import type { ArrowOptions, AutoUpdateOptions, ComputePositionConfig, Derivable, MiddlewareData, Placement, Strategy } from '@floating-ui/dom'; | ||
import type { PropsConfig } from '../types'; | ||
import type { Directive, PropsConfig, SSRHTMLElement, Widget } from '../types'; | ||
/** | ||
* Interface representing the properties for configuring Floating UI. | ||
*/ | ||
export interface FloatingUIProps { | ||
@@ -17,2 +20,5 @@ /** | ||
} | ||
/** | ||
* Represents the state of a floating UI element. | ||
*/ | ||
export interface FloatingUIState { | ||
@@ -40,4 +46,23 @@ /** | ||
} | ||
export type FloatingUI = ReturnType<typeof createFloatingUI>; | ||
export interface FloatingUIDirectives { | ||
/** | ||
* Directive to attach to the reference element | ||
*/ | ||
referenceDirective: Directive<void, SSRHTMLElement>; | ||
/** | ||
* Directive to attach to the floating element | ||
*/ | ||
floatingDirective: Directive<void, SSRHTMLElement>; | ||
/** | ||
* Directive to attach to the arrow element | ||
*/ | ||
arrowDirective: Directive<void, SSRHTMLElement>; | ||
} | ||
/** | ||
* Represents the type returned by the `createFloatingUI` function. | ||
* | ||
* This type is used to define the structure and behavior of the Floating UI component. | ||
*/ | ||
export type FloatingUI = Widget<FloatingUIProps, FloatingUIState, object, FloatingUIDirectives>; | ||
/** | ||
* Create a floating UI service. | ||
@@ -50,26 +75,2 @@ * | ||
*/ | ||
export declare const createFloatingUI: (propsConfig?: PropsConfig<FloatingUIProps>) => { | ||
directives: { | ||
/** | ||
* Directive to be used on the reference element from where the floating element will be positioned | ||
*/ | ||
referenceDirective: import("../types").Directive<void, import("../types").SSRHTMLElement>; | ||
/** | ||
* Directive to be used on the floating element | ||
*/ | ||
floatingDirective: import("../types").Directive<void, import("../types").SSRHTMLElement>; | ||
/** | ||
* Directive to be used on the arrow element, if any | ||
*/ | ||
arrowDirective: import("../types").Directive<void, import("../types").SSRHTMLElement>; | ||
}; | ||
state$: import("@amadeus-it-group/tansu").ReadableSignal<FloatingUIState>; | ||
stores: { | ||
x$: import("@amadeus-it-group/tansu").ReadableSignal<number | undefined>; | ||
y$: import("@amadeus-it-group/tansu").ReadableSignal<number | undefined>; | ||
strategy$: import("@amadeus-it-group/tansu").ReadableSignal<Strategy | undefined>; | ||
placement$: import("@amadeus-it-group/tansu").ReadableSignal<Placement | undefined>; | ||
middlewareData$: import("@amadeus-it-group/tansu").ReadableSignal<MiddlewareData | undefined>; | ||
}; | ||
patch: <U extends Partial<FloatingUIProps>>(storesValues?: void | U | undefined) => void; | ||
}; | ||
export declare const createFloatingUI: (propsConfig?: PropsConfig<FloatingUIProps>) => FloatingUI; |
import { computed, derived } from "@amadeus-it-group/tansu"; | ||
import { arrow, autoUpdate, computePosition } from "@floating-ui/dom"; | ||
import { j as createBrowserStoreDirective, k as mergeDirectives, d as directiveSubscribe } from "../directive-3-8yr-ZK.js"; | ||
import { j as createBrowserStoreDirective, k as mergeDirectives, d as directiveSubscribe } from "../directive-CKEccryv.js"; | ||
import { p as promiseStoreToValueStore } from "../promise-CY2U8bTP.js"; | ||
@@ -126,3 +126,4 @@ import { writablesForProps, stateStores } from "../utils/stores.js"; | ||
arrowDirective: mergeDirectives(arrowDirective, directiveSubscribe(arrowStyleApplyAction$)) | ||
} | ||
}, | ||
api: {} | ||
}; | ||
@@ -129,0 +130,0 @@ }; |
import type { ReadableSignal } from '@amadeus-it-group/tansu'; | ||
import type { Directive } from '../types'; | ||
/** | ||
* A readable store that tracks the currently active (focused) element in the document. | ||
* | ||
* This store is only active in a browser environment. When not in a browser environment, | ||
* it will be a readable store with a `null` value. | ||
* | ||
* @example | ||
* ```typescript | ||
* import { activeElement$ } from './focustrack'; | ||
* | ||
* activeElement$.subscribe((element) => { | ||
* console.log('Active element:', element); | ||
* }); | ||
* ``` | ||
* | ||
* The store updates whenever the active element changes, such as when the user focuses | ||
* on a different input field or clicks on a different part of the document. | ||
*/ | ||
export declare const activeElement$: ReadableSignal<Element | null>; | ||
/** | ||
* Interface representing an element that can have focus tracking. | ||
*/ | ||
export interface HasFocus { | ||
@@ -5,0 +26,0 @@ /** |
import { readable, computed } from "@amadeus-it-group/tansu"; | ||
import { g as createBrowserStoreArrayDirective } from "../directive-3-8yr-ZK.js"; | ||
import { g as createBrowserStoreArrayDirective } from "../directive-CKEccryv.js"; | ||
import { BROWSER } from "esm-env"; | ||
@@ -4,0 +4,0 @@ const evtFocusIn = "focusin"; |
@@ -0,2 +1,3 @@ | ||
import { type ReadableSignal } from '@amadeus-it-group/tansu'; | ||
/** Store exposing the location.hash string */ | ||
export declare const hash$: import("@amadeus-it-group/tansu").ReadableSignal<string>; | ||
export declare const hash$: ReadableSignal<string>; |
@@ -0,2 +1,6 @@ | ||
import { type ReadableSignal } from '@amadeus-it-group/tansu'; | ||
import type { PropsConfig } from '../types'; | ||
/** | ||
* Interface representing the properties for the Intersection service. | ||
*/ | ||
export interface IntersectionProps { | ||
@@ -8,5 +12,5 @@ /** | ||
/** | ||
* IntersectionObserverInit used in the IntersectionObserver | ||
* IntersectionObserverInit used in the {@link IntersectionObserver} | ||
* | ||
* See the [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/IntersectionObserver#options) | ||
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/IntersectionObserver#options | MDN documentation} | ||
*/ | ||
@@ -24,13 +28,5 @@ options: Partial<IntersectionObserverInit> | undefined; | ||
export declare const createIntersection: (config?: PropsConfig<IntersectionProps>) => { | ||
/** | ||
* Readable of observed elements | ||
*/ | ||
elements$: import("@amadeus-it-group/tansu").ReadableSignal<HTMLElement[]>; | ||
/** | ||
* Store of map that contains the visible elements (for the key) and the corresponding entries | ||
* | ||
* See the [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry) | ||
*/ | ||
visibleElements$: import("@amadeus-it-group/tansu").ReadableSignal<Map<Element, IntersectionObserverEntry>>; | ||
patch: <U extends Partial<IntersectionProps>>(storesValues?: void | U | undefined) => void; | ||
elements$: ReadableSignal<HTMLElement[]>; | ||
visibleElements$: ReadableSignal<Map<Element, IntersectionObserverEntry>>; | ||
patch: (storesValues: Partial<IntersectionProps>) => void; | ||
}; |
@@ -45,3 +45,3 @@ import { derived, asReadable } from "@amadeus-it-group/tansu"; | ||
* | ||
* See the [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry) | ||
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry | MDN documentation} | ||
*/ | ||
@@ -48,0 +48,0 @@ visibleElements$: asReadable(visibleElements$), |
@@ -0,1 +1,2 @@ | ||
import { type ReadableSignal } from '@amadeus-it-group/tansu'; | ||
/** | ||
@@ -7,2 +8,2 @@ * Create a store tracking the state of a {@link https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia | matchMedia} query. | ||
*/ | ||
export declare const createMatchMedia: (query: string) => import("@amadeus-it-group/tansu").ReadableSignal<boolean>; | ||
export declare const createMatchMedia: (query: string) => ReadableSignal<boolean>; |
import { readable } from "@amadeus-it-group/tansu"; | ||
import { BROWSER } from "esm-env"; | ||
import { u as addEvent } from "../directive-3-8yr-ZK.js"; | ||
import { u as addEvent } from "../directive-CKEccryv.js"; | ||
const createMatchMedia = (query) => BROWSER ? readable(false, { | ||
@@ -5,0 +5,0 @@ onUse({ set }) { |
@@ -1,3 +0,79 @@ | ||
export type NavManager = ReturnType<typeof createNavManager>; | ||
import { type ReadableSignal } from '@amadeus-it-group/tansu'; | ||
import type { Directive, SSRHTMLElement } from '../types'; | ||
/** | ||
* A type representing a function that determines the neighboring element to focus on. | ||
* @returns The next HTMLElement to focus on, or null if no suitable element is found. | ||
*/ | ||
export type FocusNeighbour = (arg?: { | ||
event?: Event; | ||
referenceElement?: HTMLElement | null; | ||
}) => HTMLElement | null; | ||
/** | ||
* A type representing a function that focuses on the end element. | ||
* @returns The HTMLElement that was focused, or null if no element was focused. | ||
*/ | ||
export type FocusEnd = (arg?: { | ||
event?: Event; | ||
}) => HTMLElement | null; | ||
/** | ||
* Represents a navigation manager that handles focusable elements in the DOM. | ||
* | ||
* @template T - The type of the configuration for the navigation manager items. | ||
*/ | ||
export type NavManager<T> = { | ||
/** | ||
* Store containing the navigable elements in DOM order | ||
*/ | ||
elementsInDomOrder$: ReadableSignal<HTMLElement[]>; | ||
/** | ||
* Directive to attach the nav manager | ||
*/ | ||
directive: Directive<NavManagerItemConfig<T>, SSRHTMLElement>; | ||
/** | ||
* Refresh the elements list. | ||
* @param now force the instant refresh of the elements | ||
*/ | ||
refreshElements: (now?: boolean) => void; | ||
/** | ||
* Focus the element at the given idex. | ||
* If the element at the given index is not focusable, use the moveDirection to step into the next focusable element. | ||
* @param index the index of the element to focus | ||
* @param moveDirection a move direction | ||
* @returns the new focusable element if found, null otherwise | ||
*/ | ||
focusIndex: (index: number, moveDirection: -1 | 0 | 1) => HTMLElement | null; | ||
/** | ||
* Focus the previous element, respecting the anscestor direction. | ||
*/ | ||
focusPrevious: FocusNeighbour; | ||
/** | ||
* Focus the next element, respecting the anscestor direction. | ||
*/ | ||
focusNext: FocusNeighbour; | ||
/** | ||
* Focus the first element, respecting the anscestor direction. | ||
*/ | ||
focusFirst: FocusEnd; | ||
/** | ||
* Focus the element at the left-end of the list. | ||
*/ | ||
focusFirstLeft: FocusEnd; | ||
/** | ||
* Focus the element at the right-end of the list. | ||
*/ | ||
focusFirstRight: FocusEnd; | ||
/** | ||
* Focus the last element, respecting the anscestor direction. | ||
*/ | ||
focusLast: FocusEnd; | ||
/** | ||
* Focus the next focusable element to the left of the currently focused element. | ||
*/ | ||
focusLeft: FocusNeighbour; | ||
/** | ||
* Focus the next focusable element to the right of the currently focused element. | ||
*/ | ||
focusRight: FocusNeighbour; | ||
}; | ||
/** | ||
* Returns the key name given the keyboard event. The key name is built using event.key (such as ArrowLeft, PageDown...), | ||
@@ -24,2 +100,3 @@ * prefixed with the modifiers. If present, modifiers are always in the same order: Meta+Ctrl+Alt+Shift+... | ||
* - navManager: navigation manager instance | ||
* @template T - The type of the context object, defaults to `any`. | ||
*/ | ||
@@ -29,7 +106,9 @@ export type NavManagerKeyHandler<T = any> = (info: { | ||
event: Event; | ||
navManager: NavManager; | ||
navManager: NavManager<T>; | ||
context?: T; | ||
}) => void; | ||
/** | ||
* Type of the parameter of the navigation manager directive. | ||
* Configuration object for a navigation manager item. | ||
* | ||
* @template T - The type of the context object. | ||
*/ | ||
@@ -64,40 +143,5 @@ export interface NavManagerItemConfig<T = any> { | ||
* | ||
* @returns a new instance of the navigation manager | ||
* @template T - The type of the context object used in the navigation manager. | ||
* @returns An object containing methods and properties for managing focus navigation. | ||
*/ | ||
export declare const createNavManager: () => { | ||
elementsInDomOrder$: import("@amadeus-it-group/tansu").ReadableSignal<HTMLElement[]>; | ||
directive: <T = any>(node: import("..").SSRHTMLElement, args: NavManagerItemConfig<T>) => void | { | ||
update?: ((args: NavManagerItemConfig<T>) => void) | undefined; | ||
destroy?: () => void; | ||
}; | ||
focusIndex: (index: number, moveDirection?: -1 | 0 | 1) => HTMLElement | null; | ||
focusPrevious: ({ event, referenceElement, }?: { | ||
event?: Event; | ||
referenceElement?: HTMLElement | null; | ||
}) => HTMLElement | null; | ||
focusNext: ({ event, referenceElement, }?: { | ||
event?: Event; | ||
referenceElement?: HTMLElement | null; | ||
}) => HTMLElement | null; | ||
focusFirst: ({ event }?: { | ||
event?: Event; | ||
}) => HTMLElement | null; | ||
focusFirstLeft: (args_0?: { | ||
event?: Event; | ||
} | undefined) => HTMLElement | null; | ||
focusFirstRight: (args_0?: { | ||
event?: Event; | ||
} | undefined) => HTMLElement | null; | ||
focusLast: ({ event }?: { | ||
event?: Event; | ||
}) => HTMLElement | null; | ||
focusLeft: (args_0?: { | ||
event?: Event; | ||
referenceElement?: HTMLElement | null; | ||
} | undefined) => HTMLElement | null; | ||
focusRight: (args_0?: { | ||
event?: Event; | ||
referenceElement?: HTMLElement | null; | ||
} | undefined) => HTMLElement | null; | ||
refreshElements: (now?: boolean) => void; | ||
}; | ||
export declare const createNavManager: <T>() => NavManager<T>; |
import { writable, computed } from "@amadeus-it-group/tansu"; | ||
import { r as registrationArray, y as computeCommonAncestor, b as browserDirective } from "../directive-3-8yr-ZK.js"; | ||
import { r as registrationArray, y as computeCommonAncestor, b as browserDirective } from "../directive-CKEccryv.js"; | ||
const isInertOrInvisible = (element) => { | ||
@@ -4,0 +4,0 @@ let curElement = element; |
import type { Directive } from '../types'; | ||
/** | ||
* Represents the arguments for a portal directive. | ||
*/ | ||
export type PortalDirectiveArg = { | ||
@@ -3,0 +6,0 @@ container?: HTMLElement | null | undefined; |
@@ -1,2 +0,2 @@ | ||
import { b as browserDirective } from "../directive-3-8yr-ZK.js"; | ||
import { b as browserDirective } from "../directive-CKEccryv.js"; | ||
const portal = browserDirective((content, newArg) => { | ||
@@ -3,0 +3,0 @@ let arg; |
import type { ReadableSignal } from '@amadeus-it-group/tansu'; | ||
import type { Directive, SSRHTMLElement } from '../types'; | ||
/** | ||
@@ -7,9 +8,4 @@ * Create a resize observer object | ||
export declare const createResizeObserver: () => { | ||
/** | ||
* Store which contains the dimensions of the observed element (ResizeObserverEntry type) | ||
* See the [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserverEntry) | ||
*/ | ||
dimensions$: ReadableSignal<ResizeObserverEntry | undefined>; | ||
/** Directive to be attached to html element in order to listen to resize events */ | ||
directive: import("..").Directive<void, import("..").SSRHTMLElement>; | ||
directive: Directive<void, SSRHTMLElement>; | ||
}; |
import { derived } from "@amadeus-it-group/tansu"; | ||
import { j as createBrowserStoreDirective } from "../directive-3-8yr-ZK.js"; | ||
import { j as createBrowserStoreDirective } from "../directive-CKEccryv.js"; | ||
import { n as noop } from "../func-DR0n-ShK.js"; | ||
@@ -23,3 +23,3 @@ const createResizeObserver = () => { | ||
* Store which contains the dimensions of the observed element (ResizeObserverEntry type) | ||
* See the [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserverEntry) | ||
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserverEntry | MDN documentation} | ||
*/ | ||
@@ -26,0 +26,0 @@ dimensions$: observedElement$, |
import type { Directive } from '../types'; | ||
/** | ||
* sliblingsInert directive | ||
* When used on an element, all siblings of the element and of its ancestors will be inert with the inert attribute. | ||
* In case it is used on multiple elements, only the last one has an effect (the directive keeps a stack of elements | ||
* on which it is used, so when the last one disappears, the previous one in the list becomes the one in effect). | ||
* A directive that sets the `inert` attribute on all sibling elements of the given element recursively up the DOM tree, | ||
* excluding the element itself and any `<script>` elements. | ||
*/ | ||
export declare const sliblingsInert: Directive; | ||
export declare const siblingsInert: Directive; |
import { computed } from "@amadeus-it-group/tansu"; | ||
import { n as noop } from "../func-DR0n-ShK.js"; | ||
import { g as createBrowserStoreArrayDirective, k as mergeDirectives, d as directiveSubscribe } from "../directive-3-8yr-ZK.js"; | ||
import { g as createBrowserStoreArrayDirective, k as mergeDirectives, d as directiveSubscribe } from "../directive-CKEccryv.js"; | ||
const internalSetSiblingsInert = (element) => { | ||
@@ -37,5 +37,5 @@ const inertValues = /* @__PURE__ */ new Map(); | ||
const inertAction$ = computed(() => setSiblingsInert(lastElement$())); | ||
const sliblingsInert = mergeDirectives(storeArrayDirective, directiveSubscribe(inertAction$)); | ||
const siblingsInert = mergeDirectives(storeArrayDirective, directiveSubscribe(inertAction$)); | ||
export { | ||
sliblingsInert | ||
siblingsInert | ||
}; |
@@ -25,3 +25,6 @@ import type { Directive, PropsConfig, SSRHTMLElement, Widget } from '../../types'; | ||
*/ | ||
context: object) => Promise<void>; | ||
context: object) => Promise<void> | void; | ||
/** | ||
* Properties for configuring a transition. | ||
*/ | ||
export interface TransitionProps { | ||
@@ -65,3 +68,3 @@ /** | ||
* | ||
* @param visible - new value of the visible propery | ||
* @param visible - new value of the visible property | ||
*/ | ||
@@ -99,2 +102,5 @@ onVisibleChange: (visible: boolean) => void; | ||
} | ||
/** | ||
* Interface representing the API for managing transitions of an element. | ||
*/ | ||
export interface TransitionApi { | ||
@@ -130,2 +136,5 @@ /** | ||
} | ||
/** | ||
* Interface representing transition directives. | ||
*/ | ||
export interface TransitionDirectives { | ||
@@ -135,6 +144,14 @@ /** | ||
*/ | ||
directive: Directive<void | Partial<TransitionProps>>; | ||
directive: Directive; | ||
} | ||
export type TransitionWidget = Widget<TransitionProps, TransitionState, TransitionApi, object, TransitionDirectives>; | ||
/** | ||
* Represents a widget that handles transitions. | ||
* | ||
* @template TransitionProps - The properties required for the transition. | ||
* @template TransitionState - The state management for the transition. | ||
* @template TransitionApi - The API interface for the transition. | ||
* @template TransitionDirectives - The directives used in the transition. | ||
*/ | ||
export type TransitionWidget = Widget<TransitionProps, TransitionState, TransitionApi, TransitionDirectives>; | ||
/** | ||
* A transition to show / hide an element without any animated. It uses the HTML `display` attribute. | ||
@@ -141,0 +158,0 @@ * |
import { computed, writable, derived, batch } from "@amadeus-it-group/tansu"; | ||
import { c as typeBoolean, f as typeFunction, d as typeBooleanOrNull } from "../../writables-DoU_XYTX.js"; | ||
import { c as typeBoolean, f as typeFunction, d as typeBooleanOrNull } from "../../writables-DCiBdIBK.js"; | ||
import { c as promiseWithResolve } from "../../promise-CY2U8bTP.js"; | ||
import { n as noop } from "../../func-DR0n-ShK.js"; | ||
import { writablesForProps, bindableDerived, stateStores } from "../../utils/stores.js"; | ||
import { h as createStoreDirective, k as mergeDirectives, d as directiveSubscribe, e as directiveUpdate } from "../../directive-3-8yr-ZK.js"; | ||
import { h as createStoreDirective, k as mergeDirectives, d as directiveSubscribe } from "../../directive-CKEccryv.js"; | ||
const neverEndingPromise = new Promise(noop); | ||
const noAnimation = async (element, direction) => { | ||
const noAnimation = (element, direction) => { | ||
element.style.display = direction === "show" ? "" : "none"; | ||
@@ -146,3 +146,3 @@ }; | ||
}; | ||
const directive = mergeDirectives(storeDirective, directiveUpdate(patch), directiveSubscribe(visibleAction$)); | ||
const directive = mergeDirectives(storeDirective, directiveSubscribe(visibleAction$)); | ||
return { | ||
@@ -161,3 +161,2 @@ ...stateStores({ | ||
}, | ||
actions: {}, | ||
api: { | ||
@@ -164,0 +163,0 @@ show: toggle.bind(null, true), |
import type { TransitionFn } from './baseTransitions'; | ||
/** | ||
* Represents the context for a collapsible element. | ||
*/ | ||
export interface CollapseContext { | ||
@@ -12,2 +15,5 @@ /** | ||
} | ||
/** | ||
* Configuration options for the collapse transition. | ||
*/ | ||
export interface CollapseConfig { | ||
@@ -14,0 +20,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
import { i as isBrowserHTMLElement, v as removeClasses, w as addClasses, x as reflow } from "../../directive-3-8yr-ZK.js"; | ||
import { i as isBrowserHTMLElement, v as removeClasses, w as addClasses, x as reflow } from "../../directive-CKEccryv.js"; | ||
import { createCSSTransition } from "./cssTransitions.js"; | ||
@@ -3,0 +3,0 @@ const createCollapseTransition = ({ |
@@ -15,2 +15,5 @@ import type { SSRHTMLElement } from '../../types'; | ||
export declare function getTransitionDurationMs(element: HTMLElement): number; | ||
/** | ||
* Defines a function type for CSS transitions. | ||
*/ | ||
export type CSSTransitionFn = (element: SSRHTMLElement, direction: 'show' | 'hide', animated: boolean, context: object) => void | (() => void); | ||
@@ -17,0 +20,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
import { i as isBrowserHTMLElement } from "../../directive-3-8yr-ZK.js"; | ||
import { i as isBrowserHTMLElement } from "../../directive-CKEccryv.js"; | ||
import { n as noop } from "../../func-DR0n-ShK.js"; | ||
@@ -3,0 +3,0 @@ import { a as promiseFromEvent, b as promiseFromTimeout } from "../../promise-CY2U8bTP.js"; |
@@ -0,1 +1,5 @@ | ||
import type { TransitionFn } from './baseTransitions'; | ||
/** | ||
* Configuration interface for simple class-based transitions. | ||
*/ | ||
export interface SimpleClassTransitionConfig { | ||
@@ -23,2 +27,5 @@ /** | ||
} | ||
/** | ||
* Represents the context for a simple class transition. | ||
*/ | ||
export interface SimpleClassTransitionContext { | ||
@@ -35,3 +42,3 @@ /** | ||
* `animationPendingClasses` are the classes attached when the transition is in a pending state | ||
* `animationPendingShowClasses` and `animationPendingHideClasses` are attached when transitionning towards one direction | ||
* `animationPendingShowClasses` and `animationPendingHideClasses` are attached when transitioning towards one direction | ||
* `showClasses` and `hideClasses` are attached when the transition has reached the show or hide state respectively | ||
@@ -42,2 +49,2 @@ * | ||
*/ | ||
export declare const createSimpleClassTransition: (config: SimpleClassTransitionConfig) => import("./baseTransitions").TransitionFn; | ||
export declare const createSimpleClassTransition: (config: SimpleClassTransitionConfig) => TransitionFn; |
import { createCSSTransition } from "./cssTransitions.js"; | ||
import { v as removeClasses, w as addClasses, x as reflow } from "../../directive-3-8yr-ZK.js"; | ||
import { v as removeClasses, w as addClasses, x as reflow } from "../../directive-CKEccryv.js"; | ||
const createSimpleClassTransition = (config) => { | ||
@@ -4,0 +4,0 @@ const { animationPendingClasses, animationPendingShowClasses, animationPendingHideClasses, showClasses, hideClasses } = config; |
170
types.d.ts
import type { ReadableSignal, StoreOptions, SubscribableStore, WritableSignal } from '@amadeus-it-group/tansu'; | ||
/** | ||
* A type that maps each property of an object type `T` to either a `ReadableSignal` of that property type or the property type itself. | ||
* | ||
* @template T - The object type whose properties are being mapped. | ||
*/ | ||
export type ValuesOrReadableSignals<T extends object> = { | ||
[K in keyof T]?: ReadableSignal<T[K] | undefined> | T[K]; | ||
}; | ||
/** | ||
* A type that maps the properties of an object type `T` to either a `WritableSignal` of the property type or the property type itself. | ||
* | ||
* @template T - The object type whose properties are being mapped. | ||
*/ | ||
export type ValuesOrWritableSignals<T extends object> = { | ||
[K in keyof T]?: WritableSignal<T[K] | undefined> | T[K]; | ||
}; | ||
/** | ||
* Interface representing the configuration for properties. | ||
* | ||
* @template U - An object type representing the properties. | ||
*/ | ||
export interface PropsConfig<U extends object> { | ||
@@ -20,3 +35,12 @@ /** | ||
} | ||
export interface Widget<Props extends object = object, State extends object = object, Api extends object = object, Actions extends object = object, Directives extends object = object> { | ||
/** | ||
* Represents a generic widget with reactive state, stores, and various functionalities. | ||
* | ||
* @template Props - The type of the properties that can be passed to the widget. | ||
* @template State - The type of the state managed by the widget. | ||
* @template Api - The type of the API functions available for interacting with the widget. | ||
* @template Actions - The type of the action handlers for user interactions. | ||
* @template Directives - The type of the directives used in the widget's template. | ||
*/ | ||
export interface Widget<Props extends object = object, State extends object = object, Api extends object = object, Directives extends object = object> { | ||
/** | ||
@@ -41,7 +65,2 @@ * the reactive state of the widget, combining all the values served by the stores | ||
/** | ||
* all the handlers that should be connected to user interactions i.e. click, keyboard and touch interactions. | ||
* typically, the handlers are event listeners that call api functions to affect the widget state | ||
*/ | ||
actions: Actions; | ||
/** | ||
* all the api functions to interact with the widget | ||
@@ -51,4 +70,9 @@ */ | ||
} | ||
export type ContextWidget<W extends Widget> = Pick<W, 'actions' | 'api' | 'directives' | 'state$' | 'stores'>; | ||
export interface WidgetSlotContext<W extends Widget> { | ||
/** | ||
* Represents the context for a widget slot, providing access to the widget and its state. | ||
* | ||
* @template W - The type of the widget. | ||
* | ||
*/ | ||
export interface WidgetSlotContext<W extends Widget> extends Pick<W, 'api' | 'directives'> { | ||
/** | ||
@@ -58,14 +82,9 @@ * the state of the widget | ||
state: WidgetState<W>; | ||
/** | ||
* the widget | ||
*/ | ||
widget: ContextWidget<W>; | ||
} | ||
/** | ||
* Extract actions, api, directives, state and stores from the widget to be passed to slots as context. | ||
* Extracts the state type from a widget type that contains a `state$` property. | ||
* | ||
* @param w - the widget | ||
* @returns the slot context | ||
* @template T - A type that extends an object with a `state$` property of type `SubscribableStore<any>`. | ||
* @returns The type of the state contained within the `state$` property if it extends an object, otherwise `never`. | ||
*/ | ||
export declare const toSlotContextWidget: <W extends Widget>(w: W) => ContextWidget<W>; | ||
export type WidgetState<T extends { | ||
@@ -76,2 +95,11 @@ state$: SubscribableStore<any>; | ||
} ? U : never; | ||
/** | ||
* Extracts the type of the argument expected by the `patch` method of a given type `T`. | ||
* | ||
* This utility type takes a generic type `T` which must have a `patch` method. The `patch` method | ||
* should accept an argument that is a partial of some object type `U`. If `T` meets this condition, | ||
* `WidgetProps` will resolve to the type `U`. Otherwise, it will resolve to `never`. | ||
* | ||
* @template T - A type that includes a `patch` method accepting a partial object. | ||
*/ | ||
export type WidgetProps<T extends { | ||
@@ -82,5 +110,19 @@ patch: (arg: any) => void; | ||
} ? U : never; | ||
/** | ||
* A factory function type for creating instances of a widget. | ||
* | ||
* @template W - The type of the widget that extends the base Widget type. | ||
* @param props - Optional configuration properties for the widget. | ||
* @returns An instance of the widget. | ||
*/ | ||
export type WidgetFactory<W extends Widget> = (props?: PropsConfig<WidgetProps<W>>) => W; | ||
/** | ||
* Subset of HTMLElement that is available in a server side rendering context. | ||
* Represents a server-side rendered HTML element with limited functionality. | ||
* | ||
* This interface extends a subset of the {@link HTMLElement} interface, providing | ||
* methods to set and remove attributes, manipulate the element's classes, and | ||
* partially manipulate the element's style. | ||
* | ||
* It inherits the {@link https://developer.mozilla.org/docs/Web/API/Element/setAttribute | setAttribute} and {@link https://developer.mozilla.org/docs/Web/API/Element/getAttribute | getAttribute} methods from the {@link HTMLElement} interface. | ||
* | ||
*/ | ||
@@ -97,2 +139,15 @@ export interface SSRHTMLElement extends Pick<HTMLElement, 'setAttribute' | 'removeAttribute'> { | ||
} | ||
/** | ||
* Represents a directive function that can be applied to an SSRHTMLElement. | ||
* | ||
* @template T - The type of the arguments passed to the directive. | ||
* @template U - The type of the SSRHTMLElement, defaults to SSRHTMLElement. | ||
* | ||
* @param node - The SSRHTMLElement to which the directive is applied. | ||
* @param args - The arguments passed to the directive. | ||
* | ||
* @returns An optional object that may contain: | ||
* - `update`: A function to update the directive with new arguments. | ||
* - `destroy`: A function to clean up when the directive is no longer needed. | ||
*/ | ||
export type Directive<T = void, U extends SSRHTMLElement = SSRHTMLElement> = (node: U, args: T) => void | { | ||
@@ -102,12 +157,51 @@ update?: (args: T) => void; | ||
}; | ||
/** | ||
* Represents a tuple containing a directive and its associated parameter. | ||
* | ||
* @template T - The type of the parameter associated with the directive. | ||
* @template U - The type of the SSRHTMLElement, defaults to SSRHTMLElement. | ||
*/ | ||
export type DirectiveAndParam<T, U extends SSRHTMLElement = SSRHTMLElement> = [Directive<T, U>, T]; | ||
/** | ||
* Represents a mapping of directives and their optional parameters. | ||
* | ||
* @template T - An array type representing the parameters for the directives. | ||
* @template U - The type of the SSR HTML element, defaults to `SSRHTMLElement`. | ||
*/ | ||
export type DirectivesAndOptParam<T extends any[], U extends SSRHTMLElement = SSRHTMLElement> = { | ||
[K in keyof T]: Directive<void, U> | DirectiveAndParam<T[K], U>; | ||
}; | ||
/** | ||
* Represents the content that can be used in a slot. | ||
* The content can be one of the following: | ||
* - `undefined` | ||
* - `null` | ||
* - A `string` | ||
* - A function that takes `props` of type `Props` and returns a `string` | ||
*/ | ||
export type SlotContent<Props extends object = object> = undefined | null | string | ((props: Props) => string); | ||
/** | ||
* A unique symbol representing an invalid value. | ||
* This can be used as a sentinel value to indicate that a variable or property | ||
* does not hold a valid value. | ||
*/ | ||
export declare const INVALID_VALUE: unique symbol; | ||
/** | ||
* A type alias for a function that normalizes a value of type `T`. | ||
* The function takes a value of type `T` and returns either a normalized value of type `T` | ||
* or a special constant `INVALID_VALUE` indicating that the value is invalid. | ||
* | ||
* @template T - The type of the value to be normalized. | ||
* @param value - The value to be normalized. | ||
* @returns The normalized value of type `T` or `INVALID_VALUE` if the value is invalid. | ||
*/ | ||
export type NormalizeValue<T> = (value: T) => T | typeof INVALID_VALUE; | ||
/** | ||
* Interface representing options for a writable store with default values. | ||
* | ||
* @template T - The type of the value stored. | ||
*/ | ||
export interface WritableWithDefaultOptions<T> { | ||
/** | ||
* the normalize value function. should return the invalidValue symbol when the provided value is invalid | ||
* the normalize value function. should return the {@link INVALID_VALUE} symbol when the provided value is invalid | ||
*/ | ||
@@ -120,9 +214,47 @@ normalizeValue?: NormalizeValue<T>; | ||
} | ||
/** | ||
* Represents a type that validates a configuration object. | ||
* | ||
* @template T - The type of the configuration object to be validated. | ||
* | ||
* This type maps each key of the configuration object `T` to an optional | ||
* `WritableWithDefaultOptions` type, allowing for partial validation. | ||
*/ | ||
export type ConfigValidator<T extends object> = { | ||
[K in keyof T]?: WritableWithDefaultOptions<T[K]>; | ||
[K in keyof T]: WritableWithDefaultOptions<T[K]> | undefined; | ||
}; | ||
/** | ||
* Represents a value that can be assigned to an attribute. | ||
*/ | ||
export type AttributeValue = string | number | boolean | undefined; | ||
/** | ||
* Represents a key of the CSSStyleDeclaration interface, excluding certain properties and methods. | ||
* | ||
* This is useful for scenarios where you need to work with CSS properties directly without | ||
* dealing with the methods and other non-style properties of CSSStyleDeclaration. | ||
*/ | ||
export type StyleKey = Exclude<keyof CSSStyleDeclaration, 'length' | 'item' | 'parentRule' | 'getPropertyValue' | 'getPropertyPriority' | 'setProperty' | 'removeProperty' | typeof Symbol.iterator | number | 'cssText'>; | ||
/** | ||
* Represents a value that can be used for styling purposes. | ||
* @remarks | ||
* This type can be a string representing a style value, or it can be undefined or null. | ||
* It is useful for scenarios where a style value might be optional or not set. | ||
*/ | ||
export type StyleValue = string | undefined | null; | ||
/** | ||
* A conditional type that checks if type `T` extends type `U`. | ||
* @template T - The type to check. | ||
* @template U - The type to check against. | ||
* @returns `1` if `T` extends `U`, otherwise `0`. | ||
*/ | ||
export type Extends<T, U> = T extends U ? 1 : 0; | ||
/** | ||
* Type utility to determine if a given type `T` is or extends `SlotContent<any>`. | ||
* | ||
* This utility uses conditional types to check if `T` extends `SlotContent<any>` or if `SlotContent<any>` extends `T`. | ||
* If either condition is true, it returns `T`, otherwise it returns `0`. | ||
* | ||
* @template T - The type to be checked. | ||
* @returns `T` if `T` is or extends `SlotContent<any>`, otherwise `0`. | ||
*/ | ||
export type IsSlotContent<T> = Extends<T, SlotContent<any>> | Extends<SlotContent<any>, T> extends 1 ? T : 0; |
10
types.js
@@ -1,12 +0,4 @@ | ||
const toSlotContextWidget = (w) => ({ | ||
actions: w.actions, | ||
api: w.api, | ||
directives: w.directives, | ||
state$: w.state$, | ||
stores: w.stores | ||
}); | ||
const INVALID_VALUE = Symbol(); | ||
export { | ||
INVALID_VALUE, | ||
toSlotContextWidget | ||
INVALID_VALUE | ||
}; |
@@ -11,5 +11,10 @@ import type { ReadableSignal } from '@amadeus-it-group/tansu'; | ||
/** | ||
* Creates a directive that wraps the provided directive to only run it in a browser environment (and not in a server-side rendering environment). | ||
* @param directive - The directive to run only in a browser. | ||
* @returns The wrapped directive. | ||
* A higher-order directive function that conditionally applies a directive based on the environment. | ||
* If running in a browser environment, it applies the given directive to the node. | ||
* If not in a browser environment, it returns a no-op function. | ||
* | ||
* @template T - The type of the directive's argument. | ||
* @template U - The type of the HTML element the directive is applied to. | ||
* @param directive - The directive to be conditionally applied. | ||
* @returns - A directive that applies the given directive in a browser environment, or a no-op in a non-browser environment. | ||
*/ | ||
@@ -26,5 +31,7 @@ export declare const browserDirective: <T, U extends HTMLElement>(directive: Directive<T, U>) => Directive<T, SSRHTMLElement>; | ||
* | ||
* @param directive - directive to bind | ||
* @param directiveArg$ - store containing the argument of the directive | ||
* @returns The bound directive that can be used with no argument. | ||
* @template T - The type of the directive argument. | ||
* @template U - The type of the SSRHTMLElement, defaults to SSRHTMLElement. | ||
* @param directive - The directive to bind to the element. | ||
* @param directiveArg$ - The signal to subscribe to for directive updates. | ||
* @returns A directive that manages the lifecycle of the bound directive. | ||
*/ | ||
@@ -36,12 +43,18 @@ export declare const bindDirective: <T, U extends SSRHTMLElement = SSRHTMLElement>(directive: Directive<T, U>, directiveArg$: ReadableSignal<T>) => Directive<void, U>; | ||
* | ||
* @param directive - directive to wrap | ||
* @returns The resulting directive. | ||
* @template T - The type of the directive's argument. | ||
* @template U - The type of the SSRHTMLElement, defaults to SSRHTMLElement. | ||
* @param directive - The directive to bind without arguments. | ||
* @returns A new directive that does not require any arguments. | ||
*/ | ||
export declare const bindDirectiveNoArg: <T, U extends SSRHTMLElement = SSRHTMLElement>(directive: Directive<T | void, U>) => Directive<void, U>; | ||
export declare const bindDirectiveNoArg: <T, U extends SSRHTMLElement = SSRHTMLElement>(directive: Directive<T, U>) => Directive<void, U>; | ||
/** | ||
* Maps the argument to another argument of a directive using a provided function. | ||
* Maps the argument of a directive to a new value using a provided function. | ||
* | ||
* @param directive - The directive to be applied. | ||
* @param fn - The function to map the argument. | ||
* @returns A new directive that applies the mapping function to the argument. | ||
* @template T - The type of the original argument. | ||
* @template U - The type of the mapped argument. | ||
* @template V - The type of the SSRHTMLElement, defaults to SSRHTMLElement. | ||
* | ||
* @param directive - The original directive to be mapped. | ||
* @param fn - The function to map the original argument to the new argument. | ||
* @returns A new directive with the mapped argument. | ||
*/ | ||
@@ -63,2 +76,3 @@ export declare const mapDirectiveArg: <T, U, V extends SSRHTMLElement = SSRHTMLElement>(directive: Directive<U, V>, fn: (arg: T) => U) => Directive<T, V>; | ||
* | ||
* @template T - The type of the argument that the update function accepts. | ||
* @param update - Function called with the directive argument when the directive is initialized and when its argument is updated. | ||
@@ -69,4 +83,9 @@ * @returns The resulting directive. | ||
/** | ||
* Utility to create a store that contains an array of items. | ||
* @returns a store containing an array of items. | ||
* Creates a registration array that allows elements to be added and removed. | ||
* | ||
* @template T - The type of elements in the array. | ||
* @returns An object that includes a readable signal of the array and a register function. | ||
* | ||
* The returned object has the following properties: | ||
* - `register`: A function to add an element to the array. It takes an element of type `T` as a parameter and returns a function to remove the element from the array. | ||
*/ | ||
@@ -162,12 +181,24 @@ export declare const registrationArray: <T>() => ReadableSignal<T[]> & { | ||
* | ||
* @param args - directives to merge into a single directive. | ||
* @returns The resulting merged directive. | ||
* @template T - The type of the argument passed to the directive. | ||
* @template U - The type of the SSRHTMLElement, defaults to SSRHTMLElement. | ||
* @param args - The directives to merge. | ||
* @returns A new directive that applies all the given directives. | ||
* | ||
* The returned directive has the following lifecycle methods: | ||
* - `update(arg)`: Updates all merged directives with the given argument. | ||
* - `destroy()`: Destroys all merged directives in reverse order. | ||
*/ | ||
export declare const mergeDirectives: <T, U extends SSRHTMLElement = SSRHTMLElement>(...args: (Directive<T, U> | Directive<void, U>)[]) => Directive<T, U>; | ||
/** | ||
* Directive that applies all the directives passed as arguments. | ||
* Applies multiple directives to a given SSRHTMLElement and provides methods to update or destroy them. | ||
* | ||
* @param element - the element to apply the directives to | ||
* @param directives - the directives to apply | ||
* @returns The directive instance. | ||
* @template T - A tuple type representing the arguments for each directive. | ||
* @template U - The type of the SSRHTMLElement, defaults to SSRHTMLElement. | ||
* | ||
* @param element - The SSRHTMLElement to which the directives will be applied. | ||
* @param directives - An array of directives and their optional parameters. | ||
* | ||
* @returns An object containing: | ||
* - `update`: A function to update the directives with new parameters. | ||
* - `destroy`: A function to destroy all applied directives. | ||
*/ | ||
@@ -186,2 +217,3 @@ export declare const multiDirective: <T extends any[], U extends SSRHTMLElement = SSRHTMLElement>(element: U, directives: DirectivesAndOptParam<T, U>) => { | ||
* Key-value pairs where keys are event types and values are event handlers. | ||
xw | ||
*/ | ||
@@ -214,8 +246,13 @@ events?: Partial<{ | ||
/** | ||
* Creates a directive for server-side rendering with bindable elements. | ||
* This directive binds events, attributes, styles, and classNames to an HTML element. | ||
* Creates a directive that binds attributes, styles, class names, and events to a DOM node. | ||
* | ||
* @param propsFn - A function that returns the AttributesDirectiveProps with the data to bind. | ||
* This function can take an optional parameter that corrspond to the second parameter of the created directive. | ||
* @returns A directive object with bound events, attributes, styles, and classNames. | ||
* @template T - The type of the arguments passed to the directive. | ||
* @param propsFn - A function that takes a readable signal of type `T` and returns an object containing | ||
* attributes, styles, class names, and events to bind to the node. | ||
* @returns A directive function that can be used to bind the specified properties to a DOM node. | ||
* | ||
* The returned directive function takes a DOM node and arguments of type `T`, and sets up the bindings | ||
* specified by the `propsFn` function. It returns an object with `update` and `destroy` methods: | ||
* - `update(args: T)`: Updates the arguments passed to the directive. | ||
* - `destroy()`: Cleans up all bindings and event listeners. | ||
*/ | ||
@@ -230,2 +267,3 @@ export declare const createAttributesDirective: <T = void>(propsFn: (arg: ReadableSignal<T>) => AttributesDirectiveProps) => Directive<T>; | ||
* | ||
* @template T - The type of the directives array. | ||
* @param directives - List of directives to generate attributes from. Each parameter can be the directive or an array with the directive and its parameter | ||
@@ -244,13 +282,24 @@ * @returns JSON object with the `attributes`, `class` and `style` keys. | ||
/** | ||
* Returns JSON representation of the attributes to be applied derived from a list of directives. | ||
* Combines multiple directives into a single attributes object. | ||
* | ||
* @param directives - List of directives to generate attributes from. Each parameter can be the directive or an array with the directive and its parameter | ||
* @returns JSON object with name/value for the attributes | ||
* This function processes an array of directives and optional parameters, | ||
* extracting attributes, class names, and styles. It then combines these | ||
* into a single attributes object, where class names are joined into a | ||
* single string and styles are formatted as a CSS string. | ||
* | ||
* @template T - The type of the directives and optional parameters. | ||
* @param directives - The directives and optional parameters to process. | ||
* @returns An object containing the combined attributes. | ||
*/ | ||
export declare function directiveAttributes<T extends any[]>(...directives: DirectivesAndOptParam<T>): Record<string, string>; | ||
/** | ||
* Same as {@link directiveAttributes}, but returns an empty object when run in a browser environement. | ||
* Generates a record of SSR (Server-Side Rendering) attributes based on the provided directives. | ||
* | ||
* @returns JSON object with name/value for the attributes | ||
* This function behaves differently depending on the environment: | ||
* - In a browser environment (`BROWSER` is true), it returns an empty object. | ||
* - In a non-browser environment, it delegates to the `directiveAttributes` function. | ||
* | ||
* @template T - A tuple type representing the directives and optional parameters. | ||
* @returns A record of SSR attributes. | ||
*/ | ||
export declare const ssrAttributes: (() => {}) | typeof directiveAttributes; | ||
export declare const ssrAttributes: <T extends any[]>(...directives: DirectivesAndOptParam<T>) => Record<string, string>; |
import "@amadeus-it-group/tansu"; | ||
import "esm-env"; | ||
import { o, a, c, b, p, n, g, j, f, h, q, d, e, i, m, k, l, r, s } from "../directive-3-8yr-ZK.js"; | ||
import { o, a, c, b, p, n, g, j, f, h, q, d, e, i, m, k, l, r, s } from "../directive-CKEccryv.js"; | ||
import "../func-DR0n-ShK.js"; | ||
@@ -5,0 +5,0 @@ import "./stores.js"; |
@@ -50,1 +50,7 @@ /** | ||
export declare const allowNull: <T>(isType: (value: any) => value is T) => (value: any) => value is T | null; | ||
/** | ||
* Builds a new type guard to check if an element belongs to an enum list | ||
* @param list - the list of all enum values | ||
* @returns the type guard | ||
*/ | ||
export declare function isFromEnum<T>(list: T[]): (value: any) => value is T; |
@@ -1,2 +0,2 @@ | ||
import type { ReadableSignal } from '@amadeus-it-group/tansu'; | ||
import type { ReadableSignal, UnsubscribeFunction, UnsubscribeObject } from '@amadeus-it-group/tansu'; | ||
import type { AttributeValue, SSRHTMLElement, StyleKey, StyleValue } from '../../types'; | ||
@@ -10,3 +10,3 @@ /** | ||
/** | ||
* Launch a reflow using a call to the provided html element getBoudingClientRect | ||
* Launch a reflow using a call to the provided html element getBoundingClientRect | ||
* @param element - the html element | ||
@@ -19,3 +19,3 @@ */ | ||
* @param element - the HTML element | ||
* @param classes - the css lcasses | ||
* @param classes - the css classes | ||
*/ | ||
@@ -58,3 +58,3 @@ export declare const addClasses: (element: SSRHTMLElement, classes?: string[]) => void; | ||
*/ | ||
export declare function bindAttribute(node: SSRHTMLElement, attributeName: string, value$: ReadableSignal<AttributeValue>): import("@amadeus-it-group/tansu").UnsubscribeFunction & import("@amadeus-it-group/tansu").UnsubscribeObject; | ||
export declare function bindAttribute(node: SSRHTMLElement, attributeName: string, value$: ReadableSignal<AttributeValue>): UnsubscribeFunction & UnsubscribeObject; | ||
/** | ||
@@ -71,3 +71,3 @@ * Binds a value from a `ReadableSignal` to the specified CSS style property of an HTML element. | ||
*/ | ||
export declare function bindStyle(node: SSRHTMLElement, styleName: StyleKey, value$: ReadableSignal<StyleValue>): import("@amadeus-it-group/tansu").UnsubscribeFunction & import("@amadeus-it-group/tansu").UnsubscribeObject; | ||
export declare function bindStyle(node: SSRHTMLElement, styleName: StyleKey, value$: ReadableSignal<StyleValue>): UnsubscribeFunction & UnsubscribeObject; | ||
/** | ||
@@ -74,0 +74,0 @@ * Binds a `ReadableSignal` of boolean to the specified className of an HTML element. |
import type { ReadableSignal } from '@amadeus-it-group/tansu'; | ||
/** | ||
* Represents the result of a promise that is still pending. | ||
*/ | ||
export interface PromisePendingResult { | ||
@@ -6,3 +9,9 @@ /** Pending status */ | ||
} | ||
/** | ||
* A constant representing a pending promise result. | ||
*/ | ||
export declare const promisePending: PromisePendingResult; | ||
/** | ||
* Represents the state of a promise, which can be either fulfilled, rejected, or pending. | ||
*/ | ||
export type PromiseState<T> = PromiseFulfilledResult<T> | PromiseRejectedResult | PromisePendingResult; | ||
@@ -9,0 +18,0 @@ /** |
@@ -8,5 +8,5 @@ /** | ||
*/ | ||
export declare const compareDefault: (a: any, b: any) => 0 | 1 | -1; | ||
export declare const compareDefault: (a: any, b: any) => -1 | 0 | 1; | ||
/** | ||
* A comparision function between DOM elements, based on [Node.compareDocumentPosition](https://developer.mozilla.org/fr/docs/Web/API/Node/compareDocumentPosition). | ||
* A comparision function between DOM elements, based on {@link https://developer.mozilla.org/fr/docs/Web/API/Node/compareDocumentPosition | Node.compareDocumentPosition}. | ||
* | ||
@@ -13,0 +13,0 @@ * @param element1 - the first node |
import type { SSRHTMLElement } from '../../types'; | ||
/** | ||
* A unique symbol used to represent the attributes and style of an SSR (Server-Side Rendering) HTML element. | ||
* This symbol can be used as a key for storing or retrieving attributes and styles associated with an SSR HTML element. | ||
*/ | ||
export declare const ssrHTMLElementAttributesAndStyle: unique symbol; | ||
@@ -3,0 +7,0 @@ /** |
import type { ReadableSignal, StoreInput, StoresInputValues, WritableSignal } from '@amadeus-it-group/tansu'; | ||
import type { ConfigValidator, PropsConfig, ValuesOrReadableSignals, WritableWithDefaultOptions } from '../types'; | ||
/** | ||
* Transforms the properties of a given type `P` into writable signals. | ||
* Each property key in `P` is suffixed with a `$` and its type is converted to a `WritableSignal`. | ||
* @template P - The original type whose properties are to be transformed. | ||
*/ | ||
export type ToWritableSignal<P> = { | ||
[K in keyof P as `${K & string}$`]-?: WritableSignal<P[K], P[K] | undefined>; | ||
}; | ||
/** | ||
* Represents a collection of readable signals for an object type `T`. | ||
* Each key in the object corresponds to a key in `T`, and the value is an optional `ReadableSignal` | ||
* that can hold the value of the corresponding property in `T` or `undefined`. | ||
* | ||
* @template T - The object type for which the readable signals are defined. | ||
*/ | ||
export type ReadableSignals<T extends object> = { | ||
[K in keyof T]?: ReadableSignal<T[K] | undefined>; | ||
}; | ||
/** | ||
* A utility type that removes the trailing dollar sign (`$`) from a string type. | ||
* | ||
* @template S - A string type that ends with a dollar sign (`$`). | ||
* @returns The string type without the trailing dollar sign (`$`), or `never` if the input type does not end with a dollar sign. | ||
*/ | ||
export type WithoutDollar<S extends `${string}$`> = S extends `${infer U}$` ? U : never; | ||
@@ -27,6 +45,7 @@ /** | ||
* ``` | ||
* @param stores - object of stores | ||
* @returns the patch function | ||
* @template T - The type of the object that the stores represent. | ||
* @param stores - The stores to be updated. | ||
* @returns - A function that takes partial values of the stores and updates them. | ||
*/ | ||
export declare function createPatch<T extends object>(stores: ToWritableSignal<T>): <U extends Partial<T>>(storesValues?: void | U | undefined) => void; | ||
export declare function createPatch<T extends object>(stores: ToWritableSignal<T>): (storesValues: Partial<T>) => void; | ||
/** | ||
@@ -39,5 +58,6 @@ * This utility function is designed to compare the first level of two objects. | ||
* | ||
* @param obj1 - First object | ||
* @param obj2 - Second object | ||
* @returns the object with changed properties | ||
* @template T - The type of the objects being compared. | ||
* @param obj1 - The first partial object to compare. | ||
* @param obj2 - The second partial object to compare. | ||
* @returns A partial object containing the properties that have different values, or `null` if the objects are identical. | ||
*/ | ||
@@ -53,2 +73,4 @@ export declare function findChangedProperties<T extends Record<string, any>>(obj1: Partial<T>, obj2: Partial<T>): Partial<T> | null; | ||
* | ||
* @template T - The type of the value. | ||
* | ||
* @param defValue - Default value used when both the own value and the config$ value are undefined. | ||
@@ -69,27 +91,33 @@ * @param config$ - Store containing the default value used when the own value is undefined | ||
* If the provided argument is already a store, it is returned as is, otherwise, a readable store is created with the provided argument as its initial value. | ||
* @param x - either a store or a simple value | ||
* @returns either x if x is already a store, or readable(x) otherwise | ||
* @template T - The type of the value. | ||
* @param x - The value to be converted to a readable store. | ||
* @returns - The readable store containing the value. | ||
*/ | ||
export declare const toReadableStore: <T>(x: ReadableSignal<T> | T) => ReadableSignal<T>; | ||
/** | ||
* If the provided argument is already a store, it is returned as is, otherwise, a writable store is created with the provided argument as its initial value. | ||
* @param x - either a writable store or a simple value | ||
* @returns either x if x is already a store, or writable(x) otherwise | ||
* Converts a value or a writable signal into a writable signal. | ||
* | ||
* @template T - The type of the value or signal. | ||
* @param x - The value or writable signal to convert. | ||
* @returns - The resulting writable signal. | ||
*/ | ||
export declare const toWritableStore: <T>(x: WritableSignal<T> | T) => WritableSignal<T, T>; | ||
export declare const toWritableStore: <T>(x: WritableSignal<T> | T) => WritableSignal<T>; | ||
/** | ||
* Extract and normalize config stores. | ||
* Normalizes configuration stores by converting them into readable signals. | ||
* | ||
* @param keys - the keys of the stores to extract / normalize | ||
* @param config - the config stores | ||
* @returns the normalized config stores | ||
* @template T - The type of the configuration object. | ||
* @param keys - An array of keys to normalize from the configuration object. | ||
* @param [config] - The configuration object or readable signals to normalize. | ||
* @returns An object containing readable signals for each key in the configuration. | ||
*/ | ||
export declare const normalizeConfigStores: <T extends object>(keys: (keyof T)[], config?: ReadableSignal<Partial<T>> | ValuesOrReadableSignals<T>) => ReadableSignals<T>; | ||
/** | ||
* Merge two stores configs into one | ||
* Merges two configuration stores into one, prioritizing the first store's values | ||
* when both stores have a value for the same key. | ||
* | ||
* @param keys - the keys of the stores to extract and merge from the two provided configs | ||
* @param config1 - the first config | ||
* @param config2 - the second config | ||
* @returns the merged config | ||
* @template T - The type of the configuration object. | ||
* @param keys - The keys to merge from the configuration stores. | ||
* @param [config1] - The first configuration store. | ||
* @param [config2] - The second configuration store. | ||
* @returns - The merged configuration store. | ||
*/ | ||
@@ -102,2 +130,4 @@ export declare const mergeConfigStores: <T extends object>(keys: (keyof T)[], config1?: ReadableSignals<T>, config2?: ReadableSignals<T>) => ReadableSignals<T>; | ||
* | ||
* @template T - The type of the default configuration object. | ||
* | ||
* @param defConfig - object containing, for each property, a default value to use in case `config$` does not provide the suitable default | ||
@@ -128,2 +158,4 @@ * value for that property | ||
* Shortcut for calling both {@link writablesWithDefault} and {@link createPatch} in one call. | ||
* | ||
* @template T - The type of the properties configuration object. | ||
* @param defConfig - object containing, for each property, a default value to use in case `config` does not provide the suitable default | ||
@@ -153,6 +185,7 @@ * value for that property | ||
*/ | ||
export declare const writablesForProps: <T extends object>(defConfig: T, propsConfig?: PropsConfig<T>, options?: { [K in keyof T]?: WritableWithDefaultOptions<T[K]>; }) => [ToWritableSignal<T>, ReturnType<typeof createPatch<T>>]; | ||
export declare const writablesForProps: <T extends object>(defConfig: T, propsConfig?: PropsConfig<T>, options?: { [K in keyof T]: WritableWithDefaultOptions<T[K]> | undefined; }) => [ToWritableSignal<T>, ReturnType<typeof createPatch<T>>]; | ||
/** | ||
* Using input stores, this function builds an object containing the stores as readable and a global state. | ||
* | ||
* @template A - The type of the state object. | ||
* @param inputStores - the input stores | ||
@@ -166,20 +199,25 @@ * @returns the object containing the stores as readable and the global state | ||
/** | ||
* Creates a derived store that binds to multiple stores and triggers a callback when the value changes for any reason. | ||
* @param onChange$ - A readable signal containing a callback function to execute when the value changes. | ||
* @param stores - An array of Svelte stores, with the main store at index 0. | ||
* @param adjustValue - A function to adjust the value of the main store. By default, the value of the main store is returned. | ||
* @param equal - A function to determine if two values are equal. Used to compare the ajusted value with the current one. | ||
* @returns The derived store that reflects the combined state of the input stores. | ||
* Creates a writable signal that derives its value from multiple stores and allows for custom adjustment and equality checks. | ||
* | ||
* @template T - The type of the derived value. | ||
* @template U - A tuple type where the first element is a writable signal of type T and the rest are store inputs. | ||
* | ||
* @param onChange$ - A readable signal that emits a function to be called when the derived value changes. | ||
* @param stores - A tuple of stores where the first element is a writable signal of type T and the rest are store inputs. | ||
* @param adjustValue - A function to adjust the derived value based on the input values from the stores. | ||
* @param equal - A function to compare the current and new values for equality. | ||
* | ||
* @returns A writable signal that derives its value from the provided stores and allows for custom adjustment and equality checks. | ||
*/ | ||
export declare const bindableDerived: <T, U extends [WritableSignal<T>, ...StoreInput<any>[]]>(onChange$: ReadableSignal<(value: T) => void>, stores: U, adjustValue?: (arg: StoresInputValues<U>) => T, equal?: (currentValue: T, newValue: T) => boolean) => WritableSignal<T, T>; | ||
export declare const bindableDerived: <T, U extends [WritableSignal<T>, ...StoreInput<any>[]]>(onChange$: ReadableSignal<(value: T) => void>, stores: U, adjustValue?: (arg: StoresInputValues<U>) => T, equal?: (currentValue: T, newValue: T) => boolean) => WritableSignal<T>; | ||
/** | ||
* Creates a computed store that contains the adjusted value of the given store and that triggers a callback when the value changes from the set or update | ||
* method of the returned writable store. | ||
* @param store$ - store to be bound | ||
* @param onChange$ - A readable signal containing a callback function to execute when the value changes from the set or update method of the returned writable store. | ||
* @param adjustValue - A function to adjust the value of the store, called in a reactive context each time the value changes or any called dependency changes. | ||
* By default, the value of store$ is returned. | ||
* @param equal - A function to determine if two values are equal. | ||
* @returns A writable store that contains the adjusted value of the given store, with the set or update functions that trigger the onChange$ callback. | ||
* Creates a bindable property that synchronizes a writable signal with an optional adjustment function and equality check. | ||
* | ||
* @template T - The type of the value being stored. | ||
* @param store$ - The writable signal that holds the current value. | ||
* @param onChange$ - A readable signal that triggers a callback when the value changes. | ||
* @param [adjustValue] - An optional function to adjust the value before storing it. Defaults to the identity function. | ||
* @param [equal] - An optional function to compare values for equality. Defaults to `tansuDefaultEqual`. | ||
* @returns A writable signal that synchronizes with the provided store and triggers the onChange callback when updated. | ||
*/ | ||
export declare const bindableProp: <T>(store$: WritableSignal<T, T | undefined>, onChange$: ReadableSignal<(newValue: T) => void>, adjustValue?: (value: T) => T, equal?: (a: T, b: T) => boolean) => WritableSignal<T, T>; | ||
export declare const bindableProp: <T>(store$: WritableSignal<T, T | undefined>, onChange$: ReadableSignal<(newValue: T) => void>, adjustValue?: (value: T) => T, equal?: (a: T, b: T) => boolean) => WritableSignal<T>; |
@@ -8,3 +8,3 @@ import { batch, computed, asWritable, readable, writable, asReadable, get, derived, equal } from "@amadeus-it-group/tansu"; | ||
var _a; | ||
for (const [name, value] of Object.entries(storesValues ?? {})) { | ||
for (const [name, value] of Object.entries(storesValues)) { | ||
(_a = stores[`${name}$`]) == null ? void 0 : _a.set(value); | ||
@@ -11,0 +11,0 @@ } |
@@ -6,7 +6,16 @@ import type { WritableWithDefaultOptions } from '../types'; | ||
* | ||
* @param filter - the guard function | ||
* @returns a function that takes a value as input, checks if it respects the type guard and returns `INVALID_VALUE` otherwise | ||
* @template T - The type that the filter function validates. | ||
* @param filter - A function that takes a value and returns a boolean indicating | ||
* whether the value is of type T. | ||
* @returns A function that takes a value and returns the value if it passes the filter, | ||
* otherwise returns `INVALID_VALUE`. | ||
*/ | ||
export declare const testToNormalizeValue: <T>(filter: (value: any) => value is T) => (value: any) => typeof INVALID_VALUE | T; | ||
export declare const testToNormalizeValue: <T>(filter: (value: any) => value is T) => ((value: any) => T | typeof INVALID_VALUE); | ||
/** | ||
* A writable object with default options for handling numbers. | ||
*/ | ||
export declare const typeNumber: WritableWithDefaultOptions<number>; | ||
/** | ||
* Options for specifying the behavior of number range validation. | ||
*/ | ||
export interface TypeNumberInRangeOptions { | ||
@@ -28,7 +37,47 @@ /** If `true`, the range checking will be strict, excluding the minimum and maximum values. Default is `false`. */ | ||
export declare function typeNumberInRangeFactory(min: number, max: number, options?: TypeNumberInRangeOptions): WritableWithDefaultOptions<number>; | ||
/** | ||
* A writable object with default options for boolean values. | ||
* | ||
* This object provides a normalized way to handle boolean values | ||
* using the `WritableWithDefaultOptions` interface. The `normalizeValue` | ||
* function ensures that the value is properly validated and normalized | ||
* as a boolean. | ||
*/ | ||
export declare const typeBoolean: WritableWithDefaultOptions<boolean>; | ||
/** | ||
* A writable with default options that normalizes its value to a boolean or null. | ||
* | ||
* This writable uses a normalization function that allows null values and ensures | ||
* the value is a boolean. | ||
*/ | ||
export declare const typeBooleanOrNull: WritableWithDefaultOptions<boolean | null>; | ||
/** | ||
* A writable object with default options for string values. | ||
* | ||
* This object provides a normalized value for strings using the `testToNormalizeValue` function | ||
* with the `isString` validator. | ||
*/ | ||
export declare const typeString: WritableWithDefaultOptions<string>; | ||
/** | ||
* A writable object that holds a function type with default options. | ||
*/ | ||
export declare const typeFunction: WritableWithDefaultOptions<(...args: any[]) => any>; | ||
/** | ||
* A writable object with default options for handling values of type `HTMLElement` or `null`. | ||
* | ||
* This object provides: | ||
* - `normalizeValue`: A function to normalize the value, ensuring it is either an `HTMLElement` or `null`. | ||
* - `equal`: A function to compare two values for equality using `Object.is`. | ||
*/ | ||
export declare const typeHTMLElementOrNull: WritableWithDefaultOptions<HTMLElement | null>; | ||
/** | ||
* A writable object with default options for handling arrays. | ||
*/ | ||
export declare const typeArray: WritableWithDefaultOptions<any[]>; | ||
/** | ||
* Build an enum normalizer | ||
* @template T - the enum type | ||
* @param enumList - list of enum values to check | ||
* @returns the enum normalizer | ||
*/ | ||
export declare function createTypeEnum<T>(enumList: T[]): WritableWithDefaultOptions<T>; |
@@ -1,4 +0,5 @@ | ||
import { t, h, c, d, f, g, a, b, e } from "../writables-DoU_XYTX.js"; | ||
import { i, t, h, c, d, f, g, a, b, e } from "../writables-DCiBdIBK.js"; | ||
import "../types.js"; | ||
export { | ||
i as createTypeEnum, | ||
t as testToNormalizeValue, | ||
@@ -5,0 +6,0 @@ h as typeArray, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
429417
12117
1