@atlaskit/ds-explorations 0.1.5 → 1.1.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.
Files changed (98) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/box/package.json +15 -0
  3. package/dist/cjs/components/box.partial.js +182 -205
  4. package/dist/cjs/components/inline.partial.js +28 -34
  5. package/dist/cjs/components/interaction-surface.partial.js +32 -1
  6. package/dist/cjs/components/stack.partial.js +28 -36
  7. package/dist/cjs/components/text.partial.js +117 -86
  8. package/dist/cjs/index.js +1 -9
  9. package/dist/cjs/internal/color-map.js +6 -5
  10. package/dist/cjs/internal/spacing-scale.js +17 -0
  11. package/dist/cjs/version.json +1 -1
  12. package/dist/es2019/components/box.partial.js +181 -189
  13. package/dist/es2019/components/inline.partial.js +27 -28
  14. package/dist/es2019/components/interaction-surface.partial.js +32 -1
  15. package/dist/es2019/components/stack.partial.js +27 -28
  16. package/dist/es2019/components/text.partial.js +74 -36
  17. package/dist/es2019/index.js +1 -2
  18. package/dist/es2019/internal/color-map.js +4 -3
  19. package/dist/es2019/internal/spacing-scale.js +9 -0
  20. package/dist/es2019/version.json +1 -1
  21. package/dist/esm/components/box.partial.js +181 -201
  22. package/dist/esm/components/inline.partial.js +27 -33
  23. package/dist/esm/components/interaction-surface.partial.js +32 -1
  24. package/dist/esm/components/stack.partial.js +27 -33
  25. package/dist/esm/components/text.partial.js +79 -47
  26. package/dist/esm/index.js +1 -2
  27. package/dist/esm/internal/color-map.js +4 -3
  28. package/dist/esm/internal/spacing-scale.js +9 -0
  29. package/dist/esm/version.json +1 -1
  30. package/dist/types/components/box.partial.d.ts +109 -21
  31. package/dist/types/components/inline.partial.d.ts +25 -3
  32. package/dist/types/components/interaction-surface.partial.d.ts +3 -0
  33. package/dist/types/components/stack.partial.d.ts +24 -2
  34. package/dist/types/components/text.partial.d.ts +9 -3
  35. package/dist/types/index.d.ts +0 -1
  36. package/dist/types/internal/color-map.d.ts +11 -9
  37. package/dist/types/internal/spacing-scale.d.ts +9 -0
  38. package/dist/types-ts4.0/components/box.partial.d.ts +109 -27
  39. package/dist/types-ts4.0/components/inline.partial.d.ts +25 -3
  40. package/dist/types-ts4.0/components/interaction-surface.partial.d.ts +3 -0
  41. package/dist/types-ts4.0/components/stack.partial.d.ts +24 -2
  42. package/dist/types-ts4.0/components/text.partial.d.ts +9 -6
  43. package/dist/types-ts4.0/index.d.ts +0 -1
  44. package/dist/types-ts4.0/internal/color-map.d.ts +11 -9
  45. package/dist/types-ts4.0/internal/spacing-scale.d.ts +22 -0
  46. package/examples/00-basic.tsx +4 -4
  47. package/examples/01-box.tsx +29 -46
  48. package/examples/02-text-advanced.tsx +38 -0
  49. package/examples/02-text.tsx +73 -62
  50. package/examples/03-stack.tsx +36 -75
  51. package/examples/04-inline.tsx +34 -76
  52. package/examples/05-badge.tsx +2 -2
  53. package/examples/06-section-message.tsx +7 -7
  54. package/examples/07-comment.tsx +4 -6
  55. package/examples/08-lozenge.tsx +9 -5
  56. package/examples/99-interactions.tsx +20 -20
  57. package/examples/config.jsonc +11 -0
  58. package/package.json +5 -2
  59. package/report.api.md +188 -48
  60. package/scripts/__tests__/__snapshots__/codegen.test.tsx.snap +52 -64
  61. package/scripts/codegen-styles.tsx +34 -6
  62. package/scripts/color-codegen-template.tsx +10 -15
  63. package/scripts/color-map-template.tsx +1 -1
  64. package/scripts/spacing-codegen-template.tsx +42 -12
  65. package/scripts/spacing-scale-template.tsx +40 -0
  66. package/scripts/utils.tsx +1 -3
  67. package/src/components/__tests__/unit/box.test.tsx +8 -11
  68. package/src/components/__tests__/unit/inline.test.tsx +3 -3
  69. package/src/components/__tests__/unit/interaction-suface.test.tsx +1 -1
  70. package/src/components/__tests__/unit/stack.test.tsx +2 -2
  71. package/src/components/__tests__/unit/text.test.tsx +32 -1
  72. package/src/components/__tests__/visual-regression/__image_snapshots__/box-snapshot-test-tsx-box-example-with-background-and-padding-block-should-match-snapshot-1-snap.png +2 -2
  73. package/src/components/__tests__/visual-regression/__image_snapshots__/box-snapshot-test-tsx-box-example-with-background-and-padding-inline-should-match-snapshot-1-snap.png +2 -2
  74. package/src/components/__tests__/visual-regression/__image_snapshots__/box-snapshot-test-tsx-box-example-with-background-and-padding-should-match-snapshot-1-snap.png +2 -2
  75. package/src/components/__tests__/visual-regression/__image_snapshots__/box-snapshot-test-tsx-box-example-with-background-color-should-match-snapshot-1-snap.png +2 -2
  76. package/src/components/__tests__/visual-regression/__image_snapshots__/box-snapshot-test-tsx-box-example-with-border-color-should-match-snapshot-1-snap.png +2 -2
  77. package/src/components/__tests__/visual-regression/__image_snapshots__/inline-snapshot-test-tsx-inline-alignment-example-should-match-snapshot-1-snap.png +2 -2
  78. package/src/components/__tests__/visual-regression/__image_snapshots__/inline-snapshot-test-tsx-inline-spacing-example-should-match-snapshot-1-snap.png +2 -2
  79. package/src/components/__tests__/visual-regression/__image_snapshots__/stack-snapshot-test-tsx-stack-alignment-example-should-match-snapshot-1-snap.png +2 -2
  80. package/src/components/__tests__/visual-regression/__image_snapshots__/stack-snapshot-test-tsx-stack-spacing-example-should-match-snapshot-1-snap.png +2 -2
  81. package/src/components/__tests__/visual-regression/__image_snapshots__/text-snapshot-test-tsx-text-example-with-line-heights-should-match-snapshot-1-snap.png +2 -2
  82. package/src/components/__tests__/visual-regression/__image_snapshots__/text-snapshot-test-tsx-text-example-with-testing-should-match-snapshot-1-snap.png +2 -2
  83. package/src/components/box.partial.tsx +293 -160
  84. package/src/components/inline.partial.tsx +44 -17
  85. package/src/components/interaction-surface.partial.tsx +2 -1
  86. package/src/components/stack.partial.tsx +43 -16
  87. package/src/components/text.partial.tsx +82 -41
  88. package/src/index.tsx +0 -1
  89. package/src/internal/color-map.tsx +4 -3
  90. package/src/internal/spacing-scale.tsx +22 -0
  91. package/text/package.json +15 -0
  92. package/tmp/api-report-tmp.d.ts +177 -43
  93. package/dist/cjs/constants.js +0 -21
  94. package/dist/es2019/constants.js +0 -14
  95. package/dist/esm/constants.js +0 -14
  96. package/dist/types/constants.d.ts +0 -15
  97. package/dist/types-ts4.0/constants.d.ts +0 -15
  98. package/src/constants.tsx +0 -16
@@ -7,20 +7,13 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = void 0;
9
9
 
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
10
  var _react = require("react");
13
11
 
14
12
  var _react2 = require("@emotion/react");
15
13
 
16
- var _constants = require("../constants");
17
-
18
14
  var _text = _interopRequireDefault(require("./text.partial"));
19
15
 
20
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
21
-
22
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
23
-
16
+ /** @jsx jsx */
24
17
  var flexAlignItemsMap = {
25
18
  center: (0, _react2.css)({
26
19
  alignItems: 'center'
@@ -87,7 +80,7 @@ var Inline = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
87
80
  testId = _ref.testId;
88
81
  var dividerComponent = typeof divider === 'string' ? (0, _react2.jsx)(_text.default, null, divider) : divider;
89
82
  return (0, _react2.jsx)("div", {
90
- style: _objectSpread({}, UNSAFE_style),
83
+ style: UNSAFE_style,
91
84
  css: [baseStyles, gap && columnGapMap[gap], alignItems && flexAlignItemsMap[alignItems], justifyContent && flexJustifyContentMap[justifyContent], flexWrap && flexWrapMap[flexWrap]],
92
85
  "data-testid": testId,
93
86
  ref: ref
@@ -99,49 +92,50 @@ Inline.displayName = 'Inline';
99
92
  var _default = Inline;
100
93
  /**
101
94
  * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
102
- * @codegen <<SignedSource::7a985afa5e15ffd4f6f9c0db0e99ceb6>>
95
+ * @codegen <<SignedSource::2dd7c6b8450b1bbd1fb8fabf12fffa33>>
103
96
  * @codegenId spacing
104
97
  * @codegenCommand yarn codegen-styles
105
98
  * @codegenParams ["columnGap"]
99
+ * @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-light.tsx <<SignedSource::07ef29d58a2b23af8b098515466d7e22>>
106
100
  */
107
101
 
108
102
  exports.default = _default;
109
103
  var columnGapMap = {
110
- 'sp-0': (0, _react2.css)({
111
- columnGap: _constants.SPACING_SCALE['sp-0']
104
+ 'scale.0': (0, _react2.css)({
105
+ columnGap: "var(--ds-scale-0, 0px)"
112
106
  }),
113
- 'sp-25': (0, _react2.css)({
114
- columnGap: _constants.SPACING_SCALE['sp-25']
107
+ 'scale.025': (0, _react2.css)({
108
+ columnGap: "var(--ds-scale-025, 2px)"
115
109
  }),
116
- 'sp-50': (0, _react2.css)({
117
- columnGap: _constants.SPACING_SCALE['sp-50']
110
+ 'scale.050': (0, _react2.css)({
111
+ columnGap: "var(--ds-scale-050, 4px)"
118
112
  }),
119
- 'sp-75': (0, _react2.css)({
120
- columnGap: _constants.SPACING_SCALE['sp-75']
113
+ 'scale.075': (0, _react2.css)({
114
+ columnGap: "var(--ds-scale-075, 6px)"
121
115
  }),
122
- 'sp-100': (0, _react2.css)({
123
- columnGap: _constants.SPACING_SCALE['sp-100']
116
+ 'scale.100': (0, _react2.css)({
117
+ columnGap: "var(--ds-scale-100, 8px)"
124
118
  }),
125
- 'sp-150': (0, _react2.css)({
126
- columnGap: _constants.SPACING_SCALE['sp-150']
119
+ 'scale.150': (0, _react2.css)({
120
+ columnGap: "var(--ds-scale-150, 12px)"
127
121
  }),
128
- 'sp-200': (0, _react2.css)({
129
- columnGap: _constants.SPACING_SCALE['sp-200']
122
+ 'scale.200': (0, _react2.css)({
123
+ columnGap: "var(--ds-scale-200, 16px)"
130
124
  }),
131
- 'sp-300': (0, _react2.css)({
132
- columnGap: _constants.SPACING_SCALE['sp-300']
125
+ 'scale.250': (0, _react2.css)({
126
+ columnGap: "var(--ds-scale-250, 20px)"
133
127
  }),
134
- 'sp-400': (0, _react2.css)({
135
- columnGap: _constants.SPACING_SCALE['sp-400']
128
+ 'scale.300': (0, _react2.css)({
129
+ columnGap: "var(--ds-scale-300, 24px)"
136
130
  }),
137
- 'sp-500': (0, _react2.css)({
138
- columnGap: _constants.SPACING_SCALE['sp-500']
131
+ 'scale.400': (0, _react2.css)({
132
+ columnGap: "var(--ds-scale-400, 32px)"
139
133
  }),
140
- 'sp-600': (0, _react2.css)({
141
- columnGap: _constants.SPACING_SCALE['sp-600']
134
+ 'scale.500': (0, _react2.css)({
135
+ columnGap: "var(--ds-scale-500, 40px)"
142
136
  }),
143
- 'sp-800': (0, _react2.css)({
144
- columnGap: _constants.SPACING_SCALE['sp-800']
137
+ 'scale.600': (0, _react2.css)({
138
+ columnGap: "var(--ds-scale-600, 48px)"
145
139
  })
146
140
  };
147
141
  /**
@@ -58,10 +58,11 @@ var InteractionSurface = function InteractionSurface(_ref) {
58
58
  var _default = InteractionSurface;
59
59
  /**
60
60
  * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
61
- * @codegen <<SignedSource::45000716488a9f41306a232c1f4c9f8d>>
61
+ * @codegen <<SignedSource::5289ea44928c279ad02274850623c9d1>>
62
62
  * @codegenId interactions
63
63
  * @codegenCommand yarn codegen-styles
64
64
  * @codegenParams ["background"]
65
+ * @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-light.tsx <<SignedSource::07ef29d58a2b23af8b098515466d7e22>>
65
66
  */
66
67
 
67
68
  exports.default = _default;
@@ -155,6 +156,21 @@ var backgroundActiveColorMap = {
155
156
  ':active': {
156
157
  backgroundColor: "var(--ds-background-information-bold-pressed, #09326C)"
157
158
  }
159
+ }),
160
+ 'elevation.surface': (0, _react2.css)({
161
+ ':active': {
162
+ backgroundColor: "var(--ds-surface-pressed, #DCDFE4)"
163
+ }
164
+ }),
165
+ 'elevation.surface.raised': (0, _react2.css)({
166
+ ':active': {
167
+ backgroundColor: "var(--ds-surface-raised-pressed, #DCDFE4)"
168
+ }
169
+ }),
170
+ 'elevation.surface.overlay': (0, _react2.css)({
171
+ ':active': {
172
+ backgroundColor: "var(--ds-surface-overlay-pressed, #DCDFE4)"
173
+ }
158
174
  })
159
175
  };
160
176
  var backgroundHoverColorMap = {
@@ -247,6 +263,21 @@ var backgroundHoverColorMap = {
247
263
  ':hover': {
248
264
  backgroundColor: "var(--ds-background-information-bold-hovered, #0055CC)"
249
265
  }
266
+ }),
267
+ 'elevation.surface': (0, _react2.css)({
268
+ ':hover': {
269
+ backgroundColor: "var(--ds-surface-hovered, #F1F2F4)"
270
+ }
271
+ }),
272
+ 'elevation.surface.raised': (0, _react2.css)({
273
+ ':hover': {
274
+ backgroundColor: "var(--ds-surface-raised-hovered, #F1F2F4)"
275
+ }
276
+ }),
277
+ 'elevation.surface.overlay': (0, _react2.css)({
278
+ ':hover': {
279
+ backgroundColor: "var(--ds-surface-overlay-hovered, #F1F2F4)"
280
+ }
250
281
  })
251
282
  };
252
283
  /**
@@ -1,24 +1,15 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
6
  exports.default = void 0;
9
7
 
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
8
  var _react = require("react");
13
9
 
14
10
  var _react2 = require("@emotion/react");
15
11
 
16
- var _constants = require("../constants");
17
-
18
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
19
-
20
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
21
-
12
+ /** @jsx jsx */
22
13
  var flexAlignItemsMap = {
23
14
  center: (0, _react2.css)({
24
15
  alignItems: 'center'
@@ -83,7 +74,7 @@ var Stack = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
83
74
  UNSAFE_style = _ref.UNSAFE_style,
84
75
  testId = _ref.testId;
85
76
  return (0, _react2.jsx)("div", {
86
- style: _objectSpread({}, UNSAFE_style),
77
+ style: UNSAFE_style,
87
78
  css: [baseStyles, gap && rowGapMap[gap], alignItems && flexAlignItemsMap[alignItems], justifyContent && flexJustifyContentMap[justifyContent], flexWrap && flexWrapMap[flexWrap]],
88
79
  "data-testid": testId,
89
80
  ref: ref
@@ -93,49 +84,50 @@ Stack.displayName = 'Stack';
93
84
  var _default = Stack;
94
85
  /**
95
86
  * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
96
- * @codegen <<SignedSource::13c9344cdb18845e176c0ca78b2972d3>>
87
+ * @codegen <<SignedSource::5d82d50cdeb38664c4c45d02608e447d>>
97
88
  * @codegenId spacing
98
89
  * @codegenCommand yarn codegen-styles
99
90
  * @codegenParams ["rowGap"]
91
+ * @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-light.tsx <<SignedSource::07ef29d58a2b23af8b098515466d7e22>>
100
92
  */
101
93
 
102
94
  exports.default = _default;
103
95
  var rowGapMap = {
104
- 'sp-0': (0, _react2.css)({
105
- rowGap: _constants.SPACING_SCALE['sp-0']
96
+ 'scale.0': (0, _react2.css)({
97
+ rowGap: "var(--ds-scale-0, 0px)"
106
98
  }),
107
- 'sp-25': (0, _react2.css)({
108
- rowGap: _constants.SPACING_SCALE['sp-25']
99
+ 'scale.025': (0, _react2.css)({
100
+ rowGap: "var(--ds-scale-025, 2px)"
109
101
  }),
110
- 'sp-50': (0, _react2.css)({
111
- rowGap: _constants.SPACING_SCALE['sp-50']
102
+ 'scale.050': (0, _react2.css)({
103
+ rowGap: "var(--ds-scale-050, 4px)"
112
104
  }),
113
- 'sp-75': (0, _react2.css)({
114
- rowGap: _constants.SPACING_SCALE['sp-75']
105
+ 'scale.075': (0, _react2.css)({
106
+ rowGap: "var(--ds-scale-075, 6px)"
115
107
  }),
116
- 'sp-100': (0, _react2.css)({
117
- rowGap: _constants.SPACING_SCALE['sp-100']
108
+ 'scale.100': (0, _react2.css)({
109
+ rowGap: "var(--ds-scale-100, 8px)"
118
110
  }),
119
- 'sp-150': (0, _react2.css)({
120
- rowGap: _constants.SPACING_SCALE['sp-150']
111
+ 'scale.150': (0, _react2.css)({
112
+ rowGap: "var(--ds-scale-150, 12px)"
121
113
  }),
122
- 'sp-200': (0, _react2.css)({
123
- rowGap: _constants.SPACING_SCALE['sp-200']
114
+ 'scale.200': (0, _react2.css)({
115
+ rowGap: "var(--ds-scale-200, 16px)"
124
116
  }),
125
- 'sp-300': (0, _react2.css)({
126
- rowGap: _constants.SPACING_SCALE['sp-300']
117
+ 'scale.250': (0, _react2.css)({
118
+ rowGap: "var(--ds-scale-250, 20px)"
127
119
  }),
128
- 'sp-400': (0, _react2.css)({
129
- rowGap: _constants.SPACING_SCALE['sp-400']
120
+ 'scale.300': (0, _react2.css)({
121
+ rowGap: "var(--ds-scale-300, 24px)"
130
122
  }),
131
- 'sp-500': (0, _react2.css)({
132
- rowGap: _constants.SPACING_SCALE['sp-500']
123
+ 'scale.400': (0, _react2.css)({
124
+ rowGap: "var(--ds-scale-400, 32px)"
133
125
  }),
134
- 'sp-600': (0, _react2.css)({
135
- rowGap: _constants.SPACING_SCALE['sp-600']
126
+ 'scale.500': (0, _react2.css)({
127
+ rowGap: "var(--ds-scale-500, 40px)"
136
128
  }),
137
- 'sp-800': (0, _react2.css)({
138
- rowGap: _constants.SPACING_SCALE['sp-800']
129
+ 'scale.600': (0, _react2.css)({
130
+ rowGap: "var(--ds-scale-600, 48px)"
139
131
  })
140
132
  };
141
133
  /**
@@ -7,114 +7,135 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = void 0;
9
9
 
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
11
11
 
12
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
12
+ var _react = require("react");
13
13
 
14
- var _react = require("@emotion/react");
14
+ var _react2 = require("@emotion/react");
15
15
 
16
16
  var _tinyInvariant = _interopRequireDefault(require("tiny-invariant"));
17
17
 
18
- var _colorMap = require("../internal/color-map");
18
+ var _colorMap = _interopRequireDefault(require("../internal/color-map"));
19
19
 
20
20
  var _surfaceProvider = require("./surface-provider");
21
21
 
22
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
23
-
24
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
25
-
22
+ var _excluded = ["children"];
26
23
  var asAllowlist = ['span', 'div', 'p'];
27
24
  var fontFamily = "-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif";
28
25
  var fontSizeMap = {
29
- '11px': (0, _react.css)({
26
+ '11px': (0, _react2.css)({
30
27
  fontSize: '11px'
31
28
  }),
32
- '12px': (0, _react.css)({
29
+ '12px': (0, _react2.css)({
33
30
  fontSize: '12px'
34
31
  }),
35
- '14px': (0, _react.css)({
32
+ '14px': (0, _react2.css)({
36
33
  fontSize: '14px'
37
34
  })
38
35
  };
39
36
  // NOTE: can't use numbers as keys or Constellation won't build. Weird one.
40
37
  var fontWeightMap = {
41
- '400': (0, _react.css)({
38
+ '400': (0, _react2.css)({
42
39
  fontWeight: 400
43
40
  }),
44
- '500': (0, _react.css)({
41
+ '500': (0, _react2.css)({
45
42
  fontWeight: 500
46
43
  }),
47
- '700': (0, _react.css)({
44
+ '600': (0, _react2.css)({
45
+ fontWeight: 600
46
+ }),
47
+ '700': (0, _react2.css)({
48
48
  fontWeight: 700
49
49
  })
50
50
  };
51
51
  var lineHeightMap = {
52
- '12px': (0, _react.css)({
52
+ '12px': (0, _react2.css)({
53
53
  lineHeight: '12px'
54
54
  }),
55
- '16px': (0, _react.css)({
55
+ '16px': (0, _react2.css)({
56
56
  lineHeight: '16px'
57
57
  }),
58
- '20px': (0, _react.css)({
58
+ '20px': (0, _react2.css)({
59
59
  lineHeight: '20px'
60
60
  }),
61
- '24px': (0, _react.css)({
61
+ '24px': (0, _react2.css)({
62
62
  lineHeight: '24px'
63
63
  }),
64
- '28px': (0, _react.css)({
64
+ '28px': (0, _react2.css)({
65
65
  lineHeight: '28px'
66
66
  }),
67
- '32px': (0, _react.css)({
67
+ '32px': (0, _react2.css)({
68
68
  lineHeight: '32px'
69
69
  }),
70
- '40px': (0, _react.css)({
70
+ '40px': (0, _react2.css)({
71
71
  lineHeight: '40px'
72
72
  })
73
73
  };
74
74
  var textAlignMap = {
75
- center: (0, _react.css)({
75
+ center: (0, _react2.css)({
76
76
  textAlign: 'center'
77
77
  }),
78
- end: (0, _react.css)({
78
+ end: (0, _react2.css)({
79
79
  textAlign: 'end'
80
80
  }),
81
- start: (0, _react.css)({
81
+ start: (0, _react2.css)({
82
82
  textAlign: 'start'
83
83
  })
84
84
  };
85
85
  var textTransformMap = {
86
- none: (0, _react.css)({
86
+ none: (0, _react2.css)({
87
87
  textTransform: 'none'
88
88
  }),
89
- lowercase: (0, _react.css)({
89
+ lowercase: (0, _react2.css)({
90
90
  textTransform: 'lowercase'
91
91
  }),
92
- uppercase: (0, _react.css)({
92
+ uppercase: (0, _react2.css)({
93
93
  textTransform: 'uppercase'
94
94
  })
95
95
  };
96
96
  var verticalAlignMap = {
97
- top: (0, _react.css)({
97
+ top: (0, _react2.css)({
98
98
  verticalAlign: 'top'
99
99
  }),
100
- middle: (0, _react.css)({
100
+ middle: (0, _react2.css)({
101
101
  verticalAlign: 'middle'
102
102
  }),
103
- bottom: (0, _react.css)({
103
+ bottom: (0, _react2.css)({
104
104
  verticalAlign: 'bottom'
105
105
  })
106
106
  };
107
- var baseStyles = (0, _react.css)({
107
+ var baseStyles = (0, _react2.css)({
108
108
  boxSizing: 'border-box',
109
109
  margin: '0px',
110
110
  padding: '0px',
111
111
  fontFamily: fontFamily
112
112
  });
113
- var truncateStyles = (0, _react.css)({
113
+ var truncateStyles = (0, _react2.css)({
114
114
  overflow: 'hidden',
115
115
  textOverflow: 'ellipsis',
116
116
  whiteSpace: 'nowrap'
117
117
  });
118
+ /**
119
+ * Custom hook designed to abstract the parsing of the color props and make it clearer in the future how color is reconciled between themes and tokens.
120
+ */
121
+
122
+ var useColor = function useColor(colorProp) {
123
+ var surface = (0, _surfaceProvider.useSurface)();
124
+ var inverseTextColor = _colorMap.default[surface];
125
+ /**
126
+ * Where the color of the surface is inverted we override the user choice
127
+ * as there is no valid choice that is not covered by the override.
128
+ */
129
+
130
+ var color = inverseTextColor !== null && inverseTextColor !== void 0 ? inverseTextColor : colorProp;
131
+ return color;
132
+ };
133
+
134
+ var HasTextAncestorContext = /*#__PURE__*/(0, _react.createContext)(false);
135
+
136
+ var useHasTextAncestor = function useHasTextAncestor() {
137
+ return (0, _react.useContext)(HasTextAncestorContext);
138
+ };
118
139
  /**
119
140
  * __Text__
120
141
  *
@@ -125,88 +146,98 @@ var truncateStyles = (0, _react.css)({
125
146
  * @internal
126
147
  */
127
148
 
128
- var Text = function Text(_ref) {
129
- var _ref$as = _ref.as,
130
- Component = _ref$as === void 0 ? 'span' : _ref$as,
131
- children = _ref.children,
132
- colorTuple = _ref.color,
133
- fontSize = _ref.fontSize,
134
- fontWeight = _ref.fontWeight,
135
- lineHeight = _ref.lineHeight,
136
- _ref$shouldTruncate = _ref.shouldTruncate,
137
- shouldTruncate = _ref$shouldTruncate === void 0 ? false : _ref$shouldTruncate,
138
- textAlign = _ref.textAlign,
139
- textTransform = _ref.textTransform,
140
- verticalAlign = _ref.verticalAlign,
141
- testId = _ref.testId,
142
- UNSAFE_style = _ref.UNSAFE_style;
143
- var surface = (0, _surfaceProvider.useSurface)(); // @ts-ignore
144
-
145
- var _ref2 = colorTuple || [],
146
- _ref3 = (0, _slicedToArray2.default)(_ref2, 2),
147
- _ref3$ = _ref3[0],
148
- color = _ref3$ === void 0 ? _colorMap.colorMap[surface] : _ref3$,
149
- fallback = _ref3[1];
150
149
 
150
+ var Text = function Text(_ref) {
151
+ var children = _ref.children,
152
+ props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
153
+ var _props$as = props.as,
154
+ Component = _props$as === void 0 ? 'span' : _props$as,
155
+ colorProp = props.color,
156
+ fontSize = props.fontSize,
157
+ fontWeight = props.fontWeight,
158
+ lineHeight = props.lineHeight,
159
+ _props$shouldTruncate = props.shouldTruncate,
160
+ shouldTruncate = _props$shouldTruncate === void 0 ? false : _props$shouldTruncate,
161
+ textAlign = props.textAlign,
162
+ textTransform = props.textTransform,
163
+ verticalAlign = props.verticalAlign,
164
+ testId = props.testId,
165
+ UNSAFE_style = props.UNSAFE_style,
166
+ id = props.id;
151
167
  (0, _tinyInvariant.default)(asAllowlist.includes(Component), "@atlaskit/ds-explorations: Text received an invalid \"as\" value of \"".concat(Component, "\""));
152
- return (0, _react.jsx)(Component, {
153
- style: _objectSpread(_objectSpread({}, UNSAFE_style), fallback && {
154
- '--ds-co-fb': fallback
155
- }),
168
+ var color = useColor(colorProp);
169
+ var isWrapped = useHasTextAncestor();
170
+ /**
171
+ * If the text is already wrapped and applies no props we can just
172
+ * render the children directly as a fragment.
173
+ */
174
+
175
+ if (isWrapped && Object.keys(props).length === 0) {
176
+ return (0, _react2.jsx)(_react.Fragment, null, children);
177
+ }
178
+
179
+ var component = (0, _react2.jsx)(Component, {
180
+ style: UNSAFE_style,
156
181
  css: [baseStyles, color && textColorMap[color], fontSize && fontSizeMap[fontSize], fontWeight && fontWeightMap[fontWeight], lineHeight && lineHeightMap[lineHeight], shouldTruncate && truncateStyles, textAlign && textAlignMap[textAlign], textTransform && textTransformMap[textTransform], verticalAlign && verticalAlignMap[verticalAlign]],
157
- "data-testid": testId
182
+ "data-testid": testId,
183
+ id: id
158
184
  }, children);
185
+ return isWrapped ? // no need to re-apply context if the text is already wrapped
186
+ component : (0, _react2.jsx)(HasTextAncestorContext.Provider, {
187
+ value: true
188
+ }, component);
159
189
  };
160
190
 
161
191
  var _default = Text;
162
192
  /**
163
193
  * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
164
- * @codegen <<SignedSource::140ffff6e1310c1c37e2067e2c232b92>>
194
+ * @codegen <<SignedSource::3d4d694e49f72e72f83ec28c1feafb76>>
165
195
  * @codegenId colors
166
196
  * @codegenCommand yarn codegen-styles
167
197
  * @codegenParams ["text"]
198
+ * @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-light.tsx <<SignedSource::07ef29d58a2b23af8b098515466d7e22>>
168
199
  */
169
200
 
170
201
  exports.default = _default;
171
202
  var textColorMap = {
172
- 'color.text': (0, _react.css)({
173
- color: "var(--ds-text, var(--ds-co-fb))"
203
+ 'color.text': (0, _react2.css)({
204
+ color: "var(--ds-text, #172B4D)"
174
205
  }),
175
- subtle: (0, _react.css)({
176
- color: "var(--ds-text-subtle, var(--ds-co-fb))"
206
+ subtle: (0, _react2.css)({
207
+ color: "var(--ds-text-subtle, #42526E)"
177
208
  }),
178
- subtlest: (0, _react.css)({
179
- color: "var(--ds-text-subtlest, var(--ds-co-fb))"
209
+ subtlest: (0, _react2.css)({
210
+ color: "var(--ds-text-subtlest, #7A869A)"
180
211
  }),
181
- disabled: (0, _react.css)({
182
- color: "var(--ds-text-disabled, var(--ds-co-fb))"
212
+ disabled: (0, _react2.css)({
213
+ color: "var(--ds-text-disabled, #A5ADBA)"
183
214
  }),
184
- inverse: (0, _react.css)({
185
- color: "var(--ds-text-inverse, var(--ds-co-fb))"
215
+ inverse: (0, _react2.css)({
216
+ color: "var(--ds-text-inverse, #FFFFFF)"
186
217
  }),
187
- brand: (0, _react.css)({
188
- color: "var(--ds-text-brand, var(--ds-co-fb))"
218
+ brand: (0, _react2.css)({
219
+ color: "var(--ds-text-brand, #0065FF)"
189
220
  }),
190
- selected: (0, _react.css)({
191
- color: "var(--ds-text-selected, var(--ds-co-fb))"
221
+ selected: (0, _react2.css)({
222
+ color: "var(--ds-text-selected, #0052CC)"
192
223
  }),
193
- danger: (0, _react.css)({
194
- color: "var(--ds-text-danger, var(--ds-co-fb))"
224
+ danger: (0, _react2.css)({
225
+ color: "var(--ds-text-danger, #DE350B)"
195
226
  }),
196
- warning: (0, _react.css)({
197
- color: "var(--ds-text-warning, var(--ds-co-fb))"
227
+ warning: (0, _react2.css)({
228
+ color: "var(--ds-text-warning, #974F0C)"
198
229
  }),
199
- 'warning.inverse': (0, _react.css)({
200
- color: "var(--ds-text-warning-inverse, var(--ds-co-fb))"
230
+ 'warning.inverse': (0, _react2.css)({
231
+ color: "var(--ds-text-warning-inverse, #172B4D)"
201
232
  }),
202
- success: (0, _react.css)({
203
- color: "var(--ds-text-success, var(--ds-co-fb))"
233
+ success: (0, _react2.css)({
234
+ color: "var(--ds-text-success, #006644)"
204
235
  }),
205
- discovery: (0, _react.css)({
206
- color: "var(--ds-text-discovery, var(--ds-co-fb))"
236
+ discovery: (0, _react2.css)({
237
+ color: "var(--ds-text-discovery, #403294)"
207
238
  }),
208
- information: (0, _react.css)({
209
- color: "var(--ds-text-information, var(--ds-co-fb))"
239
+ information: (0, _react2.css)({
240
+ color: "var(--ds-text-information, #0052CC)"
210
241
  })
211
242
  };
212
243
  /**
package/dist/cjs/index.js CHANGED
@@ -23,12 +23,6 @@ Object.defineProperty(exports, "UNSAFE_InteractionSurface", {
23
23
  return _interactionSurface.default;
24
24
  }
25
25
  });
26
- Object.defineProperty(exports, "UNSAFE_SPACING_SCALE", {
27
- enumerable: true,
28
- get: function get() {
29
- return _constants.SPACING_SCALE;
30
- }
31
- });
32
26
  Object.defineProperty(exports, "UNSAFE_Stack", {
33
27
  enumerable: true,
34
28
  get: function get() {
@@ -50,6 +44,4 @@ var _inline = _interopRequireDefault(require("./components/inline.partial"));
50
44
 
51
45
  var _stack = _interopRequireDefault(require("./components/stack.partial"));
52
46
 
53
- var _interactionSurface = _interopRequireDefault(require("./components/interaction-surface.partial"));
54
-
55
- var _constants = require("./constants");
47
+ var _interactionSurface = _interopRequireDefault(require("./components/interaction-surface.partial"));
@@ -3,17 +3,18 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.colorMap = void 0;
6
+ exports.default = void 0;
7
7
 
8
8
  /**
9
9
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
10
10
  *
11
- * Some artifact
11
+ * The color map is used to map a background color token to a matching text color that will meet contrast.
12
12
  *
13
- * @codegen <<SignedSource::8f568e4f0837f7af4a10429e060ad059>>
13
+ * @codegen <<SignedSource::b80b2a3d75c3215df8be35a6f5bda68d>>
14
14
  * @codegenCommand yarn codegen-styles
15
+ * @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-light.tsx <<SignedSource::07ef29d58a2b23af8b098515466d7e22>>
15
16
  */
16
- var colorMap = {
17
+ var _default = {
17
18
  'neutral.bold': 'inverse',
18
19
  'neutral.bold.hovered': 'inverse',
19
20
  'neutral.bold.pressed': 'inverse',
@@ -39,4 +40,4 @@ var colorMap = {
39
40
  'information.bold.hovered': 'inverse',
40
41
  'information.bold.pressed': 'inverse'
41
42
  };
42
- exports.colorMap = colorMap;
43
+ exports.default = _default;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.spacingScale = void 0;
7
+
8
+ /**
9
+ * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
10
+ *
11
+ * Some artifact
12
+ *
13
+ * @codegen <<SignedSource::caecb926afa82b027fba396074de5c2c>>
14
+ * @codegenCommand yarn codegen-styles
15
+ */
16
+ var spacingScale = ['scale.0', 'scale.025', 'scale.050', 'scale.075', 'scale.100', 'scale.150', 'scale.200', 'scale.250', 'scale.300', 'scale.400', 'scale.500', 'scale.600'];
17
+ exports.spacingScale = spacingScale;