@hitachivantara/uikit-react-core 5.3.0 → 5.4.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/dist/cjs/components/Dialog/Dialog.cjs +1 -1
- package/dist/cjs/components/Dialog/Dialog.cjs.map +1 -1
- package/dist/cjs/components/Dialog/Dialog.styles.cjs +3 -3
- package/dist/cjs/components/Dialog/Dialog.styles.cjs.map +1 -1
- package/dist/cjs/components/InlineEditor/InlineEditor.cjs +122 -0
- package/dist/cjs/components/InlineEditor/InlineEditor.cjs.map +1 -0
- package/dist/cjs/components/InlineEditor/InlineEditor.styles.cjs +74 -0
- package/dist/cjs/components/InlineEditor/InlineEditor.styles.cjs.map +1 -0
- package/dist/cjs/components/InlineEditor/inlineEditorClasses.cjs +8 -0
- package/dist/cjs/components/InlineEditor/inlineEditorClasses.cjs.map +1 -0
- package/dist/cjs/components/ScrollTo/Horizontal/HorizontalScrollListItem/HorizontalScrollListItem.cjs +51 -0
- package/dist/cjs/components/ScrollTo/Horizontal/HorizontalScrollListItem/HorizontalScrollListItem.cjs.map +1 -0
- package/dist/cjs/components/ScrollTo/Horizontal/HorizontalScrollListItem/HorizontalScrollListItem.styles.cjs +54 -0
- package/dist/cjs/components/ScrollTo/Horizontal/HorizontalScrollListItem/HorizontalScrollListItem.styles.cjs.map +1 -0
- package/dist/cjs/components/ScrollTo/Horizontal/HorizontalScrollListItem/horizontalScrollListItemClasses.cjs +8 -0
- package/dist/cjs/components/ScrollTo/Horizontal/HorizontalScrollListItem/horizontalScrollListItemClasses.cjs.map +1 -0
- package/dist/cjs/components/ScrollTo/Horizontal/ScrollToHorizontal.cjs +126 -0
- package/dist/cjs/components/ScrollTo/Horizontal/ScrollToHorizontal.cjs.map +1 -0
- package/dist/cjs/components/ScrollTo/Horizontal/ScrollToHorizontal.styles.cjs +46 -0
- package/dist/cjs/components/ScrollTo/Horizontal/ScrollToHorizontal.styles.cjs.map +1 -0
- package/dist/cjs/components/ScrollTo/Horizontal/scrollToHorizontalClasses.cjs +8 -0
- package/dist/cjs/components/ScrollTo/Horizontal/scrollToHorizontalClasses.cjs.map +1 -0
- package/dist/cjs/components/ScrollTo/Vertical/ScrollToVertical.cjs +90 -0
- package/dist/cjs/components/ScrollTo/Vertical/ScrollToVertical.cjs.map +1 -0
- package/dist/cjs/components/ScrollTo/Vertical/ScrollToVertical.styles.cjs +43 -0
- package/dist/cjs/components/ScrollTo/Vertical/ScrollToVertical.styles.cjs.map +1 -0
- package/dist/cjs/components/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.cjs +71 -0
- package/dist/cjs/components/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.cjs.map +1 -0
- package/dist/cjs/components/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.styles.cjs +54 -0
- package/dist/cjs/components/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.styles.cjs.map +1 -0
- package/dist/cjs/components/ScrollTo/Vertical/VerticalScrollListItem/verticalScrollListItemClasses.cjs +8 -0
- package/dist/cjs/components/ScrollTo/Vertical/VerticalScrollListItem/verticalScrollListItemClasses.cjs.map +1 -0
- package/dist/cjs/components/ScrollTo/Vertical/scrollToVerticalClasses.cjs +8 -0
- package/dist/cjs/components/ScrollTo/Vertical/scrollToVerticalClasses.cjs.map +1 -0
- package/dist/cjs/components/ScrollTo/useScrollTo.cjs +103 -0
- package/dist/cjs/components/ScrollTo/useScrollTo.cjs.map +1 -0
- package/dist/cjs/components/ScrollTo/utils.cjs +76 -0
- package/dist/cjs/components/ScrollTo/utils.cjs.map +1 -0
- package/dist/cjs/components/ScrollTo/withTooltip.cjs +20 -0
- package/dist/cjs/components/ScrollTo/withTooltip.cjs.map +1 -0
- package/dist/cjs/hocs/withTooltip.cjs +4 -4
- package/dist/cjs/hocs/withTooltip.cjs.map +1 -1
- package/dist/cjs/index.cjs +19 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/utils/theme.cjs +9 -0
- package/dist/cjs/utils/theme.cjs.map +1 -1
- package/dist/cjs/utils/wrapperTooltip.cjs +1 -1
- package/dist/cjs/utils/wrapperTooltip.cjs.map +1 -1
- package/dist/esm/components/Dialog/Dialog.js +2 -2
- package/dist/esm/components/Dialog/Dialog.js.map +1 -1
- package/dist/esm/components/Dialog/Dialog.styles.js +3 -3
- package/dist/esm/components/Dialog/Dialog.styles.js.map +1 -1
- package/dist/esm/components/InlineEditor/InlineEditor.js +122 -0
- package/dist/esm/components/InlineEditor/InlineEditor.js.map +1 -0
- package/dist/esm/components/InlineEditor/InlineEditor.styles.js +74 -0
- package/dist/esm/components/InlineEditor/InlineEditor.styles.js.map +1 -0
- package/dist/esm/components/InlineEditor/inlineEditorClasses.js +8 -0
- package/dist/esm/components/InlineEditor/inlineEditorClasses.js.map +1 -0
- package/dist/esm/components/ScrollTo/Horizontal/HorizontalScrollListItem/HorizontalScrollListItem.js +51 -0
- package/dist/esm/components/ScrollTo/Horizontal/HorizontalScrollListItem/HorizontalScrollListItem.js.map +1 -0
- package/dist/esm/components/ScrollTo/Horizontal/HorizontalScrollListItem/HorizontalScrollListItem.styles.js +54 -0
- package/dist/esm/components/ScrollTo/Horizontal/HorizontalScrollListItem/HorizontalScrollListItem.styles.js.map +1 -0
- package/dist/esm/components/ScrollTo/Horizontal/HorizontalScrollListItem/horizontalScrollListItemClasses.js +8 -0
- package/dist/esm/components/ScrollTo/Horizontal/HorizontalScrollListItem/horizontalScrollListItemClasses.js.map +1 -0
- package/dist/esm/components/ScrollTo/Horizontal/ScrollToHorizontal.js +126 -0
- package/dist/esm/components/ScrollTo/Horizontal/ScrollToHorizontal.js.map +1 -0
- package/dist/esm/components/ScrollTo/Horizontal/ScrollToHorizontal.styles.js +46 -0
- package/dist/esm/components/ScrollTo/Horizontal/ScrollToHorizontal.styles.js.map +1 -0
- package/dist/esm/components/ScrollTo/Horizontal/scrollToHorizontalClasses.js +8 -0
- package/dist/esm/components/ScrollTo/Horizontal/scrollToHorizontalClasses.js.map +1 -0
- package/dist/esm/components/ScrollTo/Vertical/ScrollToVertical.js +90 -0
- package/dist/esm/components/ScrollTo/Vertical/ScrollToVertical.js.map +1 -0
- package/dist/esm/components/ScrollTo/Vertical/ScrollToVertical.styles.js +43 -0
- package/dist/esm/components/ScrollTo/Vertical/ScrollToVertical.styles.js.map +1 -0
- package/dist/esm/components/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.js +71 -0
- package/dist/esm/components/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.js.map +1 -0
- package/dist/esm/components/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.styles.js +54 -0
- package/dist/esm/components/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.styles.js.map +1 -0
- package/dist/esm/components/ScrollTo/Vertical/VerticalScrollListItem/verticalScrollListItemClasses.js +8 -0
- package/dist/esm/components/ScrollTo/Vertical/VerticalScrollListItem/verticalScrollListItemClasses.js.map +1 -0
- package/dist/esm/components/ScrollTo/Vertical/scrollToVerticalClasses.js +8 -0
- package/dist/esm/components/ScrollTo/Vertical/scrollToVerticalClasses.js.map +1 -0
- package/dist/esm/components/ScrollTo/useScrollTo.js +103 -0
- package/dist/esm/components/ScrollTo/useScrollTo.js.map +1 -0
- package/dist/esm/components/ScrollTo/utils.js +76 -0
- package/dist/esm/components/ScrollTo/utils.js.map +1 -0
- package/dist/esm/components/ScrollTo/withTooltip.js +20 -0
- package/dist/esm/components/ScrollTo/withTooltip.js.map +1 -0
- package/dist/esm/hocs/withTooltip.js +4 -4
- package/dist/esm/hocs/withTooltip.js.map +1 -1
- package/dist/esm/index.js +38 -19
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/theme.js +9 -0
- package/dist/esm/utils/theme.js.map +1 -1
- package/dist/esm/utils/wrapperTooltip.js +2 -2
- package/dist/esm/utils/wrapperTooltip.js.map +1 -1
- package/dist/types/index.d.ts +193 -1
- package/package.json +5 -5
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { clsx } from "clsx";
|
|
2
|
+
import { ClassNames } from "@emotion/react";
|
|
3
|
+
import { useState, useRef, useLayoutEffect } from "react";
|
|
4
|
+
import inlineEditorClasses from "./inlineEditorClasses.js";
|
|
5
|
+
import { styles } from "./InlineEditor.styles.js";
|
|
6
|
+
import { theme } from "@hitachivantara/uikit-styles";
|
|
7
|
+
import { Edit } from "@hitachivantara/uikit-react-icons";
|
|
8
|
+
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
9
|
+
import { getVarValue } from "../../utils/theme.js";
|
|
10
|
+
import { useControlled } from "../../hooks/useControlled.js";
|
|
11
|
+
import { HvInput } from "../Input/Input.js";
|
|
12
|
+
import { HvButton } from "../Button/Button.js";
|
|
13
|
+
import { HvTypography } from "../Typography/Typography.js";
|
|
14
|
+
import { isKeypress } from "../../utils/keyboardUtils/keyCheck.js";
|
|
15
|
+
import { keyboardCodes } from "../../utils/keyboardUtils/keyboardCodes.js";
|
|
16
|
+
const getTypographyStyles = (typography) => {
|
|
17
|
+
let typographyStyles = {};
|
|
18
|
+
Object.keys(typography).map((k) => {
|
|
19
|
+
typographyStyles[k] = getVarValue(typography[k]);
|
|
20
|
+
});
|
|
21
|
+
return typographyStyles;
|
|
22
|
+
};
|
|
23
|
+
const HvInlineEditor = ({
|
|
24
|
+
className,
|
|
25
|
+
classes,
|
|
26
|
+
value: valueProp,
|
|
27
|
+
defaultValue,
|
|
28
|
+
showIcon,
|
|
29
|
+
component: InputComponent = HvInput,
|
|
30
|
+
variant = "body",
|
|
31
|
+
placeholder = "Enter text",
|
|
32
|
+
onBlur,
|
|
33
|
+
onChange,
|
|
34
|
+
onKeyDown,
|
|
35
|
+
buttonProps,
|
|
36
|
+
typographyProps,
|
|
37
|
+
...others
|
|
38
|
+
}) => {
|
|
39
|
+
const [value, setValue] = useControlled(valueProp, defaultValue);
|
|
40
|
+
const [editMode, setEditMode] = useState(false);
|
|
41
|
+
const [cachedValue, setCachedValue] = useState(value);
|
|
42
|
+
const inputRef = useRef();
|
|
43
|
+
const typographyStyles = getTypographyStyles(theme.typography[variant] || {});
|
|
44
|
+
const {
|
|
45
|
+
lineHeight
|
|
46
|
+
} = typographyStyles;
|
|
47
|
+
useLayoutEffect(() => {
|
|
48
|
+
const input = inputRef.current;
|
|
49
|
+
if (editMode && input) {
|
|
50
|
+
input.focus();
|
|
51
|
+
input.select();
|
|
52
|
+
}
|
|
53
|
+
}, [editMode]);
|
|
54
|
+
const handleClick = () => {
|
|
55
|
+
setEditMode(true);
|
|
56
|
+
setCachedValue(value);
|
|
57
|
+
};
|
|
58
|
+
const handleBlur = (event) => {
|
|
59
|
+
setEditMode(false);
|
|
60
|
+
const newValue = value || cachedValue;
|
|
61
|
+
setValue(newValue);
|
|
62
|
+
onBlur == null ? void 0 : onBlur(event, newValue);
|
|
63
|
+
};
|
|
64
|
+
const handleKeyDown = (event) => {
|
|
65
|
+
if (isKeypress(event, keyboardCodes.Esc)) {
|
|
66
|
+
setEditMode(false);
|
|
67
|
+
setValue(cachedValue);
|
|
68
|
+
}
|
|
69
|
+
onKeyDown == null ? void 0 : onKeyDown(event);
|
|
70
|
+
};
|
|
71
|
+
const handleChange = (event, val) => {
|
|
72
|
+
setValue(val);
|
|
73
|
+
onChange == null ? void 0 : onChange(event, val);
|
|
74
|
+
};
|
|
75
|
+
return /* @__PURE__ */ jsx(ClassNames, {
|
|
76
|
+
children: ({
|
|
77
|
+
css
|
|
78
|
+
}) => /* @__PURE__ */ jsx("div", {
|
|
79
|
+
className: clsx(className, inlineEditorClasses.root, classes == null ? void 0 : classes.root, css(styles.root)),
|
|
80
|
+
children: editMode ? /* @__PURE__ */ jsx(InputComponent, {
|
|
81
|
+
inputRef,
|
|
82
|
+
classes: {
|
|
83
|
+
root: clsx(classes == null ? void 0 : classes.inputRoot, inlineEditorClasses.inputRoot),
|
|
84
|
+
input: clsx(classes == null ? void 0 : classes.input, inlineEditorClasses.input, css(styles.input)),
|
|
85
|
+
inputBorderContainer: clsx(classes == null ? void 0 : classes.inputBorderContainer, inlineEditorClasses.inputBorderContainer, css(styles.inputBorderContainer))
|
|
86
|
+
},
|
|
87
|
+
inputProps: {
|
|
88
|
+
style: {
|
|
89
|
+
...typographyStyles,
|
|
90
|
+
height: InputComponent === HvInput ? lineHeight : void 0
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
value,
|
|
94
|
+
onBlur: handleBlur,
|
|
95
|
+
onChange: handleChange,
|
|
96
|
+
onKeyDown: handleKeyDown,
|
|
97
|
+
...others
|
|
98
|
+
}) : /* @__PURE__ */ jsxs(HvButton, {
|
|
99
|
+
variant: "secondaryGhost",
|
|
100
|
+
overrideIconColors: false,
|
|
101
|
+
className: clsx(classes == null ? void 0 : classes.button, inlineEditorClasses.button, css(styles.button), parseInt(lineHeight, 10) >= 28 && clsx(classes == null ? void 0 : classes.largeText, inlineEditorClasses.largeText, css(styles.largeText))),
|
|
102
|
+
onClick: handleClick,
|
|
103
|
+
...buttonProps,
|
|
104
|
+
children: [/* @__PURE__ */ jsx(HvTypography, {
|
|
105
|
+
variant,
|
|
106
|
+
noWrap: true,
|
|
107
|
+
className: clsx(classes == null ? void 0 : classes.text, inlineEditorClasses.text, css(styles.text), !value && clsx(classes == null ? void 0 : classes.textEmpty, inlineEditorClasses.textEmpty, css(styles.textEmpty))),
|
|
108
|
+
...typographyProps,
|
|
109
|
+
children: value || placeholder
|
|
110
|
+
}), /* @__PURE__ */ jsx(Edit, {
|
|
111
|
+
color: "secondary_60",
|
|
112
|
+
role: "presentation",
|
|
113
|
+
className: clsx(classes == null ? void 0 : classes.icon, inlineEditorClasses.icon, css(styles.icon), showIcon && clsx(classes == null ? void 0 : classes.iconVisible, inlineEditorClasses.iconVisible, css(styles.iconVisible)))
|
|
114
|
+
})]
|
|
115
|
+
})
|
|
116
|
+
})
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
export {
|
|
120
|
+
HvInlineEditor
|
|
121
|
+
};
|
|
122
|
+
//# sourceMappingURL=InlineEditor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InlineEditor.js","sources":["../../../../src/components/InlineEditor/InlineEditor.tsx"],"sourcesContent":["import { clsx } from \"clsx\";\nimport { ClassNames } from \"@emotion/react\";\nimport React, { useLayoutEffect, useRef, useState } from \"react\";\nimport { HvBaseProps } from \"@core/types\";\nimport { useControlled } from \"@core/hooks\";\nimport { getVarValue, isKeypress, keyboardCodes } from \"@core/utils\";\nimport {\n HvButtonProps,\n HvTypographyVariants,\n HvTypographyProps,\n HvInput,\n HvButton,\n HvTypography,\n} from \"@core/components\";\nimport inlineEditorClasses, {\n HvInlineEditorClasses,\n} from \"./inlineEditorClasses\";\nimport { styles } from \"./InlineEditor.styles\";\nimport { HvThemeTypographyProps, theme } from \"@hitachivantara/uikit-styles\";\nimport { Edit } from \"@hitachivantara/uikit-react-icons\";\n\nexport interface HvInlineEditorProps\n extends Omit<HvBaseProps<HTMLDivElement>, \"onBlur\" | \"onChange\"> {\n /** The value of the form element. */\n value?: string;\n /** Whether the Edit icon should always be visible */\n showIcon?: boolean;\n /** Component to use as the input. The component \"inherit\" from `HvBaseInput` (such as `HvInput` or `HvTextArea`) */\n component?: React.ElementType;\n /** Variant of the HvTypography to display */\n variant?: HvTypographyVariants;\n /** Called when the input is blurred. */\n onBlur?: (\n event: React.FocusEvent<HTMLTextAreaElement | HTMLInputElement>,\n value: string\n ) => void;\n /** Called when the input value changes. */\n onChange?: (event: React.SyntheticEvent, value: string) => void;\n /** Props passed to the HvButton component */\n buttonProps?: HvButtonProps;\n /** Props passed to the HvTypography text component */\n typographyProps?: HvTypographyProps;\n /** A Jss Object used to override or extend the styles applied to the empty state component. */\n classes?: HvInlineEditorClasses;\n}\n\nconst getTypographyStyles = (typography): HvThemeTypographyProps => {\n let typographyStyles = {};\n Object.keys(typography).map((k) => {\n typographyStyles[k] = getVarValue(typography[k]);\n });\n return typographyStyles;\n};\n\n/**\n * An Inline Editor allows the user to edit a record without making a major switch\n * between viewing and editing, making it an efficient method of updating a record.\n */\nexport const HvInlineEditor = ({\n className,\n classes,\n value: valueProp,\n defaultValue,\n showIcon,\n component: InputComponent = HvInput,\n variant = \"body\",\n placeholder = \"Enter text\",\n onBlur,\n onChange,\n onKeyDown,\n buttonProps,\n typographyProps,\n ...others\n}: HvInlineEditorProps) => {\n const [value, setValue] = useControlled(valueProp, defaultValue);\n const [editMode, setEditMode] = useState(false);\n const [cachedValue, setCachedValue] = useState(value);\n const inputRef = useRef<HTMLInputElement>();\n\n const typographyStyles = getTypographyStyles(theme.typography[variant] || {});\n const { lineHeight } = typographyStyles;\n\n useLayoutEffect(() => {\n const input = inputRef.current;\n if (editMode && input) {\n input.focus();\n input.select();\n }\n }, [editMode]);\n\n const handleClick = () => {\n setEditMode(true);\n setCachedValue(value);\n };\n\n const handleBlur = (event) => {\n setEditMode(false);\n\n const newValue = value || cachedValue; // empty values should be ignored\n setValue(newValue);\n onBlur?.(event, newValue);\n };\n\n const handleKeyDown = (event) => {\n if (isKeypress(event, keyboardCodes.Esc)) {\n setEditMode(false);\n setValue(cachedValue);\n }\n onKeyDown?.(event);\n };\n\n const handleChange = (event, val) => {\n setValue(val);\n onChange?.(event, val);\n };\n\n return (\n <ClassNames>\n {({ css }) => (\n <div\n className={clsx(\n className,\n inlineEditorClasses.root,\n classes?.root,\n css(styles.root)\n )}\n >\n {editMode ? (\n <InputComponent\n inputRef={inputRef}\n classes={{\n root: clsx(classes?.inputRoot, inlineEditorClasses.inputRoot),\n input: clsx(\n classes?.input,\n inlineEditorClasses.input,\n css(styles.input)\n ),\n inputBorderContainer: clsx(\n classes?.inputBorderContainer,\n inlineEditorClasses.inputBorderContainer,\n css(styles.inputBorderContainer)\n ),\n }}\n inputProps={{\n style: {\n ...typographyStyles,\n height: InputComponent === HvInput ? lineHeight : undefined,\n },\n }}\n value={value}\n onBlur={handleBlur}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n {...others}\n />\n ) : (\n <HvButton\n variant=\"secondaryGhost\"\n overrideIconColors={false}\n className={clsx(\n classes?.button,\n inlineEditorClasses.button,\n css(styles.button),\n parseInt(lineHeight as string, 10) >= 28 &&\n clsx(\n classes?.largeText,\n inlineEditorClasses.largeText,\n css(styles.largeText)\n )\n )}\n onClick={handleClick}\n {...buttonProps}\n >\n <HvTypography\n variant={variant}\n noWrap\n className={clsx(\n classes?.text,\n inlineEditorClasses.text,\n css(styles.text),\n !value &&\n clsx(\n classes?.textEmpty,\n inlineEditorClasses.textEmpty,\n css(styles.textEmpty)\n )\n )}\n {...typographyProps}\n >\n {value || placeholder}\n </HvTypography>\n <Edit\n color=\"secondary_60\"\n role=\"presentation\"\n className={clsx(\n classes?.icon,\n inlineEditorClasses.icon,\n css(styles.icon),\n showIcon &&\n clsx(\n classes?.iconVisible,\n inlineEditorClasses.iconVisible,\n css(styles.iconVisible)\n )\n )}\n />\n </HvButton>\n )}\n </div>\n )}\n </ClassNames>\n );\n};\n"],"names":["getTypographyStyles","typography","typographyStyles","Object","keys","map","k","getVarValue","HvInlineEditor","className","classes","value","valueProp","defaultValue","showIcon","component","InputComponent","HvInput","variant","placeholder","onBlur","onChange","onKeyDown","buttonProps","typographyProps","others","setValue","useControlled","editMode","setEditMode","useState","cachedValue","setCachedValue","inputRef","useRef","theme","lineHeight","useLayoutEffect","input","current","focus","select","handleClick","handleBlur","event","newValue","handleKeyDown","isKeypress","keyboardCodes","Esc","handleChange","val","ClassNames","children","css","clsx","inlineEditorClasses","root","styles","_jsx","inputRoot","inputBorderContainer","inputProps","style","height","undefined","_jsxs","HvButton","overrideIconColors","button","parseInt","largeText","onClick","HvTypography","noWrap","text","textEmpty","Edit","color","role","icon","iconVisible"],"mappings":";;;;;;;;;;;;;;;AA8CA,MAAMA,sBAAsBA,CAACC,eAAuC;AAClE,MAAIC,mBAAmB,CAAA;AACvBC,SAAOC,KAAKH,UAAU,EAAEI,IAAKC,CAAM,MAAA;AACjCJ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XvD;AAAAA,UACAwD,QAAM;AAAA,UACNjE,WAAW8C,KACT7C,mCAASiE,MACTnB,oBAAoBmB,MACpBrB,IAAII,OAAOiB,IAAI,GACf,CAAChE,SACC4C,KACE7C,mCAASkE,WACTpB,oBAAoBoB,WACpBtB,IAAII,OAAOkB,SAAS,CAAC,CACtB;AAAA,UACH,GACEpD;AAAAA,UAAe6B,UAElB1C,SAASQ;AAAAA,QAAAA,CACG,GACfwC,oBAACkB,MAAI;AAAA,UACHC,OAAM;AAAA,UACNC,MAAK;AAAA,UACLtE,WAAW8C,KACT7C,mCAASsE,MACTxB,oBAAoBwB,MACpB1B,IAAII,OAAOsB,IAAI,GACflE,YACEyC,KACE7C,mCAASuE,aACTzB,oBAAoByB,aACpB3B,IAAII,OAAOuB,WAAW,CAAC,CACxB;AAAA,QAAA,CAEL,CAAA;AAAA,MAAA,CAAA;AAAA,IAAA,CAEL;AAAA,EAAA,CAGM;AAEjB;"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { theme } from "@hitachivantara/uikit-styles";
|
|
2
|
+
import inlineEditorClasses from "./inlineEditorClasses.js";
|
|
3
|
+
import baseInputClasses from "../BaseInput/baseInputClasses.js";
|
|
4
|
+
import inputClasses from "../Input/inputClasses.js";
|
|
5
|
+
const styles = {
|
|
6
|
+
root: {
|
|
7
|
+
[`& .${baseInputClasses.inputRoot}.${inputClasses.inputRoot}`]: {
|
|
8
|
+
height: "100%"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
inputBorderContainer: {
|
|
12
|
+
top: "unset",
|
|
13
|
+
bottom: 0
|
|
14
|
+
},
|
|
15
|
+
input: {
|
|
16
|
+
padding: theme.spacing([0, "8px"])
|
|
17
|
+
},
|
|
18
|
+
text: {
|
|
19
|
+
overflow: "hidden",
|
|
20
|
+
textOverflow: "ellipsis",
|
|
21
|
+
whiteSpace: "nowrap",
|
|
22
|
+
alignSelf: "center"
|
|
23
|
+
},
|
|
24
|
+
textEmpty: {
|
|
25
|
+
color: theme.typography.placeholderText.color
|
|
26
|
+
},
|
|
27
|
+
button: {
|
|
28
|
+
padding: theme.spacing([0, "8px"]),
|
|
29
|
+
boxSizing: "border-box",
|
|
30
|
+
cursor: "text",
|
|
31
|
+
height: "100%",
|
|
32
|
+
width: "100%",
|
|
33
|
+
maxWidth: "100%",
|
|
34
|
+
justifyContent: "flex-start",
|
|
35
|
+
backgroundColor: "transparent",
|
|
36
|
+
"&:hover, &:focus": {
|
|
37
|
+
outline: `1px solid ${theme.inlineEditor.hoverBorderColor}`,
|
|
38
|
+
backgroundColor: "transparent",
|
|
39
|
+
[`& .${inlineEditorClasses.icon}`]: {
|
|
40
|
+
visibility: "visible"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"&:active": {
|
|
44
|
+
outline: `1px solid ${theme.inlineEditor.activeBorderColor}`,
|
|
45
|
+
backgroundColor: "transparent",
|
|
46
|
+
[`& .${inlineEditorClasses.icon}`]: {
|
|
47
|
+
visibility: "visible"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"& > div": {
|
|
51
|
+
width: "100%"
|
|
52
|
+
},
|
|
53
|
+
"& > div > span": {
|
|
54
|
+
width: "100%",
|
|
55
|
+
overflow: "hidden"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
icon: {
|
|
59
|
+
cursor: "pointer",
|
|
60
|
+
visibility: "hidden",
|
|
61
|
+
minWidth: 32,
|
|
62
|
+
alignSelf: "center"
|
|
63
|
+
},
|
|
64
|
+
iconVisible: {
|
|
65
|
+
visibility: "visible"
|
|
66
|
+
},
|
|
67
|
+
largeText: {
|
|
68
|
+
margin: theme.spacing([0, "8px"])
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
export {
|
|
72
|
+
styles
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=InlineEditor.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InlineEditor.styles.js","sources":["../../../../src/components/InlineEditor/InlineEditor.styles.tsx"],"sourcesContent":["import { CSSInterpolation } from \"@emotion/serialize\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\nimport { baseInputClasses, inputClasses } from \"../index\";\nimport inlineEditorClasses from \"./inlineEditorClasses\";\n\nexport const styles: {\n root: CSSInterpolation;\n inputBorderContainer: CSSInterpolation;\n input: CSSInterpolation;\n text: CSSInterpolation;\n textEmpty: CSSInterpolation;\n button: CSSInterpolation;\n icon: CSSInterpolation;\n iconVisible: CSSInterpolation;\n largeText: CSSInterpolation;\n} = {\n root: {\n [`& .${baseInputClasses.inputRoot}.${inputClasses.inputRoot}`]: {\n height: \"100%\",\n },\n },\n inputBorderContainer: {\n top: \"unset\",\n bottom: 0,\n },\n input: {\n padding: theme.spacing([0, \"8px\"]),\n },\n text: {\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n alignSelf: \"center\",\n },\n textEmpty: {\n color: theme.typography.placeholderText.color,\n },\n button: {\n padding: theme.spacing([0, \"8px\"]),\n boxSizing: \"border-box\",\n cursor: \"text\",\n height: \"100%\",\n width: \"100%\",\n maxWidth: \"100%\",\n justifyContent: \"flex-start\",\n\n backgroundColor: \"transparent\",\n \"&:hover, &:focus\": {\n outline: `1px solid ${theme.inlineEditor.hoverBorderColor}`,\n backgroundColor: \"transparent\",\n [`& .${inlineEditorClasses.icon}`]: {\n visibility: \"visible\",\n },\n },\n \"&:active\": {\n outline: `1px solid ${theme.inlineEditor.activeBorderColor}`,\n backgroundColor: \"transparent\",\n [`& .${inlineEditorClasses.icon}`]: {\n visibility: \"visible\",\n },\n },\n \"& > div\": {\n width: \"100%\",\n },\n \"& > div > span\": {\n width: \"100%\",\n overflow: \"hidden\",\n },\n },\n icon: {\n cursor: \"pointer\",\n visibility: \"hidden\",\n minWidth: 32,\n alignSelf: \"center\",\n },\n iconVisible: {\n visibility: \"visible\",\n },\n largeText: {\n margin: theme.spacing([0, \"8px\"]),\n },\n};\n"],"names":["styles","root","baseInputClasses","inputRoot","inputClasses","height","inputBorderContainer","top","bottom","input","padding","theme","spacing","text","overflow","textOverflow","whiteSpace","alignSelf","textEmpty","color","typography","placeholderText","button","boxSizing","cursor","width","maxWidth","justifyContent","backgroundColor","outline","inlineEditor","hoverBorderColor","inlineEditorClasses","icon","visibility","activeBorderColor","minWidth","iconVisible","largeText","margin"],"mappings":";;;;AAKO,MAAMA,SAUT;AAAA,EACFC,MAAM;AAAA,IACJ,CAAE,MAAKC,iBAAiBC,aAAaC,aAAaD,WAAW,GAAG;AAAA,MAC9DE,QAAQ;AAAA,IACV;AAAA,EACF;AAAA,EACAC,sBAAsB;AAAA,IACpBC,KAAK;AAAA,IACLC,QAAQ;AAAA,EACV;AAAA,EACAC,OAAO;AAAA,IACLC,SAASC,MAAMC,QAAQ,CAAC,GAAG,KAAK,CAAC;AAAA,EACnC;AAAA,EACAC,MAAM;AAAA,IACJC,UAAU;AAAA,IACVC,cAAc;AAAA,IACdC,YAAY;AAAA,IACZC,WAAW;AAAA,EACb;AAAA,EACAC,WAAW;AAAA,IACTC,OAAOR,MAAMS,WAAWC,gBAAgBF;AAAAA,EAC1C;AAAA,EACAG,QAAQ;AAAA,IACNZ,SAASC,MAAMC,QAAQ,CAAC,GAAG,KAAK,CAAC;AAAA,IACjCW,WAAW;AAAA,IACXC,QAAQ;AAAA,IACRnB,QAAQ;AAAA,IACRoB,OAAO;AAAA,IACPC,UAAU;AAAA,IACVC,gBAAgB;AAAA,IAEhBC,iBAAiB;AAAA,IACjB,oBAAoB;AAAA,MAClBC,SAAU,aAAYlB,MAAMmB,aAAaC;AAAAA,MACzCH,iBAAiB;AAAA,MACjB,CAAE,MAAKI,oBAAoBC,MAAM,GAAG;AAAA,QAClCC,YAAY;AAAA,MACd;AAAA,IACF;AAAA,IACA,YAAY;AAAA,MACVL,SAAU,aAAYlB,MAAMmB,aAAaK;AAAAA,MACzCP,iBAAiB;AAAA,MACjB,CAAE,MAAKI,oBAAoBC,MAAM,GAAG;AAAA,QAClCC,YAAY;AAAA,MACd;AAAA,IACF;AAAA,IACA,WAAW;AAAA,MACTT,OAAO;AAAA,IACT;AAAA,IACA,kBAAkB;AAAA,MAChBA,OAAO;AAAA,MACPX,UAAU;AAAA,IACZ;AAAA,EACF;AAAA,EACAmB,MAAM;AAAA,IACJT,QAAQ;AAAA,IACRU,YAAY;AAAA,IACZE,UAAU;AAAA,IACVnB,WAAW;AAAA,EACb;AAAA,EACAoB,aAAa;AAAA,IACXH,YAAY;AAAA,EACd;AAAA,EACAI,WAAW;AAAA,IACTC,QAAQ5B,MAAMC,QAAQ,CAAC,GAAG,KAAK,CAAC;AAAA,EAClC;AACF;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { getClasses } from "../../utils/classes.js";
|
|
2
|
+
const classKeys = ["root", "button", "largeText", "text", "textEmpty", "icon", "iconVisible", "inputRoot", "input", "inputBorderContainer"];
|
|
3
|
+
const inlineEditorClasses = getClasses(classKeys, "HvInlineEditor");
|
|
4
|
+
const inlineEditorClasses$1 = inlineEditorClasses;
|
|
5
|
+
export {
|
|
6
|
+
inlineEditorClasses$1 as default
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=inlineEditorClasses.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inlineEditorClasses.js","sources":["../../../../src/components/InlineEditor/inlineEditorClasses.ts"],"sourcesContent":["import { getClasses } from \"@core/utils\";\n\nexport interface HvInlineEditorClasses {\n root?: string;\n button?: string;\n largeText?: string;\n text?: string;\n textEmpty?: string;\n icon?: string;\n iconVisible?: string;\n inputRoot?: string;\n input?: string;\n inputBorderContainer?: string;\n}\n\nconst classKeys: string[] = [\n \"root\",\n \"button\",\n \"largeText\",\n \"text\",\n \"textEmpty\",\n \"icon\",\n \"iconVisible\",\n \"inputRoot\",\n \"input\",\n \"inputBorderContainer\",\n];\n\nconst inlineEditorClasses = getClasses<HvInlineEditorClasses>(\n classKeys,\n \"HvInlineEditor\"\n);\n\nexport default inlineEditorClasses;\n"],"names":["classKeys","inlineEditorClasses","getClasses"],"mappings":";AAeA,MAAMA,YAAsB,CAC1B,QACA,UACA,aACA,QACA,aACA,QACA,eACA,aACA,SACA,sBAAsB;AAGxB,MAAMC,sBAAsBC,WAC1BF,WACA,gBAAgB;AAGlB,MAAA,wBAAeC;"}
|
package/dist/esm/components/ScrollTo/Horizontal/HorizontalScrollListItem/HorizontalScrollListItem.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import horizontalScrollListItemClasses from "./horizontalScrollListItemClasses.js";
|
|
2
|
+
import { ClassNames } from "@emotion/react";
|
|
3
|
+
import { clsx } from "clsx";
|
|
4
|
+
import { styles } from "./HorizontalScrollListItem.styles.js";
|
|
5
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
6
|
+
import { setId } from "../../../../utils/setId.js";
|
|
7
|
+
const HvHorizontalScrollListItem = ({
|
|
8
|
+
id,
|
|
9
|
+
className,
|
|
10
|
+
classes,
|
|
11
|
+
selected,
|
|
12
|
+
children,
|
|
13
|
+
onClick,
|
|
14
|
+
onKeyDown,
|
|
15
|
+
tooltipWrapper,
|
|
16
|
+
...others
|
|
17
|
+
}) => {
|
|
18
|
+
const variant = selected ? "label" : "body";
|
|
19
|
+
const labelId = setId(id, "label");
|
|
20
|
+
const buttonId = setId(id, "button");
|
|
21
|
+
const Tooltip = tooltipWrapper;
|
|
22
|
+
return /* @__PURE__ */ jsx(ClassNames, {
|
|
23
|
+
children: ({
|
|
24
|
+
css
|
|
25
|
+
}) => /* @__PURE__ */ jsx("li", {
|
|
26
|
+
id,
|
|
27
|
+
className: clsx(className, classes == null ? void 0 : classes.root, horizontalScrollListItemClasses.root, css(styles.root)),
|
|
28
|
+
"aria-current": selected,
|
|
29
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
30
|
+
id: buttonId,
|
|
31
|
+
role: "button",
|
|
32
|
+
tabIndex: 0,
|
|
33
|
+
onClick,
|
|
34
|
+
onKeyDown,
|
|
35
|
+
className: clsx(classes == null ? void 0 : classes.button, horizontalScrollListItemClasses.button, css(styles.button)),
|
|
36
|
+
"aria-labelledby": labelId,
|
|
37
|
+
...others,
|
|
38
|
+
children: /* @__PURE__ */ jsx(Tooltip, {
|
|
39
|
+
id: labelId,
|
|
40
|
+
className: clsx(classes == null ? void 0 : classes.text, horizontalScrollListItemClasses.text, css(styles.text), selected && clsx(classes == null ? void 0 : classes.selected, horizontalScrollListItemClasses.selected, css(styles.selected))),
|
|
41
|
+
variant,
|
|
42
|
+
children
|
|
43
|
+
})
|
|
44
|
+
})
|
|
45
|
+
})
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
export {
|
|
49
|
+
HvHorizontalScrollListItem
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=HorizontalScrollListItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HorizontalScrollListItem.js","sources":["../../../../../../src/components/ScrollTo/Horizontal/HorizontalScrollListItem/HorizontalScrollListItem.tsx"],"sourcesContent":["import { HvBaseProps } from \"@core/types\";\nimport horizontalScrollListItemClasses, {\n HvHorizontalScrollListItemClasses,\n} from \"./horizontalScrollListItemClasses\";\nimport { ClassNames } from \"@emotion/react\";\nimport { clsx } from \"clsx\";\nimport { setId } from \"@core/utils\";\nimport { HvTypographyProps } from \"@core/components\";\nimport { styles } from \"./HorizontalScrollListItem.styles\";\n\nexport interface HvVerticalScrollListItemProps extends HvBaseProps {\n /** The text to render. */\n children: React.ReactNode;\n /** A function component that renders a typography wrapped with a tooltip. */\n tooltipWrapper: React.FunctionComponent<{\n id?: string;\n className?: string;\n variant?: HvTypographyProps[\"variant\"];\n children?: React.ReactNode;\n }>;\n /** Whether the element is selected. */\n selected?: boolean;\n /** The function to be executed when the element is clicked. */\n onClick?: (event: React.MouseEvent<HTMLDivElement>) => void;\n /** The function to be executed when the element is clicked. */\n onKeyDown?: (event: React.KeyboardEvent<HTMLDivElement>) => void;\n /** A Jss Object used to override or extend the styles applied. */\n classes?: HvHorizontalScrollListItemClasses;\n}\n\n/**\n * HvHorizontalScrollListItem a focusable item to be used as part of the horizontal scroll\n */\nexport const HvHorizontalScrollListItem = ({\n id,\n className,\n classes,\n selected,\n children,\n onClick,\n onKeyDown,\n tooltipWrapper,\n ...others\n}: HvVerticalScrollListItemProps) => {\n const variant = selected ? \"label\" : \"body\";\n const labelId = setId(id, \"label\");\n const buttonId = setId(id, \"button\");\n const Tooltip = tooltipWrapper;\n\n return (\n <ClassNames>\n {({ css }) => (\n <li\n id={id}\n className={clsx(\n className,\n classes?.root,\n horizontalScrollListItemClasses.root,\n css(styles.root)\n )}\n aria-current={selected}\n >\n <div\n id={buttonId}\n role=\"button\"\n tabIndex={0}\n onClick={onClick}\n onKeyDown={onKeyDown}\n className={clsx(\n classes?.button,\n horizontalScrollListItemClasses.button,\n css(styles.button)\n )}\n aria-labelledby={labelId}\n {...others}\n >\n <Tooltip\n id={labelId}\n className={clsx(\n classes?.text,\n horizontalScrollListItemClasses.text,\n css(styles.text),\n selected &&\n clsx(\n classes?.selected,\n horizontalScrollListItemClasses.selected,\n css(styles.selected)\n )\n )}\n variant={variant}\n >\n {children}\n </Tooltip>\n </div>\n </li>\n )}\n </ClassNames>\n );\n};\n"],"names":["HvHorizontalScrollListItem","id","className","classes","selected","children","onClick","onKeyDown","tooltipWrapper","others","variant","labelId","setId","buttonId","Tooltip","ClassNames","css","clsx","root","horizontalScrollListItemClasses","styles","role","tabIndex","button","text"],"mappings":";;;;;;AAiCO,MAAMA,6BAA6BA,CAAC;AAAA,EACzCC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACA,GAAGC;AAC0B,MAAM;AAC7BC,QAAAA,UAAUN,WAAW,UAAU;AAC/BO,QAAAA,UAAUC,MAAMX,IAAI,OAAO;AAC3BY,QAAAA,WAAWD,MAAMX,IAAI,QAAQ;AACnC,QAAMa,UAAUN;AAEhB,6BACGO,YAAU;AAAA,IAAAV,UACRA,CAAC;AAAA,MAAEW;AAAAA,IAAAA,0BACF,MAAA;AAAA,MACEf;AAAAA,MACAC,WAAWe,KACTf,WACAC,mCAASe,MACTC,gCAAgCD,MAChCF,IAAII,OAAOF,IAAI,CAAC;AAAA,MAElB,gBAAcd;AAAAA,MAASC,8BAEvB,OAAA;AAAA,QACEJ,IAAIY;AAAAA,QACJQ,MAAK;AAAA,QACLC,UAAU;AAAA,QACVhB;AAAAA,QACAC;AAAAA,QACAL,WAAWe,KACTd,mCAASoB,QACTJ,gCAAgCI,QAChCP,IAAII,OAAOG,MAAM,CAAC;AAAA,QAEpB,mBAAiBZ;AAAAA,QAAQ,GACrBF;AAAAA,QAAMJ,8BAETS,SAAO;AAAA,UACNb,IAAIU;AAAAA,UACJT,WAAWe,KACTd,mCAASqB,MACTL,gCAAgCK,MAChCR,IAAII,OAAOI,IAAI,GACfpB,YACEa,KACEd,mCAASC,UACTe,gCAAgCf,UAChCY,IAAII,OAAOhB,QAAQ,CAAC,CACrB;AAAA,UAELM;AAAAA,UAAiBL;AAAAA,QAAAA,CAER;AAAA,MAAA,CACD;AAAA,IAAA,CACN;AAAA,EAAA,CAGC;AAEjB;"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { theme } from "@hitachivantara/uikit-styles";
|
|
2
|
+
import scrollToHorizontalClasses from "../scrollToHorizontalClasses.js";
|
|
3
|
+
import { outlineStyles } from "../../../../utils/focusUtils.js";
|
|
4
|
+
const styles = {
|
|
5
|
+
root: {
|
|
6
|
+
padding: "10px 0"
|
|
7
|
+
},
|
|
8
|
+
button: {
|
|
9
|
+
display: "flex",
|
|
10
|
+
justifyContent: "center",
|
|
11
|
+
alignItems: "center",
|
|
12
|
+
height: theme.scrollTo.horizontal.buttonHeight,
|
|
13
|
+
cursor: "pointer",
|
|
14
|
+
borderBottom: theme.scrollTo.horizontal.buttonBottomBorder,
|
|
15
|
+
"&:hover": {
|
|
16
|
+
backgroundColor: theme.scrollTo.horizontal.buttonHoverBackgroundColor,
|
|
17
|
+
[`& .${scrollToHorizontalClasses.notSelected}`]: {
|
|
18
|
+
height: theme.scrollTo.dotHoverSize,
|
|
19
|
+
width: theme.scrollTo.dotHoverSize,
|
|
20
|
+
backgroundColor: theme.scrollTo.dotHoverColor
|
|
21
|
+
},
|
|
22
|
+
[`& .${scrollToHorizontalClasses.notSelectedRoot}`]: {
|
|
23
|
+
backgroundColor: theme.scrollTo.dotHoverBackgroundColor
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"&:focus": {
|
|
27
|
+
outline: "none"
|
|
28
|
+
},
|
|
29
|
+
"&:focus-visible": {
|
|
30
|
+
...outlineStyles
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
text: {
|
|
34
|
+
display: "flex",
|
|
35
|
+
flexDirection: "column",
|
|
36
|
+
alignItems: "center",
|
|
37
|
+
justifyContent: "center",
|
|
38
|
+
height: theme.scrollTo.horizontal.buttonHeight,
|
|
39
|
+
borderBottom: theme.scrollTo.horizontal.buttonBottomBorder,
|
|
40
|
+
"& p": {
|
|
41
|
+
padding: theme.scrollTo.horizontal.textPadding,
|
|
42
|
+
maxWidth: theme.scrollTo.horizontal.textMaxWidth,
|
|
43
|
+
textOverflow: "ellipsis",
|
|
44
|
+
overflow: "hidden"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
selected: {
|
|
48
|
+
borderBottom: theme.scrollTo.horizontal.selectedButtonBottomBorder
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
export {
|
|
52
|
+
styles
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=HorizontalScrollListItem.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HorizontalScrollListItem.styles.js","sources":["../../../../../../src/components/ScrollTo/Horizontal/HorizontalScrollListItem/HorizontalScrollListItem.styles.tsx"],"sourcesContent":["import { outlineStyles } from \"@core/utils\";\nimport { CSSInterpolation } from \"@emotion/serialize\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\nimport scrollToHorizontalClasses from \"../scrollToHorizontalClasses\";\n\nexport const styles: {\n root: CSSInterpolation;\n button: CSSInterpolation;\n text: CSSInterpolation;\n selected: CSSInterpolation;\n} = {\n root: {\n padding: \"10px 0\",\n },\n button: {\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n height: theme.scrollTo.horizontal.buttonHeight,\n cursor: \"pointer\",\n borderBottom: theme.scrollTo.horizontal.buttonBottomBorder,\n \"&:hover\": {\n backgroundColor: theme.scrollTo.horizontal.buttonHoverBackgroundColor,\n\n [`& .${scrollToHorizontalClasses.notSelected}`]: {\n height: theme.scrollTo.dotHoverSize,\n width: theme.scrollTo.dotHoverSize,\n backgroundColor: theme.scrollTo.dotHoverColor,\n },\n\n [`& .${scrollToHorizontalClasses.notSelectedRoot}`]: {\n backgroundColor: theme.scrollTo.dotHoverBackgroundColor,\n },\n },\n \"&:focus\": {\n outline: \"none\",\n },\n \"&:focus-visible\": {\n ...outlineStyles,\n },\n },\n text: {\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"center\",\n justifyContent: \"center\",\n height: theme.scrollTo.horizontal.buttonHeight,\n borderBottom: theme.scrollTo.horizontal.buttonBottomBorder,\n\n \"& p\": {\n padding: theme.scrollTo.horizontal.textPadding,\n maxWidth: theme.scrollTo.horizontal.textMaxWidth,\n textOverflow: \"ellipsis\",\n overflow: \"hidden\",\n },\n },\n selected: {\n borderBottom: theme.scrollTo.horizontal.selectedButtonBottomBorder,\n },\n};\n"],"names":["styles","root","padding","button","display","justifyContent","alignItems","height","theme","scrollTo","horizontal","buttonHeight","cursor","borderBottom","buttonBottomBorder","backgroundColor","buttonHoverBackgroundColor","scrollToHorizontalClasses","notSelected","dotHoverSize","width","dotHoverColor","notSelectedRoot","dotHoverBackgroundColor","outline","outlineStyles","text","flexDirection","textPadding","maxWidth","textMaxWidth","textOverflow","overflow","selected","selectedButtonBottomBorder"],"mappings":";;;AAKO,MAAMA,SAKT;AAAA,EACFC,MAAM;AAAA,IACJC,SAAS;AAAA,EACX;AAAA,EACAC,QAAQ;AAAA,IACNC,SAAS;AAAA,IACTC,gBAAgB;AAAA,IAChBC,YAAY;AAAA,IACZC,QAAQC,MAAMC,SAASC,WAAWC;AAAAA,IAClCC,QAAQ;AAAA,IACRC,cAAcL,MAAMC,SAASC,WAAWI;AAAAA,IACxC,WAAW;AAAA,MACTC,iBAAiBP,MAAMC,SAASC,WAAWM;AAAAA,MAE3C,CAAE,MAAKC,0BAA0BC,aAAa,GAAG;AAAA,QAC/CX,QAAQC,MAAMC,SAASU;AAAAA,QACvBC,OAAOZ,MAAMC,SAASU;AAAAA,QACtBJ,iBAAiBP,MAAMC,SAASY;AAAAA,MAClC;AAAA,MAEA,CAAE,MAAKJ,0BAA0BK,iBAAiB,GAAG;AAAA,QACnDP,iBAAiBP,MAAMC,SAASc;AAAAA,MAClC;AAAA,IACF;AAAA,IACA,WAAW;AAAA,MACTC,SAAS;AAAA,IACX;AAAA,IACA,mBAAmB;AAAA,MACjB,GAAGC;AAAAA,IACL;AAAA,EACF;AAAA,EACAC,MAAM;AAAA,IACJtB,SAAS;AAAA,IACTuB,eAAe;AAAA,IACfrB,YAAY;AAAA,IACZD,gBAAgB;AAAA,IAChBE,QAAQC,MAAMC,SAASC,WAAWC;AAAAA,IAClCE,cAAcL,MAAMC,SAASC,WAAWI;AAAAA,IAExC,OAAO;AAAA,MACLZ,SAASM,MAAMC,SAASC,WAAWkB;AAAAA,MACnCC,UAAUrB,MAAMC,SAASC,WAAWoB;AAAAA,MACpCC,cAAc;AAAA,MACdC,UAAU;AAAA,IACZ;AAAA,EACF;AAAA,EACAC,UAAU;AAAA,IACRpB,cAAcL,MAAMC,SAASC,WAAWwB;AAAAA,EAC1C;AACF;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { getClasses } from "../../../../utils/classes.js";
|
|
2
|
+
const classKeys = ["root", "selected", "button", "text"];
|
|
3
|
+
const horizontalScrollListItemClasses = getClasses(classKeys, "HvHorizontalScrollListItem");
|
|
4
|
+
const horizontalScrollListItemClasses$1 = horizontalScrollListItemClasses;
|
|
5
|
+
export {
|
|
6
|
+
horizontalScrollListItemClasses$1 as default
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=horizontalScrollListItemClasses.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"horizontalScrollListItemClasses.js","sources":["../../../../../../src/components/ScrollTo/Horizontal/HorizontalScrollListItem/horizontalScrollListItemClasses.ts"],"sourcesContent":["import { getClasses } from \"@core/utils\";\n\nexport interface HvHorizontalScrollListItemClasses {\n root?: string;\n selected?: string;\n button?: string;\n text?: string;\n}\n\nconst classKeys: string[] = [\"root\", \"selected\", \"button\", \"text\"];\n\nconst horizontalScrollListItemClasses =\n getClasses<HvHorizontalScrollListItemClasses>(\n classKeys,\n \"HvHorizontalScrollListItem\"\n );\n\nexport default horizontalScrollListItemClasses;\n"],"names":["classKeys","horizontalScrollListItemClasses","getClasses"],"mappings":";AASA,MAAMA,YAAsB,CAAC,QAAQ,YAAY,UAAU,MAAM;AAEjE,MAAMC,kCACJC,WACEF,WACA,4BAA4B;AAGhC,MAAA,oCAAeC;"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import scrollToHorizontalClasses from "./scrollToHorizontalClasses.js";
|
|
2
|
+
import { ClassNames } from "@emotion/react";
|
|
3
|
+
import { clsx } from "clsx";
|
|
4
|
+
import { styles } from "./ScrollToHorizontal.styles.js";
|
|
5
|
+
import { useScrollTo } from "../useScrollTo.js";
|
|
6
|
+
import { useMemo, useCallback } from "react";
|
|
7
|
+
import { withTooltip } from "../withTooltip.js";
|
|
8
|
+
import { useTheme } from "@mui/material/styles";
|
|
9
|
+
import { theme } from "@hitachivantara/uikit-styles";
|
|
10
|
+
import fade from "../../../utils/hexToRgbA.js";
|
|
11
|
+
import { CurrentStep } from "@hitachivantara/uikit-react-icons";
|
|
12
|
+
import { useMediaQuery } from "@mui/material";
|
|
13
|
+
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
14
|
+
import useUniqueId from "../../../hooks/useUniqueId.js";
|
|
15
|
+
import { HvHorizontalScrollListItem } from "./HorizontalScrollListItem/HorizontalScrollListItem.js";
|
|
16
|
+
import { useTheme as useTheme$1 } from "../../../hooks/useTheme.js";
|
|
17
|
+
import { setId } from "../../../utils/setId.js";
|
|
18
|
+
import { isKeypress } from "../../../utils/keyboardUtils/keyCheck.js";
|
|
19
|
+
import { keyboardCodes } from "../../../utils/keyboardUtils/keyboardCodes.js";
|
|
20
|
+
const {
|
|
21
|
+
Enter
|
|
22
|
+
} = keyboardCodes;
|
|
23
|
+
const HvScrollToHorizontal = ({
|
|
24
|
+
id,
|
|
25
|
+
defaultSelectedIndex = 0,
|
|
26
|
+
scrollElementId,
|
|
27
|
+
href = true,
|
|
28
|
+
onChange,
|
|
29
|
+
onClick,
|
|
30
|
+
onEnter,
|
|
31
|
+
className,
|
|
32
|
+
classes,
|
|
33
|
+
options,
|
|
34
|
+
offset = 0,
|
|
35
|
+
position = "relative",
|
|
36
|
+
tooltipPosition = "top",
|
|
37
|
+
...others
|
|
38
|
+
}) => {
|
|
39
|
+
const muiTheme = useTheme();
|
|
40
|
+
const downSm = useMediaQuery(muiTheme.breakpoints.down("sm"));
|
|
41
|
+
const upMd = useMediaQuery(muiTheme.breakpoints.up("md"));
|
|
42
|
+
const {
|
|
43
|
+
activeTheme,
|
|
44
|
+
selectedMode
|
|
45
|
+
} = useTheme$1();
|
|
46
|
+
const elementId = useUniqueId(id, "hvHorizontalScrollto");
|
|
47
|
+
const [selectedIndex, setScrollTo] = useScrollTo(defaultSelectedIndex, scrollElementId, href, offset, options, onChange);
|
|
48
|
+
const handleSelection = (event, value, index) => {
|
|
49
|
+
event.preventDefault();
|
|
50
|
+
const wrappedOnChange = () => {
|
|
51
|
+
onChange == null ? void 0 : onChange(event, index);
|
|
52
|
+
};
|
|
53
|
+
setScrollTo(event, value, index, wrappedOnChange);
|
|
54
|
+
};
|
|
55
|
+
const tooltipWrappers = useMemo(() => {
|
|
56
|
+
return options.map((option) => {
|
|
57
|
+
return withTooltip(option.label, "div", tooltipPosition);
|
|
58
|
+
});
|
|
59
|
+
}, [options, tooltipPosition]);
|
|
60
|
+
const NotSelected = useCallback(() => {
|
|
61
|
+
return /* @__PURE__ */ jsx(ClassNames, {
|
|
62
|
+
children: ({
|
|
63
|
+
css
|
|
64
|
+
}) => /* @__PURE__ */ jsx("div", {
|
|
65
|
+
className: clsx(classes == null ? void 0 : classes.notSelectedRoot, scrollToHorizontalClasses.notSelectedRoot, css(styles.notSelectedRoot)),
|
|
66
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
67
|
+
className: clsx(classes == null ? void 0 : classes.notSelected, scrollToHorizontalClasses.notSelected, css(styles.notSelected))
|
|
68
|
+
})
|
|
69
|
+
})
|
|
70
|
+
});
|
|
71
|
+
}, [classes == null ? void 0 : classes.notSelectedRoot, classes == null ? void 0 : classes.notSelected]);
|
|
72
|
+
const Selected = useCallback(() => {
|
|
73
|
+
return /* @__PURE__ */ jsx(ClassNames, {
|
|
74
|
+
children: ({
|
|
75
|
+
css
|
|
76
|
+
}) => /* @__PURE__ */ jsx(CurrentStep, {
|
|
77
|
+
height: activeTheme == null ? void 0 : activeTheme.scrollTo.dotSelectedSize,
|
|
78
|
+
width: activeTheme == null ? void 0 : activeTheme.scrollTo.dotSelectedSize,
|
|
79
|
+
className: clsx(classes == null ? void 0 : classes.selected, scrollToHorizontalClasses.selected, css(styles.selected))
|
|
80
|
+
})
|
|
81
|
+
});
|
|
82
|
+
}, [classes == null ? void 0 : classes.selected, activeTheme == null ? void 0 : activeTheme.scrollTo.dotSelectedSize]);
|
|
83
|
+
const tabs = options.map((option, index) => {
|
|
84
|
+
const selected = selectedIndex === index;
|
|
85
|
+
const tooltipWrapper = tooltipWrappers[index];
|
|
86
|
+
return /* @__PURE__ */ jsxs(HvHorizontalScrollListItem, {
|
|
87
|
+
id: setId(elementId, `item-${index}`),
|
|
88
|
+
onClick: (event) => {
|
|
89
|
+
handleSelection(event, option.value, index);
|
|
90
|
+
onClick == null ? void 0 : onClick(event, index);
|
|
91
|
+
},
|
|
92
|
+
onKeyDown: (event) => {
|
|
93
|
+
if (isKeypress(event, Enter) === true) {
|
|
94
|
+
handleSelection(event, option.value, index);
|
|
95
|
+
onEnter == null ? void 0 : onEnter(event, index);
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
tooltipWrapper,
|
|
99
|
+
selected,
|
|
100
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
101
|
+
children: option.label
|
|
102
|
+
}), selected ? /* @__PURE__ */ jsx(Selected, {}) : /* @__PURE__ */ jsx(NotSelected, {})]
|
|
103
|
+
}, option.key || option.label);
|
|
104
|
+
});
|
|
105
|
+
return /* @__PURE__ */ jsx(ClassNames, {
|
|
106
|
+
children: ({
|
|
107
|
+
css
|
|
108
|
+
}) => /* @__PURE__ */ jsx("ol", {
|
|
109
|
+
className: clsx(className, classes == null ? void 0 : classes.root, scrollToHorizontalClasses.root, css(styles.root), css({
|
|
110
|
+
width: position === "fixed" && (upMd || downSm) ? `calc(100% - 2*${theme.spacing(upMd ? 4 : 2)})` : "100%",
|
|
111
|
+
marginTop: 0,
|
|
112
|
+
marginBottom: 0,
|
|
113
|
+
marginRight: position === "fixed" && (upMd || downSm) ? theme.spacing(upMd ? 4 : 2) : 0,
|
|
114
|
+
marginLeft: position === "fixed" && (upMd || downSm) ? theme.spacing(upMd ? 4 : 2) : 0,
|
|
115
|
+
backgroundColor: fade(activeTheme == null ? void 0 : activeTheme.colors.modes[selectedMode].atmo2, activeTheme == null ? void 0 : activeTheme.scrollTo.backgroundColorOpacity)
|
|
116
|
+
}), position === "sticky" && clsx(classes == null ? void 0 : classes.positionSticky, scrollToHorizontalClasses.positionSticky, css(styles.positionSticky)), position === "fixed" && clsx(classes == null ? void 0 : classes.positionFixed, scrollToHorizontalClasses.positionFixed, css(styles.positionFixed))),
|
|
117
|
+
id: elementId,
|
|
118
|
+
...others,
|
|
119
|
+
children: tabs
|
|
120
|
+
})
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
export {
|
|
124
|
+
HvScrollToHorizontal
|
|
125
|
+
};
|
|
126
|
+
//# sourceMappingURL=ScrollToHorizontal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScrollToHorizontal.js","sources":["../../../../../src/components/ScrollTo/Horizontal/ScrollToHorizontal.tsx"],"sourcesContent":["import { HvBaseProps } from \"@core/types\";\nimport scrollToHorizontalClasses, {\n HvScrollToHorizontalClasses,\n} from \"./scrollToHorizontalClasses\";\nimport { ClassNames } from \"@emotion/react\";\nimport { clsx } from \"clsx\";\nimport { useTheme, useUniqueId } from \"@core/hooks\";\nimport { styles } from \"./ScrollToHorizontal.styles\";\nimport { useScrollTo } from \"../useScrollTo\";\nimport { HvHorizontalScrollListItem } from \"./HorizontalScrollListItem\";\nimport { isKeypress, keyboardCodes, setId } from \"@core/utils\";\nimport { useCallback, useMemo } from \"react\";\nimport { withTooltip } from \"../withTooltip\";\nimport { useTheme as useMuiTheme } from \"@mui/material/styles\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\nimport fade from \"@core/utils/hexToRgbA\";\nimport { HvScrollToTooltipPositions } from \"../types\";\nimport { CurrentStep } from \"@hitachivantara/uikit-react-icons\";\nimport { useMediaQuery } from \"@mui/material\";\n\nconst { Enter } = keyboardCodes;\n\nexport interface HvScrollToHorizontalOption {\n key?: string;\n label: string;\n value: string;\n offset?: number;\n}\n\nexport type HvScrollToHorizontalPositions = \"sticky\" | \"fixed\" | \"relative\";\n\nexport interface HvScrollToHorizontalProps\n extends HvBaseProps<HTMLOListElement, { onChange; onClick }> {\n /** An Array of Objects with Label and Value. Label is the displayed Element and Value is the local navigation location applied */\n options: HvScrollToHorizontalOption[];\n /** True if the href location link should be applied. It will create an a element around every list item */\n href?: boolean;\n /** Default selected index passed from the parent. */\n defaultSelectedIndex?: number;\n /**\n * The Id of the scrollable container containing displayed elements.\n *\n * Defaults to `window` if unspecified.\n */\n scrollElementId?: string;\n /**\n * Defines the offset from the top of each element for getting an optimal viewing region in the container.\n * This allows to exclude regions of the container that are obscured by other content (such as fixed-positioned toolbars or titles)\n * or to put more breathing room between the targeted element and the edges of the container.\n *\n * Each element can also have a specific offset via the options property.\n */\n offset?: number;\n /** Position of the Horizontal scroll to. */\n position?: HvScrollToHorizontalPositions;\n /** Position of tooltip identifying the current item. */\n tooltipPosition?: HvScrollToTooltipPositions;\n /** A function called each time the selected index changes. */\n onChange?: (\n event:\n | Event\n | React.MouseEvent<HTMLDivElement>\n | React.KeyboardEvent<HTMLDivElement>,\n index: number\n ) => void;\n /** A function called each time an user clicks on a tab element. */\n onClick?: (event: React.MouseEvent<HTMLDivElement>, index: number) => void;\n /** A function called each time an user press enter on a tab element. */\n onEnter?: (event: React.KeyboardEvent<HTMLDivElement>, index: number) => void;\n /** A Jss Object used to override or extend the styles applied. */\n classes?: HvScrollToHorizontalClasses;\n}\n\n/**\n * The horizontal scroll to element can be used to quickly navigate in a page.\n */\nexport const HvScrollToHorizontal = ({\n id,\n defaultSelectedIndex = 0,\n scrollElementId,\n href = true,\n onChange,\n onClick,\n onEnter,\n className,\n classes,\n options,\n offset = 0,\n position = \"relative\",\n tooltipPosition = \"top\",\n ...others\n}: HvScrollToHorizontalProps) => {\n const muiTheme = useMuiTheme();\n\n const downSm = useMediaQuery(muiTheme.breakpoints.down(\"sm\"));\n const upMd = useMediaQuery(muiTheme.breakpoints.up(\"md\"));\n\n const { activeTheme, selectedMode } = useTheme();\n\n const elementId = useUniqueId(id, \"hvHorizontalScrollto\");\n\n const [selectedIndex, setScrollTo] = useScrollTo(\n defaultSelectedIndex,\n scrollElementId,\n href,\n offset,\n options,\n onChange\n );\n\n const handleSelection = (\n event:\n | React.MouseEvent<HTMLDivElement>\n | React.KeyboardEvent<HTMLDivElement>,\n value: string,\n index: number\n ) => {\n event.preventDefault();\n\n const wrappedOnChange = () => {\n onChange?.(event, index);\n };\n\n setScrollTo(event, value, index, wrappedOnChange);\n };\n\n const tooltipWrappers = useMemo(() => {\n return options.map((option) => {\n return withTooltip(option.label, \"div\", tooltipPosition);\n });\n }, [options, tooltipPosition]);\n\n const NotSelected = useCallback(() => {\n return (\n <ClassNames>\n {({ css }) => (\n <div\n className={clsx(\n classes?.notSelectedRoot,\n scrollToHorizontalClasses.notSelectedRoot,\n css(styles.notSelectedRoot)\n )}\n >\n <div\n className={clsx(\n classes?.notSelected,\n scrollToHorizontalClasses.notSelected,\n css(styles.notSelected)\n )}\n />\n </div>\n )}\n </ClassNames>\n );\n }, [classes?.notSelectedRoot, classes?.notSelected]);\n\n const Selected = useCallback(() => {\n return (\n <ClassNames>\n {({ css }) => (\n <CurrentStep\n height={activeTheme?.scrollTo.dotSelectedSize}\n width={activeTheme?.scrollTo.dotSelectedSize}\n className={clsx(\n classes?.selected,\n scrollToHorizontalClasses.selected,\n css(styles.selected)\n )}\n />\n )}\n </ClassNames>\n );\n }, [classes?.selected, activeTheme?.scrollTo.dotSelectedSize]);\n\n const tabs = options.map((option, index) => {\n const selected = selectedIndex === index;\n const tooltipWrapper = tooltipWrappers[index];\n\n return (\n <HvHorizontalScrollListItem\n id={setId(elementId, `item-${index}`)}\n onClick={(event) => {\n handleSelection(event, option.value, index);\n onClick?.(event, index);\n }}\n onKeyDown={(event) => {\n if (isKeypress(event, Enter) === true) {\n handleSelection(event, option.value, index);\n onEnter?.(event, index);\n }\n }}\n tooltipWrapper={tooltipWrapper}\n selected={selected}\n key={option.key || option.label}\n >\n <p>{option.label}</p>\n {selected ? <Selected /> : <NotSelected />}\n </HvHorizontalScrollListItem>\n );\n });\n\n return (\n <ClassNames>\n {({ css }) => (\n <ol\n className={clsx(\n className,\n classes?.root,\n scrollToHorizontalClasses.root,\n css(styles.root),\n css({\n width:\n position === \"fixed\" && (upMd || downSm)\n ? `calc(100% - 2*${theme.spacing(upMd ? 4 : 2)})`\n : \"100%\",\n marginTop: 0,\n marginBottom: 0,\n marginRight:\n position === \"fixed\" && (upMd || downSm)\n ? theme.spacing(upMd ? 4 : 2)\n : 0,\n marginLeft:\n position === \"fixed\" && (upMd || downSm)\n ? theme.spacing(upMd ? 4 : 2)\n : 0,\n backgroundColor: fade(\n activeTheme?.colors.modes[selectedMode].atmo2,\n activeTheme?.scrollTo.backgroundColorOpacity\n ),\n }),\n position === \"sticky\" &&\n clsx(\n classes?.positionSticky,\n scrollToHorizontalClasses.positionSticky,\n css(styles.positionSticky)\n ),\n position === \"fixed\" &&\n clsx(\n classes?.positionFixed,\n scrollToHorizontalClasses.positionFixed,\n css(styles.positionFixed)\n )\n )}\n id={elementId}\n {...others}\n >\n {tabs}\n </ol>\n )}\n </ClassNames>\n );\n};\n"],"names":["Enter","keyboardCodes","HvScrollToHorizontal","id","defaultSelectedIndex","scrollElementId","href","onChange","onClick","onEnter","className","classes","options","offset","position","tooltipPosition","others","muiTheme","useMuiTheme","downSm","useMediaQuery","breakpoints","down","upMd","up","activeTheme","selectedMode","useTheme","elementId","useUniqueId","selectedIndex","setScrollTo","useScrollTo","handleSelection","event","value","index","preventDefault","wrappedOnChange","tooltipWrappers","useMemo","map","option","withTooltip","label","NotSelected","useCallback","ClassNames","children","css","clsx","notSelectedRoot","scrollToHorizontalClasses","styles","notSelected","Selected","CurrentStep","height","scrollTo","dotSelectedSize","width","selected","tabs","tooltipWrapper","HvHorizontalScrollListItem","setId","onKeyDown","isKeypress","_jsx","key","root","theme","spacing","marginTop","marginBottom","marginRight","marginLeft","backgroundColor","fade","colors","modes","atmo2","backgroundColorOpacity","positionSticky","positionFixed"],"mappings":";;;;;;;;;;;;;;;;;;;AAoBA,MAAM;AAAA,EAAEA;AAAM,IAAIC;AAwDX,MAAMC,uBAAuBA,CAAC;AAAA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AA,aAAc,CAAA,CAAA,CAAA;AAAA,IAHrCH,GAAAA,OAAO2B,OAAO3B,OAAOE,KAAK;AAAA,EAAA,CAMpC;AAED,6BACGG,YAAU;AAAA,IAAAC,UACRA,CAAC;AAAA,MAAEC;AAAAA,IAAAA,0BACF,MAAA;AAAA,MACEvC,WAAWwC,KACTxC,WACAC,mCAAS2D,MACTlB,0BAA0BkB,MAC1BrB,IAAII,OAAOiB,IAAI,GACfrB,IAAI;AAAA,QACFW,OACE9C,aAAa,YAAYS,QAAQJ,UAC5B,iBAAgBoD,MAAMC,QAAQjD,OAAO,IAAI,CAAC,OAC3C;AAAA,QACNkD,WAAW;AAAA,QACXC,cAAc;AAAA,QACdC,aACE7D,aAAa,YAAYS,QAAQJ,UAC7BoD,MAAMC,QAAQjD,OAAO,IAAI,CAAC,IAC1B;AAAA,QACNqD,YACE9D,aAAa,YAAYS,QAAQJ,UAC7BoD,MAAMC,QAAQjD,OAAO,IAAI,CAAC,IAC1B;AAAA,QACNsD,iBAAiBC,KACfrD,2CAAasD,OAAOC,MAAMtD,cAAcuD,OACxCxD,2CAAaiC,SAASwB,sBAAsB;AAAA,MAE/C,CAAA,GACDpE,aAAa,YACXoC,KACEvC,mCAASwE,gBACT/B,0BAA0B+B,gBAC1BlC,IAAII,OAAO8B,cAAc,CAAC,GAE9BrE,aAAa,WACXoC,KACEvC,mCAASyE,eACThC,0BAA0BgC,eAC1BnC,IAAII,OAAO+B,aAAa,CAAC,CAC1B;AAAA,MAELjF,IAAIyB;AAAAA,MAAU,GACVZ;AAAAA,MAAMgC,UAETc;AAAAA,IAAAA,CAAI;AAAA,EAAA,CAGE;AAEjB;"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { theme } from "@hitachivantara/uikit-styles";
|
|
2
|
+
const styles = {
|
|
3
|
+
root: {
|
|
4
|
+
display: "flex",
|
|
5
|
+
padding: "0 30px",
|
|
6
|
+
listStyleType: "none",
|
|
7
|
+
flexWrap: "wrap",
|
|
8
|
+
backdropFilter: `blur(${theme.scrollTo.backgroundColorBlur})`
|
|
9
|
+
},
|
|
10
|
+
positionSticky: {
|
|
11
|
+
position: "sticky",
|
|
12
|
+
zIndex: `calc(${theme.zIndices.banner} - 2)`,
|
|
13
|
+
top: 0,
|
|
14
|
+
left: 0
|
|
15
|
+
},
|
|
16
|
+
positionFixed: {
|
|
17
|
+
position: "fixed",
|
|
18
|
+
zIndex: `calc(${theme.zIndices.banner} - 2)`,
|
|
19
|
+
top: 0,
|
|
20
|
+
left: 0
|
|
21
|
+
},
|
|
22
|
+
notSelectedRoot: {
|
|
23
|
+
display: theme.scrollTo.horizontal.dotDisplay,
|
|
24
|
+
justifyContent: "center",
|
|
25
|
+
alignItems: "center",
|
|
26
|
+
height: theme.scrollTo.dotRootSize,
|
|
27
|
+
width: theme.scrollTo.dotRootSize,
|
|
28
|
+
borderRadius: theme.scrollTo.dotRootRadius
|
|
29
|
+
},
|
|
30
|
+
notSelected: {
|
|
31
|
+
height: theme.scrollTo.dotNotSelectedSize,
|
|
32
|
+
width: theme.scrollTo.dotNotSelectedSize,
|
|
33
|
+
borderRadius: "50%",
|
|
34
|
+
display: "inline-block",
|
|
35
|
+
backgroundColor: theme.scrollTo.dotNotSelectedColor
|
|
36
|
+
},
|
|
37
|
+
selected: {
|
|
38
|
+
display: theme.scrollTo.horizontal.dotDisplay,
|
|
39
|
+
height: theme.scrollTo.dotRootSize,
|
|
40
|
+
width: theme.scrollTo.dotRootSize
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
export {
|
|
44
|
+
styles
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=ScrollToHorizontal.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScrollToHorizontal.styles.js","sources":["../../../../../src/components/ScrollTo/Horizontal/ScrollToHorizontal.styles.tsx"],"sourcesContent":["import { CSSInterpolation } from \"@emotion/serialize\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nexport const styles: {\n root: CSSInterpolation;\n positionSticky: CSSInterpolation;\n positionFixed: CSSInterpolation;\n notSelectedRoot: CSSInterpolation;\n notSelected: CSSInterpolation;\n selected: CSSInterpolation;\n} = {\n root: {\n display: \"flex\",\n padding: \"0 30px\",\n listStyleType: \"none\",\n flexWrap: \"wrap\",\n backdropFilter: `blur(${theme.scrollTo.backgroundColorBlur})`,\n },\n positionSticky: {\n position: \"sticky\",\n zIndex: `calc(${theme.zIndices.banner} - 2)`,\n top: 0,\n left: 0,\n },\n positionFixed: {\n position: \"fixed\",\n zIndex: `calc(${theme.zIndices.banner} - 2)`,\n top: 0,\n left: 0,\n },\n notSelectedRoot: {\n display: theme.scrollTo.horizontal.dotDisplay,\n justifyContent: \"center\",\n alignItems: \"center\",\n height: theme.scrollTo.dotRootSize,\n width: theme.scrollTo.dotRootSize,\n borderRadius: theme.scrollTo.dotRootRadius,\n },\n notSelected: {\n height: theme.scrollTo.dotNotSelectedSize,\n width: theme.scrollTo.dotNotSelectedSize,\n borderRadius: \"50%\",\n display: \"inline-block\",\n backgroundColor: theme.scrollTo.dotNotSelectedColor,\n },\n selected: {\n display: theme.scrollTo.horizontal.dotDisplay,\n height: theme.scrollTo.dotRootSize,\n width: theme.scrollTo.dotRootSize,\n },\n};\n"],"names":["styles","root","display","padding","listStyleType","flexWrap","backdropFilter","theme","scrollTo","backgroundColorBlur","positionSticky","position","zIndex","zIndices","banner","top","left","positionFixed","notSelectedRoot","horizontal","dotDisplay","justifyContent","alignItems","height","dotRootSize","width","borderRadius","dotRootRadius","notSelected","dotNotSelectedSize","backgroundColor","dotNotSelectedColor","selected"],"mappings":";AAGO,MAAMA,SAOT;AAAA,EACFC,MAAM;AAAA,IACJC,SAAS;AAAA,IACTC,SAAS;AAAA,IACTC,eAAe;AAAA,IACfC,UAAU;AAAA,IACVC,gBAAiB,QAAOC,MAAMC,SAASC;AAAAA,EACzC;AAAA,EACAC,gBAAgB;AAAA,IACdC,UAAU;AAAA,IACVC,QAAS,QAAOL,MAAMM,SAASC;AAAAA,IAC/BC,KAAK;AAAA,IACLC,MAAM;AAAA,EACR;AAAA,EACAC,eAAe;AAAA,IACbN,UAAU;AAAA,IACVC,QAAS,QAAOL,MAAMM,SAASC;AAAAA,IAC/BC,KAAK;AAAA,IACLC,MAAM;AAAA,EACR;AAAA,EACAE,iBAAiB;AAAA,IACfhB,SAASK,MAAMC,SAASW,WAAWC;AAAAA,IACnCC,gBAAgB;AAAA,IAChBC,YAAY;AAAA,IACZC,QAAQhB,MAAMC,SAASgB;AAAAA,IACvBC,OAAOlB,MAAMC,SAASgB;AAAAA,IACtBE,cAAcnB,MAAMC,SAASmB;AAAAA,EAC/B;AAAA,EACAC,aAAa;AAAA,IACXL,QAAQhB,MAAMC,SAASqB;AAAAA,IACvBJ,OAAOlB,MAAMC,SAASqB;AAAAA,IACtBH,cAAc;AAAA,IACdxB,SAAS;AAAA,IACT4B,iBAAiBvB,MAAMC,SAASuB;AAAAA,EAClC;AAAA,EACAC,UAAU;AAAA,IACR9B,SAASK,MAAMC,SAASW,WAAWC;AAAAA,IACnCG,QAAQhB,MAAMC,SAASgB;AAAAA,IACvBC,OAAOlB,MAAMC,SAASgB;AAAAA,EACxB;AACF;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { getClasses } from "../../../utils/classes.js";
|
|
2
|
+
const classKeys = ["root", "positionSticky", "positionFixed", "notSelectedRoot", "notSelected", "selected"];
|
|
3
|
+
const scrollToHorizontalClasses = getClasses(classKeys, "HvScrollToHorizontal");
|
|
4
|
+
const scrollToHorizontalClasses$1 = scrollToHorizontalClasses;
|
|
5
|
+
export {
|
|
6
|
+
scrollToHorizontalClasses$1 as default
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=scrollToHorizontalClasses.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scrollToHorizontalClasses.js","sources":["../../../../../src/components/ScrollTo/Horizontal/scrollToHorizontalClasses.ts"],"sourcesContent":["import { getClasses } from \"@core/utils\";\n\nexport interface HvScrollToHorizontalClasses {\n root?: string;\n positionSticky?: string;\n positionFixed?: string;\n notSelectedRoot?: string;\n notSelected?: string;\n selected?: string;\n}\n\nconst classKeys: string[] = [\n \"root\",\n \"positionSticky\",\n \"positionFixed\",\n \"notSelectedRoot\",\n \"notSelected\",\n \"selected\",\n];\n\nconst scrollToHorizontalClasses = getClasses<HvScrollToHorizontalClasses>(\n classKeys,\n \"HvScrollToHorizontal\"\n);\n\nexport default scrollToHorizontalClasses;\n"],"names":["classKeys","scrollToHorizontalClasses","getClasses"],"mappings":";AAWA,MAAMA,YAAsB,CAC1B,QACA,kBACA,iBACA,mBACA,eACA,UAAU;AAGZ,MAAMC,4BAA4BC,WAChCF,WACA,sBAAsB;AAGxB,MAAA,8BAAeC;"}
|