@squiz/resource-browser 2.4.12 → 3.0.1-pre-alpha.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/README.md +4 -0
- package/lib/BrowseToSource/BrowseToSource.d.ts +8 -0
- package/lib/BrowseToSource/BrowseToSource.js +50 -0
- package/lib/Hooks/useAuth.js +11 -15
- package/lib/Hooks/useSelectedState.js +3 -7
- package/lib/Hooks/useSources.d.ts +2 -2
- package/lib/Hooks/useSources.js +19 -9
- package/lib/Icons/AdsClickIcon.d.ts +4 -0
- package/lib/Icons/AdsClickIcon.js +5 -0
- package/lib/Icons/ArrowDownIcon.d.ts +4 -0
- package/lib/Icons/ArrowDownIcon.js +5 -0
- package/lib/Icons/CircledLoopIcon.js +4 -11
- package/lib/MainContainer/MainContainer.d.ts +6 -4
- package/lib/MainContainer/MainContainer.js +33 -52
- package/lib/Plugin/Plugin.js +7 -14
- package/lib/ResourceBrowserContext/AuthProvider.js +9 -37
- package/lib/ResourceBrowserContext/ResourceBrowserContext.d.ts +1 -0
- package/lib/ResourceBrowserContext/ResourceBrowserContext.js +10 -39
- package/lib/ResourceBrowserInput/ResourceBrowserInput.d.ts +6 -4
- package/lib/ResourceBrowserInput/ResourceBrowserInput.js +5 -12
- package/lib/ResourceLauncher/ResourceLauncher.d.ts +8 -0
- package/lib/ResourceLauncher/ResourceLauncher.js +12 -0
- package/lib/ResourcePicker/ResourcePicker.js +20 -27
- package/lib/ResourcePicker/States/Error.js +6 -13
- package/lib/ResourcePicker/States/Loading.js +4 -11
- package/lib/ResourcePicker/States/Selected.js +12 -19
- package/lib/SourceDropdown/SourceDropdown.d.ts +2 -2
- package/lib/SourceDropdown/SourceDropdown.js +22 -48
- package/lib/SourceDropdownContainer/SourceDropdownContainer.d.ts +5 -0
- package/lib/SourceDropdownContainer/SourceDropdownContainer.js +12 -0
- package/lib/SourceList/SourceList.js +11 -16
- package/lib/index.css +102 -26
- package/lib/index.d.ts +4 -1
- package/lib/index.js +40 -66
- package/lib/types.d.ts +35 -3
- package/lib/types.js +5 -2
- package/lib/utils/authUtils.js +9 -16
- package/lib-esm/BrowseToSource/BrowseToSource.d.ts +8 -0
- package/lib-esm/BrowseToSource/BrowseToSource.js +50 -0
- package/lib-esm/Hooks/useAuth.d.ts +7 -0
- package/lib-esm/Hooks/useAuth.js +54 -0
- package/lib-esm/Hooks/useSelectedState.d.ts +15 -0
- package/lib-esm/Hooks/useSelectedState.js +12 -0
- package/lib-esm/Hooks/useSources.d.ts +14 -0
- package/lib-esm/Hooks/useSources.js +44 -0
- package/lib-esm/Icons/AdsClickIcon.d.ts +4 -0
- package/lib-esm/Icons/AdsClickIcon.js +5 -0
- package/lib-esm/Icons/ArrowDownIcon.d.ts +4 -0
- package/lib-esm/Icons/ArrowDownIcon.js +5 -0
- package/lib-esm/Icons/CircledLoopIcon.d.ts +4 -0
- package/lib-esm/Icons/CircledLoopIcon.js +5 -0
- package/lib-esm/MainContainer/MainContainer.d.ts +19 -0
- package/lib-esm/MainContainer/MainContainer.js +43 -0
- package/lib-esm/Plugin/Plugin.d.ts +13 -0
- package/lib-esm/Plugin/Plugin.js +12 -0
- package/lib-esm/ResourceBrowserContext/AuthProvider.d.ts +16 -0
- package/lib-esm/ResourceBrowserContext/AuthProvider.js +18 -0
- package/lib-esm/ResourceBrowserContext/ResourceBrowserContext.d.ts +15 -0
- package/lib-esm/ResourceBrowserContext/ResourceBrowserContext.js +26 -0
- package/lib-esm/ResourceBrowserInput/ResourceBrowserInput.d.ts +26 -0
- package/lib-esm/ResourceBrowserInput/ResourceBrowserInput.js +9 -0
- package/lib-esm/ResourceLauncher/ResourceLauncher.d.ts +8 -0
- package/lib-esm/ResourceLauncher/ResourceLauncher.js +12 -0
- package/lib-esm/ResourcePicker/ResourcePicker.d.ts +16 -0
- package/lib-esm/ResourcePicker/ResourcePicker.js +25 -0
- package/lib-esm/ResourcePicker/States/Error.d.ts +7 -0
- package/lib-esm/ResourcePicker/States/Error.js +6 -0
- package/lib-esm/ResourcePicker/States/Loading.d.ts +2 -0
- package/lib-esm/ResourcePicker/States/Loading.js +4 -0
- package/lib-esm/ResourcePicker/States/Selected.d.ts +15 -0
- package/lib-esm/ResourcePicker/States/Selected.js +20 -0
- package/lib-esm/SourceDropdown/SourceDropdown.d.ts +7 -0
- package/lib-esm/SourceDropdown/SourceDropdown.js +46 -0
- package/lib-esm/SourceDropdownContainer/SourceDropdownContainer.d.ts +5 -0
- package/lib-esm/SourceDropdownContainer/SourceDropdownContainer.js +12 -0
- package/lib-esm/SourceList/SourceList.d.ts +8 -0
- package/lib-esm/SourceList/SourceList.js +16 -0
- package/lib-esm/index.d.ts +18 -0
- package/lib-esm/index.js +79 -0
- package/lib-esm/types.d.ts +97 -0
- package/lib-esm/types.js +5 -0
- package/lib-esm/utils/authUtils.d.ts +5 -0
- package/lib-esm/utils/authUtils.js +31 -0
- package/package.json +18 -6
- package/src/BrowseToSource/BrowseToSource.spec.tsx +111 -0
- package/src/BrowseToSource/BrowseToSource.stories.tsx +29 -0
- package/src/BrowseToSource/BrowseToSource.tsx +111 -0
- package/src/Hooks/useSources.spec.ts +8 -4
- package/src/Hooks/useSources.ts +28 -13
- package/src/Icons/AdsClickIcon.tsx +11 -0
- package/src/Icons/ArrowDownIcon.tsx +11 -0
- package/src/MainContainer/MainContainer.spec.tsx +322 -108
- package/src/MainContainer/MainContainer.tsx +67 -27
- package/src/Plugin/Plugin.spec.tsx +2 -0
- package/src/ResourceBrowserContext/ResourceBrowserContext.spec.tsx +3 -0
- package/src/ResourceBrowserContext/ResourceBrowserContext.tsx +2 -0
- package/src/ResourceBrowserInput/ResourceBrowserInput.spec.tsx +7 -0
- package/src/ResourceBrowserInput/ResourceBrowserInput.tsx +16 -3
- package/src/ResourceLauncher/ResourceLauncher.spec.tsx +65 -0
- package/src/ResourceLauncher/ResourceLauncher.tsx +35 -0
- package/src/SourceDropdown/SourceDropdown.stories.tsx +1 -2
- package/src/SourceDropdown/SourceDropdown.tsx +8 -8
- package/src/SourceDropdownContainer/SourceDropdownContainer.spec.tsx +50 -0
- package/src/SourceDropdownContainer/SourceDropdownContainer.stories.tsx +62 -0
- package/src/SourceDropdownContainer/SourceDropdownContainer.tsx +27 -0
- package/src/__mocks__/MockModels.ts +16 -2
- package/src/__mocks__/PluginExample.tsx +8 -0
- package/src/__mocks__/StorybookHelpers.tsx +37 -1
- package/src/__mocks__/renderWithContext.tsx +1 -0
- package/src/index.spec.tsx +135 -41
- package/src/index.stories.tsx +12 -1
- package/src/index.tsx +45 -16
- package/src/types.ts +43 -3
- package/.eslintrc +0 -40
- package/.storybook/main.ts +0 -23
- package/.storybook/preview-body.html +0 -1
- package/.storybook/preview-head.html +0 -12
- package/.storybook/preview.ts +0 -16
- package/CHANGELOG.md +0 -244
- package/LICENSE.md +0 -15
- package/build.js +0 -21
- package/jest.config.ts +0 -30
- package/postcss.config.js +0 -21
- package/tailwind.config.cjs +0 -98
- package/tsconfig.json +0 -22
- package/tsconfig.storybook.json +0 -4
- package/tsconfig.test.json +0 -12
- package/vite.config.js +0 -20
@@ -0,0 +1,12 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { PluginLaunchModeType } from '../types';
|
3
|
+
function ResourceLauncher({ sources, onSourceSelect }) {
|
4
|
+
return (React.createElement("div", { className: "overflow-y-scroll w-screen max-w-[400px] min-h-[290px] flex-1 grow-[3] border-r border-gray-300 bg-gray-100 pl-6 pr-6 pb-6 pt-4" },
|
5
|
+
React.createElement("ul", { tabIndex: -1, "aria-label": `sources list`, className: "flex flex-col bg-gray-100 min-h-full focus-visible:outline-0" }, sources.map((source, index) => {
|
6
|
+
const SourceLauncher = source.plugin.renderResourceLauncher();
|
7
|
+
return (React.createElement("li", { key: index, className: "flex items-stretch relative" },
|
8
|
+
React.createElement("div", { className: `squiz-rb-plugin squiz-rb-plugin--${source.plugin?.type} w-full` },
|
9
|
+
React.createElement(SourceLauncher, { source: source, onSearch: (query) => onSourceSelect(source, { type: PluginLaunchModeType.Search, args: { query } }), onBrowse: (browseTo) => onSourceSelect(source, { type: PluginLaunchModeType.Browse, args: { browseTo } }) }))));
|
10
|
+
}))));
|
11
|
+
}
|
12
|
+
export default ResourceLauncher;
|
@@ -1,32 +1,25 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
const
|
12
|
-
const
|
13
|
-
const Loading_1 = require("./States/Loading");
|
14
|
-
const Selected_1 = require("./States/Selected");
|
15
|
-
const useSelectedState_1 = require("../Hooks/useSelectedState");
|
16
|
-
const clsx_1 = __importDefault(require("clsx"));
|
17
|
-
const ResourcePicker = ({ resource, plugin, allowedTypes, error: externalError, isLoading: isExternalLoading, isDisabled, children, onClear, isModalOpen, onModalStateChange, }) => {
|
18
|
-
const { data: selectedState, error, isLoading } = (0, useSelectedState_1.useSelectedState)({ resource, plugin });
|
1
|
+
import React from 'react';
|
2
|
+
import AdsClickRoundedIcon from '@mui/icons-material/AdsClickRounded';
|
3
|
+
import AddCircleOutlineRoundedIcon from '@mui/icons-material/AddCircleOutlineRounded';
|
4
|
+
import PhotoLibraryRoundedIcon from '@mui/icons-material/PhotoLibraryRounded';
|
5
|
+
import { ModalTrigger } from '@squiz/resource-browser-ui-lib';
|
6
|
+
import { ErrorState } from './States/Error';
|
7
|
+
import { LoadingState } from './States/Loading';
|
8
|
+
import { SelectedState } from './States/Selected';
|
9
|
+
import { useSelectedState } from '../Hooks/useSelectedState';
|
10
|
+
import clsx from 'clsx';
|
11
|
+
export const ResourcePicker = ({ resource, plugin, allowedTypes, error: externalError, isLoading: isExternalLoading, isDisabled, children, onClear, isModalOpen, onModalStateChange, }) => {
|
12
|
+
const { data: selectedState, error, isLoading } = useSelectedState({ resource, plugin });
|
19
13
|
const isImagePicker = allowedTypes && allowedTypes.length === 1 && allowedTypes.includes('image');
|
20
14
|
const isEmpty = resource === null && !isExternalLoading && !externalError;
|
21
|
-
return (
|
22
|
-
isImagePicker ? (
|
23
|
-
isEmpty ? (
|
15
|
+
return (React.createElement("div", { className: clsx('resource-picker', isDisabled && 'resource-picker--disabled') },
|
16
|
+
isImagePicker ? (React.createElement(PhotoLibraryRoundedIcon, { "aria-hidden": true, className: "w-6 h-6" })) : (React.createElement(AdsClickRoundedIcon, { "aria-hidden": true, className: "w-6 h-6" })),
|
17
|
+
isEmpty ? (React.createElement(ModalTrigger, { overlayTriggerState: {
|
24
18
|
isOpen: isModalOpen,
|
25
19
|
onOpenChange: onModalStateChange,
|
26
|
-
}, showLabel: true, label: isImagePicker ? `Choose image` : `Choose asset`, icon:
|
27
|
-
|
28
|
-
(isExternalLoading || isLoading) &&
|
29
|
-
(externalError || error) && (
|
30
|
-
!isExternalLoading && resource && selectedState && (
|
20
|
+
}, showLabel: true, label: isImagePicker ? `Choose image` : `Choose asset`, icon: React.createElement(AddCircleOutlineRoundedIcon, { "aria-hidden": true, className: `!w-4 !h-4 text-blue-300 ${isDisabled ? 'text-gray-600' : ''}` }), isDisabled: isDisabled, scope: "squiz-rb-scope" }, children)) : (React.createElement("div", { className: "resource-picker-info" },
|
21
|
+
React.createElement("div", { className: "resource-picker-info__layout" },
|
22
|
+
(isExternalLoading || isLoading) && React.createElement(LoadingState, null),
|
23
|
+
(externalError || error) && (React.createElement(ErrorState, { error: externalError || error, isDisabled: isDisabled, onClear: onClear })),
|
24
|
+
!isExternalLoading && resource && selectedState && (React.createElement(SelectedState, { isModalOpen: isModalOpen, onModalStateChange: onModalStateChange, resource: resource, showThumbnail: selectedState?.showThumbnail || false, icon: selectedState?.icon, label: selectedState?.label, description: selectedState?.description, isDisabled: isDisabled, onClear: onClear, resourcePickerContainer: children })))))));
|
31
25
|
};
|
32
|
-
exports.ResourcePicker = ResourcePicker;
|
@@ -1,13 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
}
|
5
|
-
|
6
|
-
|
7
|
-
const react_1 = __importDefault(require("react"));
|
8
|
-
const generic_browser_lib_1 = require("@squiz/generic-browser-lib");
|
9
|
-
const ErrorState = ({ error, isDisabled, onClear }) => (react_1.default.createElement(react_1.default.Fragment, null,
|
10
|
-
react_1.default.createElement(generic_browser_lib_1.Icon, { icon: 'error', "aria-hidden": true, className: "w-6 h-6 text-red-300" }),
|
11
|
-
react_1.default.createElement("div", { className: "text-red-300 w-full" }, error.message),
|
12
|
-
react_1.default.createElement(generic_browser_lib_1.ResetButton, { isDisabled: isDisabled, onClick: onClear })));
|
13
|
-
exports.ErrorState = ErrorState;
|
1
|
+
import React from 'react';
|
2
|
+
import { Icon, ResetButton } from '@squiz/generic-browser-lib';
|
3
|
+
export const ErrorState = ({ error, isDisabled, onClear }) => (React.createElement(React.Fragment, null,
|
4
|
+
React.createElement(Icon, { icon: 'error', "aria-hidden": true, className: "w-6 h-6 text-red-300" }),
|
5
|
+
React.createElement("div", { className: "text-red-300 w-full" }, error.message),
|
6
|
+
React.createElement(ResetButton, { isDisabled: isDisabled, onClick: onClear })));
|
@@ -1,11 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.LoadingState = void 0;
|
7
|
-
const react_1 = __importDefault(require("react"));
|
8
|
-
const generic_browser_lib_1 = require("@squiz/generic-browser-lib");
|
9
|
-
const LoadingState = () => (react_1.default.createElement("div", { className: "col-start-2 col-end-2" },
|
10
|
-
react_1.default.createElement(generic_browser_lib_1.Spinner, { label: "Loading selection", className: "m-2" })));
|
11
|
-
exports.LoadingState = LoadingState;
|
1
|
+
import React from 'react';
|
2
|
+
import { Spinner } from '@squiz/generic-browser-lib';
|
3
|
+
export const LoadingState = () => (React.createElement("div", { className: "col-start-2 col-end-2" },
|
4
|
+
React.createElement(Spinner, { label: "Loading selection", className: "m-2" })));
|
@@ -1,27 +1,20 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
};
|
5
|
-
|
6
|
-
exports.SelectedState = void 0;
|
7
|
-
const react_1 = __importDefault(require("react"));
|
8
|
-
const generic_browser_lib_1 = require("@squiz/generic-browser-lib");
|
9
|
-
const resource_browser_ui_lib_1 = require("@squiz/resource-browser-ui-lib");
|
10
|
-
const CircledLoopIcon_1 = require("../../Icons/CircledLoopIcon");
|
11
|
-
const SelectedState = ({ resource, showThumbnail, icon, label, description, isDisabled, onClear, resourcePickerContainer, isModalOpen, onModalStateChange, }) => {
|
1
|
+
import React from 'react';
|
2
|
+
import { ResetButton } from '@squiz/generic-browser-lib';
|
3
|
+
import { ModalTrigger } from '@squiz/resource-browser-ui-lib';
|
4
|
+
import { CircledLoopIcon } from '../../Icons/CircledLoopIcon';
|
5
|
+
export const SelectedState = ({ resource, showThumbnail, icon, label, description, isDisabled, onClear, resourcePickerContainer, isModalOpen, onModalStateChange, }) => {
|
12
6
|
const modalController = {
|
13
7
|
isOpen: isModalOpen,
|
14
8
|
onOpenChange: onModalStateChange,
|
15
9
|
};
|
16
|
-
const replaceAsset = (
|
17
|
-
return (
|
18
|
-
showThumbnail && resource.squizImage ? (
|
19
|
-
|
20
|
-
|
10
|
+
const replaceAsset = (React.createElement(ModalTrigger, { overlayTriggerState: isModalOpen && onModalStateChange ? modalController : undefined, showLabel: false, label: "Replace selection", containerClasses: "text-gray-500 hover:text-gray-800 focus:text-gray-800 disabled:text-gray-500 disabled:cursor-not-allowed", icon: React.createElement(CircledLoopIcon, { "aria-hidden": true, className: "m-1" }), isDisabled: isDisabled, scope: "squiz-rb-scope" }, resourcePickerContainer));
|
11
|
+
return (React.createElement(React.Fragment, null,
|
12
|
+
showThumbnail && resource.squizImage ? (React.createElement("div", { className: "checkered-bg w-[56px] h-[56px] overflow-hidden flex justify-center items-center rounded" },
|
13
|
+
React.createElement("img", { src: resource.squizImage.imageVariations.original.url || resource.url, className: "w-full h-full object-cover object-center", alt: resource.squizImage.name || resource.name }))) : (React.createElement("div", { className: "w-4 h-4 mt-1 flex self-start overflow-hidden" }, icon)),
|
14
|
+
React.createElement("div", { className: "justify-self-start self-center w-full overflow-hidden break-words" },
|
21
15
|
label,
|
22
16
|
description),
|
23
|
-
|
17
|
+
React.createElement("div", { className: "flex" },
|
24
18
|
replaceAsset,
|
25
|
-
|
19
|
+
React.createElement(ResetButton, { isDisabled: isDisabled, onClick: onClear }))));
|
26
20
|
};
|
27
|
-
exports.SelectedState = SelectedState;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import { ResourceBrowserSource } from '../types';
|
2
|
+
import { ResourceBrowserSource, PluginLaunchMode } from '../types';
|
3
3
|
export default function SourceDropdown({ sources, selectedSource, onSourceSelect, }: {
|
4
4
|
sources: ResourceBrowserSource[];
|
5
5
|
selectedSource: ResourceBrowserSource;
|
6
|
-
onSourceSelect(source: ResourceBrowserSource): void;
|
6
|
+
onSourceSelect(source: ResourceBrowserSource, mode?: PluginLaunchMode): void;
|
7
7
|
}): React.JSX.Element;
|
@@ -1,43 +1,19 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
}) : (function(o, m, k, k2) {
|
10
|
-
if (k2 === undefined) k2 = k;
|
11
|
-
o[k2] = m[k];
|
12
|
-
}));
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
-
}) : function(o, v) {
|
16
|
-
o["default"] = v;
|
17
|
-
});
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
-
if (mod && mod.__esModule) return mod;
|
20
|
-
var result = {};
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
-
__setModuleDefault(result, mod);
|
23
|
-
return result;
|
24
|
-
};
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
26
|
-
const react_1 = __importStar(require("react"));
|
27
|
-
const generic_browser_lib_1 = require("@squiz/generic-browser-lib");
|
28
|
-
const react_aria_1 = require("react-aria");
|
29
|
-
function SourceDropdown({ sources, selectedSource, onSourceSelect, }) {
|
30
|
-
const [uniqueId] = (0, react_1.useState)((0, generic_browser_lib_1.uuid)());
|
31
|
-
const buttonRef = (0, react_1.useRef)(null);
|
32
|
-
const [isOpen, setIsOpen] = (0, react_1.useState)(false);
|
1
|
+
import React, { useRef, useState } from 'react';
|
2
|
+
import { Icon, uuid } from '@squiz/generic-browser-lib';
|
3
|
+
import { useFocusWithin, useKeyboard } from 'react-aria';
|
4
|
+
import { ArrowDownIcon } from '../Icons/ArrowDownIcon';
|
5
|
+
export default function SourceDropdown({ sources, selectedSource, onSourceSelect, }) {
|
6
|
+
const [uniqueId] = useState(uuid());
|
7
|
+
const buttonRef = useRef(null);
|
8
|
+
const [isOpen, setIsOpen] = useState(false);
|
33
9
|
// Watch the focus and blur on the menu and close if focus leaves the control
|
34
|
-
const { focusWithinProps } =
|
10
|
+
const { focusWithinProps } = useFocusWithin({
|
35
11
|
onBlurWithin: () => {
|
36
12
|
setIsOpen(false);
|
37
13
|
},
|
38
14
|
});
|
39
15
|
// Listen for Esc key within this element
|
40
|
-
const { keyboardProps } =
|
16
|
+
const { keyboardProps } = useKeyboard({
|
41
17
|
onKeyDown: (e) => {
|
42
18
|
if (isOpen && e.key === 'Escape') {
|
43
19
|
setIsOpen(false);
|
@@ -51,22 +27,20 @@ function SourceDropdown({ sources, selectedSource, onSourceSelect, }) {
|
|
51
27
|
onSourceSelect(source);
|
52
28
|
};
|
53
29
|
if (!sources.length) {
|
54
|
-
return
|
30
|
+
return React.createElement(React.Fragment, null);
|
55
31
|
}
|
56
|
-
return (
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
react_1.default.createElement("ul", { id: `${uniqueId}-button-menu`, "aria-hidden": !isOpen, className: `absolute z-50 top-[calc(100%+5px)] -left-0.5 w-[calc(100%+4px)] bg-gray-100 border-1 shadow-md rounded border-gray-300 p-2 pb-0 overflow-y-scroll max-h-80 ${!isOpen ? 'hidden' : ''}` }, sources.map((source) => {
|
32
|
+
return (React.createElement("div", { ...focusWithinProps, ...keyboardProps, className: "relative w-full " },
|
33
|
+
React.createElement("button", { ref: buttonRef, type: "button", "aria-label": "Source quick select", "aria-expanded": isOpen, "aria-controls": `${uniqueId}-button-menu`, onClick: () => setIsOpen(!isOpen), className: "relative flex items-center p-2 w-full rounded bg-blue-100 hover:bg-blue-150" },
|
34
|
+
React.createElement("span", { className: "sr-only" }, "current source "),
|
35
|
+
React.createElement("div", { className: "truncate max-w-[200px] text-md font-semibold text-blue-400" }, selectedSource.name),
|
36
|
+
React.createElement(ArrowDownIcon, { "aria-hidden": true, className: "absolute right-2 fill-blue-300" })),
|
37
|
+
React.createElement("ul", { id: `${uniqueId}-button-menu`, "aria-hidden": !isOpen, className: `absolute z-50 top-[calc(100%+8px)] w-[100%] bg-gray-100 border-1 shadow-md rounded border-gray-300 p-2 pb-0 overflow-y-scroll max-h-80 ${!isOpen ? 'hidden' : ''}` }, sources.map((source) => {
|
63
38
|
const { id, name, type } = source;
|
64
39
|
const isSelectedSource = id === selectedSource.id;
|
65
|
-
return (
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
isSelectedSource && (
|
40
|
+
return (React.createElement("li", { key: id, className: "flex items-center text-sm font-semibold mb-2 bg-white rounded" },
|
41
|
+
React.createElement("button", { type: "button", onClick: () => handleSourceClick(source), className: `relative grow flex items-center p-2 border-1 border-white rounded hover:bg-gray-50 hover:border-gray-300 focus:bg-gray-100` },
|
42
|
+
React.createElement(Icon, { icon: type, "aria-label": type, className: "shrink-0 mr-2.5" }),
|
43
|
+
React.createElement("span", { className: "text-left mr-7" }, name),
|
44
|
+
isSelectedSource && (React.createElement(Icon, { icon: 'selected', "aria-label": "selected", className: "absolute right-4" })))));
|
70
45
|
}))));
|
71
46
|
}
|
72
|
-
exports.default = SourceDropdown;
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { AdsClickIcon } from '../Icons/AdsClickIcon';
|
3
|
+
export default function SourceDropdownContainer({ children, isCollapsed, onExpand, }) {
|
4
|
+
return (React.createElement("div", { className: "inline-flex rounded-lg p-1 bg-blue-100 min-h-[44px]" },
|
5
|
+
isCollapsed && (React.createElement("button", { "aria-label": "Expand browse options", onClick: onExpand, className: "flex items-center" },
|
6
|
+
React.createElement(AdsClickIcon, { "aria-hidden": true, className: "mx-2 fill-blue-300" }))),
|
7
|
+
!isCollapsed && (React.createElement(React.Fragment, null,
|
8
|
+
React.createElement("div", { className: "flex items-center pr-1" },
|
9
|
+
React.createElement(AdsClickIcon, { "aria-hidden": true, className: "mx-2 fill-blue-300" }),
|
10
|
+
React.createElement("span", { className: "sr-only" }, "Browse")),
|
11
|
+
children))));
|
12
|
+
}
|
@@ -1,21 +1,16 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
const react_1 = __importDefault(require("react"));
|
7
|
-
const generic_browser_lib_1 = require("@squiz/generic-browser-lib");
|
1
|
+
import React from 'react';
|
2
|
+
import { Icon } from '@squiz/generic-browser-lib';
|
8
3
|
function SourceList({ sources, onSourceSelect }) {
|
9
|
-
return (
|
10
|
-
|
11
|
-
|
12
|
-
return (
|
13
|
-
|
4
|
+
return (React.createElement("div", { className: "overflow-y-scroll w-screen max-w-[400px] flex-1 grow-[3] border-r border-gray-300 bg-gray-100 pl-4.5 pr-4.5 pb-4.5 pt-3" },
|
5
|
+
React.createElement("div", { className: "text-md font-semibold" }, "Select an environment to use"),
|
6
|
+
React.createElement("ul", { tabIndex: -1, "aria-label": `environment list`, className: "flex flex-col bg-gray-100 min-h-full focus-visible:outline-0" }, sources.map((source, index) => {
|
7
|
+
return (React.createElement("li", { key: index, className: "flex items-stretch relative" },
|
8
|
+
React.createElement("button", { onClick: () => {
|
14
9
|
onSourceSelect(source);
|
15
10
|
}, className: "w-full p-1 mt-3 bg-white border-1 border-grey-200 min-h-[64px] rounded-lg flex items-center text-md font-semibold" },
|
16
|
-
|
17
|
-
|
18
|
-
|
11
|
+
React.createElement(Icon, { icon: source.type, className: "ml-4" }),
|
12
|
+
React.createElement("span", { className: "line-clamp-2 text-left break-word ml-4" }, source.name || source.id),
|
13
|
+
React.createElement(Icon, { icon: 'arrow-right', className: "absolute ml-1 right-4" }))));
|
19
14
|
}))));
|
20
15
|
}
|
21
|
-
|
16
|
+
export default SourceList;
|
package/lib/index.css
CHANGED
@@ -366,18 +366,15 @@
|
|
366
366
|
.squiz-rb-scope .inset-0:not(.squiz-rb-plugin *) {
|
367
367
|
inset: 0px;
|
368
368
|
}
|
369
|
-
.squiz-rb-scope .-left-0:not(.squiz-rb-plugin *) {
|
370
|
-
left: -0px;
|
371
|
-
}
|
372
|
-
.squiz-rb-scope .-left-0\.5:not(.squiz-rb-plugin *) {
|
373
|
-
left: -0.125rem;
|
374
|
-
}
|
375
369
|
.squiz-rb-scope .-right-8:not(.squiz-rb-plugin *) {
|
376
370
|
right: -2rem;
|
377
371
|
}
|
378
372
|
.squiz-rb-scope .bottom-0:not(.squiz-rb-plugin *) {
|
379
373
|
bottom: 0px;
|
380
374
|
}
|
375
|
+
.squiz-rb-scope .left-1:not(.squiz-rb-plugin *) {
|
376
|
+
left: 0.25rem;
|
377
|
+
}
|
381
378
|
.squiz-rb-scope .right-2:not(.squiz-rb-plugin *) {
|
382
379
|
right: 0.5rem;
|
383
380
|
}
|
@@ -396,8 +393,8 @@
|
|
396
393
|
.squiz-rb-scope .top-3:not(.squiz-rb-plugin *) {
|
397
394
|
top: 0.75rem;
|
398
395
|
}
|
399
|
-
.squiz-rb-scope .top-\[calc\(100\%\+
|
400
|
-
top: calc(100% +
|
396
|
+
.squiz-rb-scope .top-\[calc\(100\%\+8px\)\]:not(.squiz-rb-plugin *) {
|
397
|
+
top: calc(100% + 8px);
|
401
398
|
}
|
402
399
|
.squiz-rb-scope .z-50:not(.squiz-rb-plugin *) {
|
403
400
|
z-index: 50;
|
@@ -426,6 +423,10 @@
|
|
426
423
|
.squiz-rb-scope .m-5:not(.squiz-rb-plugin *) {
|
427
424
|
margin: 1.25rem;
|
428
425
|
}
|
426
|
+
.squiz-rb-scope .mx-2:not(.squiz-rb-plugin *) {
|
427
|
+
margin-left: 0.5rem;
|
428
|
+
margin-right: 0.5rem;
|
429
|
+
}
|
429
430
|
.squiz-rb-scope .mx-20:not(.squiz-rb-plugin *) {
|
430
431
|
margin-left: 5rem;
|
431
432
|
margin-right: 5rem;
|
@@ -454,6 +455,9 @@
|
|
454
455
|
.squiz-rb-scope .ml-4:not(.squiz-rb-plugin *) {
|
455
456
|
margin-left: 1rem;
|
456
457
|
}
|
458
|
+
.squiz-rb-scope .ml-\[6px\]:not(.squiz-rb-plugin *) {
|
459
|
+
margin-left: 6px;
|
460
|
+
}
|
457
461
|
.squiz-rb-scope .ml-auto:not(.squiz-rb-plugin *) {
|
458
462
|
margin-left: auto;
|
459
463
|
}
|
@@ -463,6 +467,9 @@
|
|
463
467
|
.squiz-rb-scope .mr-2\.5:not(.squiz-rb-plugin *) {
|
464
468
|
margin-right: 0.625rem;
|
465
469
|
}
|
470
|
+
.squiz-rb-scope .mr-3:not(.squiz-rb-plugin *) {
|
471
|
+
margin-right: 0.75rem;
|
472
|
+
}
|
466
473
|
.squiz-rb-scope .mr-4:not(.squiz-rb-plugin *) {
|
467
474
|
margin-right: 1rem;
|
468
475
|
}
|
@@ -475,6 +482,9 @@
|
|
475
482
|
.squiz-rb-scope .mr-8:not(.squiz-rb-plugin *) {
|
476
483
|
margin-right: 2rem;
|
477
484
|
}
|
485
|
+
.squiz-rb-scope .mr-\[6px\]:not(.squiz-rb-plugin *) {
|
486
|
+
margin-right: 6px;
|
487
|
+
}
|
478
488
|
.squiz-rb-scope .mr-auto:not(.squiz-rb-plugin *) {
|
479
489
|
margin-right: auto;
|
480
490
|
}
|
@@ -505,6 +515,9 @@
|
|
505
515
|
.squiz-rb-scope .flex:not(.squiz-rb-plugin *) {
|
506
516
|
display: flex;
|
507
517
|
}
|
518
|
+
.squiz-rb-scope .inline-flex:not(.squiz-rb-plugin *) {
|
519
|
+
display: inline-flex;
|
520
|
+
}
|
508
521
|
.squiz-rb-scope .grid:not(.squiz-rb-plugin *) {
|
509
522
|
display: grid;
|
510
523
|
}
|
@@ -532,8 +545,8 @@
|
|
532
545
|
.squiz-rb-scope .h-9:not(.squiz-rb-plugin *) {
|
533
546
|
height: 2.25rem;
|
534
547
|
}
|
535
|
-
.squiz-rb-scope .h-\[
|
536
|
-
height:
|
548
|
+
.squiz-rb-scope .h-\[36px\]:not(.squiz-rb-plugin *) {
|
549
|
+
height: 36px;
|
537
550
|
}
|
538
551
|
.squiz-rb-scope .h-\[50vh\]:not(.squiz-rb-plugin *) {
|
539
552
|
height: 50vh;
|
@@ -550,9 +563,18 @@
|
|
550
563
|
.squiz-rb-scope .max-h-80:not(.squiz-rb-plugin *) {
|
551
564
|
max-height: 20rem;
|
552
565
|
}
|
566
|
+
.squiz-rb-scope .min-h-\[290px\]:not(.squiz-rb-plugin *) {
|
567
|
+
min-height: 290px;
|
568
|
+
}
|
569
|
+
.squiz-rb-scope .min-h-\[44px\]:not(.squiz-rb-plugin *) {
|
570
|
+
min-height: 44px;
|
571
|
+
}
|
553
572
|
.squiz-rb-scope .min-h-\[64px\]:not(.squiz-rb-plugin *) {
|
554
573
|
min-height: 64px;
|
555
574
|
}
|
575
|
+
.squiz-rb-scope .min-h-\[68px\]:not(.squiz-rb-plugin *) {
|
576
|
+
min-height: 68px;
|
577
|
+
}
|
556
578
|
.squiz-rb-scope .min-h-full:not(.squiz-rb-plugin *) {
|
557
579
|
min-height: 100%;
|
558
580
|
}
|
@@ -580,11 +602,17 @@
|
|
580
602
|
.squiz-rb-scope .w-6:not(.squiz-rb-plugin *) {
|
581
603
|
width: 1.5rem;
|
582
604
|
}
|
583
|
-
.squiz-rb-scope .w
|
584
|
-
width:
|
605
|
+
.squiz-rb-scope .w-\[100\%\]:not(.squiz-rb-plugin *) {
|
606
|
+
width: 100%;
|
585
607
|
}
|
586
|
-
.squiz-rb-scope .w-\[
|
587
|
-
width:
|
608
|
+
.squiz-rb-scope .w-\[200px\]:not(.squiz-rb-plugin *) {
|
609
|
+
width: 200px;
|
610
|
+
}
|
611
|
+
.squiz-rb-scope .w-\[204px\]:not(.squiz-rb-plugin *) {
|
612
|
+
width: 204px;
|
613
|
+
}
|
614
|
+
.squiz-rb-scope .w-\[350px\]:not(.squiz-rb-plugin *) {
|
615
|
+
width: 350px;
|
588
616
|
}
|
589
617
|
.squiz-rb-scope .w-\[400px\]:not(.squiz-rb-plugin *) {
|
590
618
|
width: 400px;
|
@@ -592,8 +620,8 @@
|
|
592
620
|
.squiz-rb-scope .w-\[56px\]:not(.squiz-rb-plugin *) {
|
593
621
|
width: 56px;
|
594
622
|
}
|
595
|
-
.squiz-rb-scope .w-\[calc\(100
|
596
|
-
width: calc(100%
|
623
|
+
.squiz-rb-scope .w-\[calc\(100\%-2px\)\]:not(.squiz-rb-plugin *) {
|
624
|
+
width: calc(100% - 2px);
|
597
625
|
}
|
598
626
|
.squiz-rb-scope .w-full:not(.squiz-rb-plugin *) {
|
599
627
|
width: 100%;
|
@@ -675,6 +703,9 @@
|
|
675
703
|
.squiz-rb-scope .overflow-hidden:not(.squiz-rb-plugin *) {
|
676
704
|
overflow: hidden;
|
677
705
|
}
|
706
|
+
.squiz-rb-scope .overflow-y-auto:not(.squiz-rb-plugin *) {
|
707
|
+
overflow-y: auto;
|
708
|
+
}
|
678
709
|
.squiz-rb-scope .overflow-y-hidden:not(.squiz-rb-plugin *) {
|
679
710
|
overflow-y: hidden;
|
680
711
|
}
|
@@ -722,13 +753,25 @@
|
|
722
753
|
.squiz-rb-scope .border-solid:not(.squiz-rb-plugin *) {
|
723
754
|
border-style: solid;
|
724
755
|
}
|
756
|
+
.squiz-rb-scope .border-blue-200:not(.squiz-rb-plugin *) {
|
757
|
+
--tw-border-opacity: 1;
|
758
|
+
border-color: rgb(143 192 235 / var(--tw-border-opacity));
|
759
|
+
}
|
725
760
|
.squiz-rb-scope .border-current:not(.squiz-rb-plugin *) {
|
726
761
|
border-color: currentColor;
|
727
762
|
}
|
763
|
+
.squiz-rb-scope .border-gray-200:not(.squiz-rb-plugin *) {
|
764
|
+
--tw-border-opacity: 1;
|
765
|
+
border-color: rgb(237 237 237 / var(--tw-border-opacity));
|
766
|
+
}
|
728
767
|
.squiz-rb-scope .border-gray-300:not(.squiz-rb-plugin *) {
|
729
768
|
--tw-border-opacity: 1;
|
730
769
|
border-color: rgb(224 224 224 / var(--tw-border-opacity));
|
731
770
|
}
|
771
|
+
.squiz-rb-scope .border-gray-400:not(.squiz-rb-plugin *) {
|
772
|
+
--tw-border-opacity: 1;
|
773
|
+
border-color: rgb(186 186 186 / var(--tw-border-opacity));
|
774
|
+
}
|
732
775
|
.squiz-rb-scope .border-white:not(.squiz-rb-plugin *) {
|
733
776
|
--tw-border-opacity: 1;
|
734
777
|
border-color: rgb(255 255 255 / var(--tw-border-opacity));
|
@@ -763,6 +806,9 @@
|
|
763
806
|
.squiz-rb-scope .bg-opacity-10:not(.squiz-rb-plugin *) {
|
764
807
|
--tw-bg-opacity: 0.1;
|
765
808
|
}
|
809
|
+
.squiz-rb-scope .fill-blue-300:not(.squiz-rb-plugin *) {
|
810
|
+
fill: #0774d2;
|
811
|
+
}
|
766
812
|
.squiz-rb-scope .object-cover:not(.squiz-rb-plugin *) {
|
767
813
|
-o-object-fit: cover;
|
768
814
|
object-fit: cover;
|
@@ -771,12 +817,12 @@
|
|
771
817
|
-o-object-position: center;
|
772
818
|
object-position: center;
|
773
819
|
}
|
820
|
+
.squiz-rb-scope .p-0:not(.squiz-rb-plugin *) {
|
821
|
+
padding: 0px;
|
822
|
+
}
|
774
823
|
.squiz-rb-scope .p-1:not(.squiz-rb-plugin *) {
|
775
824
|
padding: 0.25rem;
|
776
825
|
}
|
777
|
-
.squiz-rb-scope .p-1\.5:not(.squiz-rb-plugin *) {
|
778
|
-
padding: 0.375rem;
|
779
|
-
}
|
780
826
|
.squiz-rb-scope .p-2:not(.squiz-rb-plugin *) {
|
781
827
|
padding: 0.5rem;
|
782
828
|
}
|
@@ -814,17 +860,21 @@
|
|
814
860
|
padding-left: 1.75rem;
|
815
861
|
padding-right: 1.75rem;
|
816
862
|
}
|
863
|
+
.squiz-rb-scope .py-0:not(.squiz-rb-plugin *) {
|
864
|
+
padding-top: 0px;
|
865
|
+
padding-bottom: 0px;
|
866
|
+
}
|
867
|
+
.squiz-rb-scope .py-0\.5:not(.squiz-rb-plugin *) {
|
868
|
+
padding-top: 0.125rem;
|
869
|
+
padding-bottom: 0.125rem;
|
870
|
+
}
|
817
871
|
.squiz-rb-scope .py-2:not(.squiz-rb-plugin *) {
|
818
872
|
padding-top: 0.5rem;
|
819
873
|
padding-bottom: 0.5rem;
|
820
874
|
}
|
821
|
-
.squiz-rb-scope .py-
|
822
|
-
padding-top:
|
823
|
-
padding-bottom:
|
824
|
-
}
|
825
|
-
.squiz-rb-scope .py-4\.5:not(.squiz-rb-plugin *) {
|
826
|
-
padding-top: 1.125rem;
|
827
|
-
padding-bottom: 1.125rem;
|
875
|
+
.squiz-rb-scope .py-3:not(.squiz-rb-plugin *) {
|
876
|
+
padding-top: 0.75rem;
|
877
|
+
padding-bottom: 0.75rem;
|
828
878
|
}
|
829
879
|
.squiz-rb-scope .py-8:not(.squiz-rb-plugin *) {
|
830
880
|
padding-top: 2rem;
|
@@ -839,12 +889,24 @@
|
|
839
889
|
.squiz-rb-scope .pb-4\.5:not(.squiz-rb-plugin *) {
|
840
890
|
padding-bottom: 1.125rem;
|
841
891
|
}
|
892
|
+
.squiz-rb-scope .pb-6:not(.squiz-rb-plugin *) {
|
893
|
+
padding-bottom: 1.5rem;
|
894
|
+
}
|
895
|
+
.squiz-rb-scope .pl-1:not(.squiz-rb-plugin *) {
|
896
|
+
padding-left: 0.25rem;
|
897
|
+
}
|
842
898
|
.squiz-rb-scope .pl-4:not(.squiz-rb-plugin *) {
|
843
899
|
padding-left: 1rem;
|
844
900
|
}
|
845
901
|
.squiz-rb-scope .pl-4\.5:not(.squiz-rb-plugin *) {
|
846
902
|
padding-left: 1.125rem;
|
847
903
|
}
|
904
|
+
.squiz-rb-scope .pl-6:not(.squiz-rb-plugin *) {
|
905
|
+
padding-left: 1.5rem;
|
906
|
+
}
|
907
|
+
.squiz-rb-scope .pr-1:not(.squiz-rb-plugin *) {
|
908
|
+
padding-right: 0.25rem;
|
909
|
+
}
|
848
910
|
.squiz-rb-scope .pr-10:not(.squiz-rb-plugin *) {
|
849
911
|
padding-right: 2.5rem;
|
850
912
|
}
|
@@ -854,9 +916,15 @@
|
|
854
916
|
.squiz-rb-scope .pr-4\.5:not(.squiz-rb-plugin *) {
|
855
917
|
padding-right: 1.125rem;
|
856
918
|
}
|
919
|
+
.squiz-rb-scope .pr-6:not(.squiz-rb-plugin *) {
|
920
|
+
padding-right: 1.5rem;
|
921
|
+
}
|
857
922
|
.squiz-rb-scope .pt-3:not(.squiz-rb-plugin *) {
|
858
923
|
padding-top: 0.75rem;
|
859
924
|
}
|
925
|
+
.squiz-rb-scope .pt-4:not(.squiz-rb-plugin *) {
|
926
|
+
padding-top: 1rem;
|
927
|
+
}
|
860
928
|
.squiz-rb-scope .text-left:not(.squiz-rb-plugin *) {
|
861
929
|
text-align: left;
|
862
930
|
}
|
@@ -1131,6 +1199,14 @@
|
|
1131
1199
|
--tw-bg-opacity: 1;
|
1132
1200
|
background-color: rgb(230 241 250 / var(--tw-bg-opacity));
|
1133
1201
|
}
|
1202
|
+
.squiz-rb-scope .hover\:bg-blue-150:hover:not(.squiz-rb-plugin *) {
|
1203
|
+
--tw-bg-opacity: 1;
|
1204
|
+
background-color: rgb(199 223 245 / var(--tw-bg-opacity));
|
1205
|
+
}
|
1206
|
+
.squiz-rb-scope .hover\:bg-gray-100:hover:not(.squiz-rb-plugin *) {
|
1207
|
+
--tw-bg-opacity: 1;
|
1208
|
+
background-color: rgb(245 245 245 / var(--tw-bg-opacity));
|
1209
|
+
}
|
1134
1210
|
.squiz-rb-scope .hover\:bg-gray-50:hover:not(.squiz-rb-plugin *) {
|
1135
1211
|
--tw-bg-opacity: 1;
|
1136
1212
|
background-color: rgb(247 247 247 / var(--tw-bg-opacity));
|
package/lib/index.d.ts
CHANGED
@@ -2,7 +2,10 @@ import React from 'react';
|
|
2
2
|
import { ResourceBrowserContext, ResourceBrowserContextProvider } from './ResourceBrowserContext/ResourceBrowserContext';
|
3
3
|
import { ResourceBrowserUnresolvedResource, ResourceBrowserResource } from './types';
|
4
4
|
import { AuthProvider, useAuthContext, AuthContext } from './ResourceBrowserContext/AuthProvider';
|
5
|
-
|
5
|
+
import BrowseToSource from './BrowseToSource/BrowseToSource';
|
6
|
+
import SourceDropdown from './SourceDropdown/SourceDropdown';
|
7
|
+
import SourceDropdownContainer from './SourceDropdownContainer/SourceDropdownContainer';
|
8
|
+
export { ResourceBrowserContext, ResourceBrowserContextProvider, useAuthContext, AuthProvider, AuthContext, BrowseToSource, SourceDropdown, SourceDropdownContainer, };
|
6
9
|
export * from './types';
|
7
10
|
export type ResourceBrowserProps = {
|
8
11
|
modalTitle: string;
|