preact-intlayer 9.7.3 → 9.8.0-canary.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/UI/ContentSelector.cjs.map +1 -1
- package/dist/cjs/format/useDate.cjs +10 -4
- package/dist/cjs/format/useDate.cjs.map +1 -1
- package/dist/esm/UI/ContentSelector.mjs.map +1 -1
- package/dist/esm/format/useDate.mjs +12 -6
- package/dist/esm/format/useDate.mjs.map +1 -1
- package/dist/types/UI/ContentSelector.d.ts +2 -2
- package/dist/types/UI/ContentSelector.d.ts.map +1 -1
- package/dist/types/format/useDate.d.ts +3 -2
- package/dist/types/format/useDate.d.ts.map +1 -1
- package/dist/types/html/types.d.ts +4 -4
- package/dist/types/html/types.d.ts.map +1 -1
- package/package.json +8 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentSelector.cjs","names":["useRef","useState","useCallback"],"sources":["../../../src/UI/ContentSelector.tsx"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"ContentSelector.cjs","names":["useRef","useState","useCallback"],"sources":["../../../src/UI/ContentSelector.tsx"],"sourcesContent":["import type {\n FunctionalComponent,\n HTMLAttributes,\n MouseEventHandler,\n} from 'preact';\nimport { useCallback, useEffect, useRef, useState } from 'preact/hooks';\n\nconst DEFAULT_PRESS_DETECT_DURATION = 250;\n\ntype ContentSelectorProps = {\n onPress: () => void;\n onHover?: () => void;\n onUnhover?: () => void;\n onClickOutside?: () => void;\n pressDuration?: number;\n isSelecting?: boolean;\n} & Omit<HTMLAttributes<HTMLDivElement>, 'content'>;\n\nexport const ContentSelector: FunctionalComponent<ContentSelectorProps> = ({\n children,\n onPress: onSelect,\n onHover,\n onUnhover,\n onClickOutside: onUnselect,\n pressDuration = DEFAULT_PRESS_DETECT_DURATION,\n isSelecting: isSelectingProp,\n ...props\n}) => {\n const divRef = useRef<HTMLDivElement>(null);\n const [isHovered, setIsHovered] = useState(false);\n const [isSelectingState, setIsSelectingState] = useState(isSelectingProp);\n const pressTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const isChildrenString = typeof children === 'string';\n\n const handleOnLongPress = () => {\n setIsSelectingState(true);\n onSelect();\n };\n\n const startPressTimer = () => {\n pressTimerRef.current = setTimeout(() => {\n handleOnLongPress();\n }, pressDuration);\n };\n\n const clearPressTimer = () => {\n if (pressTimerRef.current) {\n clearTimeout(pressTimerRef.current);\n pressTimerRef.current = null;\n }\n };\n\n const handleMouseDown = () => {\n clearPressTimer(); // Ensure any previous timer is cleared\n startPressTimer();\n };\n\n const handleMouseEnter = () => {\n setIsHovered(true);\n onHover?.();\n };\n\n const handleMouseUp = () => {\n if (isHovered) {\n setIsHovered(false);\n onUnhover?.();\n }\n clearPressTimer();\n };\n\n // Use useCallback to ensure the function identity remains stable\n const handleClickOutside = useCallback(\n (event: MouseEvent) => {\n if (divRef.current && !divRef.current.contains(event.target as Node)) {\n setIsSelectingState(false);\n onUnselect?.();\n }\n },\n [onUnselect]\n );\n\n useEffect(() => {\n // Attach click outside listener\n document.addEventListener('mousedown', handleClickOutside);\n\n return () => {\n // Cleanup\n document.removeEventListener('mousedown', handleClickOutside);\n // clearPressTimer(); // Ensure to clear the timer when component unmounts\n };\n }, [handleClickOutside]);\n\n const handleOnClick: MouseEventHandler<HTMLDivElement> = (e) => {\n if (isSelectingState) {\n e.preventDefault();\n e.stopPropagation();\n }\n };\n\n const handleOnBlur = () => {\n // Stop editing when the element loses focus\n setIsSelectingState(false);\n };\n\n return (\n <span\n style={{\n display: isChildrenString ? 'inline' : 'inline-block',\n cursor: 'pointer',\n userSelect: 'none',\n borderRadius: '0.375rem',\n outlineWidth: '2px',\n outlineOffset: '4px',\n outlineStyle: 'solid',\n outlineColor:\n isSelectingProp || isSelectingState || isHovered\n ? 'inherit'\n : 'transparent',\n transition: 'all 100ms 50ms ease-in-out',\n }}\n role=\"button\"\n tabIndex={0}\n onKeyUp={() => null}\n onClick={handleOnClick}\n onMouseDown={handleMouseDown}\n onMouseUp={handleMouseUp}\n onMouseLeave={handleMouseUp}\n onTouchStart={handleMouseDown}\n onTouchEnd={handleMouseUp}\n onTouchCancel={handleMouseUp}\n onBlur={handleOnBlur}\n onMouseEnter={handleMouseEnter}\n ref={divRef}\n {...props}\n >\n {children}\n </span>\n );\n};\n"],"mappings":";;;;;AAOA,MAAM,gCAAgC;AAWtC,MAAa,mBAA8D,EACzE,UACA,SAAS,UACT,SACA,WACA,gBAAgB,YAChB,gBAAgB,+BAChB,aAAa,iBACb,GAAG,YACC;CACJ,MAAM,aAASA,qBAAuB,IAAI;CAC1C,MAAM,CAAC,WAAW,oBAAgBC,uBAAS,KAAK;CAChD,MAAM,CAAC,kBAAkB,2BAAuBA,uBAAS,eAAe;CACxE,MAAM,oBAAgBD,qBAA6C,IAAI;CACvE,MAAM,mBAAmB,OAAO,aAAa;CAE7C,MAAM,0BAA0B;EAC9B,oBAAoB,IAAI;EACxB,SAAS;CACX;CAEA,MAAM,wBAAwB;EAC5B,cAAc,UAAU,iBAAiB;GACvC,kBAAkB;EACpB,GAAG,aAAa;CAClB;CAEA,MAAM,wBAAwB;EAC5B,IAAI,cAAc,SAAS;GACzB,aAAa,cAAc,OAAO;GAClC,cAAc,UAAU;EAC1B;CACF;CAEA,MAAM,wBAAwB;EAC5B,gBAAgB;EAChB,gBAAgB;CAClB;CAEA,MAAM,yBAAyB;EAC7B,aAAa,IAAI;EACjB,UAAU;CACZ;CAEA,MAAM,sBAAsB;EAC1B,IAAI,WAAW;GACb,aAAa,KAAK;GAClB,YAAY;EACd;EACA,gBAAgB;CAClB;CAGA,MAAM,yBAAqBE,2BACxB,UAAsB;EACrB,IAAI,OAAO,WAAW,CAAC,OAAO,QAAQ,SAAS,MAAM,MAAc,GAAG;GACpE,oBAAoB,KAAK;GACzB,aAAa;EACf;CACF,GACA,CAAC,UAAU,CACb;CAEA,kCAAgB;EAEd,SAAS,iBAAiB,aAAa,kBAAkB;EAEzD,aAAa;GAEX,SAAS,oBAAoB,aAAa,kBAAkB;EAE9D;CACF,GAAG,CAAC,kBAAkB,CAAC;CAEvB,MAAM,iBAAoD,MAAM;EAC9D,IAAI,kBAAkB;GACpB,EAAE,eAAe;GACjB,EAAE,gBAAgB;EACpB;CACF;CAEA,MAAM,qBAAqB;EAEzB,oBAAoB,KAAK;CAC3B;CAEA,OACE,4CAAC,QAAD;EACE,OAAO;GACL,SAAS,mBAAmB,WAAW;GACvC,QAAQ;GACR,YAAY;GACZ,cAAc;GACd,cAAc;GACd,eAAe;GACf,cAAc;GACd,cACE,mBAAmB,oBAAoB,YACnC,YACA;GACN,YAAY;EACd;EACA,MAAK;EACL,UAAU;EACV,eAAe;EACf,SAAS;EACT,aAAa;EACb,WAAW;EACX,cAAc;EACd,cAAc;EACd,YAAY;EACZ,eAAe;EACf,QAAQ;EACR,cAAc;EACd,KAAK;EACL,GAAI;EAEH;CACG;AAEV"}
|
|
@@ -32,10 +32,16 @@ let _intlayer_core_formatters = require("@intlayer/core/formatters");
|
|
|
32
32
|
*/
|
|
33
33
|
const useDate = () => {
|
|
34
34
|
const { locale } = (0, preact_hooks.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
|
|
35
|
-
return (
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
return (0, preact_hooks.useCallback)((...args) => {
|
|
36
|
+
const options = typeof args[1] === "string" ? {
|
|
37
|
+
..._intlayer_core_formatters.presets[args[1]],
|
|
38
|
+
locale
|
|
39
|
+
} : {
|
|
40
|
+
...args[1],
|
|
41
|
+
locale: args[1]?.locale ?? locale
|
|
42
|
+
};
|
|
43
|
+
return (0, _intlayer_core_formatters.date)(args[0], options);
|
|
44
|
+
}, [locale]);
|
|
39
45
|
};
|
|
40
46
|
|
|
41
47
|
exports.useDate = useDate;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDate.cjs","names":["useContext","IntlayerClientContext","date"],"sources":["../../../src/format/useDate.ts"],"sourcesContent":["import { date } from '@intlayer/core/formatters';\nimport { useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * React client hook that provides a localized date/time formatter\n * bound to the current application locale.\n *\n * @returns {(date: Date | string | number, options?: DateProps) => string}\n * A function to format dates or timestamps into localized date/time strings.\n *\n * @example\n * ```tsx\n * const formatDate = useDate();\n *\n * formatDate(new Date(\"2025-01-01\"));\n * // \"Jan 1, 2025\"\n *\n * formatDate(\"2025-01-01T15:30:00Z\", {\n * dateStyle: \"full\",\n * timeStyle: \"short\",\n * });\n * // \"Wednesday, January 1, 2025 at 3:30 PM\"\n *\n * formatDate(1735689600000, { locale: \"fr-FR\", dateStyle: \"long\" });\n * // \"1 janvier 2025\"\n * ```\n *\n * @see createDate\n */\nexport const useDate = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return (...args: Parameters<typeof date>)
|
|
1
|
+
{"version":3,"file":"useDate.cjs","names":["useContext","IntlayerClientContext","useCallback","presets","date"],"sources":["../../../src/format/useDate.ts"],"sourcesContent":["import { date, presets } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * React client hook that provides a localized date/time formatter\n * bound to the current application locale.\n *\n * @returns {(date: Date | string | number, options?: DateProps) => string}\n * A function to format dates or timestamps into localized date/time strings.\n *\n * @example\n * ```tsx\n * const formatDate = useDate();\n *\n * formatDate(new Date(\"2025-01-01\"));\n * // \"Jan 1, 2025\"\n *\n * formatDate(\"2025-01-01T15:30:00Z\", {\n * dateStyle: \"full\",\n * timeStyle: \"short\",\n * });\n * // \"Wednesday, January 1, 2025 at 3:30 PM\"\n *\n * formatDate(1735689600000, { locale: \"fr-FR\", dateStyle: \"long\" });\n * // \"1 janvier 2025\"\n * ```\n *\n * @see createDate\n */\nexport const useDate = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof date>) => {\n const options =\n typeof args[1] === 'string'\n ? { ...presets[args[1]], locale }\n : { ...args[1], locale: args[1]?.locale ?? locale };\n\n return date(args[0], options as Parameters<typeof date>[1]);\n },\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,gBAAgB;CAC3B,MAAM,EAAE,eAAWA,yBAAWC,qDAAqB,KAAK,CAAC;CAEzD,WAAOC,2BACJ,GAAG,SAAkC;EACpC,MAAM,UACJ,OAAO,KAAK,OAAO,WACf;GAAE,GAAGC,kCAAQ,KAAK;GAAK;EAAO,IAC9B;GAAE,GAAG,KAAK;GAAI,QAAQ,KAAK,EAAE,EAAE,UAAU;EAAO;EAEtD,WAAOC,gCAAK,KAAK,IAAI,OAAqC;CAC5D,GACA,CAAC,MAAM,CACT;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentSelector.mjs","names":[],"sources":["../../../src/UI/ContentSelector.tsx"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"ContentSelector.mjs","names":[],"sources":["../../../src/UI/ContentSelector.tsx"],"sourcesContent":["import type {\n FunctionalComponent,\n HTMLAttributes,\n MouseEventHandler,\n} from 'preact';\nimport { useCallback, useEffect, useRef, useState } from 'preact/hooks';\n\nconst DEFAULT_PRESS_DETECT_DURATION = 250;\n\ntype ContentSelectorProps = {\n onPress: () => void;\n onHover?: () => void;\n onUnhover?: () => void;\n onClickOutside?: () => void;\n pressDuration?: number;\n isSelecting?: boolean;\n} & Omit<HTMLAttributes<HTMLDivElement>, 'content'>;\n\nexport const ContentSelector: FunctionalComponent<ContentSelectorProps> = ({\n children,\n onPress: onSelect,\n onHover,\n onUnhover,\n onClickOutside: onUnselect,\n pressDuration = DEFAULT_PRESS_DETECT_DURATION,\n isSelecting: isSelectingProp,\n ...props\n}) => {\n const divRef = useRef<HTMLDivElement>(null);\n const [isHovered, setIsHovered] = useState(false);\n const [isSelectingState, setIsSelectingState] = useState(isSelectingProp);\n const pressTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const isChildrenString = typeof children === 'string';\n\n const handleOnLongPress = () => {\n setIsSelectingState(true);\n onSelect();\n };\n\n const startPressTimer = () => {\n pressTimerRef.current = setTimeout(() => {\n handleOnLongPress();\n }, pressDuration);\n };\n\n const clearPressTimer = () => {\n if (pressTimerRef.current) {\n clearTimeout(pressTimerRef.current);\n pressTimerRef.current = null;\n }\n };\n\n const handleMouseDown = () => {\n clearPressTimer(); // Ensure any previous timer is cleared\n startPressTimer();\n };\n\n const handleMouseEnter = () => {\n setIsHovered(true);\n onHover?.();\n };\n\n const handleMouseUp = () => {\n if (isHovered) {\n setIsHovered(false);\n onUnhover?.();\n }\n clearPressTimer();\n };\n\n // Use useCallback to ensure the function identity remains stable\n const handleClickOutside = useCallback(\n (event: MouseEvent) => {\n if (divRef.current && !divRef.current.contains(event.target as Node)) {\n setIsSelectingState(false);\n onUnselect?.();\n }\n },\n [onUnselect]\n );\n\n useEffect(() => {\n // Attach click outside listener\n document.addEventListener('mousedown', handleClickOutside);\n\n return () => {\n // Cleanup\n document.removeEventListener('mousedown', handleClickOutside);\n // clearPressTimer(); // Ensure to clear the timer when component unmounts\n };\n }, [handleClickOutside]);\n\n const handleOnClick: MouseEventHandler<HTMLDivElement> = (e) => {\n if (isSelectingState) {\n e.preventDefault();\n e.stopPropagation();\n }\n };\n\n const handleOnBlur = () => {\n // Stop editing when the element loses focus\n setIsSelectingState(false);\n };\n\n return (\n <span\n style={{\n display: isChildrenString ? 'inline' : 'inline-block',\n cursor: 'pointer',\n userSelect: 'none',\n borderRadius: '0.375rem',\n outlineWidth: '2px',\n outlineOffset: '4px',\n outlineStyle: 'solid',\n outlineColor:\n isSelectingProp || isSelectingState || isHovered\n ? 'inherit'\n : 'transparent',\n transition: 'all 100ms 50ms ease-in-out',\n }}\n role=\"button\"\n tabIndex={0}\n onKeyUp={() => null}\n onClick={handleOnClick}\n onMouseDown={handleMouseDown}\n onMouseUp={handleMouseUp}\n onMouseLeave={handleMouseUp}\n onTouchStart={handleMouseDown}\n onTouchEnd={handleMouseUp}\n onTouchCancel={handleMouseUp}\n onBlur={handleOnBlur}\n onMouseEnter={handleMouseEnter}\n ref={divRef}\n {...props}\n >\n {children}\n </span>\n );\n};\n"],"mappings":";;;;AAOA,MAAM,gCAAgC;AAWtC,MAAa,mBAA8D,EACzE,UACA,SAAS,UACT,SACA,WACA,gBAAgB,YAChB,gBAAgB,+BAChB,aAAa,iBACb,GAAG,YACC;CACJ,MAAM,SAAS,OAAuB,IAAI;CAC1C,MAAM,CAAC,WAAW,gBAAgB,SAAS,KAAK;CAChD,MAAM,CAAC,kBAAkB,uBAAuB,SAAS,eAAe;CACxE,MAAM,gBAAgB,OAA6C,IAAI;CACvE,MAAM,mBAAmB,OAAO,aAAa;CAE7C,MAAM,0BAA0B;EAC9B,oBAAoB,IAAI;EACxB,SAAS;CACX;CAEA,MAAM,wBAAwB;EAC5B,cAAc,UAAU,iBAAiB;GACvC,kBAAkB;EACpB,GAAG,aAAa;CAClB;CAEA,MAAM,wBAAwB;EAC5B,IAAI,cAAc,SAAS;GACzB,aAAa,cAAc,OAAO;GAClC,cAAc,UAAU;EAC1B;CACF;CAEA,MAAM,wBAAwB;EAC5B,gBAAgB;EAChB,gBAAgB;CAClB;CAEA,MAAM,yBAAyB;EAC7B,aAAa,IAAI;EACjB,UAAU;CACZ;CAEA,MAAM,sBAAsB;EAC1B,IAAI,WAAW;GACb,aAAa,KAAK;GAClB,YAAY;EACd;EACA,gBAAgB;CAClB;CAGA,MAAM,qBAAqB,aACxB,UAAsB;EACrB,IAAI,OAAO,WAAW,CAAC,OAAO,QAAQ,SAAS,MAAM,MAAc,GAAG;GACpE,oBAAoB,KAAK;GACzB,aAAa;EACf;CACF,GACA,CAAC,UAAU,CACb;CAEA,gBAAgB;EAEd,SAAS,iBAAiB,aAAa,kBAAkB;EAEzD,aAAa;GAEX,SAAS,oBAAoB,aAAa,kBAAkB;EAE9D;CACF,GAAG,CAAC,kBAAkB,CAAC;CAEvB,MAAM,iBAAoD,MAAM;EAC9D,IAAI,kBAAkB;GACpB,EAAE,eAAe;GACjB,EAAE,gBAAgB;EACpB;CACF;CAEA,MAAM,qBAAqB;EAEzB,oBAAoB,KAAK;CAC3B;CAEA,OACE,oBAAC,QAAD;EACE,OAAO;GACL,SAAS,mBAAmB,WAAW;GACvC,QAAQ;GACR,YAAY;GACZ,cAAc;GACd,cAAc;GACd,eAAe;GACf,cAAc;GACd,cACE,mBAAmB,oBAAoB,YACnC,YACA;GACN,YAAY;EACd;EACA,MAAK;EACL,UAAU;EACV,eAAe;EACf,SAAS;EACT,aAAa;EACb,WAAW;EACX,cAAc;EACd,cAAc;EACd,YAAY;EACZ,eAAe;EACf,QAAQ;EACR,cAAc;EACd,KAAK;EACL,GAAI;EAEH;CACG;AAEV"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IntlayerClientContext } from "../client/IntlayerProvider.mjs";
|
|
2
|
-
import { useContext } from "preact/hooks";
|
|
3
|
-
import { date } from "@intlayer/core/formatters";
|
|
2
|
+
import { useCallback, useContext } from "preact/hooks";
|
|
3
|
+
import { date, presets } from "@intlayer/core/formatters";
|
|
4
4
|
|
|
5
5
|
// src/format/useDate.ts
|
|
6
6
|
/**
|
|
@@ -31,10 +31,16 @@ import { date } from "@intlayer/core/formatters";
|
|
|
31
31
|
*/
|
|
32
32
|
const useDate = () => {
|
|
33
33
|
const { locale } = useContext(IntlayerClientContext) ?? {};
|
|
34
|
-
return (...args) =>
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
return useCallback((...args) => {
|
|
35
|
+
const options = typeof args[1] === "string" ? {
|
|
36
|
+
...presets[args[1]],
|
|
37
|
+
locale
|
|
38
|
+
} : {
|
|
39
|
+
...args[1],
|
|
40
|
+
locale: args[1]?.locale ?? locale
|
|
41
|
+
};
|
|
42
|
+
return date(args[0], options);
|
|
43
|
+
}, [locale]);
|
|
38
44
|
};
|
|
39
45
|
|
|
40
46
|
export { useDate };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDate.mjs","names":[],"sources":["../../../src/format/useDate.ts"],"sourcesContent":["import { date } from '@intlayer/core/formatters';\nimport { useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * React client hook that provides a localized date/time formatter\n * bound to the current application locale.\n *\n * @returns {(date: Date | string | number, options?: DateProps) => string}\n * A function to format dates or timestamps into localized date/time strings.\n *\n * @example\n * ```tsx\n * const formatDate = useDate();\n *\n * formatDate(new Date(\"2025-01-01\"));\n * // \"Jan 1, 2025\"\n *\n * formatDate(\"2025-01-01T15:30:00Z\", {\n * dateStyle: \"full\",\n * timeStyle: \"short\",\n * });\n * // \"Wednesday, January 1, 2025 at 3:30 PM\"\n *\n * formatDate(1735689600000, { locale: \"fr-FR\", dateStyle: \"long\" });\n * // \"1 janvier 2025\"\n * ```\n *\n * @see createDate\n */\nexport const useDate = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return (...args: Parameters<typeof date>)
|
|
1
|
+
{"version":3,"file":"useDate.mjs","names":[],"sources":["../../../src/format/useDate.ts"],"sourcesContent":["import { date, presets } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * React client hook that provides a localized date/time formatter\n * bound to the current application locale.\n *\n * @returns {(date: Date | string | number, options?: DateProps) => string}\n * A function to format dates or timestamps into localized date/time strings.\n *\n * @example\n * ```tsx\n * const formatDate = useDate();\n *\n * formatDate(new Date(\"2025-01-01\"));\n * // \"Jan 1, 2025\"\n *\n * formatDate(\"2025-01-01T15:30:00Z\", {\n * dateStyle: \"full\",\n * timeStyle: \"short\",\n * });\n * // \"Wednesday, January 1, 2025 at 3:30 PM\"\n *\n * formatDate(1735689600000, { locale: \"fr-FR\", dateStyle: \"long\" });\n * // \"1 janvier 2025\"\n * ```\n *\n * @see createDate\n */\nexport const useDate = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof date>) => {\n const options =\n typeof args[1] === 'string'\n ? { ...presets[args[1]], locale }\n : { ...args[1], locale: args[1]?.locale ?? locale };\n\n return date(args[0], options as Parameters<typeof date>[1]);\n },\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,gBAAgB;CAC3B,MAAM,EAAE,WAAW,WAAW,qBAAqB,KAAK,CAAC;CAEzD,OAAO,aACJ,GAAG,SAAkC;EACpC,MAAM,UACJ,OAAO,KAAK,OAAO,WACf;GAAE,GAAG,QAAQ,KAAK;GAAK;EAAO,IAC9B;GAAE,GAAG,KAAK;GAAI,QAAQ,KAAK,EAAE,EAAE,UAAU;EAAO;EAEtD,OAAO,KAAK,KAAK,IAAI,OAAqC;CAC5D,GACA,CAAC,MAAM,CACT;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FunctionalComponent,
|
|
1
|
+
import { FunctionalComponent, HTMLAttributes } from "preact";
|
|
2
2
|
type ContentSelectorProps = {
|
|
3
3
|
onPress: () => void;
|
|
4
4
|
onHover?: () => void;
|
|
@@ -6,7 +6,7 @@ type ContentSelectorProps = {
|
|
|
6
6
|
onClickOutside?: () => void;
|
|
7
7
|
pressDuration?: number;
|
|
8
8
|
isSelecting?: boolean;
|
|
9
|
-
} & Omit<
|
|
9
|
+
} & Omit<HTMLAttributes<HTMLDivElement>, 'content'>;
|
|
10
10
|
export declare const ContentSelector: FunctionalComponent<ContentSelectorProps>;
|
|
11
11
|
export {};
|
|
12
12
|
//# sourceMappingURL=ContentSelector.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentSelector.d.ts","names":[],"sources":["../../../src/UI/ContentSelector.tsx"],"mappings":";
|
|
1
|
+
{"version":3,"file":"ContentSelector.d.ts","names":[],"sources":["../../../src/UI/ContentSelector.tsx"],"mappings":";KASK;EACH;EACA;EACA;EACA;EACA;EACA;IACE,KAAK,eAAe;qBAEX,iBAAiB,oBAAoB"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { date } from "@intlayer/core/formatters";
|
|
2
1
|
/**
|
|
3
2
|
* React client hook that provides a localized date/time formatter
|
|
4
3
|
* bound to the current application locale.
|
|
@@ -25,5 +24,7 @@ import { date } from "@intlayer/core/formatters";
|
|
|
25
24
|
*
|
|
26
25
|
* @see createDate
|
|
27
26
|
*/
|
|
28
|
-
export declare const useDate: () => (
|
|
27
|
+
export declare const useDate: () => (date: string | number | Date, options?: import("@intlayer/core/formatters").DateTimePreset | (Intl.DateTimeFormatOptions & {
|
|
28
|
+
locale?: import("@intlayer/types").LocalesValues;
|
|
29
|
+
})) => string;
|
|
29
30
|
//# sourceMappingURL=useDate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDate.d.ts","names":[],"sources":["../../../src/format/useDate.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDate.d.ts","names":[],"sources":["../../../src/format/useDate.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;qBA8Ba,gBAAO,wBAAA,MAAA,8CAAA,kBAAA,KAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FunctionalComponent, JSX } from "preact";
|
|
1
|
+
import { FunctionalComponent, HTMLAttributes, JSX } from "preact";
|
|
2
2
|
import { HTMLTagsType } from "@intlayer/core/transpiler";
|
|
3
3
|
/**
|
|
4
4
|
* Helper to extract specific props from the configuration value.
|
|
@@ -7,7 +7,7 @@ type PropsFromConfig<Value> = Value extends true ? {} : Value extends object ? V
|
|
|
7
7
|
/**
|
|
8
8
|
* Smart Type to resolve props based on the key K.
|
|
9
9
|
*/
|
|
10
|
-
type ElementProps<K> = K extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[K] :
|
|
10
|
+
type ElementProps<K> = K extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[K] : HTMLAttributes<HTMLElement>;
|
|
11
11
|
/**
|
|
12
12
|
* Helper: Defines the mapping for the explicitly listed keys in T.
|
|
13
13
|
* Handles whether they are Required or Optional.
|
|
@@ -17,7 +17,7 @@ type DefinedComponents<T, IsRequired extends boolean> = IsRequired extends true
|
|
|
17
17
|
* Helper: Defines the standard HTML tags NOT listed in T.
|
|
18
18
|
* These are always optional when included.
|
|
19
19
|
*/
|
|
20
|
-
type RestHTMLComponents<T> = { [K in Exclude<keyof HTMLTagsType, keyof T>]?: FunctionalComponent<K extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[K] :
|
|
20
|
+
type RestHTMLComponents<T> = { [K in Exclude<keyof HTMLTagsType, keyof T>]?: FunctionalComponent<K extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[K] : HTMLAttributes<HTMLElement>>; };
|
|
21
21
|
/**
|
|
22
22
|
* The supported modes for the HTMLComponents type.
|
|
23
23
|
*/
|
|
@@ -28,7 +28,7 @@ export type HTMLComponentMode = 'permissive' | 'optional' | 'inclusive' | 'stric
|
|
|
28
28
|
export type HTMLComponents<Mode extends HTMLComponentMode = 'optional', T = {}> = Mode extends 'strict' ? DefinedComponents<T, true> : Mode extends 'inclusive' // Inclusive: Keys in T are required. Rest of HTML is optional.
|
|
29
29
|
? DefinedComponents<T, true> & RestHTMLComponents<T> : Mode extends 'permissive' // Permissive: Keys in T optional. Rest of HTML optional. Any other string allowed.
|
|
30
30
|
? DefinedComponents<T, false> & RestHTMLComponents<T> & {
|
|
31
|
-
[key: string]: FunctionalComponent<
|
|
31
|
+
[key: string]: FunctionalComponent<HTMLAttributes<HTMLElement>>;
|
|
32
32
|
} // Optional (Default): Keys in T optional. Rest of HTML optional.
|
|
33
33
|
: DefinedComponents<T, false> & RestHTMLComponents<T>;
|
|
34
34
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/html/types.ts"],"mappings":";;;;;KAMK,gBAAgB,SAAS,0BAE1B,uBACE;;;;KAMD,aAAa,KAAK,gBAAgB,IAAI,oBACvC,IAAI,kBAAkB,KACtB,
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/html/types.ts"],"mappings":";;;;;KAMK,gBAAgB,SAAS,0BAE1B,uBACE;;;;KAMD,aAAa,KAAK,gBAAgB,IAAI,oBACvC,IAAI,kBAAkB,KACtB,eAAe;;;;;KAMd,kBAAkB,GAAG,8BAA8B,6BAGjD,WAAW,IAAI,oBACd,aAAa,KAAK,gBAAgB,EAAE,aAKrC,WAAW,KAAK,oBACf,aAAa,KAAK,gBAAgB,EAAE;;;;;KAQvC,mBAAmB,QACrB,KAAK,cAAc,oBAAoB,MAAM,oBAC5C,gBAAgB,IAAI,oBAChB,IAAI,kBAAkB,KACtB,eAAe;;;;YAOX;;;;YASA,eACV,aAAa,gCACb,UACE,wBAEA,kBAAkB,WAClB;GAEE,kBAAkB,WAAW,mBAAmB,KAChD;GAEE,kBAAkB,YAChB,mBAAmB;GAChB,cAAc,oBAAoB,eAAe;;GAGtD,kBAAkB,YAAY,mBAAmB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "preact-intlayer",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.8.0-canary.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Easily internationalize i18n your Preact applications with type-safe multilingual content management.",
|
|
6
6
|
"keywords": [
|
|
@@ -101,12 +101,12 @@
|
|
|
101
101
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
102
102
|
},
|
|
103
103
|
"dependencies": {
|
|
104
|
-
"@intlayer/api": "9.
|
|
105
|
-
"@intlayer/config": "9.
|
|
106
|
-
"@intlayer/core": "9.
|
|
107
|
-
"@intlayer/editor": "9.
|
|
108
|
-
"@intlayer/engine": "9.
|
|
109
|
-
"@intlayer/types": "9.
|
|
104
|
+
"@intlayer/api": "9.8.0-canary.1",
|
|
105
|
+
"@intlayer/config": "9.8.0-canary.1",
|
|
106
|
+
"@intlayer/core": "9.8.0-canary.1",
|
|
107
|
+
"@intlayer/editor": "9.8.0-canary.1",
|
|
108
|
+
"@intlayer/engine": "9.8.0-canary.1",
|
|
109
|
+
"@intlayer/types": "9.8.0-canary.1"
|
|
110
110
|
},
|
|
111
111
|
"devDependencies": {
|
|
112
112
|
"@types/node": "^26",
|
|
@@ -123,7 +123,7 @@
|
|
|
123
123
|
"preact": ">=8.0.0"
|
|
124
124
|
},
|
|
125
125
|
"optionalDependencies": {
|
|
126
|
-
"@intlayer/analytics": "9.
|
|
126
|
+
"@intlayer/analytics": "9.8.0-canary.1"
|
|
127
127
|
},
|
|
128
128
|
"engines": {
|
|
129
129
|
"node": ">=14.18"
|