@team-monolith/cds 0.13.0 → 0.14.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/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/patterns/SegmentedControl/SegmentedControlButton.d.ts +8 -0
- package/dist/patterns/SegmentedControl/SegmentedControlButton.js +49 -0
- package/dist/patterns/SegmentedControl/SegmentedControlGroup.d.ts +25 -0
- package/dist/patterns/SegmentedControl/SegmentedControlGroup.js +50 -0
- package/dist/patterns/SegmentedControl/SegmentedControlGroupPropsContext.d.ts +5 -0
- package/dist/patterns/SegmentedControl/SegmentedControlGroupPropsContext.js +5 -0
- package/dist/patterns/SegmentedControl/SegmentedControlSquareButton.d.ts +8 -0
- package/dist/patterns/SegmentedControl/SegmentedControlSquareButton.js +44 -0
- package/dist/patterns/SegmentedControl/index.d.ts +3 -0
- package/dist/patterns/SegmentedControl/index.js +3 -0
- package/dist/utils/zIndex.d.ts +6 -0
- package/dist/utils/zIndex.js +10 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ButtonProps } from "../..";
|
|
2
|
+
export interface SegmentedControlButtonProps extends Omit<ButtonProps, "color" | "size"> {
|
|
3
|
+
value: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* [피그마](https://www.figma.com/file/PnQp3tPxiCjgsPZfLUaUL1/Codle-PD-Kit---Patterns?node-id=181%3A89883)
|
|
7
|
+
*/
|
|
8
|
+
export declare function SegmentedControlButton(props: SegmentedControlButtonProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
var __assign = (this && this.__assign) || function () {
|
|
6
|
+
__assign = Object.assign || function(t) {
|
|
7
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8
|
+
s = arguments[i];
|
|
9
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10
|
+
t[p] = s[p];
|
|
11
|
+
}
|
|
12
|
+
return t;
|
|
13
|
+
};
|
|
14
|
+
return __assign.apply(this, arguments);
|
|
15
|
+
};
|
|
16
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
17
|
+
var t = {};
|
|
18
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
19
|
+
t[p] = s[p];
|
|
20
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
21
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
22
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
23
|
+
t[p[i]] = s[p[i]];
|
|
24
|
+
}
|
|
25
|
+
return t;
|
|
26
|
+
};
|
|
27
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
28
|
+
/** @jsxImportSource @emotion/react */
|
|
29
|
+
import { css } from "@emotion/react";
|
|
30
|
+
import { useContext } from "react";
|
|
31
|
+
import { SegmentedControlGroupPropsContext } from "./SegmentedControlGroupPropsContext";
|
|
32
|
+
import { Button, shadows } from "../..";
|
|
33
|
+
/**
|
|
34
|
+
* [피그마](https://www.figma.com/file/PnQp3tPxiCjgsPZfLUaUL1/Codle-PD-Kit---Patterns?node-id=181%3A89883)
|
|
35
|
+
*/
|
|
36
|
+
export function SegmentedControlButton(props) {
|
|
37
|
+
var onClick = props.onClick, other = __rest(props, ["onClick"]);
|
|
38
|
+
var context = useContext(SegmentedControlGroupPropsContext);
|
|
39
|
+
var handleClick = function (e) {
|
|
40
|
+
var _a;
|
|
41
|
+
(_a = context.onClick) === null || _a === void 0 ? void 0 : _a.call(context, props.value);
|
|
42
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
43
|
+
};
|
|
44
|
+
var isActive = context.multiSelect
|
|
45
|
+
? context.value.includes(props.value)
|
|
46
|
+
: context.value === props.value;
|
|
47
|
+
return (_jsx(Button, __assign({ css: css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n justify-content: center;\n flex-grow: 1;\n ", "\n "], ["\n display: flex;\n justify-content: center;\n flex-grow: 1;\n ", "\n "])), isActive && "box-shadow: ".concat(shadows.shadow04, ";")) }, other, { color: isActive ? "primary" : "textNeutral", size: context.size, onClick: handleClick })));
|
|
48
|
+
}
|
|
49
|
+
var templateObject_1;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ButtonSize, SquareButtonSize } from "../..";
|
|
3
|
+
export type SegmentedControlGroupProps = {
|
|
4
|
+
className?: string;
|
|
5
|
+
component?: React.ElementType;
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
/** 컴포넌트 크기 */
|
|
8
|
+
size: ButtonSize | SquareButtonSize;
|
|
9
|
+
/** 전체 너비 유무 */
|
|
10
|
+
fullWidth?: boolean;
|
|
11
|
+
} & ({
|
|
12
|
+
/** 중복 선택 가능 유무 */
|
|
13
|
+
multiSelect?: false;
|
|
14
|
+
/** 선택된 값 */
|
|
15
|
+
value: string | undefined;
|
|
16
|
+
onChange?: (newValue: string) => void;
|
|
17
|
+
} | {
|
|
18
|
+
multiSelect: true;
|
|
19
|
+
value: string[];
|
|
20
|
+
onChange?: (newValue: string[]) => void;
|
|
21
|
+
});
|
|
22
|
+
/**
|
|
23
|
+
* [피그마](https://www.figma.com/file/PnQp3tPxiCjgsPZfLUaUL1/Codle-PD-Kit---Patterns?node-id=181%3A89883)
|
|
24
|
+
*/
|
|
25
|
+
export declare function SegmentedControlGroup(props: SegmentedControlGroupProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
var __assign = (this && this.__assign) || function () {
|
|
6
|
+
__assign = Object.assign || function(t) {
|
|
7
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8
|
+
s = arguments[i];
|
|
9
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10
|
+
t[p] = s[p];
|
|
11
|
+
}
|
|
12
|
+
return t;
|
|
13
|
+
};
|
|
14
|
+
return __assign.apply(this, arguments);
|
|
15
|
+
};
|
|
16
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
17
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
18
|
+
if (ar || !(i in from)) {
|
|
19
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
20
|
+
ar[i] = from[i];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
24
|
+
};
|
|
25
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
26
|
+
/** @jsxImportSource @emotion/react */
|
|
27
|
+
import { css, useTheme } from "@emotion/react";
|
|
28
|
+
import { SegmentedControlGroupPropsContext } from "./SegmentedControlGroupPropsContext";
|
|
29
|
+
/**
|
|
30
|
+
* [피그마](https://www.figma.com/file/PnQp3tPxiCjgsPZfLUaUL1/Codle-PD-Kit---Patterns?node-id=181%3A89883)
|
|
31
|
+
*/
|
|
32
|
+
export function SegmentedControlGroup(props) {
|
|
33
|
+
var _a = props.component, Component = _a === void 0 ? "div" : _a, className = props.className, children = props.children, fullWidth = props.fullWidth, multiSelect = props.multiSelect;
|
|
34
|
+
var theme = useTheme();
|
|
35
|
+
return (_jsx(Component, __assign({ className: className, css: css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n gap: 4px;\n\n width: ", ";\n background-color: ", ";\n border-radius: 8px;\n border: 1px solid ", ";\n "], ["\n display: flex;\n gap: 4px;\n\n width: ", ";\n background-color: ", ";\n border-radius: 8px;\n border: 1px solid ", ";\n "])), fullWidth ? "100%" : "fit-content", theme.color.background.neutralAlt, theme.color.background.neutralAltActive) }, { children: _jsx(SegmentedControlGroupPropsContext.Provider, __assign({ value: __assign(__assign({}, props), { onClick: function (newValue) {
|
|
36
|
+
var _a, _b, _c;
|
|
37
|
+
if (multiSelect) {
|
|
38
|
+
if (props.value.includes(newValue)) {
|
|
39
|
+
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, props.value.filter(function (value) { return value !== newValue; }));
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
(_b = props.onChange) === null || _b === void 0 ? void 0 : _b.call(props, __spreadArray(__spreadArray([], props.value, true), [newValue], false));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
(_c = props.onChange) === null || _c === void 0 ? void 0 : _c.call(props, newValue);
|
|
47
|
+
}
|
|
48
|
+
} }) }, { children: children })) })));
|
|
49
|
+
}
|
|
50
|
+
var templateObject_1;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { SegmentedControlGroupProps } from "./SegmentedControlGroup";
|
|
3
|
+
export declare const SegmentedControlGroupPropsContext: import("react").Context<SegmentedControlGroupProps & {
|
|
4
|
+
onClick?: ((newValue: string) => void) | undefined;
|
|
5
|
+
}>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SquareButtonProps } from "../..";
|
|
2
|
+
export interface SegmentedControlSquareButtonProps extends Omit<SquareButtonProps, "color" | "size"> {
|
|
3
|
+
value: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* [피그마](https://www.figma.com/file/PnQp3tPxiCjgsPZfLUaUL1/Codle-PD-Kit---Patterns?node-id=181%3A89883)
|
|
7
|
+
*/
|
|
8
|
+
export declare function SegmentedControlSquareButton(props: SegmentedControlSquareButtonProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
var __assign = (this && this.__assign) || function () {
|
|
6
|
+
__assign = Object.assign || function(t) {
|
|
7
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8
|
+
s = arguments[i];
|
|
9
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10
|
+
t[p] = s[p];
|
|
11
|
+
}
|
|
12
|
+
return t;
|
|
13
|
+
};
|
|
14
|
+
return __assign.apply(this, arguments);
|
|
15
|
+
};
|
|
16
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
17
|
+
/** @jsxImportSource @emotion/react */
|
|
18
|
+
import styled from "@emotion/styled";
|
|
19
|
+
import { useContext } from "react";
|
|
20
|
+
import { shadows, SquareButton, } from "../..";
|
|
21
|
+
import { SegmentedControlGroupPropsContext } from "./SegmentedControlGroupPropsContext";
|
|
22
|
+
/**
|
|
23
|
+
* [피그마](https://www.figma.com/file/PnQp3tPxiCjgsPZfLUaUL1/Codle-PD-Kit---Patterns?node-id=181%3A89883)
|
|
24
|
+
*/
|
|
25
|
+
export function SegmentedControlSquareButton(props) {
|
|
26
|
+
var context = useContext(SegmentedControlGroupPropsContext);
|
|
27
|
+
var isActive = context.multiSelect
|
|
28
|
+
? context.value.includes(props.value)
|
|
29
|
+
: context.value === props.value;
|
|
30
|
+
return (_jsx(StyledSquareButton, __assign({}, props, { isActive: isActive, color: isActive ? "primary" : "icon", size: context.size, fullWidth: context.fullWidth, onClick: function () {
|
|
31
|
+
var _a;
|
|
32
|
+
if (context.onClick) {
|
|
33
|
+
context.onClick(props.value);
|
|
34
|
+
(_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
35
|
+
}
|
|
36
|
+
} })));
|
|
37
|
+
}
|
|
38
|
+
var StyledSquareButton = styled(SquareButton, {
|
|
39
|
+
shouldForwardProp: function (prop) { return prop !== "isActive"; },
|
|
40
|
+
})(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n justify-content: center;\n flex-grow: 1;\n button {\n ", "\n }\n"], ["\n display: flex;\n justify-content: center;\n flex-grow: 1;\n button {\n ", "\n }\n"])), function (_a) {
|
|
41
|
+
var isActive = _a.isActive;
|
|
42
|
+
return isActive && "box-shadow: ".concat(shadows.shadow04, ";");
|
|
43
|
+
});
|
|
44
|
+
var templateObject_1;
|
package/dist/utils/zIndex.d.ts
CHANGED
package/dist/utils/zIndex.js
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
// ZINDEX의 내용이 CDS에 적합하지 의문이 있다.
|
|
2
|
+
// 이 곳의 정보가 직접 사용되는 컴포넌트가 많지 않고
|
|
3
|
+
// 사용하는 주체 (코들, 주피터)에서 결정해야하는 경우가 많기 때문이다.
|
|
4
|
+
// https://www.figma.com/file/2p3WzTRpZQ97A37HVXM1Sc/master?type=design&node-id=402-48963&mode=design&t=YFltSOZZy7PAYK3x-0
|
|
1
5
|
export var ZINDEX = {
|
|
6
|
+
FAB: 900,
|
|
7
|
+
GUIDE: 800,
|
|
8
|
+
ALERT: 700,
|
|
9
|
+
DIALOG: 600,
|
|
10
|
+
NAV: 500,
|
|
11
|
+
MOBILE_NAV_MODAL: 490,
|
|
2
12
|
inputBase: 1, // https://github.com/mui/material-ui/blob/master/packages/mui-material/src/internal/SwitchBase.js#L35
|
|
3
13
|
};
|