@splunk/themes 1.2.1 → 1.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/CHANGELOG.md +18 -0
- package/design-tokens/colors.js +98 -18
- package/design-tokens/deprecated.js +4 -0
- package/enterprise/dark.js +24 -6
- package/enterprise/light.js +25 -7
- package/index.js +57 -1
- package/mixins/prose.js +1 -1
- package/package.json +8 -4
- package/prisma/dark.js +24 -6
- package/prisma/light.js +24 -6
- package/splunk-magnetic/index.js +20 -3
- package/storybook-addon-splunk-themes/SplunkThemesTool.js +14 -14
- package/storybook-addon-splunk-themes/constants.js +6 -1
- package/storybook-addon-splunk-themes/util.js +14 -8
- package/storybook-addon-splunk-themes/withSplunkTheme.js +174 -31
- package/types/design-tokens/colors.d.ts +192 -32
- package/types/design-tokens/deprecated.d.ts +8 -0
- package/types/design-tokens/index.d.ts +21 -4
- package/types/enterprise/dark.d.ts +22 -5
- package/types/enterprise/light.d.ts +22 -5
- package/types/index.d.ts +7 -0
- package/types/mixins/typography.d.ts +1 -1
- package/types/prisma/dark.d.ts +21 -4
- package/types/prisma/light.d.ts +21 -4
- package/types/splunk-magnetic/index.d.ts +148 -46
- package/types/storybook-addon-splunk-themes/constants.d.ts +2 -0
- package/types/storybook-addon-splunk-themes/themeOptions.d.ts +1 -1
- package/types/storybook-addon-splunk-themes/util.d.ts +3 -3
|
@@ -3,13 +3,18 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.CHANGED = exports.SET = exports.CONFIGURE = exports.UPDATE = exports.DISABLE_DUAL_THEME_KEY = exports.PARAM_KEY = exports.ADDON_ID = void 0;
|
|
6
|
+
exports.CHANGED = exports.SET = exports.CONFIGURE = exports.UPDATE = exports.ENABLE_SPLUNK_MAGNETIC_KEY = exports.DISABLE_MULTI_THEME_OPTIONS_KEY = exports.DISABLE_DUAL_THEME_KEY = exports.PARAM_KEY = exports.ADDON_ID = void 0;
|
|
7
7
|
var ADDON_ID = '@splunk/themes';
|
|
8
8
|
exports.ADDON_ID = ADDON_ID;
|
|
9
9
|
var PARAM_KEY = 'splunkThemes';
|
|
10
|
+
// TODO(SUI-8284): Remove deprecated `disableDualTheme` in next major version
|
|
10
11
|
exports.PARAM_KEY = PARAM_KEY;
|
|
11
12
|
var DISABLE_DUAL_THEME_KEY = 'disableDualTheme';
|
|
12
13
|
exports.DISABLE_DUAL_THEME_KEY = DISABLE_DUAL_THEME_KEY;
|
|
14
|
+
var DISABLE_MULTI_THEME_OPTIONS_KEY = 'disableMultiThemeOptions';
|
|
15
|
+
exports.DISABLE_MULTI_THEME_OPTIONS_KEY = DISABLE_MULTI_THEME_OPTIONS_KEY;
|
|
16
|
+
var ENABLE_SPLUNK_MAGNETIC_KEY = 'enableSplunkMagneticOption';
|
|
17
|
+
exports.ENABLE_SPLUNK_MAGNETIC_KEY = ENABLE_SPLUNK_MAGNETIC_KEY;
|
|
13
18
|
var UPDATE = "".concat(ADDON_ID, "/update");
|
|
14
19
|
exports.UPDATE = UPDATE;
|
|
15
20
|
var CONFIGURE = "".concat(ADDON_ID, "/configure");
|
|
@@ -18,6 +18,8 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
18
18
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
19
19
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
20
20
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
21
|
+
// TODO(SUI-8284): Remove deprecated `both` in types in next major version
|
|
22
|
+
|
|
21
23
|
var normalizeThemeOptions = function normalizeThemeOptions() {
|
|
22
24
|
var paramOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
23
25
|
var globalOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -25,26 +27,30 @@ var normalizeThemeOptions = function normalizeThemeOptions() {
|
|
|
25
27
|
};
|
|
26
28
|
|
|
27
29
|
// merge the existing theme with the newly selected theme
|
|
28
|
-
// this functon only allows the most recently-
|
|
29
|
-
// because allowing more than one
|
|
30
|
+
// this functon only allows the most recently-selected multi-option (both/all) to persist
|
|
31
|
+
// because allowing more than one leads to an unwieldy visualization
|
|
30
32
|
exports.normalizeThemeOptions = normalizeThemeOptions;
|
|
31
33
|
var getMergedTheme = function getMergedTheme(globalsTheme, newTheme) {
|
|
32
|
-
var
|
|
34
|
+
var firstMultiOptionEntry = Object.entries(newTheme).find(
|
|
35
|
+
// TODO(SUI-8284): Remove deprecated `both` value support in next major version
|
|
36
|
+
function (_ref) {
|
|
33
37
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
34
38
|
value = _ref2[1];
|
|
35
|
-
return value === 'both';
|
|
39
|
+
return value === 'all' || value === 'both';
|
|
36
40
|
});
|
|
37
|
-
var _ref3 =
|
|
41
|
+
var _ref3 = firstMultiOptionEntry || [],
|
|
38
42
|
_ref4 = _slicedToArray(_ref3, 1),
|
|
39
|
-
|
|
43
|
+
firstMultiOption = _ref4[0];
|
|
40
44
|
var finalValue;
|
|
41
45
|
|
|
42
|
-
// only allow "
|
|
46
|
+
// only allow "multi" for a single theme setting; if a new one is passed, remove the old one
|
|
43
47
|
var mergedTheme = Object.entries(_themeOptions.themeOptions).reduce(function (themeAccum, _ref5) {
|
|
44
48
|
var _ref6 = _slicedToArray(_ref5, 1),
|
|
45
49
|
key = _ref6[0];
|
|
46
50
|
if ((0, _themeOptions.isThemeOptionKey)(key)) {
|
|
47
|
-
if (
|
|
51
|
+
if (
|
|
52
|
+
// TODO(SUI-8284): Remove deprecated `both` value support in next major version
|
|
53
|
+
((globalsTheme === null || globalsTheme === void 0 ? void 0 : globalsTheme[key]) === 'all' || (globalsTheme === null || globalsTheme === void 0 ? void 0 : globalsTheme[key]) === 'both') && firstMultiOption != null && key !== firstMultiOption) {
|
|
48
54
|
var defaultThemeOptionValue = _themeOptions.themeOptions[key].values[0];
|
|
49
55
|
finalValue = defaultThemeOptionValue;
|
|
50
56
|
} else {
|
|
@@ -17,18 +17,57 @@ var _themes = require("./themes");
|
|
|
17
17
|
var _util = require("./util");
|
|
18
18
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
19
19
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) { "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); } return f; })(e, t); }
|
|
20
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
21
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
22
20
|
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
23
21
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
24
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
25
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) { n[e] = r[e]; } return n; }
|
|
26
22
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0) { ; } } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
27
23
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
28
24
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) { ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } } return n; }, _extends.apply(null, arguments); }
|
|
25
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
26
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
27
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
28
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
29
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
30
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) { n[e] = r[e]; } return n; }
|
|
31
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
32
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
29
33
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
30
34
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
31
35
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
36
|
+
function _templateObject7() {
|
|
37
|
+
var data = _taggedTemplateLiteral(["\n grid-row: 1;\n grid-column: labelText / colEnd;\n"]);
|
|
38
|
+
_templateObject7 = function _templateObject7() {
|
|
39
|
+
return data;
|
|
40
|
+
};
|
|
41
|
+
return data;
|
|
42
|
+
}
|
|
43
|
+
function _templateObject6() {
|
|
44
|
+
var data = _taggedTemplateLiteral(["\n font-size: 68px;\n"]);
|
|
45
|
+
_templateObject6 = function _templateObject6() {
|
|
46
|
+
return data;
|
|
47
|
+
};
|
|
48
|
+
return data;
|
|
49
|
+
}
|
|
50
|
+
function _templateObject5() {
|
|
51
|
+
var data = _taggedTemplateLiteral(["\n stroke: ", ";\n fill: ", ";\n"]);
|
|
52
|
+
_templateObject5 = function _templateObject5() {
|
|
53
|
+
return data;
|
|
54
|
+
};
|
|
55
|
+
return data;
|
|
56
|
+
}
|
|
57
|
+
function _templateObject4() {
|
|
58
|
+
var data = _taggedTemplateLiteral(["\n grid-row: 1;\n grid-column: colStart / labelText;\n height: 20px;\n width: 20px;\n"]);
|
|
59
|
+
_templateObject4 = function _templateObject4() {
|
|
60
|
+
return data;
|
|
61
|
+
};
|
|
62
|
+
return data;
|
|
63
|
+
}
|
|
64
|
+
function _templateObject3() {
|
|
65
|
+
var data = _taggedTemplateLiteral(["\n display: grid;\n grid-template-rows: 100%;\n grid-template-columns: [colStart] min-content [labelText] auto [colEnd];\n gap: ", ";\n padding: ", ";\n background-color: ", ";\n border-radius: ", ";\n"]);
|
|
66
|
+
_templateObject3 = function _templateObject3() {
|
|
67
|
+
return data;
|
|
68
|
+
};
|
|
69
|
+
return data;
|
|
70
|
+
}
|
|
32
71
|
function _templateObject2() {
|
|
33
72
|
var data = _taggedTemplateLiteral(["\n display: flex;\n gap: ", ";\n flex-direction: column;\n"]);
|
|
34
73
|
_templateObject2 = function _templateObject2() {
|
|
@@ -45,61 +84,165 @@ function _templateObject() {
|
|
|
45
84
|
}
|
|
46
85
|
function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
|
|
47
86
|
var StoryWrapper = _styledComponents["default"].div(_templateObject(), _variables["default"].backgroundColorPage, _variables["default"].spacingLarge);
|
|
48
|
-
var
|
|
49
|
-
|
|
50
|
-
var
|
|
87
|
+
var MultiStoryContainer = _styledComponents["default"].div(_templateObject2(), _variables["default"].spacingLarge);
|
|
88
|
+
var StyledWarning = _styledComponents["default"].div(_templateObject3(), _variables["default"].spacingSmall, _variables["default"].spacingSmall, _variables["default"].neutral200, _variables["default"].borderRadius);
|
|
89
|
+
var WarningIcon = _styledComponents["default"].svg(_templateObject4());
|
|
90
|
+
var StyledTriangle = _styledComponents["default"].polygon(_templateObject5(), _variables["default"].accentColorWarning, _variables["default"].accentColorWarning);
|
|
91
|
+
var StyledText = _styledComponents["default"].text(_templateObject6());
|
|
92
|
+
var StyledContent = _styledComponents["default"].span(_templateObject7());
|
|
93
|
+
var warningIcon = /*#__PURE__*/_react["default"].createElement(WarningIcon, {
|
|
94
|
+
viewBox: "0 0 100 100",
|
|
95
|
+
"aria-label": "warning icon"
|
|
96
|
+
}, /*#__PURE__*/_react["default"].createElement(StyledTriangle, {
|
|
97
|
+
points: "50 15, 100 100, 0 100"
|
|
98
|
+
}), /*#__PURE__*/_react["default"].createElement(StyledText, {
|
|
99
|
+
x: "41",
|
|
100
|
+
y: "88"
|
|
101
|
+
}, "!"));
|
|
102
|
+
var handleSplunkMagneticFamily = function handleSplunkMagneticFamily(themeProps) {
|
|
103
|
+
if (themeProps.family === 'splunk-magnetic') {
|
|
104
|
+
return _objectSpread(_objectSpread({}, themeProps), {}, {
|
|
105
|
+
family: 'prisma',
|
|
106
|
+
customizeTheme: _splunkMagnetic["default"]
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
return themeProps;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
// The Splunk Magnetic option reuses Prisma tokens under the hood. We translate the
|
|
113
|
+
// toolbar selection here so the underlying theme provider always receives a Prisma family.
|
|
114
|
+
// Multi-render selections ("all" / "both") are treated as undefined because each variant
|
|
115
|
+
// gets its own explicit family inside the MultiStory renderer below.
|
|
116
|
+
var normalizeFamilyForProvider = function normalizeFamilyForProvider(family) {
|
|
117
|
+
if (!family) {
|
|
118
|
+
return undefined;
|
|
119
|
+
}
|
|
120
|
+
if (family === 'splunk-magnetic') {
|
|
121
|
+
return 'prisma';
|
|
122
|
+
}
|
|
123
|
+
if (family === 'all' || family === 'both') {
|
|
124
|
+
return undefined;
|
|
125
|
+
}
|
|
126
|
+
return family;
|
|
127
|
+
};
|
|
128
|
+
var shouldRenderMultiThemes = function shouldRenderMultiThemes(_ref) {
|
|
129
|
+
var activeMultiThemeKey = _ref.activeMultiThemeKey,
|
|
130
|
+
currentTheme = _ref.currentTheme,
|
|
131
|
+
hasDisabledMultiThemeOptions = _ref.hasDisabledMultiThemeOptions;
|
|
132
|
+
if (hasDisabledMultiThemeOptions || !activeMultiThemeKey) {
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
var themeValue = currentTheme[activeMultiThemeKey];
|
|
136
|
+
|
|
137
|
+
// TODO(SUI-8284): Remove deprecated `both` value support in next major version
|
|
138
|
+
return themeValue === 'all' || themeValue === 'both';
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
// Renders a story multiple times side-by-side with different theme variants
|
|
142
|
+
var MultiStory = function MultiStory(_ref2) {
|
|
51
143
|
var _children$props;
|
|
52
|
-
var children =
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
144
|
+
var children = _ref2.children,
|
|
145
|
+
themeOption = _ref2.themeOption,
|
|
146
|
+
themeProviderProps = _ref2.themeProviderProps,
|
|
147
|
+
hasEnabledSplunkMagneticOption = _ref2.hasEnabledSplunkMagneticOption;
|
|
56
148
|
if (/*#__PURE__*/(0, _react.isValidElement)(children) && (children === null || children === void 0 ? void 0 : (_children$props = children.props) === null || _children$props === void 0 ? void 0 : _children$props.componentId)) {
|
|
57
149
|
var _themeOptions$themeOp;
|
|
58
150
|
var themeOptionValues = ((_themeOptions$themeOp = _themeOptions.themeOptions[themeOption]) === null || _themeOptions$themeOp === void 0 ? void 0 : _themeOptions$themeOp.values) || [];
|
|
59
|
-
|
|
151
|
+
|
|
152
|
+
// Add splunk magnetic option to family values if enabled
|
|
153
|
+
if (themeOption === 'family' && hasEnabledSplunkMagneticOption) {
|
|
154
|
+
themeOptionValues = [].concat(_toConsumableArray(themeOptionValues), ['splunk-magnetic']);
|
|
155
|
+
}
|
|
156
|
+
return /*#__PURE__*/_react["default"].createElement(MultiStoryContainer, null, themeOptionValues.map(function (themeOptionValue) {
|
|
157
|
+
var variantThemeProviderProps = handleSplunkMagneticFamily(_objectSpread(_objectSpread({}, themeProviderProps), {}, _defineProperty({}, themeOption, themeOptionValue)));
|
|
60
158
|
return /*#__PURE__*/_react["default"].createElement(_SplunkThemeProvider["default"], _extends({
|
|
61
159
|
key: themeOptionValue
|
|
62
|
-
},
|
|
160
|
+
}, variantThemeProviderProps), /*#__PURE__*/_react["default"].createElement(_themes.GlobalStyles, null), /*#__PURE__*/_react["default"].createElement(StoryWrapper, null, children));
|
|
63
161
|
}));
|
|
64
162
|
}
|
|
65
163
|
|
|
66
|
-
// Required to render correctly, otherwise
|
|
164
|
+
// Required to render correctly, otherwise MultiStory isn't considered a valid component
|
|
67
165
|
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
68
166
|
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, children);
|
|
69
167
|
};
|
|
70
168
|
var WithSplunkTheme = function WithSplunkTheme(Story, context) {
|
|
169
|
+
var _parameters$themeSupp;
|
|
71
170
|
var globals = context.globals,
|
|
72
|
-
parameters = context.parameters
|
|
73
|
-
args = context.args;
|
|
171
|
+
parameters = context.parameters;
|
|
74
172
|
var globalsTheme = globals[_constants.PARAM_KEY];
|
|
75
173
|
var themesConfig = parameters[_constants.PARAM_KEY];
|
|
174
|
+
var disableDualThemeDeprecated = parameters.disableDualTheme || false;
|
|
175
|
+
var disableMultiThemeOptions = parameters.disableMultiThemeOptions || false;
|
|
176
|
+
var hasEnabledSplunkMagneticOption = parameters.enableSplunkMagneticOption || false;
|
|
177
|
+
|
|
178
|
+
// Determine the effective disable state (new param takes precedence)
|
|
179
|
+
var hasDisabledMultiThemeOptions = disableMultiThemeOptions || disableDualThemeDeprecated;
|
|
180
|
+
|
|
181
|
+
// Show deprecation warning if deprecated parameter is used
|
|
182
|
+
if ('disableDualTheme' in parameters) {
|
|
183
|
+
// eslint-disable-next-line no-console
|
|
184
|
+
console.warn('The `disableDualTheme` parameter is deprecated and will be removed in the next major version. Use `disableMultiThemeOptions` instead.');
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Check for contradictory settings between deprecated and new parameters
|
|
188
|
+
if ('disableDualTheme' in parameters && 'disableMultiThemeOptions' in parameters && Boolean(disableDualThemeDeprecated) !== Boolean(disableMultiThemeOptions)) {
|
|
189
|
+
// eslint-disable-next-line no-console
|
|
190
|
+
console.warn('Contradictory theme parameters detected. The new `disableMultiThemeOptions` parameter will take precedence over the deprecated `disableDualTheme` parameter. Please remove the deprecated parameter as it will be removed in the next major version.');
|
|
191
|
+
}
|
|
192
|
+
if (hasDisabledMultiThemeOptions) {
|
|
193
|
+
// eslint-disable-next-line no-console
|
|
194
|
+
console.warn('This story has multi-theme options disabled, so the `all` option will not show in the themes dropdown.');
|
|
195
|
+
}
|
|
76
196
|
var currentTheme = (0, _util.normalizeThemeOptions)(themesConfig, globalsTheme);
|
|
77
|
-
var
|
|
197
|
+
var supportedFamily = parameters === null || parameters === void 0 ? void 0 : (_parameters$themeSupp = parameters.themeSupport) === null || _parameters$themeSupp === void 0 ? void 0 : _parameters$themeSupp.family;
|
|
198
|
+
var activeMultiThemeKey = null;
|
|
78
199
|
|
|
79
200
|
// ideally fromPairs would be fromEntries but our ES2015 target doesn't allow this
|
|
80
201
|
var cleanedThemeProviderProps = (0, _lodash.fromPairs)(Object.entries(currentTheme).filter(function (_ref3) {
|
|
81
202
|
var _ref4 = _slicedToArray(_ref3, 2),
|
|
82
203
|
key = _ref4[0],
|
|
83
204
|
value = _ref4[1];
|
|
84
|
-
|
|
85
|
-
|
|
205
|
+
// TODO(SUI-8284): Remove deprecated `both` value support in next major version
|
|
206
|
+
var isMultiOptionValue = value === 'all' || value === 'both';
|
|
207
|
+
if ((0, _themeOptions.isThemeOptionKey)(key) && isMultiOptionValue) {
|
|
208
|
+
activeMultiThemeKey = key;
|
|
209
|
+
|
|
210
|
+
// TODO(SUI-8284): Remove deprecated `both` value support in next major version
|
|
211
|
+
if (currentTheme[activeMultiThemeKey] === 'both') {
|
|
212
|
+
// eslint-disable-next-line no-console
|
|
213
|
+
console.warn('Theme configuration option `both` is deprecated and will be removed in the next major version. Use `all` instead.');
|
|
214
|
+
}
|
|
86
215
|
return false;
|
|
87
216
|
}
|
|
88
217
|
return true;
|
|
89
218
|
}));
|
|
90
|
-
var
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
219
|
+
var rawFamily = currentTheme.family;
|
|
220
|
+
var normalizedFamily = normalizeFamilyForProvider(rawFamily);
|
|
221
|
+
var isSplunkMagneticSelection = rawFamily === 'splunk-magnetic';
|
|
222
|
+
var isMultiFamilySelection = rawFamily === 'all' || rawFamily === 'both';
|
|
223
|
+
var displayedFamily = isSplunkMagneticSelection ? 'splunk-magnetic' : normalizedFamily;
|
|
224
|
+
|
|
225
|
+
// Warn whenever the selected family isn't supported (including when Magnetic proxies Prisma).
|
|
226
|
+
var shouldShowFamilyWarning = Boolean(supportedFamily && !isMultiFamilySelection && (isSplunkMagneticSelection ? supportedFamily !== 'splunk-magnetic' : normalizedFamily && supportedFamily !== normalizedFamily));
|
|
227
|
+
var resolvedThemeProviderProps = handleSplunkMagneticFamily(cleanedThemeProviderProps);
|
|
228
|
+
var warningContent = shouldShowFamilyWarning ? /*#__PURE__*/_react["default"].createElement(_SplunkThemeProvider["default"], _extends({}, resolvedThemeProviderProps, {
|
|
229
|
+
// Adjust colorScheme so that it matches with the overall storybook background which is light in 'all'/'light' but dark in 'dark'.
|
|
230
|
+
colorScheme: resolvedThemeProviderProps.colorScheme === 'dark' ? 'dark' : 'light'
|
|
231
|
+
}), /*#__PURE__*/_react["default"].createElement(StyledWarning, null, warningIcon, /*#__PURE__*/_react["default"].createElement(StyledContent, null, "This story does not support the theme family ", /*#__PURE__*/_react["default"].createElement("em", null, displayedFamily), ". The supported theme family is ", /*#__PURE__*/_react["default"].createElement("em", null, supportedFamily), ". Select the supported theme family in the toolbar.")), /*#__PURE__*/_react["default"].createElement("hr", null)) : null;
|
|
232
|
+
if (shouldRenderMultiThemes({
|
|
233
|
+
activeMultiThemeKey: activeMultiThemeKey,
|
|
234
|
+
currentTheme: currentTheme,
|
|
235
|
+
hasDisabledMultiThemeOptions: hasDisabledMultiThemeOptions
|
|
236
|
+
})) {
|
|
237
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, warningContent, /*#__PURE__*/_react["default"].createElement(MultiStory, {
|
|
238
|
+
themeOption: activeMultiThemeKey,
|
|
239
|
+
themeProviderProps: cleanedThemeProviderProps,
|
|
240
|
+
hasEnabledSplunkMagneticOption: hasEnabledSplunkMagneticOption
|
|
241
|
+
}, /*#__PURE__*/_react["default"].createElement(Story, context)));
|
|
99
242
|
}
|
|
100
|
-
return /*#__PURE__*/_react["default"].createElement(_SplunkThemeProvider["default"], _extends({},
|
|
101
|
-
colorScheme:
|
|
102
|
-
}), /*#__PURE__*/_react["default"].createElement(_themes.GlobalStyles, null), /*#__PURE__*/_react["default"].createElement(Story, context));
|
|
243
|
+
return /*#__PURE__*/_react["default"].createElement(_SplunkThemeProvider["default"], _extends({}, resolvedThemeProviderProps, {
|
|
244
|
+
colorScheme: resolvedThemeProviderProps.colorScheme
|
|
245
|
+
}), /*#__PURE__*/_react["default"].createElement(_themes.GlobalStyles, null), warningContent, /*#__PURE__*/_react["default"].createElement(Story, context));
|
|
103
246
|
};
|
|
104
247
|
var withSplunkTheme = WithSplunkTheme;
|
|
105
248
|
exports.withSplunkTheme = withSplunkTheme;
|
|
@@ -119,6 +119,90 @@ declare const actionColors: {
|
|
|
119
119
|
* Hover border color for Destructive Secondary Buttons.
|
|
120
120
|
*/
|
|
121
121
|
actionColorBorderDestructiveSecondaryHover: string;
|
|
122
|
+
/**
|
|
123
|
+
* Default text color for Primary Buttons.
|
|
124
|
+
*
|
|
125
|
+
* @categoryFont
|
|
126
|
+
*/
|
|
127
|
+
actionColorContentPrimary: string;
|
|
128
|
+
/**
|
|
129
|
+
* Disabled text color for Primary Buttons.
|
|
130
|
+
*
|
|
131
|
+
* @categoryFont
|
|
132
|
+
*/
|
|
133
|
+
actionColorContentPrimaryDisabled: string;
|
|
134
|
+
/**
|
|
135
|
+
* Default text color for Secondary Buttons.
|
|
136
|
+
*
|
|
137
|
+
* @categoryFont
|
|
138
|
+
*/
|
|
139
|
+
actionColorContentSecondary: string;
|
|
140
|
+
/**
|
|
141
|
+
* Disabled text color for Secondary Buttons.
|
|
142
|
+
*
|
|
143
|
+
* @categoryFont
|
|
144
|
+
*/
|
|
145
|
+
actionColorContentSecondaryDisabled: string;
|
|
146
|
+
/**
|
|
147
|
+
* Active text color for Subtle Buttons.
|
|
148
|
+
*
|
|
149
|
+
* @categoryFont
|
|
150
|
+
*/
|
|
151
|
+
actionColorContentSubtleActive: string;
|
|
152
|
+
/**
|
|
153
|
+
* Hover text color for Subtle Buttons.
|
|
154
|
+
*
|
|
155
|
+
* @categoryFont
|
|
156
|
+
*/
|
|
157
|
+
actionColorContentSubtleHover: string;
|
|
158
|
+
/**
|
|
159
|
+
* Default text color for Standalone Buttons.
|
|
160
|
+
*
|
|
161
|
+
* @categoryFont
|
|
162
|
+
*/
|
|
163
|
+
actionColorContentStandalone: string;
|
|
164
|
+
/**
|
|
165
|
+
* Active (pressed) text color for Standalone Buttons.
|
|
166
|
+
*
|
|
167
|
+
* @categoryFont
|
|
168
|
+
*/
|
|
169
|
+
actionColorContentStandaloneActive: string;
|
|
170
|
+
/**
|
|
171
|
+
* Disabled text color for Standalone Buttons.
|
|
172
|
+
*
|
|
173
|
+
* @categoryFont
|
|
174
|
+
*/
|
|
175
|
+
actionColorContentStandaloneDisabled: string;
|
|
176
|
+
/**
|
|
177
|
+
* Hover text color for Standalone Buttons.
|
|
178
|
+
*
|
|
179
|
+
* @categoryFont
|
|
180
|
+
*/
|
|
181
|
+
actionColorContentStandaloneHover: string;
|
|
182
|
+
/**
|
|
183
|
+
* Default text color for Destructive Buttons.
|
|
184
|
+
*
|
|
185
|
+
* @categoryFont
|
|
186
|
+
*/
|
|
187
|
+
actionColorContentDestructive: string;
|
|
188
|
+
/**
|
|
189
|
+
* Disabled text color for Destructive Buttons.
|
|
190
|
+
*
|
|
191
|
+
* @categoryFont
|
|
192
|
+
*/
|
|
193
|
+
actionColorContentDestructiveDisabled: string;
|
|
194
|
+
/**
|
|
195
|
+
* Default text color for Destructive Secondary Buttons.
|
|
196
|
+
*
|
|
197
|
+
* @categoryFont
|
|
198
|
+
*/
|
|
199
|
+
actionColorContentDestructiveSecondary: string;
|
|
200
|
+
/**
|
|
201
|
+
* Disabled text color for Destructive Secondary Buttons.
|
|
202
|
+
*
|
|
203
|
+
* @categoryFont
|
|
204
|
+
*/
|
|
205
|
+
actionColorContentDestructiveSecondaryDisabled: string;
|
|
122
206
|
};
|
|
123
207
|
/**
|
|
124
208
|
* #### Interactive colors
|
|
@@ -285,6 +369,18 @@ declare const contentColors: {
|
|
|
285
369
|
* Text color for links.
|
|
286
370
|
*/
|
|
287
371
|
contentColorLink: string;
|
|
372
|
+
/**
|
|
373
|
+
* Text color for visited links.
|
|
374
|
+
*/
|
|
375
|
+
contentColorLinkVisited: string;
|
|
376
|
+
/**
|
|
377
|
+
* Text color for disabled links.
|
|
378
|
+
*/
|
|
379
|
+
contentColorLinkDisabled: string;
|
|
380
|
+
/**
|
|
381
|
+
* Text color for visited links in a disabled state.
|
|
382
|
+
*/
|
|
383
|
+
contentColorLinkVisitedDisabled: string;
|
|
288
384
|
/**
|
|
289
385
|
* Brand accent text color.
|
|
290
386
|
*/
|
|
@@ -309,10 +405,6 @@ declare const contentColors: {
|
|
|
309
405
|
* Text color for disabled content that does not pass 4.5:1 contrast.
|
|
310
406
|
*/
|
|
311
407
|
contentColorDisabled: string;
|
|
312
|
-
/**
|
|
313
|
-
* Text color used to convey informational context or status.
|
|
314
|
-
*/
|
|
315
|
-
contentColorInfo: string;
|
|
316
408
|
/**
|
|
317
409
|
* Text color used on top of inverted backgrounds.
|
|
318
410
|
*/
|
|
@@ -325,22 +417,10 @@ declare const contentColors: {
|
|
|
325
417
|
* Text color for error or negative status messaging.
|
|
326
418
|
*/
|
|
327
419
|
contentColorNegative: string;
|
|
328
|
-
/**
|
|
329
|
-
* Stronger negative text color for greater emphasis.
|
|
330
|
-
*/
|
|
331
|
-
contentColorNegativeStrong: string;
|
|
332
420
|
/**
|
|
333
421
|
* Disabled negative text color that does not pass 4.5:1 contrast.
|
|
334
422
|
*/
|
|
335
423
|
contentColorNegativeWeak: string;
|
|
336
|
-
/**
|
|
337
|
-
* Text color for success or positive status messaging.
|
|
338
|
-
*/
|
|
339
|
-
contentColorPositive: string;
|
|
340
|
-
/**
|
|
341
|
-
* Text color for cautionary or warning status messaging.
|
|
342
|
-
*/
|
|
343
|
-
contentColorWarning: string;
|
|
344
424
|
};
|
|
345
425
|
/**
|
|
346
426
|
* #### UI Colors
|
|
@@ -489,6 +569,18 @@ declare const colors: {
|
|
|
489
569
|
* Text color for links.
|
|
490
570
|
*/
|
|
491
571
|
contentColorLink: string;
|
|
572
|
+
/**
|
|
573
|
+
* Text color for visited links.
|
|
574
|
+
*/
|
|
575
|
+
contentColorLinkVisited: string;
|
|
576
|
+
/**
|
|
577
|
+
* Text color for disabled links.
|
|
578
|
+
*/
|
|
579
|
+
contentColorLinkDisabled: string;
|
|
580
|
+
/**
|
|
581
|
+
* Text color for visited links in a disabled state.
|
|
582
|
+
*/
|
|
583
|
+
contentColorLinkVisitedDisabled: string;
|
|
492
584
|
/**
|
|
493
585
|
* Brand accent text color.
|
|
494
586
|
*/
|
|
@@ -513,10 +605,6 @@ declare const colors: {
|
|
|
513
605
|
* Text color for disabled content that does not pass 4.5:1 contrast.
|
|
514
606
|
*/
|
|
515
607
|
contentColorDisabled: string;
|
|
516
|
-
/**
|
|
517
|
-
* Text color used to convey informational context or status.
|
|
518
|
-
*/
|
|
519
|
-
contentColorInfo: string;
|
|
520
608
|
/**
|
|
521
609
|
* Text color used on top of inverted backgrounds.
|
|
522
610
|
*/
|
|
@@ -529,22 +617,10 @@ declare const colors: {
|
|
|
529
617
|
* Text color for error or negative status messaging.
|
|
530
618
|
*/
|
|
531
619
|
contentColorNegative: string;
|
|
532
|
-
/**
|
|
533
|
-
* Stronger negative text color for greater emphasis.
|
|
534
|
-
*/
|
|
535
|
-
contentColorNegativeStrong: string;
|
|
536
620
|
/**
|
|
537
621
|
* Disabled negative text color that does not pass 4.5:1 contrast.
|
|
538
622
|
*/
|
|
539
623
|
contentColorNegativeWeak: string;
|
|
540
|
-
/**
|
|
541
|
-
* Text color for success or positive status messaging.
|
|
542
|
-
*/
|
|
543
|
-
contentColorPositive: string;
|
|
544
|
-
/**
|
|
545
|
-
* Text color for cautionary or warning status messaging.
|
|
546
|
-
*/
|
|
547
|
-
contentColorWarning: string;
|
|
548
624
|
/**
|
|
549
625
|
* Default background color for the navigation headers.
|
|
550
626
|
*/
|
|
@@ -781,6 +857,90 @@ declare const colors: {
|
|
|
781
857
|
* Hover border color for Destructive Secondary Buttons.
|
|
782
858
|
*/
|
|
783
859
|
actionColorBorderDestructiveSecondaryHover: string;
|
|
860
|
+
/**
|
|
861
|
+
* Default text color for Primary Buttons.
|
|
862
|
+
*
|
|
863
|
+
* @categoryFont
|
|
864
|
+
*/
|
|
865
|
+
actionColorContentPrimary: string;
|
|
866
|
+
/**
|
|
867
|
+
* Disabled text color for Primary Buttons.
|
|
868
|
+
*
|
|
869
|
+
* @categoryFont
|
|
870
|
+
*/
|
|
871
|
+
actionColorContentPrimaryDisabled: string;
|
|
872
|
+
/**
|
|
873
|
+
* Default text color for Secondary Buttons.
|
|
874
|
+
*
|
|
875
|
+
* @categoryFont
|
|
876
|
+
*/
|
|
877
|
+
actionColorContentSecondary: string;
|
|
878
|
+
/**
|
|
879
|
+
* Disabled text color for Secondary Buttons.
|
|
880
|
+
*
|
|
881
|
+
* @categoryFont
|
|
882
|
+
*/
|
|
883
|
+
actionColorContentSecondaryDisabled: string;
|
|
884
|
+
/**
|
|
885
|
+
* Active text color for Subtle Buttons.
|
|
886
|
+
*
|
|
887
|
+
* @categoryFont
|
|
888
|
+
*/
|
|
889
|
+
actionColorContentSubtleActive: string;
|
|
890
|
+
/**
|
|
891
|
+
* Hover text color for Subtle Buttons.
|
|
892
|
+
*
|
|
893
|
+
* @categoryFont
|
|
894
|
+
*/
|
|
895
|
+
actionColorContentSubtleHover: string;
|
|
896
|
+
/**
|
|
897
|
+
* Default text color for Standalone Buttons.
|
|
898
|
+
*
|
|
899
|
+
* @categoryFont
|
|
900
|
+
*/
|
|
901
|
+
actionColorContentStandalone: string;
|
|
902
|
+
/**
|
|
903
|
+
* Active (pressed) text color for Standalone Buttons.
|
|
904
|
+
*
|
|
905
|
+
* @categoryFont
|
|
906
|
+
*/
|
|
907
|
+
actionColorContentStandaloneActive: string;
|
|
908
|
+
/**
|
|
909
|
+
* Disabled text color for Standalone Buttons.
|
|
910
|
+
*
|
|
911
|
+
* @categoryFont
|
|
912
|
+
*/
|
|
913
|
+
actionColorContentStandaloneDisabled: string;
|
|
914
|
+
/**
|
|
915
|
+
* Hover text color for Standalone Buttons.
|
|
916
|
+
*
|
|
917
|
+
* @categoryFont
|
|
918
|
+
*/
|
|
919
|
+
actionColorContentStandaloneHover: string;
|
|
920
|
+
/**
|
|
921
|
+
* Default text color for Destructive Buttons.
|
|
922
|
+
*
|
|
923
|
+
* @categoryFont
|
|
924
|
+
*/
|
|
925
|
+
actionColorContentDestructive: string;
|
|
926
|
+
/**
|
|
927
|
+
* Disabled text color for Destructive Buttons.
|
|
928
|
+
*
|
|
929
|
+
* @categoryFont
|
|
930
|
+
*/
|
|
931
|
+
actionColorContentDestructiveDisabled: string;
|
|
932
|
+
/**
|
|
933
|
+
* Default text color for Destructive Secondary Buttons.
|
|
934
|
+
*
|
|
935
|
+
* @categoryFont
|
|
936
|
+
*/
|
|
937
|
+
actionColorContentDestructiveSecondary: string;
|
|
938
|
+
/**
|
|
939
|
+
* Disabled text color for Destructive Secondary Buttons.
|
|
940
|
+
*
|
|
941
|
+
* @categoryFont
|
|
942
|
+
*/
|
|
943
|
+
actionColorContentDestructiveSecondaryDisabled: string;
|
|
784
944
|
};
|
|
785
945
|
type ActionColors = typeof actionColors;
|
|
786
946
|
type InteractiveColors = typeof interactiveColors;
|
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
* @categoryValue
|
|
5
5
|
*/
|
|
6
6
|
declare const deprecated: {
|
|
7
|
+
contentColorInfo: string;
|
|
8
|
+
contentColorWarning: string;
|
|
9
|
+
contentColorPositive: string;
|
|
10
|
+
contentColorNegativeStrong: string;
|
|
7
11
|
/**
|
|
8
12
|
* Use a more specific token based on the semantic use case:
|
|
9
13
|
* [`interactiveColorAccent`](#interactiveColorAccent), [`contentColorAccent`](#contentColorAccent), or [`focusColor`](#focusColor).
|
|
@@ -311,6 +315,10 @@ declare const deprecated: {
|
|
|
311
315
|
type Deprecated = typeof deprecated;
|
|
312
316
|
export type { Deprecated };
|
|
313
317
|
declare const _default: {
|
|
318
|
+
contentColorInfo: string;
|
|
319
|
+
contentColorWarning: string;
|
|
320
|
+
contentColorPositive: string;
|
|
321
|
+
contentColorNegativeStrong: string;
|
|
314
322
|
/**
|
|
315
323
|
* Use a more specific token based on the semantic use case:
|
|
316
324
|
* [`interactiveColorAccent`](#interactiveColorAccent), [`contentColorAccent`](#contentColorAccent), or [`focusColor`](#focusColor).
|