@pega/cosmos-react-core 7.0.0-build.13.2 → 7.0.0-build.15.0
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/ListToolbar/ListToolbar.d.ts +1 -1
- package/lib/components/ListToolbar/ListToolbar.d.ts.map +1 -1
- package/lib/components/ListToolbar/ListToolbar.js +5 -5
- package/lib/components/ListToolbar/ListToolbar.js.map +1 -1
- package/lib/components/ListToolbar/ListToolbar.test-ids.d.ts +1 -1
- package/lib/components/ListToolbar/ListToolbar.test-ids.d.ts.map +1 -1
- package/lib/components/ListToolbar/ListToolbar.test-ids.js +4 -1
- package/lib/components/ListToolbar/ListToolbar.test-ids.js.map +1 -1
- package/lib/components/Location/CurrentLocationButton.d.ts +1 -6
- package/lib/components/Location/CurrentLocationButton.d.ts.map +1 -1
- package/lib/components/Location/CurrentLocationButton.js +10 -20
- package/lib/components/Location/CurrentLocationButton.js.map +1 -1
- package/lib/components/Location/Location.types.d.ts +48 -17
- package/lib/components/Location/Location.types.d.ts.map +1 -1
- package/lib/components/Location/Location.types.js +9 -1
- package/lib/components/Location/Location.types.js.map +1 -1
- package/lib/components/Location/LocationDisplay.d.ts +5 -4
- package/lib/components/Location/LocationDisplay.d.ts.map +1 -1
- package/lib/components/Location/LocationDisplay.js +17 -4
- package/lib/components/Location/LocationDisplay.js.map +1 -1
- package/lib/components/Location/LocationInput.d.ts +22 -17
- package/lib/components/Location/LocationInput.d.ts.map +1 -1
- package/lib/components/Location/LocationInput.js +36 -14
- package/lib/components/Location/LocationInput.js.map +1 -1
- package/lib/components/Location/LocationView.d.ts +17 -7
- package/lib/components/Location/LocationView.d.ts.map +1 -1
- package/lib/components/Location/LocationView.js +34 -38
- package/lib/components/Location/LocationView.js.map +1 -1
- package/lib/components/Location/index.d.ts +2 -2
- package/lib/components/Location/index.d.ts.map +1 -1
- package/lib/components/Location/index.js +1 -1
- package/lib/components/Location/index.js.map +1 -1
- package/lib/components/Location/utils.d.ts +2 -2
- package/lib/components/Location/utils.d.ts.map +1 -1
- package/lib/components/Location/utils.js +1 -1
- package/lib/components/Location/utils.js.map +1 -1
- package/lib/hooks/useI18n.d.ts +0 -1
- package/lib/hooks/useI18n.d.ts.map +1 -1
- package/lib/i18n/default.d.ts +0 -1
- package/lib/i18n/default.d.ts.map +1 -1
- package/lib/i18n/default.js +1 -2
- package/lib/i18n/default.js.map +1 -1
- package/lib/i18n/i18n.d.ts +0 -1
- package/lib/i18n/i18n.d.ts.map +1 -1
- package/lib/styles/GlobalStyle.d.ts +1 -1
- package/lib/styles/GlobalStyle.d.ts.map +1 -1
- package/lib/styles/GlobalStyle.js +7 -1
- package/lib/styles/GlobalStyle.js.map +1 -1
- package/package.json +1 -1
- package/lib/components/Location/types.d.ts +0 -45
- package/lib/components/Location/types.d.ts.map +0 -1
- package/lib/components/Location/types.js +0 -10
- package/lib/components/Location/types.js.map +0 -1
|
@@ -2,7 +2,7 @@ import type { FunctionComponent } from 'react';
|
|
|
2
2
|
import type { ForwardProps } from '../../types';
|
|
3
3
|
import type { ListToolbarProps } from './ListToolbar.types';
|
|
4
4
|
declare const _default: FunctionComponent<ListToolbarProps & ForwardProps> & {
|
|
5
|
-
getTestIds: (testIdProp?: string | undefined) => import("../../types").TestIdsRecord<readonly ["view-selector", "count", "heading", "info"]>;
|
|
5
|
+
getTestIds: (testIdProp?: string | undefined) => import("../../types").TestIdsRecord<readonly ["view-selector", "count", "heading", "info", "create-new", "search-input", "search-button"]>;
|
|
6
6
|
};
|
|
7
7
|
export default _default;
|
|
8
8
|
//# sourceMappingURL=ListToolbar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListToolbar.d.ts","sourceRoot":"","sources":["../../../src/components/ListToolbar/ListToolbar.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAA8C,MAAM,OAAO,CAAC;AAK3F,OAAO,KAAK,EAAU,YAAY,EAAE,MAAM,aAAa,CAAC;AAuCxD,OAAO,KAAK,EACV,gBAAgB,EAMjB,MAAM,qBAAqB,CAAC;;;;
|
|
1
|
+
{"version":3,"file":"ListToolbar.d.ts","sourceRoot":"","sources":["../../../src/components/ListToolbar/ListToolbar.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAA8C,MAAM,OAAO,CAAC;AAK3F,OAAO,KAAK,EAAU,YAAY,EAAE,MAAM,aAAa,CAAC;AAuCxD,OAAO,KAAK,EACV,gBAAgB,EAMjB,MAAM,qBAAqB,CAAC;;;;AAsb7B,wBAA+D"}
|
|
@@ -70,10 +70,10 @@ const ListToolbar = forwardRef(function ListToolbar({ testId, name, headingTag =
|
|
|
70
70
|
if (!createNew?.onClick)
|
|
71
71
|
return null;
|
|
72
72
|
const text = createNew.label ?? t('create_new');
|
|
73
|
-
return (_jsx(Button, { variant: 'simple', icon: true, label: text, "aria-label": text, onClick: createNew.onClick, children: _jsx(Icon, { name: 'plus' }) }));
|
|
73
|
+
return (_jsx(Button, { "data-testid": testIds.createNew, variant: 'simple', icon: true, label: text, "aria-label": text, onClick: createNew.onClick, children: _jsx(Icon, { name: 'plus' }) }));
|
|
74
74
|
}, [t, createNew, isSmallOrAbove]);
|
|
75
75
|
useEscape(onSearchEscape, searchInputRef);
|
|
76
|
-
const searchInput = useMemo(() => (_jsx(SearchInput, { ...search, onSearchSubmit: (value) => {
|
|
76
|
+
const searchInput = useMemo(() => (_jsx(SearchInput, { "data-testid": testIds.searchInput, ...search, onSearchSubmit: (value) => {
|
|
77
77
|
search?.onSearchSubmit?.(value);
|
|
78
78
|
onSearchEscape();
|
|
79
79
|
}, onClick: (e) => {
|
|
@@ -85,7 +85,7 @@ const ListToolbar = forwardRef(function ListToolbar({ testId, name, headingTag =
|
|
|
85
85
|
}, ref: searchInputRef })), [search, onSearchEscape]);
|
|
86
86
|
const searchLabel = t('search');
|
|
87
87
|
const expandableSearch = useMemo(() => {
|
|
88
|
-
return isSearchOpen ? (searchInput) : (_jsx(Button, { variant: 'simple', icon: true, label: searchLabel, onClick: () => {
|
|
88
|
+
return isSearchOpen ? (searchInput) : (_jsx(Button, { "data-testid": testIds.searchButton, variant: 'simple', icon: true, label: searchLabel, onClick: () => {
|
|
89
89
|
setIsSearchOpen(true);
|
|
90
90
|
setTimeout(() => searchInputRef.current?.focus());
|
|
91
91
|
}, onKeyDown: (e) => {
|
|
@@ -174,7 +174,7 @@ const ListToolbar = forwardRef(function ListToolbar({ testId, name, headingTag =
|
|
|
174
174
|
}, children: [_jsxs(StyledContainer, { container: {
|
|
175
175
|
alignItems: 'center',
|
|
176
176
|
gap: 1
|
|
177
|
-
}, children: [_jsxs(StyledHeadingText, { "data-testid": testIds.heading, variant: headingTag, required: formControlProps?.required, "aria-describedby": formControlProps?.info ? `${uid}-info` : undefined, children: [formControlProps?.info && formControlProps.status === 'error' && (_jsxs(_Fragment, { children: [_jsx(StyledErrorIcon, { name: 'warn-solid' }), _jsx(VisuallyHiddenText, { children: ` ${t('error')} ` })] })), !viewSelector || viewSelector.views.length <= 1 ? (labelText) : (_jsx(MenuButton, { variant: 'text', text: labelText, as: StyledViewSelector, menu: {
|
|
177
|
+
}, children: [_jsxs(StyledHeadingText, { "data-testid": testIds.heading, variant: headingTag, required: formControlProps?.required, "aria-describedby": formControlProps?.info ? `${uid}-info` : undefined, children: [formControlProps?.info && formControlProps.status === 'error' && (_jsxs(_Fragment, { children: [_jsx(StyledErrorIcon, { name: 'warn-solid' }), _jsx(VisuallyHiddenText, { children: ` ${t('error')} ` })] })), !viewSelector || viewSelector.views.length <= 1 ? (labelText) : (_jsx(MenuButton, { "data-testid": testIds.viewSelector, variant: 'text', text: labelText, as: StyledViewSelector, menu: {
|
|
178
178
|
mode: 'single-select',
|
|
179
179
|
items: viewSelector.views.map(view => {
|
|
180
180
|
if (hasProp(view, 'items')) {
|
|
@@ -203,7 +203,7 @@ const ListToolbar = forwardRef(function ListToolbar({ testId, name, headingTag =
|
|
|
203
203
|
};
|
|
204
204
|
}),
|
|
205
205
|
onItemClick: viewSelector.onViewSelect
|
|
206
|
-
}
|
|
206
|
+
} }))] }), formControlProps?.additionalInfo && (_jsx(AdditionalInfo, { heading: formControlProps.additionalInfo.heading, contextualLabel: labelText, children: formControlProps.additionalInfo.content })), isSmallOrAbove && count && _jsx(CountMeta, { "data-testid": testIds.count, count: count })] }), _jsxs(Flex, { container: { alignItems: 'center', gap: 1 }, children: [isSmallOrAbove && additionalActions, search && isSmallOrAbove && expandableSearch, isSmallOrAbove && createNewButton, isSmallOrAbove && basicModeActions && (_jsx(Actions, { items: basicModeActions.map(({ icon, ...restActionProps }) => ({
|
|
207
207
|
...restActionProps,
|
|
208
208
|
visual: icon && _jsx(Icon, { name: icon })
|
|
209
209
|
})), menuAt: 1, ref: consolidatedActionsButtonRef })), !isSmallOrAbove && count && _jsx(CountMeta, { "data-testid": testIds.count, count: count })] })] }), !isSmallOrAbove && (_jsxs(_Fragment, { children: [!!count?.selected && additionalActions, _jsxs(StyledSearchContainer, { container: { alignItems: 'start', justify: 'between', gap: 1 }, children: [_jsx(Flex, { as: StyledSearchForm, container: { alignItems: 'center', wrap: 'wrap', gap: 1 }, item: { grow: 1 }, children: search && searchInput }), createNewButton, basicModeActions && (_jsx(Actions, { items: basicModeActions.map(({ icon, ...restActionProps }) => ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListToolbar.js","sourceRoot":"","sources":["../../../src/components/ListToolbar/ListToolbar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGtF,OAAO,kBAAkB,MAAM,uBAAuB,CAAC;AACvD,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,MAAM,MAAM,WAAW,CAAC;AAE/B,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,SAAS,EACT,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back, useEffect, useMemo, useRef, useState } from 'react';\nimport type { FunctionComponent, KeyboardEvent, PropsWithoutRef, MouseEvent } from 'react';\n\nimport VisuallyHiddenText from '../VisuallyHiddenText';\nimport Actions from '../Actions';\nimport Button from '../Button';\nimport type { Action, ForwardProps } from '../../types';\nimport {\n useBreakpoint,\n useConfiguration,\n useConsolidatedRef,\n useEscape,\n useI18n,\n useTestIds,\n useUID\n} from '../../hooks';\nimport Flex from '../Flex';\nimport SearchInput from '../SearchInput';\nimport Icon, { registerIcon } from '../Icon';\nimport * as filterIcon from '../Icon/icons/filter.icon';\nimport * as arrowUpDownIcon from '../Icon/icons/arrow-up-down.icon';\nimport * as rowIcon from '../Icon/icons/row.icon';\nimport * as plusIcon from '../Icon/icons/plus.icon';\nimport * as moreIcon from '../Icon/icons/more.icon';\nimport { hasProp, withTestIds } from '../../utils';\nimport { formatNumber } from '../Number';\nimport MenuButton from '../MenuButton';\nimport Avatar from '../Avatar';\nimport AdditionalInfo from '../AdditionalInfo';\n\nimport PresetMenuPopover from './PresetMenuPopover';\nimport type { PresetMenuPopoverProps } from './PresetMenuPopover';\nimport {\n StyledViewSelector,\n StyledSearchForm,\n StyledListToolbar,\n StyledHeadingText,\n StyledCountMeta,\n StyledContainer,\n StyledListToolbarContent,\n StyledListToolbarDialog,\n StyledErrorIcon,\n StyledInfo,\n StyledSearchContainer\n} from './ListToolbar.styles';\nimport type {\n ListToolbarProps,\n PresetMenuProps,\n QueryOptionDialogProps,\n QueryOptionId,\n ViewProps,\n ViewSelectorProps\n} from './ListToolbar.types';\nimport helpers from './helpers';\nimport { getListToolbarTestIds } from './ListToolbar.test-ids';\n\nregisterIcon(filterIcon, arrowUpDownIcon, rowIcon, plusIcon, moreIcon);\n\nconst CountMeta = ({\n count,\n ...restProps\n}: { count: NonNullable<ListToolbarProps['count']> } & ForwardProps) => {\n const { locale } = useConfiguration();\n const t = useI18n();\n const totalFormattedValue = formatNumber(count.total ?? 0, {\n locale,\n options: {\n useGrouping: true\n }\n });\n return (\n <StyledCountMeta variant='secondary' {...restProps}>\n {count.selected\n ? t(\n 'selected_count',\n [formatNumber(count.selected, { locale, options: { useGrouping: true } })],\n { count: count.selected }\n )\n : count.total !== undefined &&\n t(\n 'results_count',\n [count.totalHasMore ? `${totalFormattedValue}+` : totalFormattedValue],\n {\n count: count.total\n }\n )}\n </StyledCountMeta>\n );\n};\n\nconst generateViewName = (\n view: ViewProps,\n texts: { default: string; appDefault: string },\n options: {\n defaultId?: ViewSelectorProps['defaultId'];\n appDefaultId?: ViewSelectorProps['appDefaultId'];\n }\n) => {\n return `${view.text} ${view.id === options.defaultId ? `(${texts.default})` : ''} ${\n view.id === options.appDefaultId ? `(${texts.appDefault})` : ''\n }`;\n};\n\nconst ListToolbar: FunctionComponent<ListToolbarProps & ForwardProps> = forwardRef(\n function ListToolbar(\n {\n testId,\n name,\n headingTag = 'h3',\n viewSelector,\n formControlProps,\n createNew,\n search,\n count,\n additionalActions,\n filter,\n sort,\n group,\n actions,\n actionsButtonRef,\n ...restProps\n }: PropsWithoutRef<ListToolbarProps>,\n ref: ListToolbarProps['ref']\n ) {\n const uid = useUID();\n const t = useI18n();\n const testIds = useTestIds(testId, getListToolbarTestIds);\n\n const isSmallOrAbove = useBreakpoint('sm');\n const consolidatedActionsButtonRef = useConsolidatedRef(actionsButtonRef);\n const toolbarContentRef = useRef<HTMLDivElement>(null);\n const searchInputRef = useRef<HTMLInputElement>(null);\n const searchButtonRef = useRef<HTMLButtonElement>(null);\n const [isSearchOpen, setIsSearchOpen] = useState(!!search?.value);\n\n const onSearchEscape = () => {\n if (!search?.value) {\n setIsSearchOpen(false);\n }\n setTimeout(() => searchButtonRef.current?.focus());\n };\n\n useEffect(() => {\n if (search?.value) {\n setIsSearchOpen(true);\n }\n }, [search?.value]);\n\n const [currentQueryOptionId, setCurrentQueryOptionId] = useState<QueryOptionId | null>(null);\n const queryOptionPopoverTarget = useRef<HTMLButtonElement>();\n\n const [actionsQueryOptionPreset, setActionsQueryOptionPreset] =\n useState<Pick<PresetMenuPopoverProps, 'heading' | 'menu'>>();\n const [optionPresetMenuOpen, setOptionPresetMenuOpen] = useState(false);\n\n const createNewButton = useMemo(() => {\n if (!createNew?.onClick) return null;\n const text = createNew.label ?? t('create_new');\n\n return (\n <Button variant='simple' icon label={text} aria-label={text} onClick={createNew.onClick}>\n <Icon name='plus' />\n </Button>\n );\n }, [t, createNew, isSmallOrAbove]);\n\n useEscape(onSearchEscape, searchInputRef);\n const searchInput = useMemo(\n () => (\n <SearchInput\n {...search}\n onSearchSubmit={(value: string) => {\n search?.onSearchSubmit?.(value);\n onSearchEscape();\n }}\n onClick={(e: MouseEvent<HTMLInputElement>) => {\n e.preventDefault();\n }}\n onBlur={() => {\n if (!search?.value) {\n setIsSearchOpen(false);\n }\n }}\n ref={searchInputRef}\n />\n ),\n [search, onSearchEscape]\n );\n\n const searchLabel = t('search');\n const expandableSearch = useMemo(() => {\n return isSearchOpen ? (\n searchInput\n ) : (\n <Button\n variant='simple'\n icon\n label={searchLabel}\n onClick={() => {\n setIsSearchOpen(true);\n setTimeout(() => searchInputRef.current?.focus());\n }}\n onKeyDown={(e: KeyboardEvent<HTMLElement>) => {\n if (e.target !== searchInputRef.current && (e.key === 'Enter' || e.key === ' ')) {\n setIsSearchOpen(true);\n setTimeout(() => {\n searchInputRef.current?.focus();\n searchInputRef.current?.select();\n });\n }\n }}\n ref={searchButtonRef}\n >\n <Icon name='search' />\n </Button>\n );\n }, [searchLabel, setIsSearchOpen, isSearchOpen, searchInput]);\n\n let queryOptionPopover = null;\n if (currentQueryOptionId) {\n const queryOptionProps = { filter, sort, group }[currentQueryOptionId];\n if (\n queryOptionProps &&\n hasProp(queryOptionProps, 'renderer') &&\n queryOptionPopoverTarget.current\n ) {\n queryOptionPopover = (\n <StyledListToolbarDialog\n target={queryOptionPopoverTarget.current}\n heading={t(currentQueryOptionId)}\n placement='bottom-end'\n onCancel={() => {\n if (queryOptionProps.onCancel() === false) return;\n setCurrentQueryOptionId(null);\n }}\n onSubmit={() => {\n if (queryOptionProps.onSubmit() === false) return;\n setCurrentQueryOptionId(null);\n }}\n >\n <queryOptionProps.renderer />\n </StyledListToolbarDialog>\n );\n }\n }\n\n const getQueryOptionAction = useCallback(\n (\n id: 'sort' | 'group' | 'filter',\n icon: string,\n queryOptionProps: QueryOptionDialogProps | PresetMenuProps\n ) => {\n return {\n text: t(id),\n id,\n icon,\n count: queryOptionProps.count,\n onClick: () => {\n if (hasProp(queryOptionProps, 'renderer')) {\n setCurrentQueryOptionId(id);\n queryOptionPopoverTarget.current = consolidatedActionsButtonRef.current ?? undefined;\n }\n if (hasProp(queryOptionProps, 'items')) {\n setActionsQueryOptionPreset({\n heading: t(id),\n menu: {\n mode: queryOptionProps.mode,\n items: queryOptionProps.items.map(item => ({ ...item, primary: item.text })),\n onItemClick: queryOptionProps.onItemClick\n }\n });\n setOptionPresetMenuOpen(true);\n }\n }\n };\n },\n []\n );\n\n const basicModeActions = useMemo(() => {\n let basicActions: Action[] = [];\n if (filter) {\n const filterAction: Action = getQueryOptionAction('filter', 'filter', filter);\n basicActions.push(filterAction);\n }\n if (sort) {\n const sortAction: Action = getQueryOptionAction('sort', 'arrow-up-down', sort);\n basicActions.push(sortAction);\n }\n if (group) {\n const groupAction: Action = getQueryOptionAction('group', 'row', group);\n basicActions.push(groupAction);\n }\n if (actions) {\n basicActions = basicActions.concat(actions);\n }\n\n return basicActions.length ? basicActions : undefined;\n }, [actions, filter, sort, group, getQueryOptionAction]);\n\n let labelText = name;\n\n if (viewSelector) {\n const viewItems = helpers.getViews(viewSelector.views);\n\n if (viewItems.length > 1) {\n const selectedViewName =\n helpers.getSelectedView(viewSelector.views)?.text ?? viewItems[0].text;\n\n labelText = `${name}: ${selectedViewName}`;\n }\n }\n\n return (\n <Flex data-testid={testIds.root} container {...restProps} as={StyledListToolbar} ref={ref}>\n <StyledListToolbarContent\n container={{ direction: 'column', pad: [0.5, 0.5, 0.5, undefined] }}\n ref={toolbarContentRef}\n item={{ grow: 1 }}\n >\n <Flex\n container={{\n alignItems: 'start',\n justify: 'between',\n gap: 0.5\n }}\n >\n <StyledContainer\n container={{\n alignItems: 'center',\n gap: 1\n }}\n >\n <StyledHeadingText\n data-testid={testIds.heading}\n variant={headingTag}\n required={formControlProps?.required}\n aria-describedby={formControlProps?.info ? `${uid}-info` : undefined}\n >\n {formControlProps?.info && formControlProps.status === 'error' && (\n <>\n <StyledErrorIcon name='warn-solid' />\n <VisuallyHiddenText>{` ${t('error')} `}</VisuallyHiddenText>\n </>\n )}\n {!viewSelector || viewSelector.views.length <= 1 ? (\n labelText\n ) : (\n <MenuButton\n variant='text'\n text={labelText}\n as={StyledViewSelector}\n menu={{\n mode: 'single-select',\n items: viewSelector.views.map(view => {\n if (hasProp(view, 'items')) {\n return {\n id: view.text,\n label: view.text,\n items: view.items.map(groupedView => {\n return {\n ...groupedView,\n primary: generateViewName(\n groupedView,\n { default: t('default'), appDefault: t('app_default') },\n {\n defaultId: viewSelector.defaultId,\n appDefaultId: viewSelector.appDefaultId\n }\n ),\n visual: groupedView.visual ? (\n <Avatar {...groupedView.visual} />\n ) : undefined\n };\n })\n };\n }\n\n return {\n ...view,\n primary: generateViewName(\n view,\n { default: t('default'), appDefault: t('app_default') },\n {\n defaultId: viewSelector.defaultId,\n appDefaultId: viewSelector.appDefaultId\n }\n ),\n visual: view.visual ? <Avatar {...view.visual} /> : undefined\n };\n }),\n onItemClick: viewSelector.onViewSelect\n }}\n testId={testIds.viewSelector}\n />\n )}\n </StyledHeadingText>\n {formControlProps?.additionalInfo && (\n <AdditionalInfo\n heading={formControlProps.additionalInfo.heading}\n contextualLabel={labelText}\n >\n {formControlProps.additionalInfo.content}\n </AdditionalInfo>\n )}\n {isSmallOrAbove && count && <CountMeta data-testid={testIds.count} count={count} />}\n </StyledContainer>\n <Flex container={{ alignItems: 'center', gap: 1 }}>\n {isSmallOrAbove && additionalActions}\n {search && isSmallOrAbove && expandableSearch}\n {isSmallOrAbove && createNewButton}\n {isSmallOrAbove && basicModeActions && (\n <Actions\n items={basicModeActions.map(({ icon, ...restActionProps }) => ({\n ...restActionProps,\n visual: icon && <Icon name={icon} />\n }))}\n menuAt={1}\n ref={consolidatedActionsButtonRef}\n />\n )}\n {!isSmallOrAbove && count && <CountMeta data-testid={testIds.count} count={count} />}\n </Flex>\n </Flex>\n {!isSmallOrAbove && (\n <>\n {!!count?.selected && additionalActions}\n <StyledSearchContainer\n container={{ alignItems: 'start', justify: 'between', gap: 1 }}\n >\n <Flex\n as={StyledSearchForm}\n container={{ alignItems: 'center', wrap: 'wrap', gap: 1 }}\n item={{ grow: 1 }}\n >\n {search && searchInput}\n </Flex>\n {createNewButton}\n {basicModeActions && (\n <Actions\n items={basicModeActions.map(({ icon, ...restActionProps }) => ({\n ...restActionProps,\n visual: icon && <Icon name={icon} />\n }))}\n menuAt={1}\n ref={consolidatedActionsButtonRef}\n />\n )}\n </StyledSearchContainer>\n </>\n )}\n {formControlProps?.info && (\n <StyledInfo\n role={\n formControlProps.status === 'error' || formControlProps.status === 'warning'\n ? 'alert'\n : undefined\n }\n id={`${uid}-info`}\n data-testid={testIds.info}\n status={formControlProps.status}\n >\n {formControlProps.info}\n </StyledInfo>\n )}\n </StyledListToolbarContent>\n\n {queryOptionPopover}\n\n <PresetMenuPopover\n buttonRef={consolidatedActionsButtonRef}\n heading={actionsQueryOptionPreset?.heading}\n menu={actionsQueryOptionPreset?.menu}\n isOpen={optionPresetMenuOpen}\n onClose={() => setOptionPresetMenuOpen(false)}\n />\n </Flex>\n );\n }\n);\n\nexport default withTestIds(ListToolbar, getListToolbarTestIds);\n"]}
|
|
1
|
+
{"version":3,"file":"ListToolbar.js","sourceRoot":"","sources":["../../../src/components/ListToolbar/ListToolbar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGtF,OAAO,k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wBAAwB,EAAE,IAAI,EACpC,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,GAAG,EAAE,CAAC,uBAAuB,CAAC,KAAK,CAAC,GAC7C,IACG,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC,WAAW,EAAE,qBAAqB,CAAC,CAAC","sourcesContent":["import { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport type { FunctionComponent, KeyboardEvent, PropsWithoutRef, MouseEvent } from 'react';\n\nimport VisuallyHiddenText from '../VisuallyHiddenText';\nimport Actions from '../Actions';\nimport Button from '../Button';\nimport type { Action, ForwardProps } from '../../types';\nimport {\n useBreakpoint,\n useConfiguration,\n useConsolidatedRef,\n useEscape,\n useI18n,\n useTestIds,\n useUID\n} from '../../hooks';\nimport Flex from '../Flex';\nimport SearchInput from '../SearchInput';\nimport Icon, { registerIcon } from '../Icon';\nimport * as filterIcon from '../Icon/icons/filter.icon';\nimport * as arrowUpDownIcon from '../Icon/icons/arrow-up-down.icon';\nimport * as rowIcon from '../Icon/icons/row.icon';\nimport * as plusIcon from '../Icon/icons/plus.icon';\nimport * as moreIcon from '../Icon/icons/more.icon';\nimport { hasProp, withTestIds } from '../../utils';\nimport { formatNumber } from '../Number';\nimport MenuButton from '../MenuButton';\nimport Avatar from '../Avatar';\nimport AdditionalInfo from '../AdditionalInfo';\n\nimport PresetMenuPopover from './PresetMenuPopover';\nimport type { PresetMenuPopoverProps } from './PresetMenuPopover';\nimport {\n StyledViewSelector,\n StyledSearchForm,\n StyledListToolbar,\n StyledHeadingText,\n StyledCountMeta,\n StyledContainer,\n StyledListToolbarContent,\n StyledListToolbarDialog,\n StyledErrorIcon,\n StyledInfo,\n StyledSearchContainer\n} from './ListToolbar.styles';\nimport type {\n ListToolbarProps,\n PresetMenuProps,\n QueryOptionDialogProps,\n QueryOptionId,\n ViewProps,\n ViewSelectorProps\n} from './ListToolbar.types';\nimport helpers from './helpers';\nimport { getListToolbarTestIds } from './ListToolbar.test-ids';\n\nregisterIcon(filterIcon, arrowUpDownIcon, rowIcon, plusIcon, moreIcon);\n\nconst CountMeta = ({\n count,\n ...restProps\n}: { count: NonNullable<ListToolbarProps['count']> } & ForwardProps) => {\n const { locale } = useConfiguration();\n const t = useI18n();\n const totalFormattedValue = formatNumber(count.total ?? 0, {\n locale,\n options: {\n useGrouping: true\n }\n });\n return (\n <StyledCountMeta variant='secondary' {...restProps}>\n {count.selected\n ? t(\n 'selected_count',\n [formatNumber(count.selected, { locale, options: { useGrouping: true } })],\n { count: count.selected }\n )\n : count.total !== undefined &&\n t(\n 'results_count',\n [count.totalHasMore ? `${totalFormattedValue}+` : totalFormattedValue],\n {\n count: count.total\n }\n )}\n </StyledCountMeta>\n );\n};\n\nconst generateViewName = (\n view: ViewProps,\n texts: { default: string; appDefault: string },\n options: {\n defaultId?: ViewSelectorProps['defaultId'];\n appDefaultId?: ViewSelectorProps['appDefaultId'];\n }\n) => {\n return `${view.text} ${view.id === options.defaultId ? `(${texts.default})` : ''} ${\n view.id === options.appDefaultId ? `(${texts.appDefault})` : ''\n }`;\n};\n\nconst ListToolbar: FunctionComponent<ListToolbarProps & ForwardProps> = forwardRef(\n function ListToolbar(\n {\n testId,\n name,\n headingTag = 'h3',\n viewSelector,\n formControlProps,\n createNew,\n search,\n count,\n additionalActions,\n filter,\n sort,\n group,\n actions,\n actionsButtonRef,\n ...restProps\n }: PropsWithoutRef<ListToolbarProps>,\n ref: ListToolbarProps['ref']\n ) {\n const uid = useUID();\n const t = useI18n();\n const testIds = useTestIds(testId, getListToolbarTestIds);\n\n const isSmallOrAbove = useBreakpoint('sm');\n const consolidatedActionsButtonRef = useConsolidatedRef(actionsButtonRef);\n const toolbarContentRef = useRef<HTMLDivElement>(null);\n const searchInputRef = useRef<HTMLInputElement>(null);\n const searchButtonRef = useRef<HTMLButtonElement>(null);\n const [isSearchOpen, setIsSearchOpen] = useState(!!search?.value);\n\n const onSearchEscape = () => {\n if (!search?.value) {\n setIsSearchOpen(false);\n }\n setTimeout(() => searchButtonRef.current?.focus());\n };\n\n useEffect(() => {\n if (search?.value) {\n setIsSearchOpen(true);\n }\n }, [search?.value]);\n\n const [currentQueryOptionId, setCurrentQueryOptionId] = useState<QueryOptionId | null>(null);\n const queryOptionPopoverTarget = useRef<HTMLButtonElement>();\n\n const [actionsQueryOptionPreset, setActionsQueryOptionPreset] =\n useState<Pick<PresetMenuPopoverProps, 'heading' | 'menu'>>();\n const [optionPresetMenuOpen, setOptionPresetMenuOpen] = useState(false);\n\n const createNewButton = useMemo(() => {\n if (!createNew?.onClick) return null;\n const text = createNew.label ?? t('create_new');\n\n return (\n <Button\n data-testid={testIds.createNew}\n variant='simple'\n icon\n label={text}\n aria-label={text}\n onClick={createNew.onClick}\n >\n <Icon name='plus' />\n </Button>\n );\n }, [t, createNew, isSmallOrAbove]);\n\n useEscape(onSearchEscape, searchInputRef);\n const searchInput = useMemo(\n () => (\n <SearchInput\n data-testid={testIds.searchInput}\n {...search}\n onSearchSubmit={(value: string) => {\n search?.onSearchSubmit?.(value);\n onSearchEscape();\n }}\n onClick={(e: MouseEvent<HTMLInputElement>) => {\n e.preventDefault();\n }}\n onBlur={() => {\n if (!search?.value) {\n setIsSearchOpen(false);\n }\n }}\n ref={searchInputRef}\n />\n ),\n [search, onSearchEscape]\n );\n\n const searchLabel = t('search');\n const expandableSearch = useMemo(() => {\n return isSearchOpen ? (\n searchInput\n ) : (\n <Button\n data-testid={testIds.searchButton}\n variant='simple'\n icon\n label={searchLabel}\n onClick={() => {\n setIsSearchOpen(true);\n setTimeout(() => searchInputRef.current?.focus());\n }}\n onKeyDown={(e: KeyboardEvent<HTMLElement>) => {\n if (e.target !== searchInputRef.current && (e.key === 'Enter' || e.key === ' ')) {\n setIsSearchOpen(true);\n setTimeout(() => {\n searchInputRef.current?.focus();\n searchInputRef.current?.select();\n });\n }\n }}\n ref={searchButtonRef}\n >\n <Icon name='search' />\n </Button>\n );\n }, [searchLabel, setIsSearchOpen, isSearchOpen, searchInput]);\n\n let queryOptionPopover = null;\n if (currentQueryOptionId) {\n const queryOptionProps = { filter, sort, group }[currentQueryOptionId];\n if (\n queryOptionProps &&\n hasProp(queryOptionProps, 'renderer') &&\n queryOptionPopoverTarget.current\n ) {\n queryOptionPopover = (\n <StyledListToolbarDialog\n target={queryOptionPopoverTarget.current}\n heading={t(currentQueryOptionId)}\n placement='bottom-end'\n onCancel={() => {\n if (queryOptionProps.onCancel() === false) return;\n setCurrentQueryOptionId(null);\n }}\n onSubmit={() => {\n if (queryOptionProps.onSubmit() === false) return;\n setCurrentQueryOptionId(null);\n }}\n >\n <queryOptionProps.renderer />\n </StyledListToolbarDialog>\n );\n }\n }\n\n const getQueryOptionAction = useCallback(\n (\n id: 'sort' | 'group' | 'filter',\n icon: string,\n queryOptionProps: QueryOptionDialogProps | PresetMenuProps\n ) => {\n return {\n text: t(id),\n id,\n icon,\n count: queryOptionProps.count,\n onClick: () => {\n if (hasProp(queryOptionProps, 'renderer')) {\n setCurrentQueryOptionId(id);\n queryOptionPopoverTarget.current = consolidatedActionsButtonRef.current ?? undefined;\n }\n if (hasProp(queryOptionProps, 'items')) {\n setActionsQueryOptionPreset({\n heading: t(id),\n menu: {\n mode: queryOptionProps.mode,\n items: queryOptionProps.items.map(item => ({ ...item, primary: item.text })),\n onItemClick: queryOptionProps.onItemClick\n }\n });\n setOptionPresetMenuOpen(true);\n }\n }\n };\n },\n []\n );\n\n const basicModeActions = useMemo(() => {\n let basicActions: Action[] = [];\n if (filter) {\n const filterAction: Action = getQueryOptionAction('filter', 'filter', filter);\n basicActions.push(filterAction);\n }\n if (sort) {\n const sortAction: Action = getQueryOptionAction('sort', 'arrow-up-down', sort);\n basicActions.push(sortAction);\n }\n if (group) {\n const groupAction: Action = getQueryOptionAction('group', 'row', group);\n basicActions.push(groupAction);\n }\n if (actions) {\n basicActions = basicActions.concat(actions);\n }\n\n return basicActions.length ? basicActions : undefined;\n }, [actions, filter, sort, group, getQueryOptionAction]);\n\n let labelText = name;\n\n if (viewSelector) {\n const viewItems = helpers.getViews(viewSelector.views);\n\n if (viewItems.length > 1) {\n const selectedViewName =\n helpers.getSelectedView(viewSelector.views)?.text ?? viewItems[0].text;\n\n labelText = `${name}: ${selectedViewName}`;\n }\n }\n\n return (\n <Flex data-testid={testIds.root} container {...restProps} as={StyledListToolbar} ref={ref}>\n <StyledListToolbarContent\n container={{ direction: 'column', pad: [0.5, 0.5, 0.5, undefined] }}\n ref={toolbarContentRef}\n item={{ grow: 1 }}\n >\n <Flex\n container={{\n alignItems: 'start',\n justify: 'between',\n gap: 0.5\n }}\n >\n <StyledContainer\n container={{\n alignItems: 'center',\n gap: 1\n }}\n >\n <StyledHeadingText\n data-testid={testIds.heading}\n variant={headingTag}\n required={formControlProps?.required}\n aria-describedby={formControlProps?.info ? `${uid}-info` : undefined}\n >\n {formControlProps?.info && formControlProps.status === 'error' && (\n <>\n <StyledErrorIcon name='warn-solid' />\n <VisuallyHiddenText>{` ${t('error')} `}</VisuallyHiddenText>\n </>\n )}\n {!viewSelector || viewSelector.views.length <= 1 ? (\n labelText\n ) : (\n <MenuButton\n data-testid={testIds.viewSelector}\n variant='text'\n text={labelText}\n as={StyledViewSelector}\n menu={{\n mode: 'single-select',\n items: viewSelector.views.map(view => {\n if (hasProp(view, 'items')) {\n return {\n id: view.text,\n label: view.text,\n items: view.items.map(groupedView => {\n return {\n ...groupedView,\n primary: generateViewName(\n groupedView,\n { default: t('default'), appDefault: t('app_default') },\n {\n defaultId: viewSelector.defaultId,\n appDefaultId: viewSelector.appDefaultId\n }\n ),\n visual: groupedView.visual ? (\n <Avatar {...groupedView.visual} />\n ) : undefined\n };\n })\n };\n }\n\n return {\n ...view,\n primary: generateViewName(\n view,\n { default: t('default'), appDefault: t('app_default') },\n {\n defaultId: viewSelector.defaultId,\n appDefaultId: viewSelector.appDefaultId\n }\n ),\n visual: view.visual ? <Avatar {...view.visual} /> : undefined\n };\n }),\n onItemClick: viewSelector.onViewSelect\n }}\n />\n )}\n </StyledHeadingText>\n {formControlProps?.additionalInfo && (\n <AdditionalInfo\n heading={formControlProps.additionalInfo.heading}\n contextualLabel={labelText}\n >\n {formControlProps.additionalInfo.content}\n </AdditionalInfo>\n )}\n {isSmallOrAbove && count && <CountMeta data-testid={testIds.count} count={count} />}\n </StyledContainer>\n <Flex container={{ alignItems: 'center', gap: 1 }}>\n {isSmallOrAbove && additionalActions}\n {search && isSmallOrAbove && expandableSearch}\n {isSmallOrAbove && createNewButton}\n {isSmallOrAbove && basicModeActions && (\n <Actions\n items={basicModeActions.map(({ icon, ...restActionProps }) => ({\n ...restActionProps,\n visual: icon && <Icon name={icon} />\n }))}\n menuAt={1}\n ref={consolidatedActionsButtonRef}\n />\n )}\n {!isSmallOrAbove && count && <CountMeta data-testid={testIds.count} count={count} />}\n </Flex>\n </Flex>\n {!isSmallOrAbove && (\n <>\n {!!count?.selected && additionalActions}\n <StyledSearchContainer\n container={{ alignItems: 'start', justify: 'between', gap: 1 }}\n >\n <Flex\n as={StyledSearchForm}\n container={{ alignItems: 'center', wrap: 'wrap', gap: 1 }}\n item={{ grow: 1 }}\n >\n {search && searchInput}\n </Flex>\n {createNewButton}\n {basicModeActions && (\n <Actions\n items={basicModeActions.map(({ icon, ...restActionProps }) => ({\n ...restActionProps,\n visual: icon && <Icon name={icon} />\n }))}\n menuAt={1}\n ref={consolidatedActionsButtonRef}\n />\n )}\n </StyledSearchContainer>\n </>\n )}\n {formControlProps?.info && (\n <StyledInfo\n role={\n formControlProps.status === 'error' || formControlProps.status === 'warning'\n ? 'alert'\n : undefined\n }\n id={`${uid}-info`}\n data-testid={testIds.info}\n status={formControlProps.status}\n >\n {formControlProps.info}\n </StyledInfo>\n )}\n </StyledListToolbarContent>\n\n {queryOptionPopover}\n\n <PresetMenuPopover\n buttonRef={consolidatedActionsButtonRef}\n heading={actionsQueryOptionPreset?.heading}\n menu={actionsQueryOptionPreset?.menu}\n isOpen={optionPresetMenuOpen}\n onClose={() => setOptionPresetMenuOpen(false)}\n />\n </Flex>\n );\n }\n);\n\nexport default withTestIds(ListToolbar, getListToolbarTestIds);\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const getListToolbarTestIds: (testIdProp?: string | undefined) => import("../..").TestIdsRecord<readonly ["view-selector", "count", "heading", "info"]>;
|
|
1
|
+
export declare const getListToolbarTestIds: (testIdProp?: string | undefined) => import("../..").TestIdsRecord<readonly ["view-selector", "count", "heading", "info", "create-new", "search-input", "search-button"]>;
|
|
2
2
|
//# sourceMappingURL=ListToolbar.test-ids.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListToolbar.test-ids.d.ts","sourceRoot":"","sources":["../../../src/components/ListToolbar/ListToolbar.test-ids.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,qBAAqB,
|
|
1
|
+
{"version":3,"file":"ListToolbar.test-ids.d.ts","sourceRoot":"","sources":["../../../src/components/ListToolbar/ListToolbar.test-ids.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,qBAAqB,2KAQvB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListToolbar.test-ids.js","sourceRoot":"","sources":["../../../src/components/ListToolbar/ListToolbar.test-ids.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,CAAC,MAAM,qBAAqB,GAAG,aAAa,CAAC,cAAc,EAAE;IACjE,eAAe;IACf,OAAO;IACP,SAAS;IACT,MAAM;
|
|
1
|
+
{"version":3,"file":"ListToolbar.test-ids.js","sourceRoot":"","sources":["../../../src/components/ListToolbar/ListToolbar.test-ids.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,CAAC,MAAM,qBAAqB,GAAG,aAAa,CAAC,cAAc,EAAE;IACjE,eAAe;IACf,OAAO;IACP,SAAS;IACT,MAAM;IACN,YAAY;IACZ,cAAc;IACd,eAAe;CACP,CAAC,CAAC","sourcesContent":["import { createTestIds } from '../../utils';\n\nexport const getListToolbarTestIds = createTestIds('list-toolbar', [\n 'view-selector',\n 'count',\n 'heading',\n 'info',\n 'create-new',\n 'search-input',\n 'search-button'\n] as const);\n"]}
|
|
@@ -12,15 +12,10 @@ interface OnChangeCoordsValue {
|
|
|
12
12
|
type OnChangeValue = OnChangeAddressValue | OnChangeCoordsValue;
|
|
13
13
|
export type CurrentLocationButtonProps = {
|
|
14
14
|
/** Callback fired after click on my current location button if location was found. */
|
|
15
|
-
|
|
15
|
+
onResolve?: (value: OnChangeValue) => void;
|
|
16
16
|
/** Callback fired when an error occurs. */
|
|
17
17
|
onError?: (error: Error) => void;
|
|
18
|
-
/** Get current location on component first render */
|
|
19
|
-
defaultToCurrentLocation?: boolean;
|
|
20
18
|
};
|
|
21
|
-
export declare const StyledCurrentLocationButton: import("styled-components").StyledComponent<import("react").FunctionComponent<import("../Button").ButtonProps & import("../..").ForwardProps>, import("styled-components").DefaultTheme, {
|
|
22
|
-
currentLocationDisabled: boolean;
|
|
23
|
-
}, never>;
|
|
24
19
|
declare const CurrentLocationButton: FC<CurrentLocationButtonProps>;
|
|
25
20
|
export default CurrentLocationButton;
|
|
26
21
|
//# sourceMappingURL=CurrentLocationButton.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CurrentLocationButton.d.ts","sourceRoot":"","sources":["../../../src/components/Location/CurrentLocationButton.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"CurrentLocationButton.d.ts","sourceRoot":"","sources":["../../../src/components/Location/CurrentLocationButton.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAahC,UAAU,oBAAoB;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,UAAU,mBAAmB;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,KAAK,aAAa,GAAG,oBAAoB,GAAG,mBAAmB,CAAC;AAEhE,MAAM,MAAM,0BAA0B,GAAG;IACvC,sFAAsF;IACtF,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC3C,2CAA2C;IAC3C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC,CAAC;AAEF,QAAA,MAAM,qBAAqB,EAAE,EAAE,CAAC,0BAA0B,CAqDzD,CAAC;AACF,eAAe,qBAAqB,CAAC"}
|
|
@@ -1,51 +1,41 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useContext, useEffect, useState } from 'react';
|
|
3
|
-
import styled, { css } from 'styled-components';
|
|
4
3
|
import Tooltip from '../Tooltip';
|
|
5
4
|
import { useElement, useI18n } from '../../hooks';
|
|
6
5
|
import Icon, { registerIcon } from '../Icon';
|
|
7
6
|
import * as locationIcon from '../Icon/icons/location.icon';
|
|
8
7
|
import Button from '../Button';
|
|
9
|
-
import { defaultThemeProp } from '../../theme';
|
|
10
8
|
import MapsContext from './MapsContext';
|
|
11
9
|
import { getNavigatorPosition, getAddress, loadMapsAPI } from './utils';
|
|
12
10
|
registerIcon(locationIcon);
|
|
13
|
-
|
|
14
|
-
${currentLocationDisabled &&
|
|
15
|
-
css `
|
|
16
|
-
opacity: ${disabledOpacity};
|
|
17
|
-
cursor: auto;
|
|
18
|
-
`}
|
|
19
|
-
`);
|
|
20
|
-
StyledCurrentLocationButton.defaultProps = defaultThemeProp;
|
|
21
|
-
const CurrentLocationButton = ({ onChange, onError, defaultToCurrentLocation }) => {
|
|
11
|
+
const CurrentLocationButton = ({ onResolve, onError }) => {
|
|
22
12
|
const t = useI18n();
|
|
23
13
|
const { name, ...providerOpts } = useContext(MapsContext);
|
|
24
14
|
const [currentLocationDisabled, setCurrentLocationDisabled] = useState(false);
|
|
15
|
+
const [busy, setBusy] = useState(false);
|
|
25
16
|
const [el, setEl] = useElement();
|
|
26
17
|
const getCurrentLocation = useCallback(() => {
|
|
27
|
-
|
|
18
|
+
setBusy(true);
|
|
19
|
+
Promise.all([getNavigatorPosition(), loadMapsAPI(name, providerOpts)])
|
|
28
20
|
.catch(error => {
|
|
29
21
|
setCurrentLocationDisabled(true);
|
|
30
22
|
throw error;
|
|
31
23
|
})
|
|
32
|
-
.then(getAddress)
|
|
24
|
+
.then(([navigatorPosition]) => getAddress(navigatorPosition))
|
|
33
25
|
.then(address => {
|
|
34
|
-
|
|
26
|
+
onResolve?.(address);
|
|
35
27
|
})
|
|
36
|
-
.catch(error => onError?.(error))
|
|
37
|
-
|
|
28
|
+
.catch(error => onError?.(error))
|
|
29
|
+
.finally(() => setBusy(false));
|
|
30
|
+
}, [onResolve, onError]);
|
|
38
31
|
useEffect(() => {
|
|
39
32
|
navigator.permissions?.query({ name: 'geolocation' }).then(result => {
|
|
40
33
|
if (result.state === 'denied') {
|
|
41
34
|
setCurrentLocationDisabled(true);
|
|
42
35
|
}
|
|
43
36
|
});
|
|
44
|
-
if (defaultToCurrentLocation) {
|
|
45
|
-
loadMapsAPI(name, providerOpts).then(getCurrentLocation);
|
|
46
|
-
}
|
|
47
37
|
}, []);
|
|
48
|
-
return (_jsxs(_Fragment, { children: [_jsx(Button, { ref: setEl,
|
|
38
|
+
return (_jsxs(_Fragment, { children: [_jsx(Button, { ref: setEl, variant: 'simple', icon: true, onClick: getCurrentLocation, "aria-label": t('my_current_location_button_a11y'), disabled: currentLocationDisabled, loading: busy, children: _jsx(Icon, { name: 'location' }) }), el && currentLocationDisabled && (_jsx(Tooltip, { shown: true, target: el, children: t('allow_location_permissions_text') }))] }));
|
|
49
39
|
};
|
|
50
40
|
export default CurrentLocationButton;
|
|
51
41
|
//# sourceMappingURL=CurrentLocationButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CurrentLocationButton.js","sourceRoot":"","sources":["../../../src/components/Location/CurrentLocationButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"CurrentLocationButton.js","sourceRoot":"","sources":["../../../src/components/Location/CurrentLocationButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGrE,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,YAAY,MAAM,6BAA6B,CAAC;AAC5D,OAAO,MAAM,MAAM,WAAW,CAAC;AAE/B,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAExE,YAAY,CAAC,YAAY,CAAC,CAAC;AAuB3B,MAAM,qBAAqB,GAAmC,CAAC,EAC7D,SAAS,EACT,OAAO,EACoB,EAAE,EAAE;IAC/B,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IACpB,MAAM,EAAE,IAAI,EAAE,GAAG,YAAY,EAAE,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;IAC1D,MAAM,CAAC,uBAAuB,EAAE,0BAA0B,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9E,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC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ACf,CAAC,CAAC,iCAAiC,CAAC,EAChD,QAAQ,EAAE,uBAAuB,EACjC,OAAO,EAAE,IAAI,YAEb,KAAC,IAAI,IAAC,IAAI,EAAC,UAAU,GAAG,GACjB,EACR,EAAE,IAAI,uBAAuB,IAAI,CAChC,KAAC,OAAO,IAAC,KAAK,QAAC,MAAM,EAAE,EAAE,YACtB,CAAC,CAAC,iCAAiC,CAAC,GAC7B,CACX,IACA,CACJ,CAAC;AACJ,CAAC,CAAC;AACF,eAAe,qBAAqB,CAAC","sourcesContent":["import { useCallback, useContext, useEffect, useState } from 'react';\nimport type { FC } from 'react';\n\nimport Tooltip from '../Tooltip';\nimport { useElement, useI18n } from '../../hooks';\nimport Icon, { registerIcon } from '../Icon';\nimport * as locationIcon from '../Icon/icons/location.icon';\nimport Button from '../Button';\n\nimport MapsContext from './MapsContext';\nimport { getNavigatorPosition, getAddress, loadMapsAPI } from './utils';\n\nregisterIcon(locationIcon);\n\ninterface OnChangeAddressValue {\n name: string;\n address?: string;\n latitude?: number;\n longitude?: number;\n}\n\ninterface OnChangeCoordsValue {\n latitude: number;\n longitude: number;\n}\n\ntype OnChangeValue = OnChangeAddressValue | OnChangeCoordsValue;\n\nexport type CurrentLocationButtonProps = {\n /** Callback fired after click on my current location button if location was found. */\n onResolve?: (value: OnChangeValue) => void;\n /** Callback fired when an error occurs. */\n onError?: (error: Error) => void;\n};\n\nconst CurrentLocationButton: FC<CurrentLocationButtonProps> = ({\n onResolve,\n onError\n}: CurrentLocationButtonProps) => {\n const t = useI18n();\n const { name, ...providerOpts } = useContext(MapsContext);\n const [currentLocationDisabled, setCurrentLocationDisabled] = useState(false);\n const [busy, setBusy] = useState(false);\n const [el, setEl] = useElement();\n\n const getCurrentLocation = useCallback(() => {\n setBusy(true);\n Promise.all([getNavigatorPosition(), loadMapsAPI(name, providerOpts)])\n .catch(error => {\n setCurrentLocationDisabled(true);\n throw error;\n })\n .then(([navigatorPosition]) => getAddress(navigatorPosition))\n .then(address => {\n onResolve?.(address);\n })\n .catch(error => onError?.(error))\n .finally(() => setBusy(false));\n }, [onResolve, onError]);\n\n useEffect(() => {\n navigator.permissions?.query({ name: 'geolocation' }).then(result => {\n if (result.state === 'denied') {\n setCurrentLocationDisabled(true);\n }\n });\n }, []);\n\n return (\n <>\n <Button\n ref={setEl}\n variant='simple'\n icon\n onClick={getCurrentLocation}\n aria-label={t('my_current_location_button_a11y')}\n disabled={currentLocationDisabled}\n loading={busy}\n >\n <Icon name='location' />\n </Button>\n {el && currentLocationDisabled && (\n <Tooltip shown target={el}>\n {t('allow_location_permissions_text')}\n </Tooltip>\n )}\n </>\n );\n};\nexport default CurrentLocationButton;\n"]}
|
|
@@ -1,19 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
import type {
|
|
3
|
-
export
|
|
4
|
-
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
/// <reference types="google.maps" />
|
|
2
|
+
import type { FieldValueListItem } from '../FieldValueList';
|
|
3
|
+
export declare type LatLng = {
|
|
4
|
+
/** The latitude representation. */
|
|
5
|
+
latitude: ReturnType<google.maps.LatLng['lat']>;
|
|
6
|
+
/** The longitude representation. */
|
|
7
|
+
longitude: ReturnType<google.maps.LatLng['lng']>;
|
|
8
|
+
};
|
|
9
|
+
export declare type Bias = {
|
|
10
|
+
/** Predictions will be biased towards, but not restricted to, the given bounds. Both location and radius will be ignored if bounds is set.
|
|
11
|
+
* Array stores south-west coordinate of bounding box and north-east coordinate of bounding box. */
|
|
12
|
+
bounds?: [LatLng, LatLng];
|
|
13
|
+
/** Predictions will be biased towards the given location and radius. */
|
|
14
|
+
location?: {
|
|
15
|
+
/** Must to provide both center and radius. */
|
|
16
|
+
/** Location coordinate or current (means user current location). */
|
|
17
|
+
center: LatLng | 'current';
|
|
18
|
+
/** The radius is specified in meters. */
|
|
19
|
+
radius: number;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export declare type ProviderOpts = {
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
};
|
|
25
|
+
export interface MapsProvider {
|
|
26
|
+
name: string;
|
|
27
|
+
loadAPI: (options: ProviderOpts) => Promise<void>;
|
|
28
|
+
loadedPromise: Promise<void> | null;
|
|
29
|
+
loadedApiKey: string;
|
|
30
|
+
}
|
|
31
|
+
export declare const QUERY_FIELDS: string[];
|
|
32
|
+
export declare const QUERY_TYPES: string[];
|
|
33
|
+
export declare const LocationNotFoundError = "Location not found";
|
|
34
|
+
export declare const GeolocationUnsupportedError = "Geolocation unsupported";
|
|
35
|
+
export declare const GoogleMapsAPINotFoundError = "Cannot load Google Maps API";
|
|
36
|
+
export declare const IsNotAnObjectError = "Provider data given is not an object";
|
|
37
|
+
export declare const ProviderNotSupportedError = "Not supported maps provider given";
|
|
38
|
+
export declare const CoordsCannotBeParsedError = "Coords cannot be parsed!";
|
|
39
|
+
export declare const GeocoderFailedError = "Geocoder failed due to";
|
|
40
|
+
export interface Location {
|
|
41
|
+
name?: google.maps.places.PlaceResult['name'];
|
|
42
|
+
address?: google.maps.places.PlaceResult['formatted_address'];
|
|
43
|
+
latitude?: ReturnType<google.maps.LatLng['lat']>;
|
|
44
|
+
longitude?: ReturnType<google.maps.LatLng['lng']>;
|
|
45
|
+
}
|
|
46
|
+
export interface Pin extends LatLng {
|
|
47
|
+
title?: string;
|
|
48
|
+
additionalInfo?: FieldValueListItem[];
|
|
18
49
|
}
|
|
19
50
|
//# sourceMappingURL=Location.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Location.types.d.ts","sourceRoot":"","sources":["../../../src/components/Location/Location.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"Location.types.d.ts","sourceRoot":"","sources":["../../../src/components/Location/Location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yBAAyB,sCAAsC,CAAC;AAC7E,eAAO,MAAM,yBAAyB,6BAA6B,CAAC;AACpE,eAAO,MAAM,mBAAmB,2BAA2B,CAAC;AAE5D,MAAM,WAAW,QAAQ;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAC9C,OAAO,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC;IAC9D,QAAQ,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACjD,SAAS,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;CACnD;AAED,MAAM,WAAW,GAAI,SAAQ,MAAM;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,kBAAkB,EAAE,CAAC;CACvC"}
|
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const QUERY_FIELDS = ['name', 'formatted_address', 'geometry.location', 'place_id'];
|
|
2
|
+
export const QUERY_TYPES = ['establishment', 'geocode'];
|
|
3
|
+
export const LocationNotFoundError = 'Location not found';
|
|
4
|
+
export const GeolocationUnsupportedError = 'Geolocation unsupported';
|
|
5
|
+
export const GoogleMapsAPINotFoundError = 'Cannot load Google Maps API';
|
|
6
|
+
export const IsNotAnObjectError = 'Provider data given is not an object';
|
|
7
|
+
export const ProviderNotSupportedError = 'Not supported maps provider given';
|
|
8
|
+
export const CoordsCannotBeParsedError = 'Coords cannot be parsed!';
|
|
9
|
+
export const GeocoderFailedError = 'Geocoder failed due to';
|
|
2
10
|
//# sourceMappingURL=Location.types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Location.types.js","sourceRoot":"","sources":["../../../src/components/Location/Location.types.ts"],"names":[],"mappings":"","sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"Location.types.js","sourceRoot":"","sources":["../../../src/components/Location/Location.types.ts"],"names":[],"mappings":"AAkCA,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,UAAU,CAAC,CAAC;AAC3F,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC;AAExD,MAAM,CAAC,MAAM,qBAAqB,GAAG,oBAAoB,CAAC;AAC1D,MAAM,CAAC,MAAM,2BAA2B,GAAG,yBAAyB,CAAC;AACrE,MAAM,CAAC,MAAM,0BAA0B,GAAG,6BAA6B,CAAC;AACxE,MAAM,CAAC,MAAM,kBAAkB,GAAG,sCAAsC,CAAC;AACzE,MAAM,CAAC,MAAM,yBAAyB,GAAG,mCAAmC,CAAC;AAC7E,MAAM,CAAC,MAAM,yBAAyB,GAAG,0BAA0B,CAAC;AACpE,MAAM,CAAC,MAAM,mBAAmB,GAAG,wBAAwB,CAAC","sourcesContent":["import type { FieldValueListItem } from '../FieldValueList';\n\nexport declare type LatLng = {\n /** The latitude representation. */\n latitude: ReturnType<google.maps.LatLng['lat']>;\n /** The longitude representation. */\n longitude: ReturnType<google.maps.LatLng['lng']>;\n};\n\nexport declare type Bias = {\n /** Predictions will be biased towards, but not restricted to, the given bounds. Both location and radius will be ignored if bounds is set.\n * Array stores south-west coordinate of bounding box and north-east coordinate of bounding box. */\n bounds?: [LatLng, LatLng];\n /** Predictions will be biased towards the given location and radius. */\n location?: {\n /** Must to provide both center and radius. */\n /** Location coordinate or current (means user current location). */\n center: LatLng | 'current';\n /** The radius is specified in meters. */\n radius: number;\n };\n};\n\nexport declare type ProviderOpts = {\n [key: string]: any;\n};\n\nexport interface MapsProvider {\n name: string;\n loadAPI: (options: ProviderOpts) => Promise<void>;\n loadedPromise: Promise<void> | null;\n loadedApiKey: string;\n}\n\nexport const QUERY_FIELDS = ['name', 'formatted_address', 'geometry.location', 'place_id'];\nexport const QUERY_TYPES = ['establishment', 'geocode'];\n\nexport const LocationNotFoundError = 'Location not found';\nexport const GeolocationUnsupportedError = 'Geolocation unsupported';\nexport const GoogleMapsAPINotFoundError = 'Cannot load Google Maps API';\nexport const IsNotAnObjectError = 'Provider data given is not an object';\nexport const ProviderNotSupportedError = 'Not supported maps provider given';\nexport const CoordsCannotBeParsedError = 'Coords cannot be parsed!';\nexport const GeocoderFailedError = 'Geocoder failed due to';\n\nexport interface Location {\n name?: google.maps.places.PlaceResult['name'];\n address?: google.maps.places.PlaceResult['formatted_address'];\n latitude?: ReturnType<google.maps.LatLng['lat']>;\n longitude?: ReturnType<google.maps.LatLng['lng']>;\n}\n\nexport interface Pin extends LatLng {\n title?: string;\n additionalInfo?: FieldValueListItem[];\n}\n"]}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { FunctionComponent, Ref } from 'react';
|
|
2
2
|
import type { BaseProps, ForwardProps } from '../../types';
|
|
3
|
-
import type {
|
|
3
|
+
import type { LocationViewProps } from './LocationView';
|
|
4
|
+
import type { LatLng } from './Location.types';
|
|
4
5
|
export interface LocationDisplayProps extends BaseProps {
|
|
5
6
|
/** Location address or coordinates */
|
|
6
|
-
value?: string | LatLng;
|
|
7
|
+
value?: string | 'current' | LatLng;
|
|
7
8
|
/** The text to be displayed. */
|
|
8
9
|
displayText?: string;
|
|
9
10
|
/**
|
|
@@ -15,12 +16,12 @@ export interface LocationDisplayProps extends BaseProps {
|
|
|
15
16
|
* Height of the map container.
|
|
16
17
|
* @default '25rem'
|
|
17
18
|
*/
|
|
18
|
-
height?:
|
|
19
|
+
height?: LocationViewProps['height'];
|
|
19
20
|
/**
|
|
20
21
|
* How much the map should zoom.
|
|
21
22
|
* @default 13
|
|
22
23
|
*/
|
|
23
|
-
zoomLevel?:
|
|
24
|
+
zoomLevel?: LocationViewProps['zoomLevel'];
|
|
24
25
|
/** Ref for the wrapping element. */
|
|
25
26
|
ref?: Ref<HTMLAnchorElement | HTMLSpanElement>;
|
|
26
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocationDisplay.d.ts","sourceRoot":"","sources":["../../../src/components/Location/LocationDisplay.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAmB,GAAG,EAAE,MAAM,OAAO,CAAC;AAIrE,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"LocationDisplay.d.ts","sourceRoot":"","sources":["../../../src/components/Location/LocationDisplay.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAmB,GAAG,EAAE,MAAM,OAAO,CAAC;AAIrE,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAI3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG/C,MAAM,WAAW,oBAAqB,SAAQ,SAAS;IACrD,sCAAsC;IACtC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC;IACpC,gCAAgC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,OAAO,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,KAAK,CAAC;IACtC;;;OAGG;IACH,MAAM,CAAC,EAAE,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IACrC;;;OAGG;IACH,SAAS,CAAC,EAAE,iBAAiB,CAAC,WAAW,CAAC,CAAC;IAC3C,oCAAoC;IACpC,GAAG,CAAC,EAAE,GAAG,CAAC,iBAAiB,GAAG,eAAe,CAAC,CAAC;CAChD;AAED,QAAA,MAAM,eAAe,EAAE,iBAAiB,CAAC,oBAAoB,GAAG,YAAY,CAkE3E,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useContext } from 'react';
|
|
2
|
+
import { forwardRef, useContext, useEffect, useState } from 'react';
|
|
3
3
|
import Text from '../Text';
|
|
4
4
|
import Link from '../Link';
|
|
5
5
|
import NoValue from '../NoValue/NoValue';
|
|
6
6
|
import LocationView from './LocationView';
|
|
7
7
|
import MapsContext from './MapsContext';
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
import { getCoords, loadMapsAPI } from './utils';
|
|
9
|
+
const LocationDisplay = forwardRef(function LocationDisplay({ value, displayText, variant = 'text-map', height = '25rem', zoomLevel = 13, ...restProps }, ref) {
|
|
10
|
+
const { name, ...providerOpts } = useContext(MapsContext);
|
|
11
|
+
const [location, setLocation] = useState();
|
|
12
|
+
const [loading, setLoading] = useState(false);
|
|
10
13
|
const valueString = typeof value === 'string' ? value : `${value?.latitude}, ${value?.longitude}`;
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (['text-map', 'map'].includes(variant) && value) {
|
|
16
|
+
(async () => {
|
|
17
|
+
setLoading(true);
|
|
18
|
+
await loadMapsAPI(name, providerOpts);
|
|
19
|
+
setLocation(await getCoords(value));
|
|
20
|
+
setLoading(false);
|
|
21
|
+
})();
|
|
22
|
+
}
|
|
23
|
+
}, [variant, value]);
|
|
11
24
|
return !value ? (_jsx(Text, { ref: ref, ...restProps, "aria-hidden": 'true', children: _jsx(NoValue, {}) })) : (_jsxs(_Fragment, { children: [(variant === 'text' || variant === 'text-map') &&
|
|
12
|
-
(name === 'google' ? (_jsx(Link, { ref: ref, ...restProps, target: '_blank', rel: 'noopener noreferrer', href: `https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(typeof value === 'string' ? value : `${value?.latitude}, ${value?.longitude}`)}`, children: displayText || valueString })) : (_jsx(Text, { ref: ref, ...restProps, children: displayText || valueString }))), (variant === 'text-map' || variant === 'map') && (_jsx(LocationView, { location:
|
|
25
|
+
(name === 'google' ? (_jsx(Link, { ref: ref, ...restProps, target: '_blank', rel: 'noopener noreferrer', href: `https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(typeof value === 'string' ? value : `${value?.latitude}, ${value?.longitude}`)}`, children: displayText || valueString })) : (_jsx(Text, { ref: ref, ...restProps, children: displayText || valueString }))), (variant === 'text-map' || variant === 'map') && (_jsx(LocationView, { pins: location ? [location] : [], centerMapOnChange: true, height: height, zoomLevel: zoomLevel, loading: loading }))] }));
|
|
13
26
|
});
|
|
14
27
|
export default LocationDisplay;
|
|
15
28
|
//# sourceMappingURL=LocationDisplay.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocationDisplay.js","sourceRoot":"","sources":["../../../src/components/Location/LocationDisplay.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"LocationDisplay.js","sourceRoot":"","sources":["../../../src/components/Location/LocationDisplay.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGpE,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,MAAM,SAAS,CAAC;AAE3B,OAAO,OAAO,MAAM,oBAAoB,CAAC;AAEzC,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAE1C,OAAO,WAAW,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AA0BjD,MAAM,eAAe,GAA2D,UAAU,CACxF,SAAS,eAAe,CACtB,EACE,KAAK,EACL,WAAW,EACX,OAAO,GAAG,UAAU,EACpB,MAAM,GAAG,OAAO,EAChB,SAAS,GAAG,EAAE,EACd,GAAG,SAAS,EAC0B,EACxC,GAAgC;IAEhC,MAAM,EAAE,IAAI,E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KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,QAAQ,KAAK,KAAK,EAAE,SAAS,EAAE,CAC9E,EAAE,YAEF,WAAW,IAAI,WAAW,GACtB,CACR,CAAC,CAAC,CAAC,CACF,KAAC,IAAI,IAAC,GAAG,EAAE,GAA2B,KAAM,SAAS,YAClD,WAAW,IAAI,WAAW,GACtB,CACR,CAAC,EACH,CAAC,OAAO,KAAK,UAAU,IAAI,OAAO,KAAK,KAAK,CAAC,IAAI,CAChD,KAAC,YAAY,IACX,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,EAChC,iBAAiB,QACjB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,OAAO,GAChB,CACH,IACA,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import { forwardRef, useContext, useEffect, useState } from 'react';\nimport type { FunctionComponent, PropsWithoutRef, Ref } from 'react';\n\nimport Text from '../Text';\nimport Link from '../Link';\nimport type { BaseProps, ForwardProps } from '../../types';\nimport NoValue from '../NoValue/NoValue';\n\nimport LocationView from './LocationView';\nimport type { LocationViewProps } from './LocationView';\nimport MapsContext from './MapsContext';\nimport type { LatLng } from './Location.types';\nimport { getCoords, loadMapsAPI } from './utils';\n\nexport interface LocationDisplayProps extends BaseProps {\n /** Location address or coordinates */\n value?: string | 'current' | LatLng;\n /** The text to be displayed. */\n displayText?: string;\n /**\n * Controls styling of the field.\n * @default 'text-map'\n */\n variant?: 'text-map' | 'text' | 'map';\n /**\n * Height of the map container.\n * @default '25rem'\n */\n height?: LocationViewProps['height'];\n /**\n * How much the map should zoom.\n * @default 13\n */\n zoomLevel?: LocationViewProps['zoomLevel'];\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLAnchorElement | HTMLSpanElement>;\n}\n\nconst LocationDisplay: FunctionComponent<LocationDisplayProps & ForwardProps> = forwardRef(\n function LocationDisplay(\n {\n value,\n displayText,\n variant = 'text-map',\n height = '25rem',\n zoomLevel = 13,\n ...restProps\n }: PropsWithoutRef<LocationDisplayProps>,\n ref: LocationDisplayProps['ref']\n ) {\n const { name, ...providerOpts } = useContext(MapsContext);\n const [location, setLocation] = useState<LatLng>();\n const [loading, setLoading] = useState(false);\n\n const valueString =\n typeof value === 'string' ? value : `${value?.latitude}, ${value?.longitude}`;\n\n useEffect(() => {\n if (['text-map', 'map'].includes(variant) && value) {\n (async () => {\n setLoading(true);\n await loadMapsAPI(name, providerOpts);\n setLocation(await getCoords(value));\n setLoading(false);\n })();\n }\n }, [variant, value]);\n\n return !value ? (\n <Text ref={ref as Ref<HTMLSpanElement>} {...restProps} aria-hidden='true'>\n <NoValue />\n </Text>\n ) : (\n <>\n {(variant === 'text' || variant === 'text-map') &&\n (name === 'google' ? (\n <Link\n ref={ref as Ref<HTMLAnchorElement>}\n {...restProps}\n target='_blank'\n rel='noopener noreferrer'\n href={`https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(\n typeof value === 'string' ? value : `${value?.latitude}, ${value?.longitude}`\n )}`}\n >\n {displayText || valueString}\n </Link>\n ) : (\n <Text ref={ref as Ref<HTMLSpanElement>} {...restProps}>\n {displayText || valueString}\n </Text>\n ))}\n {(variant === 'text-map' || variant === 'map') && (\n <LocationView\n pins={location ? [location] : []}\n centerMapOnChange\n height={height}\n zoomLevel={zoomLevel}\n loading={loading}\n />\n )}\n </>\n );\n }\n);\n\nexport default LocationDisplay;\n"]}
|