@atlaskit/primitives 0.9.0 → 0.9.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/CHANGELOG.md +6 -0
- package/constellation/inline/code.mdx +1 -1
- package/constellation/stack/code.mdx +1 -1
- package/constellation/xcss/examples.mdx +21 -0
- package/constellation/xcss/logo.png +0 -0
- package/constellation/xcss/migration.mdx +142 -0
- package/constellation/xcss/usage.mdx +115 -0
- package/dist/cjs/components/box.js +1 -1
- package/dist/cjs/components/inline.js +1 -1
- package/dist/cjs/components/internal/base-box.js +1 -1
- package/dist/cjs/components/stack.js +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/{internal → xcss}/xcss.js +20 -8
- package/dist/es2019/components/box.js +1 -1
- package/dist/es2019/components/inline.js +1 -1
- package/dist/es2019/components/internal/base-box.js +1 -1
- package/dist/es2019/components/stack.js +1 -1
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/{internal → xcss}/xcss.js +19 -6
- package/dist/esm/components/box.js +1 -1
- package/dist/esm/components/inline.js +1 -1
- package/dist/esm/components/internal/base-box.js +1 -1
- package/dist/esm/components/stack.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/esm/{internal → xcss}/xcss.js +20 -8
- package/dist/types/components/inline.d.ts +1 -1
- package/dist/types/components/internal/base-box.d.ts +1 -1
- package/dist/types/components/stack.d.ts +1 -1
- package/dist/types/components/types.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/{internal → xcss}/style-maps.partial.d.ts +3 -0
- package/dist/types/{internal → xcss}/xcss.d.ts +17 -10
- package/package.json +11 -2
- package/report.api.md +8 -5
- package/tmp/api-report-tmp.d.ts +674 -0
- package/dist/cjs/components/internal/extract-react-types/inline-props.js +0 -7
- package/dist/cjs/components/internal/extract-react-types/stack-props.js +0 -7
- package/dist/es2019/components/internal/extract-react-types/inline-props.js +0 -1
- package/dist/es2019/components/internal/extract-react-types/stack-props.js +0 -1
- package/dist/esm/components/internal/extract-react-types/inline-props.js +0 -1
- package/dist/esm/components/internal/extract-react-types/stack-props.js +0 -1
- package/dist/types/components/internal/extract-react-types/inline-props.d.ts +0 -2
- package/dist/types/components/internal/extract-react-types/stack-props.d.ts +0 -2
- /package/dist/cjs/{internal → xcss}/style-maps.partial.js +0 -0
- /package/dist/es2019/{internal → xcss}/style-maps.partial.js +0 -0
- /package/dist/esm/{internal → xcss}/style-maps.partial.js +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
1
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
3
|
import _typeof from "@babel/runtime/helpers/typeof";
|
|
3
4
|
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
@@ -40,6 +41,9 @@ var tokensMap = {
|
|
|
40
41
|
minHeight: dimensionMap,
|
|
41
42
|
minInlineSize: dimensionMap,
|
|
42
43
|
minWidth: dimensionMap,
|
|
44
|
+
outlineOffset: paddingMap,
|
|
45
|
+
outlineWidth: borderWidthMap,
|
|
46
|
+
outlineColor: borderColorMap,
|
|
43
47
|
overflow: overflowMap,
|
|
44
48
|
overflowBlock: overflowBlockMap,
|
|
45
49
|
overflowInline: overflowInlineMap,
|
|
@@ -61,7 +65,7 @@ var tokensMap = {
|
|
|
61
65
|
width: dimensionMap,
|
|
62
66
|
zIndex: layerMap
|
|
63
67
|
};
|
|
64
|
-
var uniqueSymbol = Symbol('
|
|
68
|
+
var uniqueSymbol = Symbol('UNSAFE_INTERNAL_styles');
|
|
65
69
|
var isSafeEnvToThrow = function isSafeEnvToThrow() {
|
|
66
70
|
return (typeof process === "undefined" ? "undefined" : _typeof(process)) === 'object' && _typeof(process.env) === 'object' && process.env.NODE_ENV !== 'production';
|
|
67
71
|
};
|
|
@@ -115,10 +119,7 @@ var transformStyles = function transformStyles(styleObj) {
|
|
|
115
119
|
};
|
|
116
120
|
var baseXcss = function baseXcss(style) {
|
|
117
121
|
var transformedStyles = transformStyles(style);
|
|
118
|
-
return {
|
|
119
|
-
symbol: uniqueSymbol,
|
|
120
|
-
styles: cssEmotion(transformedStyles)
|
|
121
|
-
};
|
|
122
|
+
return _defineProperty({}, uniqueSymbol, cssEmotion(transformedStyles));
|
|
122
123
|
};
|
|
123
124
|
|
|
124
125
|
/**
|
|
@@ -132,9 +133,8 @@ export var parseXcss = function parseXcss(args) {
|
|
|
132
133
|
return x && parseXcss(x);
|
|
133
134
|
}).filter(Boolean);
|
|
134
135
|
}
|
|
135
|
-
var
|
|
136
|
-
|
|
137
|
-
if ((typeof process === "undefined" ? "undefined" : _typeof(process)) && process.env.NODE_ENV === 'development' && symbol !== uniqueSymbol) {
|
|
136
|
+
var styles = args[uniqueSymbol];
|
|
137
|
+
if ((typeof process === "undefined" ? "undefined" : _typeof(process)) && process.env.NODE_ENV === 'development' && typeof styles === 'undefined') {
|
|
138
138
|
throw new Error('Styles generated from unsafe source, use the `xcss` export from `@atlaskit/primitives`.');
|
|
139
139
|
}
|
|
140
140
|
return styles;
|
|
@@ -146,6 +146,18 @@ var boxWrapper = function boxWrapper(style) {
|
|
|
146
146
|
var inlineWrapper = function inlineWrapper(style) {
|
|
147
147
|
return xcss(style);
|
|
148
148
|
};
|
|
149
|
+
/**
|
|
150
|
+
* ### xcss
|
|
151
|
+
*
|
|
152
|
+
* `xcss` is a safer, tokens-first approach to CSS-in-JS. It allows token-backed values for
|
|
153
|
+
* CSS application.
|
|
154
|
+
*
|
|
155
|
+
* ```tsx
|
|
156
|
+
* const styles = xcss({
|
|
157
|
+
* padding: 'space.100'
|
|
158
|
+
* })
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
149
161
|
export function xcss(style) {
|
|
150
162
|
return baseXcss(style);
|
|
151
163
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { ElementType, ReactNode } from 'react';
|
|
3
|
-
import { type Gap, type RowGap } from '../
|
|
3
|
+
import { type Gap, type RowGap } from '../xcss/style-maps.partial';
|
|
4
4
|
export interface InlineProps<T extends ElementType = 'div'> {
|
|
5
5
|
/**
|
|
6
6
|
* The DOM element to render as the Inline. Defaults to `div`.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { ComponentPropsWithoutRef, ComponentPropsWithRef, ElementType, FC, ReactElement, ReactNode } from 'react';
|
|
3
|
-
import { BackgroundColor, Padding, PaddingBlock, PaddingBlockEnd, PaddingBlockStart, PaddingInline, PaddingInlineEnd, PaddingInlineStart } from '../../
|
|
3
|
+
import { BackgroundColor, Padding, PaddingBlock, PaddingBlockEnd, PaddingBlockStart, PaddingInline, PaddingInlineEnd, PaddingInlineStart } from '../../xcss/style-maps.partial';
|
|
4
4
|
import type { BasePrimitiveProps } from '../types';
|
|
5
5
|
export declare type BaseBoxProps<T extends ElementType = 'div'> = Omit<ComponentPropsWithoutRef<T>, 'as' | 'className'> & BasePrimitiveProps & BaseBoxPropsFoundation<T>;
|
|
6
6
|
declare type BaseBoxPropsFoundation<T extends ElementType> = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { ElementType, ReactNode } from 'react';
|
|
3
|
-
import { type Gap } from '../
|
|
3
|
+
import { type Gap } from '../xcss/style-maps.partial';
|
|
4
4
|
export interface StackProps<T extends ElementType = 'div'> {
|
|
5
5
|
/**
|
|
6
6
|
* The DOM element to render as the Stack. Defaults to `div`.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CSSProperties } from 'react';
|
|
2
|
-
import { type BoxXCSS } from '../
|
|
2
|
+
import { type BoxXCSS } from '../xcss/xcss';
|
|
3
3
|
export declare type BasePrimitiveProps = {
|
|
4
4
|
/**
|
|
5
5
|
* A unique string that appears as data attribute `data-testid` in the rendered code, serving as a hook for automated tests.
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { default as Box, type BoxProps } from './components/box';
|
|
2
2
|
export { default as Inline, type InlineProps } from './components/inline';
|
|
3
|
-
export { xcss } from './
|
|
3
|
+
export { xcss } from './xcss/xcss';
|
|
4
4
|
export { default as Stack, type StackProps } from './components/stack';
|
|
@@ -458,6 +458,9 @@ export declare type TokenisedProps = {
|
|
|
458
458
|
minHeight?: MinHeight;
|
|
459
459
|
minInlineSize?: MinInlineSize;
|
|
460
460
|
minWidth?: MinWidth;
|
|
461
|
+
outlineColor?: BorderColor;
|
|
462
|
+
outlineOffset?: Padding;
|
|
463
|
+
outlineWidth?: BorderWidth;
|
|
461
464
|
overflow?: Overflow;
|
|
462
465
|
overflowBlock?: OverflowBlock;
|
|
463
466
|
overflowInline?: OverflowInline;
|
|
@@ -17,34 +17,41 @@ declare type CSSPseudos = {
|
|
|
17
17
|
declare type SafeCSSObject = CSSPseudos & TokenisedProps & Omit<CSSPropertiesWithMultiValues, keyof TokenisedProps>;
|
|
18
18
|
declare type ScopedSafeCSSObject<T extends keyof SafeCSSObject> = Pick<SafeCSSObject, T>;
|
|
19
19
|
declare const boxWrapper: (style: any) => {
|
|
20
|
-
readonly
|
|
21
|
-
readonly styles: BoxStyles;
|
|
20
|
+
readonly [uniqueSymbol]: BoxStyles;
|
|
22
21
|
};
|
|
23
22
|
declare const inlineWrapper: (style: any) => {
|
|
24
|
-
readonly
|
|
25
|
-
readonly styles: InlineStyles;
|
|
23
|
+
readonly [uniqueSymbol]: InlineStyles;
|
|
26
24
|
};
|
|
27
25
|
declare type XCSS = ReturnType<typeof boxWrapper> | ReturnType<typeof inlineWrapper>;
|
|
28
26
|
declare type AllowedBoxStyles = keyof SafeCSSObject;
|
|
29
27
|
declare type AllowedInlineStyles = 'backgroundColor' | 'padding';
|
|
28
|
+
/**
|
|
29
|
+
* ### xcss
|
|
30
|
+
*
|
|
31
|
+
* `xcss` is a safer, tokens-first approach to CSS-in-JS. It allows token-backed values for
|
|
32
|
+
* CSS application.
|
|
33
|
+
*
|
|
34
|
+
* ```tsx
|
|
35
|
+
* const styles = xcss({
|
|
36
|
+
* padding: 'space.100'
|
|
37
|
+
* })
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
30
40
|
export declare function xcss<Primitive extends typeof Box | typeof Inline = typeof Box>(style: Primitive extends typeof Box ? ScopedSafeCSSObject<AllowedBoxStyles> | ScopedSafeCSSObject<AllowedBoxStyles>[] : Primitive extends typeof Inline ? ScopedSafeCSSObject<AllowedInlineStyles> | ScopedSafeCSSObject<AllowedInlineStyles>[] : never): {
|
|
31
|
-
readonly
|
|
32
|
-
readonly styles: Primitive extends (<T extends import("react").ElementType<any> = "div">(props: import("../index").BoxProps<T>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | null) & import("react").FC<import("../index").BoxProps<"div">> ? BoxStyles : Primitive extends import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Pick<import("../index").InlineProps<import("react").ElementType<any>>, "as" | "children" | "testId" | "alignInline" | "alignBlock" | "shouldWrap" | "spread" | "grow" | "space" | "rowSpace" | "separator"> & import("react").RefAttributes<any>>> ? InlineStyles : never;
|
|
41
|
+
readonly [uniqueSymbol]: Primitive extends (<T extends import("react").ElementType<any> = "div">(props: import("../index").BoxProps<T>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | null) & import("react").FC<import("../index").BoxProps<"div">> ? BoxStyles : Primitive extends import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Pick<import("../index").InlineProps<import("react").ElementType<any>>, "as" | "children" | "testId" | "alignInline" | "alignBlock" | "shouldWrap" | "spread" | "grow" | "space" | "rowSpace" | "separator"> & import("react").RefAttributes<any>>> ? InlineStyles : never;
|
|
33
42
|
};
|
|
34
43
|
declare const boxTag: unique symbol;
|
|
35
44
|
export declare type BoxStyles = SerializedStyles & {
|
|
36
45
|
[boxTag]: true;
|
|
37
46
|
};
|
|
38
47
|
export declare type BoxXCSS = {
|
|
39
|
-
readonly
|
|
40
|
-
readonly styles: BoxStyles;
|
|
48
|
+
readonly [uniqueSymbol]: BoxStyles;
|
|
41
49
|
};
|
|
42
50
|
declare const inlineTag: unique symbol;
|
|
43
51
|
export declare type InlineStyles = SerializedStyles & {
|
|
44
52
|
[inlineTag]: true;
|
|
45
53
|
};
|
|
46
54
|
export declare type InlineXCSS = {
|
|
47
|
-
readonly
|
|
48
|
-
readonly styles: InlineStyles;
|
|
55
|
+
readonly [uniqueSymbol]: InlineStyles;
|
|
49
56
|
};
|
|
50
57
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/primitives",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "Primitives are token-backed low-level building blocks.",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -55,6 +55,15 @@
|
|
|
55
55
|
"status": {
|
|
56
56
|
"type": "alpha"
|
|
57
57
|
}
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"title": "xCSS",
|
|
61
|
+
"folder": "xcss",
|
|
62
|
+
"slug": "primitives/xcss",
|
|
63
|
+
"id": "@atlaskit/primitives/xcss",
|
|
64
|
+
"status": {
|
|
65
|
+
"type": "alpha"
|
|
66
|
+
}
|
|
58
67
|
}
|
|
59
68
|
]
|
|
60
69
|
}
|
|
@@ -142,4 +151,4 @@
|
|
|
142
151
|
}
|
|
143
152
|
},
|
|
144
153
|
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0"
|
|
145
|
-
}
|
|
154
|
+
}
|
package/report.api.md
CHANGED
|
@@ -311,8 +311,7 @@ const boxTag: unique symbol;
|
|
|
311
311
|
|
|
312
312
|
// @public (undocumented)
|
|
313
313
|
type BoxXCSS = {
|
|
314
|
-
readonly
|
|
315
|
-
readonly styles: BoxStyles;
|
|
314
|
+
readonly [uniqueSymbol]: BoxStyles;
|
|
316
315
|
};
|
|
317
316
|
|
|
318
317
|
// @public (undocumented)
|
|
@@ -949,6 +948,9 @@ type TokenisedProps = {
|
|
|
949
948
|
minHeight?: MinHeight;
|
|
950
949
|
minInlineSize?: MinInlineSize;
|
|
951
950
|
minWidth?: MinWidth;
|
|
951
|
+
outlineColor?: BorderColor;
|
|
952
|
+
outlineOffset?: Padding;
|
|
953
|
+
outlineWidth?: BorderWidth;
|
|
952
954
|
overflow?: Overflow;
|
|
953
955
|
overflowBlock?: OverflowBlock;
|
|
954
956
|
overflowInline?: OverflowInline;
|
|
@@ -976,7 +978,7 @@ const uniqueSymbol: unique symbol;
|
|
|
976
978
|
// @public (undocumented)
|
|
977
979
|
type Width = keyof typeof dimensionMap;
|
|
978
980
|
|
|
979
|
-
// @public
|
|
981
|
+
// @public
|
|
980
982
|
export function xcss<Primitive extends typeof Box | typeof Inline = typeof Box>(
|
|
981
983
|
style: Primitive extends typeof Box
|
|
982
984
|
?
|
|
@@ -988,8 +990,9 @@ export function xcss<Primitive extends typeof Box | typeof Inline = typeof Box>(
|
|
|
988
990
|
| ScopedSafeCSSObject<AllowedInlineStyles>[]
|
|
989
991
|
: never,
|
|
990
992
|
): {
|
|
991
|
-
readonly
|
|
992
|
-
|
|
993
|
+
readonly [uniqueSymbol]: Primitive extends (<
|
|
994
|
+
T extends ElementType<any> = 'div',
|
|
995
|
+
>(
|
|
993
996
|
props: BoxProps<T>,
|
|
994
997
|
) => ReactElement<any, JSXElementConstructor<any> | string> | null) &
|
|
995
998
|
FC<BoxProps<'div'>>
|