@pega/cosmos-react-core 9.0.0-build.9.4 → 9.0.0-build.9.5
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/lib/components/DateTime/Input/DateInput.d.ts.map +1 -1
- package/lib/components/DateTime/Input/DateInput.js +6 -4
- package/lib/components/DateTime/Input/DateInput.js.map +1 -1
- package/lib/components/DateTime/Input/DateTimeInput.d.ts.map +1 -1
- package/lib/components/DateTime/Input/DateTimeInput.js +5 -3
- package/lib/components/DateTime/Input/DateTimeInput.js.map +1 -1
- package/lib/components/DateTime/Input/WeekInput.d.ts.map +1 -1
- package/lib/components/DateTime/Input/WeekInput.js +6 -4
- package/lib/components/DateTime/Input/WeekInput.js.map +1 -1
- package/lib/components/FieldGroup/FieldGroupList.d.ts.map +1 -1
- package/lib/components/FieldGroup/FieldGroupList.js +4 -2
- package/lib/components/FieldGroup/FieldGroupList.js.map +1 -1
- package/lib/components/FieldGroup/FieldGroupList.utils.d.ts +1 -1
- package/lib/components/FieldGroup/FieldGroupList.utils.js +2 -2
- package/lib/components/FieldGroup/FieldGroupList.utils.js.map +1 -1
- package/lib/hooks/useI18n.d.ts +22 -0
- package/lib/hooks/useI18n.d.ts.map +1 -1
- package/lib/hooks/useItemIntersection.d.ts +2 -1
- package/lib/hooks/useItemIntersection.d.ts.map +1 -1
- package/lib/hooks/useItemIntersection.js +10 -6
- package/lib/hooks/useItemIntersection.js.map +1 -1
- package/lib/i18n/default.d.ts +22 -0
- package/lib/i18n/default.d.ts.map +1 -1
- package/lib/i18n/default.js +23 -0
- package/lib/i18n/default.js.map +1 -1
- package/lib/i18n/i18n.d.ts +22 -0
- package/lib/i18n/i18n.d.ts.map +1 -1
- package/lib/utils/getFocusables.d.ts +4 -2
- package/lib/utils/getFocusables.d.ts.map +1 -1
- package/lib/utils/getFocusables.js +9 -7
- package/lib/utils/getFocusables.js.map +1 -1
- package/lib/utils/isInstance.d.ts +4 -4
- package/lib/utils/isInstance.d.ts.map +1 -1
- package/lib/utils/isInstance.js +20 -8
- package/lib/utils/isInstance.js.map +1 -1
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@ import { transparentize } from 'polished';
|
|
|
5
5
|
import Button from '../Button';
|
|
6
6
|
import Icon, { registerIcon } from '../Icon';
|
|
7
7
|
import * as plusIcon from '../Icon/icons/plus.icon';
|
|
8
|
-
import { useDirection, useI18n } from '../../hooks';
|
|
8
|
+
import { useDirection, useI18n, useLiveLog } from '../../hooks';
|
|
9
9
|
import { defaultThemeProp } from '../../theme';
|
|
10
10
|
import { getActiveElement, getFocusables, tryCatch } from '../../utils';
|
|
11
11
|
import Flex from '../Flex';
|
|
@@ -123,6 +123,7 @@ const ListItem = ({ item, index, isAddFocused, handleDelete, fieldGroupRef }) =>
|
|
|
123
123
|
const { id, children, name = '', isDynamic, headingTag, ...restItemProps } = item;
|
|
124
124
|
const t = useI18n();
|
|
125
125
|
const { rtl } = useDirection();
|
|
126
|
+
const { announcePolite } = useLiveLog();
|
|
126
127
|
const { depth = 1, ancestorIndices = [], isAncestorHighlighted = false } = useContext(FieldGroupListContext);
|
|
127
128
|
const [isItemFocused, setIsItemFocused] = useState(false);
|
|
128
129
|
const [isDeleteHovered, setIsDeleteHovered] = useState(false);
|
|
@@ -155,6 +156,7 @@ const ListItem = ({ item, index, isAddFocused, handleDelete, fieldGroupRef }) =>
|
|
|
155
156
|
iconOnly: true,
|
|
156
157
|
onClick: () => {
|
|
157
158
|
handleDelete(id);
|
|
159
|
+
announcePolite({ message: t('deleted', [contextualLabel]) });
|
|
158
160
|
},
|
|
159
161
|
onMouseEnter: () => setIsDeleteHovered(true),
|
|
160
162
|
onMouseLeave: () => setIsDeleteHovered(false)
|
|
@@ -206,7 +208,7 @@ const FieldGroupList = forwardRef(function FieldGroupList({ label, additionalCon
|
|
|
206
208
|
e.stopPropagation();
|
|
207
209
|
}, onBlur: (e) => {
|
|
208
210
|
e.stopPropagation();
|
|
209
|
-
}, children: [label && (_jsxs(Flex, { container: { gap: 0.5, alignItems: 'center' }, children: [_jsx(Text, { variant: 'h3', children: label }), additionalContext && (_jsx(AdditionalInfo, { contextualLabel: label, children: additionalContext })), _jsx(StyledDivider, { "aria-hidden": 'true' })] })), items.length === 0 ? (_jsx(EmptyState, {})) : (_jsx(Flex, { container: { direction: 'column', gap: 1 }, as: StyledFieldGroupList, ref: ref, ...restProps, children: items.map((item, index) => {
|
|
211
|
+
}, children: [label && (_jsxs(Flex, { container: { gap: 0.5, alignItems: 'center' }, children: [_jsx(Text, { variant: 'h3', children: label }), additionalContext && (_jsx(AdditionalInfo, { contextualLabel: label, children: additionalContext })), _jsx(StyledDivider, { "aria-hidden": 'true' })] })), items.length === 0 ? (_jsx(EmptyState, {})) : (_jsx(Flex, { container: { direction: 'column', gap: 1 }, as: StyledFieldGroupList, ref: ref, "aria-label": label, ...restProps, children: items.map((item, index) => {
|
|
210
212
|
const handleDelete = onDelete || item.onDelete
|
|
211
213
|
? (id) => {
|
|
212
214
|
deletedItemIndexRef.current = index;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldGroupList.js","sourceRoot":"","sources":["../../../src/components/FieldGroup/FieldGroupList.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,eAAe,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE3F,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG1C,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAA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AAC,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC;4BACpB,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC;wBACjB,CAAC;wBACH,CAAC,CAAC,SAAS,CAAC;oBAEhB,OAAO,CACL,KAAC,QAAQ,IAEP,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,EACZ,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,EAC1B,aAAa,EAAE,CAAC,EAA8B,EAAE,EAAE;4BAChD,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;wBAC/B,CAAC,IAPI,IAAI,CAAC,EAAE,CAQZ,CACH,CAAC;gBACJ,CAAC,CAAC,GACG,CACR,EAEA,KAAK,IAAI,CACR,MAAC,eAAe,IACd,OAAO,EAAC,MAAM,EACd,OAAO,EAAE,KAAK,EACd,OAAO,EAAE,GAAG,EAAE;oBACZ,eAAe,CAAC,IAAI,CAAC,CAAC;gBACxB,CAAC,EACD,MAAM,EAAE,GAAG,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC,EACpC,GAAG,EAAE,SAAS,aAEd,KAAC,IAAI,IAAC,IAAI,EAAC,MAAM,GAAG,EACnB,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAC9C,CACnB,IACI,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import { forwardRef, useRef, useLayoutEffect, useContext, useMemo, useState } from 'react';\nimport type { PropsWithoutRef, Ref, FocusEvent } from 'react';\nimport styled, { css } from 'styled-components';\nimport { transparentize } from 'polished';\n\nimport type { ForwardRefForwardPropsComponent } from '../../types';\nimport Button from '../Button';\nimport Icon, { registerIcon } from '../Icon';\nimport * as plusIcon from '../Icon/icons/plus.icon';\nimport { useDirection, useI18n } from '../../hooks';\nimport { defaultThemeProp } from '../../theme';\nimport { getActiveElement, getFocusables, tryCatch } from '../../utils';\nimport Flex from '../Flex';\nimport EmptyState from '../EmptyState';\nimport AdditionalInfo from '../AdditionalInfo';\nimport Text from '../Text';\nimport { nlpColors, readableHue } from '../../styles';\n\nimport { getIndexDetails } from './FieldGroupList.utils';\nimport FieldGroup, {\n StyledFieldGroup,\n StyledFieldGroupContent,\n StyledFieldGroupLegend,\n StyledGroupContainer,\n StyledFieldHeader\n} from './FieldGroup';\nimport type { FieldGroupProps } from './FieldGroup';\nimport FieldGroupListContext from './FieldGroupListContext';\n\nregisterIcon(plusIcon);\n\nexport type FieldGroupListItemProps = FieldGroupProps & {\n /** The ID of the field group list item */\n id: string;\n /** Item level onDelete callback. */\n onDelete?: (id: string) => void;\n /** Indicates if the item is dynamic. */\n isDynamic?: boolean;\n};\n\nexport interface FieldGroupListProps {\n items: FieldGroupListItemProps[];\n contextualLabel?: string;\n label?: string;\n additionalContext?: string | JSX.Element;\n onAdd?: () => void;\n onDelete?: (id: string) => void;\n ref?: Ref<HTMLOListElement>;\n}\n\nexport interface ListItemProps {\n item: FieldGroupListItemProps;\n index: number;\n isAddFocused: boolean;\n handleDelete: FieldGroupListProps['onDelete'];\n fieldGroupRef: (el: HTMLFieldSetElement | null) => void;\n}\n\nconst StyledFieldGroupList = styled.ol(\n () => css`\n list-style: none;\n `\n);\n\nStyledFieldGroupList.defaultProps = defaultThemeProp;\n\nexport const StyledListItem = styled.li<{\n depth: number;\n listGroupIndex: number;\n shouldHighlight: boolean;\n}>(\n ({\n theme: {\n base: { spacing, palette, 'border-radius': borderRadius }\n },\n depth,\n listGroupIndex,\n shouldHighlight\n }) => {\n const bgColor = tryCatch(\n () => readableHue(nlpColors[listGroupIndex % nlpColors.length], palette['app-background']),\n () => nlpColors[listGroupIndex % nlpColors.length]\n );\n\n return css`\n display: block;\n\n > ${StyledGroupContainer} {\n position: relative;\n padding-inline-end: ${spacing};\n\n &::before {\n content: '';\n position: absolute;\n inset-block-start: 0;\n bottom: 0;\n inset-inline-start: 0;\n width: calc(0.5 * ${spacing});\n background: ${transparentize(0.75, bgColor)};\n }\n\n ${depth > 1 &&\n css`\n margin-inline-end: -${spacing};\n `}\n\n ${shouldHighlight &&\n css`\n border-start-end-radius: calc(0.5 * ${borderRadius});\n border-end-end-radius: calc(0.5 * ${borderRadius});\n background: ${transparentize(0.95, palette['foreground-color'])};\n `}\n }\n\n > ${StyledGroupContainer} > ${StyledFieldGroup} {\n margin-block-start: 0;\n padding: ${spacing} 0;\n\n &:not(:last-of-type) {\n border-bottom: 0.0625rem solid ${palette['border-line']};\n margin-block-end: calc(2 * ${spacing});\n }\n\n legend {\n margin-block-end: 0;\n }\n }\n\n > ${StyledGroupContainer} > ${StyledFieldGroup} > ${StyledFieldGroupContent} {\n padding-inline-start: calc(1.5 * ${spacing});\n }\n\n > ${StyledGroupContainer} > ${StyledFieldGroup} > ${StyledFieldGroupLegend} {\n ${StyledFieldHeader} {\n margin-inline-start: calc(0.5 * ${spacing});\n padding-inline: ${spacing};\n height: calc(4 * ${spacing});\n border-start-end-radius: calc(0.5 * ${borderRadius});\n border-end-end-radius: calc(0.5 * ${borderRadius});\n background: ${transparentize(0.75, bgColor)};\n }\n }\n `;\n }\n);\n\nStyledListItem.defaultProps = defaultThemeProp;\n\nconst StyledAddButton = styled(Button)(\n ({\n theme: {\n base: {\n spacing,\n 'hit-area': { 'mouse-min': hitAreaMouse }\n }\n }\n }) => css`\n display: inline-flex;\n align-items: center;\n min-height: ${hitAreaMouse};\n min-width: ${hitAreaMouse};\n width: fit-content;\n margin-inline-start: calc(2 * ${spacing});\n `\n);\n\nStyledAddButton.defaultProps = defaultThemeProp;\n\nconst StyledFieldGroupListContainer = styled.div<{ hasAdd: boolean }>(\n ({\n theme: {\n base: { spacing, palette, 'border-radius': borderRadius }\n },\n hasAdd\n }) => css`\n position: relative;\n margin-block-start: ${spacing};\n\n ${hasAdd &&\n css`\n &::before {\n content: '';\n position: absolute;\n inset-inline-start: 0;\n bottom: calc(1.5 * ${spacing});\n width: calc(1.5 * ${spacing});\n height: calc(2.5 * ${spacing});\n border-end-start-radius: calc(0.5 * ${borderRadius});\n border-inline-start: calc(0.5 * ${spacing}) solid ${palette['border-line']};\n border-bottom: calc(0.5 * ${spacing}) solid ${palette['border-line']};\n }\n `}\n `\n);\n\nStyledFieldGroupListContainer.defaultProps = defaultThemeProp;\n\nconst StyledDivider = styled.div(\n ({\n theme: {\n base: { spacing, palette }\n }\n }) => css`\n flex: 1;\n height: calc(0.5 * ${spacing});\n background-color: ${palette['border-line']};\n `\n);\n\nStyledDivider.defaultProps = defaultThemeProp;\n\nconst ListItem = ({ item, index, isAddFocused, handleDelete, fieldGroupRef }: ListItemProps) => {\n const { id, children, name = '', isDynamic, headingTag, ...restItemProps } = item;\n\n const t = useI18n();\n const { rtl } = useDirection();\n const {\n depth = 1,\n ancestorIndices = [],\n isAncestorHighlighted = false\n } = useContext(FieldGroupListContext);\n\n const [isItemFocused, setIsItemFocused] = useState(false);\n const [isDeleteHovered, setIsDeleteHovered] = useState(false);\n\n const listIndices = [...ancestorIndices, index];\n const { rootIndex, currentIndex, compoundIndex } = getIndexDetails(listIndices);\n\n const shouldHighlight =\n !isAncestorHighlighted && (isAddFocused || isDeleteHovered || isItemFocused);\n\n let formattedName: string;\n if (isDynamic) {\n formattedName = name;\n } else {\n formattedName = rtl ? `${currentIndex}\\u200F ${name}` : `${currentIndex} ${name}`;\n }\n const contextualLabel = isDynamic ? name : `${name} ${compoundIndex}`;\n\n const ctxValue = useMemo(\n () => ({\n depth: depth + 1,\n isAncestorHighlighted: shouldHighlight || isAncestorHighlighted,\n ancestorIndices: listIndices\n }),\n [depth, index, shouldHighlight, isAncestorHighlighted, listIndices]\n );\n\n return (\n <StyledListItem\n depth={depth}\n listGroupIndex={rootIndex}\n shouldHighlight={shouldHighlight}\n onFocus={() => {\n setIsItemFocused(true);\n }}\n onBlur={() => {\n setIsItemFocused(false);\n }}\n >\n <FieldGroupListContext.Provider value={ctxValue}>\n <FieldGroup\n name={formattedName}\n contextualLabel={contextualLabel}\n headingTag={headingTag}\n {...restItemProps}\n actions={\n handleDelete\n ? [\n {\n id: 'delete',\n text: t('delete'),\n icon: 'trash',\n iconOnly: true,\n onClick: () => {\n handleDelete(id);\n },\n onMouseEnter: () => setIsDeleteHovered(true),\n onMouseLeave: () => setIsDeleteHovered(false)\n }\n ]\n : undefined\n }\n ref={fieldGroupRef}\n >\n {children}\n </FieldGroup>\n </FieldGroupListContext.Provider>\n </StyledListItem>\n );\n};\n\nconst FieldGroupList: ForwardRefForwardPropsComponent<FieldGroupListProps> = forwardRef(\n function FieldGroupList(\n {\n label,\n additionalContext,\n items,\n onAdd,\n onDelete,\n contextualLabel,\n ...restProps\n }: PropsWithoutRef<FieldGroupListProps>,\n ref: FieldGroupListProps['ref']\n ) {\n const t = useI18n();\n\n const addBtnRef = useRef<HTMLButtonElement>(null);\n const itemRefs = useRef<(HTMLFieldSetElement | null)[]>([]);\n const deletedItemIndexRef = useRef<number | null>(null);\n\n const [isAddFocused, setIsAddFocused] = useState(false);\n\n const focusElement = (\n itemRef: HTMLFieldSetElement | null,\n focusPreference: 'action' | 'content'\n ) => {\n if (!itemRef) return;\n\n const focusables = getFocusables(itemRef);\n const groupItemLegend = itemRef.querySelector(':scope > legend');\n\n const groupActionButtons = focusables.filter(focusable =>\n groupItemLegend?.contains(focusable)\n );\n\n const groupContentFocusables = focusables.filter(\n focusable => !groupItemLegend?.contains(focusable)\n );\n\n if (focusPreference === 'action') {\n (groupActionButtons[0] || groupContentFocusables[0])?.focus();\n } else {\n (groupContentFocusables[0] || groupActionButtons[0])?.focus();\n }\n };\n\n useLayoutEffect(() => {\n const currentActiveEl = getActiveElement();\n\n if (deletedItemIndexRef.current !== null) {\n const deletedIndex = deletedItemIndexRef.current;\n\n if (items.length === 0 && addBtnRef.current) {\n addBtnRef.current.focus();\n } else {\n const nextIndex = Math.min(deletedIndex, items.length - 1);\n const nextItemRef = itemRefs.current[nextIndex];\n focusElement(nextItemRef, 'action');\n }\n\n deletedItemIndexRef.current = null;\n }\n\n if (currentActiveEl === addBtnRef.current) {\n const lastIndex = items.length - 1;\n const lastItemRef = itemRefs.current[lastIndex];\n focusElement(lastItemRef, 'content');\n }\n }, [items.length]);\n\n return (\n <Flex\n container={{ direction: 'column', gap: 1 }}\n as={StyledFieldGroupListContainer}\n hasAdd={!!onAdd}\n onFocus={(e: FocusEvent) => {\n e.stopPropagation();\n }}\n onBlur={(e: FocusEvent) => {\n e.stopPropagation();\n }}\n >\n {label && (\n <Flex container={{ gap: 0.5, alignItems: 'center' }}>\n <Text variant='h3'>{label}</Text>\n\n {additionalContext && (\n <AdditionalInfo contextualLabel={label}>{additionalContext}</AdditionalInfo>\n )}\n\n <StyledDivider aria-hidden='true' />\n </Flex>\n )}\n\n {items.length === 0 ? (\n <EmptyState />\n ) : (\n <Flex\n container={{ direction: 'column', gap: 1 }}\n as={StyledFieldGroupList}\n ref={ref}\n {...restProps}\n >\n {items.map((item, index) => {\n const handleDelete =\n onDelete || item.onDelete\n ? (id: string) => {\n deletedItemIndexRef.current = index;\n item.onDelete?.(id);\n onDelete?.(id);\n }\n : undefined;\n\n return (\n <ListItem\n key={item.id}\n item={item}\n index={index}\n isAddFocused={isAddFocused}\n handleDelete={handleDelete}\n fieldGroupRef={(el: HTMLFieldSetElement | null) => {\n itemRefs.current[index] = el;\n }}\n />\n );\n })}\n </Flex>\n )}\n\n {onAdd && (\n <StyledAddButton\n variant='link'\n onClick={onAdd}\n onFocus={() => {\n setIsAddFocused(true);\n }}\n onBlur={() => setIsAddFocused(false)}\n ref={addBtnRef}\n >\n <Icon name='plus' />\n {contextualLabel ? t('add_noun', [contextualLabel]) : t('add')}\n </StyledAddButton>\n )}\n </Flex>\n );\n }\n);\n\nexport default FieldGroupList;\n"]}
|
|
1
|
+
{"version":3,"file":"FieldGroupList.js","sourceRoot":"","sources":["../../../src/components/FieldGroup/FieldGroupList.tsx"],"names":[],"mappings":";AAAA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CAAC,CAAC;gBACxB,CAAC,EACD,MAAM,EAAE,GAAG,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC,EACpC,GAAG,EAAE,SAAS,aAEd,KAAC,IAAI,IAAC,IAAI,EAAC,MAAM,GAAG,EACnB,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAC9C,CACnB,IACI,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import { forwardRef, useRef, useLayoutEffect, useContext, useMemo, useState } from 'react';\nimport type { PropsWithoutRef, Ref, FocusEvent } from 'react';\nimport styled, { css } from 'styled-components';\nimport { transparentize } from 'polished';\n\nimport type { ForwardRefForwardPropsComponent } from '../../types';\nimport Button from '../Button';\nimport Icon, { registerIcon } from '../Icon';\nimport * as plusIcon from '../Icon/icons/plus.icon';\nimport { useDirection, useI18n, useLiveLog } from '../../hooks';\nimport { defaultThemeProp } from '../../theme';\nimport { getActiveElement, getFocusables, tryCatch } from '../../utils';\nimport Flex from '../Flex';\nimport EmptyState from '../EmptyState';\nimport AdditionalInfo from '../AdditionalInfo';\nimport Text from '../Text';\nimport { nlpColors, readableHue } from '../../styles';\n\nimport { getIndexDetails } from './FieldGroupList.utils';\nimport FieldGroup, {\n StyledFieldGroup,\n StyledFieldGroupContent,\n StyledFieldGroupLegend,\n StyledGroupContainer,\n StyledFieldHeader\n} from './FieldGroup';\nimport type { FieldGroupProps } from './FieldGroup';\nimport FieldGroupListContext from './FieldGroupListContext';\n\nregisterIcon(plusIcon);\n\nexport type FieldGroupListItemProps = FieldGroupProps & {\n /** The ID of the field group list item */\n id: string;\n /** Item level onDelete callback. */\n onDelete?: (id: string) => void;\n /** Indicates if the item is dynamic. */\n isDynamic?: boolean;\n};\n\nexport interface FieldGroupListProps {\n items: FieldGroupListItemProps[];\n contextualLabel?: string;\n label?: string;\n additionalContext?: string | JSX.Element;\n onAdd?: () => void;\n onDelete?: (id: string) => void;\n ref?: Ref<HTMLOListElement>;\n}\n\nexport interface ListItemProps {\n item: FieldGroupListItemProps;\n index: number;\n isAddFocused: boolean;\n handleDelete: FieldGroupListProps['onDelete'];\n fieldGroupRef: (el: HTMLFieldSetElement | null) => void;\n}\n\nconst StyledFieldGroupList = styled.ol(\n () => css`\n list-style: none;\n `\n);\n\nStyledFieldGroupList.defaultProps = defaultThemeProp;\n\nexport const StyledListItem = styled.li<{\n depth: number;\n listGroupIndex: number;\n shouldHighlight: boolean;\n}>(\n ({\n theme: {\n base: { spacing, palette, 'border-radius': borderRadius }\n },\n depth,\n listGroupIndex,\n shouldHighlight\n }) => {\n const bgColor = tryCatch(\n () => readableHue(nlpColors[listGroupIndex % nlpColors.length], palette['app-background']),\n () => nlpColors[listGroupIndex % nlpColors.length]\n );\n\n return css`\n display: block;\n\n > ${StyledGroupContainer} {\n position: relative;\n padding-inline-end: ${spacing};\n\n &::before {\n content: '';\n position: absolute;\n inset-block-start: 0;\n bottom: 0;\n inset-inline-start: 0;\n width: calc(0.5 * ${spacing});\n background: ${transparentize(0.75, bgColor)};\n }\n\n ${depth > 1 &&\n css`\n margin-inline-end: -${spacing};\n `}\n\n ${shouldHighlight &&\n css`\n border-start-end-radius: calc(0.5 * ${borderRadius});\n border-end-end-radius: calc(0.5 * ${borderRadius});\n background: ${transparentize(0.95, palette['foreground-color'])};\n `}\n }\n\n > ${StyledGroupContainer} > ${StyledFieldGroup} {\n margin-block-start: 0;\n padding: ${spacing} 0;\n\n &:not(:last-of-type) {\n border-bottom: 0.0625rem solid ${palette['border-line']};\n margin-block-end: calc(2 * ${spacing});\n }\n\n legend {\n margin-block-end: 0;\n }\n }\n\n > ${StyledGroupContainer} > ${StyledFieldGroup} > ${StyledFieldGroupContent} {\n padding-inline-start: calc(1.5 * ${spacing});\n }\n\n > ${StyledGroupContainer} > ${StyledFieldGroup} > ${StyledFieldGroupLegend} {\n ${StyledFieldHeader} {\n margin-inline-start: calc(0.5 * ${spacing});\n padding-inline: ${spacing};\n height: calc(4 * ${spacing});\n border-start-end-radius: calc(0.5 * ${borderRadius});\n border-end-end-radius: calc(0.5 * ${borderRadius});\n background: ${transparentize(0.75, bgColor)};\n }\n }\n `;\n }\n);\n\nStyledListItem.defaultProps = defaultThemeProp;\n\nconst StyledAddButton = styled(Button)(\n ({\n theme: {\n base: {\n spacing,\n 'hit-area': { 'mouse-min': hitAreaMouse }\n }\n }\n }) => css`\n display: inline-flex;\n align-items: center;\n min-height: ${hitAreaMouse};\n min-width: ${hitAreaMouse};\n width: fit-content;\n margin-inline-start: calc(2 * ${spacing});\n `\n);\n\nStyledAddButton.defaultProps = defaultThemeProp;\n\nconst StyledFieldGroupListContainer = styled.div<{ hasAdd: boolean }>(\n ({\n theme: {\n base: { spacing, palette, 'border-radius': borderRadius }\n },\n hasAdd\n }) => css`\n position: relative;\n margin-block-start: ${spacing};\n\n ${hasAdd &&\n css`\n &::before {\n content: '';\n position: absolute;\n inset-inline-start: 0;\n bottom: calc(1.5 * ${spacing});\n width: calc(1.5 * ${spacing});\n height: calc(2.5 * ${spacing});\n border-end-start-radius: calc(0.5 * ${borderRadius});\n border-inline-start: calc(0.5 * ${spacing}) solid ${palette['border-line']};\n border-bottom: calc(0.5 * ${spacing}) solid ${palette['border-line']};\n }\n `}\n `\n);\n\nStyledFieldGroupListContainer.defaultProps = defaultThemeProp;\n\nconst StyledDivider = styled.div(\n ({\n theme: {\n base: { spacing, palette }\n }\n }) => css`\n flex: 1;\n height: calc(0.5 * ${spacing});\n background-color: ${palette['border-line']};\n `\n);\n\nStyledDivider.defaultProps = defaultThemeProp;\n\nconst ListItem = ({ item, index, isAddFocused, handleDelete, fieldGroupRef }: ListItemProps) => {\n const { id, children, name = '', isDynamic, headingTag, ...restItemProps } = item;\n\n const t = useI18n();\n const { rtl } = useDirection();\n const { announcePolite } = useLiveLog();\n\n const {\n depth = 1,\n ancestorIndices = [],\n isAncestorHighlighted = false\n } = useContext(FieldGroupListContext);\n\n const [isItemFocused, setIsItemFocused] = useState(false);\n const [isDeleteHovered, setIsDeleteHovered] = useState(false);\n\n const listIndices = [...ancestorIndices, index];\n const { rootIndex, currentIndex, compoundIndex } = getIndexDetails(listIndices);\n\n const shouldHighlight =\n !isAncestorHighlighted && (isAddFocused || isDeleteHovered || isItemFocused);\n\n let formattedName: string;\n if (isDynamic) {\n formattedName = name;\n } else {\n formattedName = rtl ? `${currentIndex}\\u200F ${name}` : `${currentIndex} ${name}`;\n }\n const contextualLabel = isDynamic ? name : `${name} ${compoundIndex}`;\n\n const ctxValue = useMemo(\n () => ({\n depth: depth + 1,\n isAncestorHighlighted: shouldHighlight || isAncestorHighlighted,\n ancestorIndices: listIndices\n }),\n [depth, index, shouldHighlight, isAncestorHighlighted, listIndices]\n );\n\n return (\n <StyledListItem\n depth={depth}\n listGroupIndex={rootIndex}\n shouldHighlight={shouldHighlight}\n onFocus={() => {\n setIsItemFocused(true);\n }}\n onBlur={() => {\n setIsItemFocused(false);\n }}\n >\n <FieldGroupListContext.Provider value={ctxValue}>\n <FieldGroup\n name={formattedName}\n contextualLabel={contextualLabel}\n headingTag={headingTag}\n {...restItemProps}\n actions={\n handleDelete\n ? [\n {\n id: 'delete',\n text: t('delete'),\n icon: 'trash',\n iconOnly: true,\n onClick: () => {\n handleDelete(id);\n announcePolite({ message: t('deleted', [contextualLabel]) });\n },\n onMouseEnter: () => setIsDeleteHovered(true),\n onMouseLeave: () => setIsDeleteHovered(false)\n }\n ]\n : undefined\n }\n ref={fieldGroupRef}\n >\n {children}\n </FieldGroup>\n </FieldGroupListContext.Provider>\n </StyledListItem>\n );\n};\n\nconst FieldGroupList: ForwardRefForwardPropsComponent<FieldGroupListProps> = forwardRef(\n function FieldGroupList(\n {\n label,\n additionalContext,\n items,\n onAdd,\n onDelete,\n contextualLabel,\n ...restProps\n }: PropsWithoutRef<FieldGroupListProps>,\n ref: FieldGroupListProps['ref']\n ) {\n const t = useI18n();\n\n const addBtnRef = useRef<HTMLButtonElement>(null);\n const itemRefs = useRef<(HTMLFieldSetElement | null)[]>([]);\n const deletedItemIndexRef = useRef<number | null>(null);\n\n const [isAddFocused, setIsAddFocused] = useState(false);\n\n const focusElement = (\n itemRef: HTMLFieldSetElement | null,\n focusPreference: 'action' | 'content'\n ) => {\n if (!itemRef) return;\n\n const focusables = getFocusables(itemRef);\n const groupItemLegend = itemRef.querySelector(':scope > legend');\n\n const groupActionButtons = focusables.filter(focusable =>\n groupItemLegend?.contains(focusable)\n );\n\n const groupContentFocusables = focusables.filter(\n focusable => !groupItemLegend?.contains(focusable)\n );\n\n if (focusPreference === 'action') {\n (groupActionButtons[0] || groupContentFocusables[0])?.focus();\n } else {\n (groupContentFocusables[0] || groupActionButtons[0])?.focus();\n }\n };\n\n useLayoutEffect(() => {\n const currentActiveEl = getActiveElement();\n\n if (deletedItemIndexRef.current !== null) {\n const deletedIndex = deletedItemIndexRef.current;\n\n if (items.length === 0 && addBtnRef.current) {\n addBtnRef.current.focus();\n } else {\n const nextIndex = Math.min(deletedIndex, items.length - 1);\n const nextItemRef = itemRefs.current[nextIndex];\n focusElement(nextItemRef, 'action');\n }\n\n deletedItemIndexRef.current = null;\n }\n\n if (currentActiveEl === addBtnRef.current) {\n const lastIndex = items.length - 1;\n const lastItemRef = itemRefs.current[lastIndex];\n focusElement(lastItemRef, 'content');\n }\n }, [items.length]);\n\n return (\n <Flex\n container={{ direction: 'column', gap: 1 }}\n as={StyledFieldGroupListContainer}\n hasAdd={!!onAdd}\n onFocus={(e: FocusEvent) => {\n e.stopPropagation();\n }}\n onBlur={(e: FocusEvent) => {\n e.stopPropagation();\n }}\n >\n {label && (\n <Flex container={{ gap: 0.5, alignItems: 'center' }}>\n <Text variant='h3'>{label}</Text>\n\n {additionalContext && (\n <AdditionalInfo contextualLabel={label}>{additionalContext}</AdditionalInfo>\n )}\n\n <StyledDivider aria-hidden='true' />\n </Flex>\n )}\n\n {items.length === 0 ? (\n <EmptyState />\n ) : (\n <Flex\n container={{ direction: 'column', gap: 1 }}\n as={StyledFieldGroupList}\n ref={ref}\n aria-label={label}\n {...restProps}\n >\n {items.map((item, index) => {\n const handleDelete =\n onDelete || item.onDelete\n ? (id: string) => {\n deletedItemIndexRef.current = index;\n item.onDelete?.(id);\n onDelete?.(id);\n }\n : undefined;\n\n return (\n <ListItem\n key={item.id}\n item={item}\n index={index}\n isAddFocused={isAddFocused}\n handleDelete={handleDelete}\n fieldGroupRef={(el: HTMLFieldSetElement | null) => {\n itemRefs.current[index] = el;\n }}\n />\n );\n })}\n </Flex>\n )}\n\n {onAdd && (\n <StyledAddButton\n variant='link'\n onClick={onAdd}\n onFocus={() => {\n setIsAddFocused(true);\n }}\n onBlur={() => setIsAddFocused(false)}\n ref={addBtnRef}\n >\n <Icon name='plus' />\n {contextualLabel ? t('add_noun', [contextualLabel]) : t('add')}\n </StyledAddButton>\n )}\n </Flex>\n );\n }\n);\n\nexport default FieldGroupList;\n"]}
|
|
@@ -23,7 +23,7 @@ export declare const getFormattedListNumber: (levelIndex: number, depth: number)
|
|
|
23
23
|
* @returns An object containing:
|
|
24
24
|
* - `rootIndex`: The zero-based index at the root level (e.g., 0 for "1.", 1 for "2.").
|
|
25
25
|
* - `currentIndex`: The index at the latest depth (e.g., "a." or "i.").
|
|
26
|
-
* - `compoundIndex`: The full compound index (e.g., "1
|
|
26
|
+
* - `compoundIndex`: The full compound index (e.g., "1 A II").
|
|
27
27
|
*/
|
|
28
28
|
export declare const getIndexDetails: (indices: number[]) => {
|
|
29
29
|
rootIndex: number;
|
|
@@ -62,13 +62,13 @@ export const getFormattedListNumber = (levelIndex, depth) => {
|
|
|
62
62
|
* @returns An object containing:
|
|
63
63
|
* - `rootIndex`: The zero-based index at the root level (e.g., 0 for "1.", 1 for "2.").
|
|
64
64
|
* - `currentIndex`: The index at the latest depth (e.g., "a." or "i.").
|
|
65
|
-
* - `compoundIndex`: The full compound index (e.g., "1
|
|
65
|
+
* - `compoundIndex`: The full compound index (e.g., "1 A II").
|
|
66
66
|
*/
|
|
67
67
|
export const getIndexDetails = (indices) => {
|
|
68
68
|
const indexSegments = indices.map((levelIndex, index) => getFormattedListNumber(levelIndex, index));
|
|
69
69
|
const rootIndex = indices[0];
|
|
70
70
|
const currentIndex = `${indexSegments[indexSegments.length - 1]}.`;
|
|
71
|
-
const compoundIndex = indexSegments.join('
|
|
71
|
+
const compoundIndex = indexSegments.join(' ').toUpperCase();
|
|
72
72
|
return { rootIndex, currentIndex, compoundIndex };
|
|
73
73
|
};
|
|
74
74
|
//# sourceMappingURL=FieldGroupList.utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldGroupList.utils.js","sourceRoot":"","sources":["../../../src/components/FieldGroup/FieldGroupList.utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAAW,EAAE,EAAE;IAC5C,MAAM,QAAQ,GAAuB;QACnC,CAAC,GAAG,EAAE,IAAI,CAAC;QACX,CAAC,IAAI,EAAE,GAAG,CAAC;QACX,CAAC,GAAG,EAAE,GAAG,CAAC;QACV,CAAC,IAAI,EAAE,GAAG,CAAC;QACX,CAAC,GAAG,EAAE,GAAG,CAAC;QACV,CAAC,IAAI,EAAE,EAAE,CAAC;QACV,CAAC,GAAG,EAAE,EAAE,CAAC;QACT,CAAC,IAAI,EAAE,EAAE,CAAC;QACV,CAAC,GAAG,EAAE,EAAE,CAAC;QACT,CAAC,IAAI,EAAE,CAAC,CAAC;QACT,CAAC,GAAG,EAAE,CAAC,CAAC;QACR,CAAC,IAAI,EAAE,CAAC,CAAC;QACT,CAAC,GAAG,EAAE,CAAC,CAAC;KACT,CAAC;IAEF,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,QAAQ,EAAE,CAAC;QACtC,OAAO,GAAG,IAAI,KAAK,EAAE,CAA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G,GAAG,aAAa,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC;IACnE,MAAM,aAAa,GAAG,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"FieldGroupList.utils.js","sourceRoot":"","sources":["../../../src/components/FieldGroup/FieldGroupList.utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAAW,EAAE,EAAE;IAC5C,MAAM,QAAQ,GAAuB;QACnC,CAAC,GAAG,EAAE,IAAI,CAAC;QACX,CAAC,IAAI,EAAE,GAAG,CAAC;QACX,CAAC,GAAG,EAAE,GAAG,CAAC;QACV,CAAC,IAAI,EAAE,GAAG,CAAC;QACX,CAAC,GAAG,EAAE,GAAG,CAAC;QACV,CAAC,IAAI,EAAE,EAAE,CAAC;QACV,CAAC,GAAG,EAAE,EAAE,CAAC;QACT,CAAC,IAAI,EAAE,EAAE,CAAC;QACV,CAAC,GAAG,EAAE,EAAE,CAAC;QACT,CAAC,IAAI,EAAE,CAAC,CAAC;QACT,CAAC,GAAG,EAAE,CAAC,CAAC;QACR,CAAC,IAAI,EAAE,CAAC,CAAC;QACT,CAAC,GAAG,EAAE,CAAC,CAAC;KACT,CAAC;IAEF,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,QAAQ,EAAE,CAAC;QACtC,OAAO,GAAG,IAAI,KAAK,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC;YAChB,GAAG,IAAI,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,GAAW,EAAE,EAAE;IACjD,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,OAAO,GAAG,IAAI,CAAC,EAAE,C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to convert.\n * @returns The Roman numeral representation.\n */\nexport const convertToRoman = (num: number) => {\n const romanMap: [string, number][] = [\n ['m', 1000],\n ['cm', 900],\n ['d', 500],\n ['cd', 400],\n ['c', 100],\n ['xc', 90],\n ['l', 50],\n ['xl', 40],\n ['x', 10],\n ['ix', 9],\n ['v', 5],\n ['iv', 4],\n ['i', 1]\n ];\n\n let result = '';\n for (const [roman, value] of romanMap) {\n while (num >= value) {\n result += roman;\n num -= value;\n }\n }\n\n return result;\n};\n\n/**\n * Converts a number to a base-26 alphabetic string (a, b, c... aa, ab, ac...).\n * @param num - The 0-based index to convert.\n * @returns The alphabetic representation.\n */\nexport const convertToAlphabetic = (num: number) => {\n let result = '';\n while (num >= 0) {\n result = String.fromCharCode((num % 26) + 97) + result;\n num = Math.floor(num / 26) - 1;\n }\n\n return result;\n};\n\n/**\n * Generates a list number based on depth and index.\n * @param levelIndex - The index of the item in the list (0-based).\n * @param depth - The depth of the list (0-based).\n * @returns The formatted list number.\n */\nexport const getFormattedListNumber = (levelIndex: number, depth: number) => {\n if (depth % 3 === 0) {\n return (levelIndex + 1).toString();\n }\n\n if (depth % 3 === 1) {\n return convertToAlphabetic(levelIndex);\n }\n\n return convertToRoman(levelIndex + 1);\n};\n\n/**\n * Generates a compound index and the current list index based on the depth and index of the current item and its ancestors.\n * @param indices - An array of indices representing the position at each depth (e.g., [0, 1, 2]).\n * @returns An object containing:\n * - `rootIndex`: The zero-based index at the root level (e.g., 0 for \"1.\", 1 for \"2.\").\n * - `currentIndex`: The index at the latest depth (e.g., \"a.\" or \"i.\").\n * - `compoundIndex`: The full compound index (e.g., \"1 A II\").\n */\nexport const getIndexDetails = (\n indices: number[]\n): { rootIndex: number; currentIndex: string; compoundIndex: string } => {\n const indexSegments = indices.map((levelIndex, index) =>\n getFormattedListNumber(levelIndex, index)\n );\n\n const rootIndex = indices[0];\n const currentIndex = `${indexSegments[indexSegments.length - 1]}.`;\n const compoundIndex = indexSegments.join(' ').toUpperCase();\n\n return { rootIndex, currentIndex, compoundIndex };\n};\n"]}
|
package/lib/hooks/useI18n.d.ts
CHANGED
|
@@ -143,6 +143,7 @@ declare const useI18n: () => import("../i18n/translate").TranslationFunction<Rea
|
|
|
143
143
|
select_noun: string;
|
|
144
144
|
actions_for: string;
|
|
145
145
|
edited: string;
|
|
146
|
+
deleted: string;
|
|
146
147
|
done: string;
|
|
147
148
|
uploading: string;
|
|
148
149
|
loading: string;
|
|
@@ -316,6 +317,7 @@ declare const useI18n: () => import("../i18n/translate").TranslationFunction<Rea
|
|
|
316
317
|
choose_week: string;
|
|
317
318
|
set_current_week_ally: string;
|
|
318
319
|
auto_focus_next_input_description: string;
|
|
320
|
+
year_input_description: string;
|
|
319
321
|
boolean_display_true_label: string;
|
|
320
322
|
boolean_display_false_label: string;
|
|
321
323
|
step_changed_to_name: string;
|
|
@@ -1346,6 +1348,26 @@ declare const useI18n: () => import("../i18n/translate").TranslationFunction<Rea
|
|
|
1346
1348
|
download_app: string;
|
|
1347
1349
|
qr_code_not_available: string;
|
|
1348
1350
|
qr_code: string;
|
|
1351
|
+
expand_all: string;
|
|
1352
|
+
collapse_all: string;
|
|
1353
|
+
expand_steps: string;
|
|
1354
|
+
collapse_steps: string;
|
|
1355
|
+
expand_step: string;
|
|
1356
|
+
collapse_step: string;
|
|
1357
|
+
expanded_step: string;
|
|
1358
|
+
collapsed_step: string;
|
|
1359
|
+
add_step: string;
|
|
1360
|
+
generate_comments: string;
|
|
1361
|
+
action_set: string;
|
|
1362
|
+
action_when: string;
|
|
1363
|
+
action_append: string;
|
|
1364
|
+
action_call: string;
|
|
1365
|
+
action_create: string;
|
|
1366
|
+
action_for_each: string;
|
|
1367
|
+
action_exit: string;
|
|
1368
|
+
action_return: string;
|
|
1369
|
+
action_remove: string;
|
|
1370
|
+
action_error_handler: string;
|
|
1349
1371
|
app_header_notifications_empty: string;
|
|
1350
1372
|
app_header_notifications_loading: string;
|
|
1351
1373
|
open_app_header_notifications: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useI18n.d.ts","sourceRoot":"","sources":["../../src/hooks/useI18n.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,QAAA,MAAM,OAAO
|
|
1
|
+
{"version":3,"file":"useI18n.d.ts","sourceRoot":"","sources":["../../src/hooks/useI18n.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,QAAA,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAGZ,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -5,8 +5,9 @@ import type { RefObject } from 'react';
|
|
|
5
5
|
* @param offset Index of the list item which needs to be observed.
|
|
6
6
|
* @param cb Callback that needs to be fired on intersect
|
|
7
7
|
* @param itemSelector Selector used to get the node list of items
|
|
8
|
+
* @param boundingRef Ref to use as the bounding root for querying items. Required for use when selected items are rendered within a ShadowRoot.
|
|
8
9
|
* @returns void.
|
|
9
10
|
*/
|
|
10
|
-
declare const useItemIntersection: (containerRef: RefObject<HTMLElement>, offset: number, cb: () => void, itemSelector: string) => void;
|
|
11
|
+
declare const useItemIntersection: (containerRef: RefObject<HTMLElement>, offset: number, cb: () => void, itemSelector: string, boundingRef?: RefObject<HTMLElement>) => void;
|
|
11
12
|
export default useItemIntersection;
|
|
12
13
|
//# sourceMappingURL=useItemIntersection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useItemIntersection.d.ts","sourceRoot":"","sources":["../../src/hooks/useItemIntersection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"useItemIntersection.d.ts","sourceRoot":"","sources":["../../src/hooks/useItemIntersection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC;;;;;;;;GAQG;AAEH,QAAA,MAAM,mBAAmB,GACvB,cAAc,SAAS,CAAC,WAAW,CAAC,EACpC,QAAQ,MAAM,EACd,IAAI,MAAM,IAAI,EACd,cAAc,MAAM,EACpB,cAAc,SAAS,CAAC,WAAW,CAAC,SAmCrC,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
|
+
import { isInstance } from '../utils';
|
|
2
3
|
/**
|
|
3
4
|
* @example useItemIntersection(listRef,offset,() => { do_some_thing; });
|
|
4
5
|
* @param containerRef The ref of the List.
|
|
5
6
|
* @param offset Index of the list item which needs to be observed.
|
|
6
7
|
* @param cb Callback that needs to be fired on intersect
|
|
7
8
|
* @param itemSelector Selector used to get the node list of items
|
|
9
|
+
* @param boundingRef Ref to use as the bounding root for querying items. Required for use when selected items are rendered within a ShadowRoot.
|
|
8
10
|
* @returns void.
|
|
9
11
|
*/
|
|
10
|
-
const useItemIntersection = (containerRef, offset, cb, itemSelector) => {
|
|
12
|
+
const useItemIntersection = (containerRef, offset, cb, itemSelector, boundingRef) => {
|
|
11
13
|
useEffect(() => {
|
|
12
|
-
if (!containerRef.current)
|
|
13
|
-
return;
|
|
14
14
|
let item = null;
|
|
15
15
|
if (offset > 0) {
|
|
16
|
-
const
|
|
16
|
+
const elementToQuery = containerRef?.current ?? boundingRef?.current?.getRootNode() ?? document;
|
|
17
|
+
if (!isInstance(elementToQuery, HTMLElement, SVGElement, ShadowRoot, Document)) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const items = elementToQuery.querySelectorAll(itemSelector);
|
|
17
21
|
if (items.length > offset) {
|
|
18
22
|
item = items[offset];
|
|
19
23
|
}
|
|
@@ -24,14 +28,14 @@ const useItemIntersection = (containerRef, offset, cb, itemSelector) => {
|
|
|
24
28
|
cb();
|
|
25
29
|
}
|
|
26
30
|
}, {
|
|
27
|
-
root: containerRef.current
|
|
31
|
+
root: containerRef.current ?? null
|
|
28
32
|
});
|
|
29
33
|
intersectionObserver.observe(item);
|
|
30
34
|
return () => {
|
|
31
35
|
intersectionObserver.disconnect();
|
|
32
36
|
};
|
|
33
37
|
}
|
|
34
|
-
}, [cb,
|
|
38
|
+
}, [cb, offset]);
|
|
35
39
|
};
|
|
36
40
|
export default useItemIntersection;
|
|
37
41
|
//# sourceMappingURL=useItemIntersection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useItemIntersection.js","sourceRoot":"","sources":["../../src/hooks/useItemIntersection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGlC
|
|
1
|
+
{"version":3,"file":"useItemIntersection.js","sourceRoot":"","sources":["../../src/hooks/useItemIntersection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGlC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC;;;;;;;;GAQG;AAEH,MAAM,mBAAmB,GAAG,CAC1B,YAAoC,EACpC,MAAc,EACd,EAAc,EACd,YAAoB,EACpB,WAAoC,EACpC,EAAE;IACF,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,IAAI,GAAuB,IAAI,CAAC;QACpC,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;YACf,MAAM,cAAc,GAClB,YAAY,EAAE,OAAO,IAAI,WAAW,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,QAAQ,CAAC;YAE3E,IAAI,CAAC,UAAU,CAAC,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,CAAC;gBAC/E,OAAO;YACT,CAAC;YAED,MAAM,KAAK,GAA4B,cAAc,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;YAErF,IAAI,KAAK,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC;gBAC1B,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;YACvB,CAAC;QACH,CAAC;QACD,IAAI,IAAI,EAAE,CAAC;YACT,MAAM,oBAAoB,GAAG,IAAI,oBAAoB,CACnD,CAAC,OAAoC,EAAE,EAAE;gBACvC,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,cAAc,EAAE,CAAC;oBAC9B,EAAE,EAAE,CAAC;gBACP,CAAC;YACH,CAAC,EACD;gBACE,IAAI,EAAE,YAAY,CAAC,OAAO,IAAI,IAAI;aACnC,CACF,CAAC;YACF,oBAAoB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACnC,OAAO,GAAG,EAAE;gBACV,oBAAoB,CAAC,UAAU,EAAE,CAAC;YACpC,CAAC,CAAC;QACJ,CAAC;IACH,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;AACnB,CAAC,CAAC;AAEF,eAAe,mBAAmB,CAAC","sourcesContent":["import { useEffect } from 'react';\nimport type { RefObject } from 'react';\n\nimport { isInstance } from '../utils';\n\n/**\n * @example useItemIntersection(listRef,offset,() => { do_some_thing; });\n * @param containerRef The ref of the List.\n * @param offset Index of the list item which needs to be observed.\n * @param cb Callback that needs to be fired on intersect\n * @param itemSelector Selector used to get the node list of items\n * @param boundingRef Ref to use as the bounding root for querying items. Required for use when selected items are rendered within a ShadowRoot.\n * @returns void.\n */\n\nconst useItemIntersection = (\n containerRef: RefObject<HTMLElement>,\n offset: number,\n cb: () => void,\n itemSelector: string,\n boundingRef?: RefObject<HTMLElement>\n) => {\n useEffect(() => {\n let item: HTMLElement | null = null;\n if (offset > 0) {\n const elementToQuery =\n containerRef?.current ?? boundingRef?.current?.getRootNode() ?? document;\n\n if (!isInstance(elementToQuery, HTMLElement, SVGElement, ShadowRoot, Document)) {\n return;\n }\n\n const items: NodeListOf<HTMLElement> = elementToQuery.querySelectorAll(itemSelector);\n\n if (items.length > offset) {\n item = items[offset];\n }\n }\n if (item) {\n const intersectionObserver = new IntersectionObserver(\n (entries: IntersectionObserverEntry[]) => {\n if (entries[0].isIntersecting) {\n cb();\n }\n },\n {\n root: containerRef.current ?? null\n }\n );\n intersectionObserver.observe(item);\n return () => {\n intersectionObserver.disconnect();\n };\n }\n }, [cb, offset]);\n};\n\nexport default useItemIntersection;\n"]}
|
package/lib/i18n/default.d.ts
CHANGED
|
@@ -139,6 +139,7 @@ declare const _default: {
|
|
|
139
139
|
select_noun: string;
|
|
140
140
|
actions_for: string;
|
|
141
141
|
edited: string;
|
|
142
|
+
deleted: string;
|
|
142
143
|
done: string;
|
|
143
144
|
uploading: string;
|
|
144
145
|
loading: string;
|
|
@@ -312,6 +313,7 @@ declare const _default: {
|
|
|
312
313
|
choose_week: string;
|
|
313
314
|
set_current_week_ally: string;
|
|
314
315
|
auto_focus_next_input_description: string;
|
|
316
|
+
year_input_description: string;
|
|
315
317
|
boolean_display_true_label: string;
|
|
316
318
|
boolean_display_false_label: string;
|
|
317
319
|
step_changed_to_name: string;
|
|
@@ -1343,6 +1345,26 @@ declare const _default: {
|
|
|
1343
1345
|
download_app: string;
|
|
1344
1346
|
qr_code_not_available: string;
|
|
1345
1347
|
qr_code: string;
|
|
1348
|
+
expand_all: string;
|
|
1349
|
+
collapse_all: string;
|
|
1350
|
+
expand_steps: string;
|
|
1351
|
+
collapse_steps: string;
|
|
1352
|
+
expand_step: string;
|
|
1353
|
+
collapse_step: string;
|
|
1354
|
+
expanded_step: string;
|
|
1355
|
+
collapsed_step: string;
|
|
1356
|
+
add_step: string;
|
|
1357
|
+
generate_comments: string;
|
|
1358
|
+
action_set: string;
|
|
1359
|
+
action_when: string;
|
|
1360
|
+
action_append: string;
|
|
1361
|
+
action_call: string;
|
|
1362
|
+
action_create: string;
|
|
1363
|
+
action_for_each: string;
|
|
1364
|
+
action_exit: string;
|
|
1365
|
+
action_return: string;
|
|
1366
|
+
action_remove: string;
|
|
1367
|
+
action_error_handler: string;
|
|
1346
1368
|
app_header_notifications_empty: string;
|
|
1347
1369
|
app_header_notifications_loading: string;
|
|
1348
1370
|
open_app_header_notifications: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../src/i18n/default.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../src/i18n/default.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAqMxB,6CAA6C;;;;IAK7C,4CAA4C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA0F5C,uCAAuC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA1xDzC,wBA60DE"}
|
package/lib/i18n/default.js
CHANGED
|
@@ -148,6 +148,7 @@ export default {
|
|
|
148
148
|
actions_for: 'Actions - {0}',
|
|
149
149
|
/* States */
|
|
150
150
|
edited: 'Edited {0}',
|
|
151
|
+
deleted: '{0} deleted',
|
|
151
152
|
done: 'Done',
|
|
152
153
|
uploading: 'Uploading',
|
|
153
154
|
loading: 'Loading…',
|
|
@@ -341,6 +342,7 @@ export default {
|
|
|
341
342
|
choose_week: 'Choose week',
|
|
342
343
|
set_current_week_ally: 'Set to current week',
|
|
343
344
|
auto_focus_next_input_description: 'Automatically moves focus to next input when current input is completed.',
|
|
345
|
+
year_input_description: 'You may also enter a four-digit year manually.',
|
|
344
346
|
/* core:Boolean */
|
|
345
347
|
boolean_display_true_label: 'Yes',
|
|
346
348
|
boolean_display_false_label: 'No',
|
|
@@ -1433,6 +1435,27 @@ export default {
|
|
|
1433
1435
|
download_app: 'Download app',
|
|
1434
1436
|
qr_code_not_available: 'No QR code available yet',
|
|
1435
1437
|
qr_code: 'QR code',
|
|
1438
|
+
/* build: Automation */
|
|
1439
|
+
expand_all: 'Expand all',
|
|
1440
|
+
collapse_all: 'Collapse all',
|
|
1441
|
+
expand_steps: 'Expand all steps',
|
|
1442
|
+
collapse_steps: 'Collapse all steps',
|
|
1443
|
+
expand_step: 'Expand step {0}',
|
|
1444
|
+
collapse_step: 'Collapse step {0}',
|
|
1445
|
+
expanded_step: 'Expanded step {0}',
|
|
1446
|
+
collapsed_step: 'Collapsed step {0}',
|
|
1447
|
+
add_step: 'Add step',
|
|
1448
|
+
generate_comments: 'Generate comments',
|
|
1449
|
+
action_set: 'Set',
|
|
1450
|
+
action_when: 'When',
|
|
1451
|
+
action_append: 'Append',
|
|
1452
|
+
action_call: 'Call',
|
|
1453
|
+
action_create: 'Create',
|
|
1454
|
+
action_for_each: 'For each',
|
|
1455
|
+
action_exit: 'Exit',
|
|
1456
|
+
action_return: 'Return',
|
|
1457
|
+
action_remove: 'Remove',
|
|
1458
|
+
action_error_handler: 'Error handler',
|
|
1436
1459
|
/* wss:AppHeader */
|
|
1437
1460
|
app_header_notifications_empty: 'No notifications',
|
|
1438
1461
|
app_header_notifications_loading: 'Loading notifications',
|