@ultraviolet/plus 0.14.0 → 0.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { ReactNode, MouseEventHandler, ComponentProps } from 'react';
|
|
2
|
+
import { ReactNode, MouseEventHandler, ComponentProps, RefObject } from 'react';
|
|
3
3
|
import * as _emotion_react_jsx_runtime from '@emotion/react/jsx-runtime';
|
|
4
4
|
import { langs } from '@uiw/codemirror-extensions-langs';
|
|
5
5
|
import CodeMirror from '@uiw/react-codemirror';
|
|
@@ -66,7 +66,7 @@ type CodeEditorProps = {
|
|
|
66
66
|
};
|
|
67
67
|
declare const CodeEditor: ({ title, value, onChange, extensions, onBlur, height, readOnly, }: CodeEditorProps) => _emotion_react_jsx_runtime.JSX.Element;
|
|
68
68
|
|
|
69
|
-
declare const _default: {
|
|
69
|
+
declare const _default$1: {
|
|
70
70
|
readonly 'estimate.cost.description': "This summary provides a cost estimation based on your configuration, the amount of time you expect to use the resource for, and the scale of your expected usage. For the purposes of this calculation, we consider that 1 month equals to 730 hours.";
|
|
71
71
|
readonly 'estimate.cost.label': "Estimated cost";
|
|
72
72
|
readonly 'estimate.cost.beta.free': "Free During Beta";
|
|
@@ -186,7 +186,7 @@ type EstimateCostProps = {
|
|
|
186
186
|
/**
|
|
187
187
|
* Locales for the component. By default, it will use the english locales.
|
|
188
188
|
*/
|
|
189
|
-
locales?: typeof _default;
|
|
189
|
+
locales?: typeof _default$1;
|
|
190
190
|
/**
|
|
191
191
|
* Defines the currency to be shown in the component.
|
|
192
192
|
* To find out all currencies checkout https://en.wikipedia.org/wiki/ISO_4217#List_of_ISO_4217_currency_codes section "Code" of the table.
|
|
@@ -479,6 +479,68 @@ declare const Navigation: {
|
|
|
479
479
|
Separator: () => _emotion_react_jsx_runtime.JSX.Element;
|
|
480
480
|
};
|
|
481
481
|
|
|
482
|
+
declare const _default: {
|
|
483
|
+
readonly 'navigation.pin.tooltip': "Pin product";
|
|
484
|
+
readonly 'navigation.unpin.tooltip': "Unpin product";
|
|
485
|
+
readonly 'navigation.pinned.item.group.label': "Pinned items";
|
|
486
|
+
readonly 'navigation.expand.button': "Expand sidebar";
|
|
487
|
+
readonly 'navigation.collapse.button': "Collapse sidebar";
|
|
488
|
+
};
|
|
489
|
+
|
|
490
|
+
type ContextProps = {
|
|
491
|
+
expanded: boolean;
|
|
492
|
+
toggleExpand: (toggle?: boolean) => void;
|
|
493
|
+
animation: boolean | 'expand' | 'collapse';
|
|
494
|
+
pinnedFeature?: boolean;
|
|
495
|
+
onClickPinUnpin?: (pinned: string[]) => void;
|
|
496
|
+
pinItem: (item: string) => void;
|
|
497
|
+
unpinItem: (item: string) => void;
|
|
498
|
+
pinnedItems: string[];
|
|
499
|
+
pinLimit: number;
|
|
500
|
+
navigationRef: RefObject<HTMLDivElement>;
|
|
501
|
+
locales: typeof _default;
|
|
502
|
+
width: number;
|
|
503
|
+
setWidth: (width: number) => void;
|
|
504
|
+
};
|
|
505
|
+
declare const useNavigation: () => ContextProps;
|
|
506
|
+
type NavigationProviderProps = {
|
|
507
|
+
children: ReactNode;
|
|
508
|
+
initialWidth?: number;
|
|
509
|
+
/**
|
|
510
|
+
* This enable / disable the pinned feature of the navigation
|
|
511
|
+
* Pinned allows the use to pin (or favorite) some items in the navigation
|
|
512
|
+
*/
|
|
513
|
+
pinnedFeature?: boolean;
|
|
514
|
+
/**
|
|
515
|
+
* This define how many items can be pinned at the same time.
|
|
516
|
+
* If you want to disable the limit just set `Infinity` to this prop
|
|
517
|
+
*/
|
|
518
|
+
pinLimit?: number;
|
|
519
|
+
/**
|
|
520
|
+
* The initial pinned items. This should be an array of labels you've set on
|
|
521
|
+
* your `<Navigation.Item>`
|
|
522
|
+
*/
|
|
523
|
+
initialPinned?: string[];
|
|
524
|
+
/**
|
|
525
|
+
* The initial expanded state of the navigation. If set to true the
|
|
526
|
+
* navigation will be expanded by default otherwise it will be collapsed
|
|
527
|
+
*/
|
|
528
|
+
initialExpanded?: boolean;
|
|
529
|
+
/**
|
|
530
|
+
* This function is triggered when the user click on the pin/unpin button
|
|
531
|
+
* of an item
|
|
532
|
+
*/
|
|
533
|
+
onClickPinUnpin?: (pinned: string[]) => void;
|
|
534
|
+
locales?: typeof _default;
|
|
535
|
+
/**
|
|
536
|
+
* This function is triggered when user click on expand button on the footer
|
|
537
|
+
* of the navigation. This is not triggered when the user resize the navigation
|
|
538
|
+
* and it automatically collapse / expand.
|
|
539
|
+
*/
|
|
540
|
+
onClickExpand?: (expanded: boolean) => void;
|
|
541
|
+
};
|
|
542
|
+
declare const NavigationProvider: ({ children, pinnedFeature, onClickPinUnpin, initialPinned, initialExpanded, locales, pinLimit, onClickExpand, initialWidth, }: NavigationProviderProps) => _emotion_react_jsx_runtime.JSX.Element;
|
|
543
|
+
|
|
482
544
|
type FAQProps = {
|
|
483
545
|
description: string;
|
|
484
546
|
productIconName?: ComponentProps<typeof ProductIcon>['name'];
|
|
@@ -536,4 +598,4 @@ declare const SteppedListContainer: {
|
|
|
536
598
|
}) => _emotion_react_jsx_runtime.JSX.Element;
|
|
537
599
|
};
|
|
538
600
|
|
|
539
|
-
export { CodeEditor, ContentCard, ContentCardGroup, Conversation, CustomerSatisfaction, EstimateCost, FAQ, Navigation, SteppedListContainer, _default as estimateCostDefaultLocales };
|
|
601
|
+
export { CodeEditor, ContentCard, ContentCardGroup, Conversation, CustomerSatisfaction, EstimateCost, FAQ, Navigation, NavigationProvider, SteppedListContainer, _default$1 as estimateCostDefaultLocales, useNavigation };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { useContext, createContext } from 'react';
|
|
2
|
-
import { NAVIGATION_WIDTH } from './constants.js';
|
|
1
|
+
import { useContext, useState, useRef, useCallback, useMemo, createContext } from 'react';
|
|
2
|
+
import { ANIMATION_DURATION, NAVIGATION_WIDTH } from './constants.js';
|
|
3
3
|
import NavigationLocales from './locales/en.js';
|
|
4
|
-
import '@emotion/react/jsx-runtime';
|
|
4
|
+
import { jsx } from '@emotion/react/jsx-runtime';
|
|
5
5
|
|
|
6
6
|
const NavigationContext = /*#__PURE__*/createContext({
|
|
7
7
|
expanded: true,
|
|
@@ -23,5 +23,68 @@ const NavigationContext = /*#__PURE__*/createContext({
|
|
|
23
23
|
setWidth: () => {}
|
|
24
24
|
});
|
|
25
25
|
const useNavigation = () => useContext(NavigationContext);
|
|
26
|
+
const NavigationProvider = ({
|
|
27
|
+
children,
|
|
28
|
+
pinnedFeature = false,
|
|
29
|
+
onClickPinUnpin,
|
|
30
|
+
initialPinned,
|
|
31
|
+
initialExpanded = true,
|
|
32
|
+
locales = NavigationLocales,
|
|
33
|
+
pinLimit = 7,
|
|
34
|
+
onClickExpand,
|
|
35
|
+
initialWidth = NAVIGATION_WIDTH
|
|
36
|
+
}) => {
|
|
37
|
+
const [expanded, setExpanded] = useState(initialExpanded);
|
|
38
|
+
const [pinnedItems, setPinnedItems] = useState(initialPinned ?? []);
|
|
39
|
+
const [animation, setAnimation] = useState(false);
|
|
40
|
+
const [width, setWidth] = useState(initialWidth);
|
|
41
|
+
const navigationRef = useRef(null);
|
|
26
42
|
|
|
27
|
-
|
|
43
|
+
// This function will be triggered when expand/collapse button is clicked
|
|
44
|
+
const toggleExpand = useCallback(toggle => {
|
|
45
|
+
if (typeof toggle !== 'boolean' && toggle !== undefined) {
|
|
46
|
+
throw new Error(`toggleExpand only accepts boolean or undefined as parameter. You most likely did <button onClick={toggleExpand}> instead of <button onClick={() => toggleExpand()}>`);
|
|
47
|
+
}
|
|
48
|
+
if (toggle !== undefined && toggle === expanded) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
onClickExpand?.(!expanded);
|
|
52
|
+
if (navigationRef.current) {
|
|
53
|
+
navigationRef.current.style.width = '';
|
|
54
|
+
}
|
|
55
|
+
setAnimation(expanded ? 'collapse' : 'expand');
|
|
56
|
+
setTimeout(() => {
|
|
57
|
+
setExpanded(toggle !== undefined ? toggle : !expanded);
|
|
58
|
+
setAnimation(false);
|
|
59
|
+
}, ANIMATION_DURATION);
|
|
60
|
+
}, [expanded, onClickExpand, setAnimation, setExpanded]);
|
|
61
|
+
const pinItem = useCallback(item => {
|
|
62
|
+
setPinnedItems([...pinnedItems, item]);
|
|
63
|
+
onClickPinUnpin?.(pinnedItems);
|
|
64
|
+
}, [onClickPinUnpin, pinnedItems]);
|
|
65
|
+
const unpinItem = useCallback(item => {
|
|
66
|
+
setPinnedItems(pinnedItems.filter(localItem => localItem !== item));
|
|
67
|
+
onClickPinUnpin?.(pinnedItems);
|
|
68
|
+
}, [onClickPinUnpin, pinnedItems]);
|
|
69
|
+
const value = useMemo(() => ({
|
|
70
|
+
expanded,
|
|
71
|
+
toggleExpand,
|
|
72
|
+
pinnedItems,
|
|
73
|
+
pinItem,
|
|
74
|
+
unpinItem,
|
|
75
|
+
pinnedFeature,
|
|
76
|
+
locales,
|
|
77
|
+
pinLimit,
|
|
78
|
+
animation,
|
|
79
|
+
setAnimation,
|
|
80
|
+
navigationRef,
|
|
81
|
+
width,
|
|
82
|
+
setWidth
|
|
83
|
+
}), [expanded, toggleExpand, pinnedItems, pinItem, unpinItem, pinnedFeature, locales, pinLimit, animation, width]);
|
|
84
|
+
return jsx(NavigationContext.Provider, {
|
|
85
|
+
value: value,
|
|
86
|
+
children: children
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export { NavigationContext, NavigationProvider, useNavigation };
|
package/dist/src/index.js
CHANGED
|
@@ -6,5 +6,6 @@ export { default as estimateCostDefaultLocales } from './components/EstimateCost
|
|
|
6
6
|
export { CustomerSatisfaction } from './components/CustomerSatisfaction/index.js';
|
|
7
7
|
export { Conversation } from './components/Conversation/index.js';
|
|
8
8
|
export { Navigation } from './components/Navigation/Navigation.js';
|
|
9
|
+
export { NavigationProvider, useNavigation } from './components/Navigation/NavigationProvider.js';
|
|
9
10
|
export { FAQ } from './components/FAQ/index.js';
|
|
10
11
|
export { SteppedListContainer } from './components/SteppedListCard/SteppedListContainer.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultraviolet/plus",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.1",
|
|
4
4
|
"description": "Ultraviolet Plus",
|
|
5
5
|
"homepage": "https://github.com/scaleway/ultraviolet#readme",
|
|
6
6
|
"repository": {
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"@uiw/react-codemirror": "4.21.25",
|
|
57
57
|
"react-intersection-observer": "9.8.2",
|
|
58
58
|
"@ultraviolet/themes": "1.10.0",
|
|
59
|
-
"@ultraviolet/ui": "1.48.
|
|
59
|
+
"@ultraviolet/ui": "1.48.1"
|
|
60
60
|
},
|
|
61
61
|
"scripts": {
|
|
62
62
|
"build": "rollup -c ../../rollup.config.mjs",
|