@octaviaflow/feature-flags 1.0.0 → 1.1.3

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 (3) hide show
  1. package/es/index.js +147 -301
  2. package/lib/index.js +147 -301
  3. package/package.json +5 -13
package/es/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
 
2
2
 
3
- var enabled$1 = {};
3
+ const enabled$1 = {};
4
4
  try {
5
5
  if (process.env.CARBON_ENABLE_CSS_CUSTOM_PROPERTIES) {
6
- if (process.env.CARBON_ENABLE_CSS_CUSTOM_PROPERTIES === 'true') {
6
+ if (process.env.CARBON_ENABLE_CSS_CUSTOM_PROPERTIES === "true") {
7
7
  enabled$1.enableCssCustomProperties = true;
8
8
  } else {
9
9
  enabled$1.enableCssCustomProperties = false;
@@ -12,7 +12,7 @@ try {
12
12
  enabled$1.enableCssCustomProperties = false;
13
13
  }
14
14
  if (process.env.CARBON_ENABLE_CSS_GRID) {
15
- if (process.env.CARBON_ENABLE_CSS_GRID === 'true') {
15
+ if (process.env.CARBON_ENABLE_CSS_GRID === "true") {
16
16
  enabled$1.enableCssGrid = true;
17
17
  } else {
18
18
  enabled$1.enableCssGrid = false;
@@ -21,7 +21,7 @@ try {
21
21
  enabled$1.enableCssGrid = false;
22
22
  }
23
23
  if (process.env.CARBON_ENABLE_V11_RELEASE) {
24
- if (process.env.CARBON_ENABLE_V11_RELEASE === 'true') {
24
+ if (process.env.CARBON_ENABLE_V11_RELEASE === "true") {
25
25
  enabled$1.enableV11Release = true;
26
26
  } else {
27
27
  enabled$1.enableV11Release = false;
@@ -30,7 +30,7 @@ try {
30
30
  enabled$1.enableV11Release = true;
31
31
  }
32
32
  if (process.env.CARBON_ENABLE_EXPERIMENTAL_TILE_CONTRAST) {
33
- if (process.env.CARBON_ENABLE_EXPERIMENTAL_TILE_CONTRAST === 'true') {
33
+ if (process.env.CARBON_ENABLE_EXPERIMENTAL_TILE_CONTRAST === "true") {
34
34
  enabled$1.enableExperimentalTileContrast = true;
35
35
  } else {
36
36
  enabled$1.enableExperimentalTileContrast = false;
@@ -39,7 +39,7 @@ try {
39
39
  enabled$1.enableExperimentalTileContrast = false;
40
40
  }
41
41
  if (process.env.CARBON_ENABLE_V12_TILE_DEFAULT_ICONS) {
42
- if (process.env.CARBON_ENABLE_V12_TILE_DEFAULT_ICONS === 'true') {
42
+ if (process.env.CARBON_ENABLE_V12_TILE_DEFAULT_ICONS === "true") {
43
43
  enabled$1.enableV12TileDefaultIcons = true;
44
44
  } else {
45
45
  enabled$1.enableV12TileDefaultIcons = false;
@@ -48,7 +48,7 @@ try {
48
48
  enabled$1.enableV12TileDefaultIcons = false;
49
49
  }
50
50
  if (process.env.CARBON_ENABLE_V12_TILE_RADIO_ICONS) {
51
- if (process.env.CARBON_ENABLE_V12_TILE_RADIO_ICONS === 'true') {
51
+ if (process.env.CARBON_ENABLE_V12_TILE_RADIO_ICONS === "true") {
52
52
  enabled$1.enableV12TileRadioIcons = true;
53
53
  } else {
54
54
  enabled$1.enableV12TileRadioIcons = false;
@@ -57,7 +57,7 @@ try {
57
57
  enabled$1.enableV12TileRadioIcons = false;
58
58
  }
59
59
  if (process.env.CARBON_ENABLE_V12_OVERFLOWMENU) {
60
- if (process.env.CARBON_ENABLE_V12_OVERFLOWMENU === 'true') {
60
+ if (process.env.CARBON_ENABLE_V12_OVERFLOWMENU === "true") {
61
61
  enabled$1.enableV12Overflowmenu = true;
62
62
  } else {
63
63
  enabled$1.enableV12Overflowmenu = false;
@@ -66,7 +66,7 @@ try {
66
66
  enabled$1.enableV12Overflowmenu = false;
67
67
  }
68
68
  if (process.env.CARBON_ENABLE_TREEVIEW_CONTROLLABLE) {
69
- if (process.env.CARBON_ENABLE_TREEVIEW_CONTROLLABLE === 'true') {
69
+ if (process.env.CARBON_ENABLE_TREEVIEW_CONTROLLABLE === "true") {
70
70
  enabled$1.enableTreeviewControllable = true;
71
71
  } else {
72
72
  enabled$1.enableTreeviewControllable = false;
@@ -75,7 +75,7 @@ try {
75
75
  enabled$1.enableTreeviewControllable = false;
76
76
  }
77
77
  if (process.env.CARBON_ENABLE_V12_STRUCTURED_LIST_VISIBLE_ICONS) {
78
- if (process.env.CARBON_ENABLE_V12_STRUCTURED_LIST_VISIBLE_ICONS === 'true') {
78
+ if (process.env.CARBON_ENABLE_V12_STRUCTURED_LIST_VISIBLE_ICONS === "true") {
79
79
  enabled$1.enableV12StructuredListVisibleIcons = true;
80
80
  } else {
81
81
  enabled$1.enableV12StructuredListVisibleIcons = false;
@@ -84,7 +84,7 @@ try {
84
84
  enabled$1.enableV12StructuredListVisibleIcons = false;
85
85
  }
86
86
  if (process.env.CARBON_ENABLE_EXPERIMENTAL_FOCUS_WRAP_WITHOUT_SENTINELS) {
87
- if (process.env.CARBON_ENABLE_EXPERIMENTAL_FOCUS_WRAP_WITHOUT_SENTINELS === 'true') {
87
+ if (process.env.CARBON_ENABLE_EXPERIMENTAL_FOCUS_WRAP_WITHOUT_SENTINELS === "true") {
88
88
  enabled$1.enableExperimentalFocusWrapWithoutSentinels = true;
89
89
  } else {
90
90
  enabled$1.enableExperimentalFocusWrapWithoutSentinels = false;
@@ -93,7 +93,7 @@ try {
93
93
  enabled$1.enableExperimentalFocusWrapWithoutSentinels = false;
94
94
  }
95
95
  if (process.env.CARBON_ENABLE_V12_DYNAMIC_FLOATING_STYLES) {
96
- if (process.env.CARBON_ENABLE_V12_DYNAMIC_FLOATING_STYLES === 'true') {
96
+ if (process.env.CARBON_ENABLE_V12_DYNAMIC_FLOATING_STYLES === "true") {
97
97
  enabled$1.enableV12DynamicFloatingStyles = true;
98
98
  } else {
99
99
  enabled$1.enableV12DynamicFloatingStyles = false;
@@ -114,319 +114,165 @@ try {
114
114
  enabled$1.enableExperimentalFocusWrapWithoutSentinels = false;
115
115
  enabled$1.enableV12DynamicFloatingStyles = false;
116
116
  }
117
- var featureFlagInfo = [{
118
- name: "enable-css-custom-properties",
119
- description: "Describe what the flag does",
120
- enabled: enabled$1.enableCssCustomProperties
121
- }, {
122
- name: "enable-css-grid",
123
- description: "Enable CSS Grid Layout in the Grid and Column React components\n",
124
- enabled: enabled$1.enableCssGrid
125
- }, {
126
- name: "enable-v11-release",
127
- description: "Enable the features and functionality for the v11 Release\n",
128
- enabled: enabled$1.enableV11Release
129
- }, {
130
- name: "enable-experimental-tile-contrast",
131
- description: "Enable the experimental tile improved contrast styles\n",
132
- enabled: enabled$1.enableExperimentalTileContrast
133
- }, {
134
- name: "enable-v12-tile-default-icons",
135
- description: "Enable rendering of default icons in the tile components\n",
136
- enabled: enabled$1.enableV12TileDefaultIcons
137
- }, {
138
- name: "enable-v12-tile-radio-icons",
139
- description: "Enable rendering of radio icons in the RadioTile component\n",
140
- enabled: enabled$1.enableV12TileRadioIcons
141
- }, {
142
- name: "enable-v12-overflowmenu",
143
- description: "Enable the use of the v12 OverflowMenu leveraging the Menu subcomponents\n",
144
- enabled: enabled$1.enableV12Overflowmenu
145
- }, {
146
- name: "enable-treeview-controllable",
147
- description: "Enable the new TreeView controllable API\n",
148
- enabled: enabled$1.enableTreeviewControllable
149
- }, {
150
- name: "enable-v12-structured-list-visible-icons",
151
- description: "Enable rendering of radio icons in the StructuredList component\n",
152
- enabled: enabled$1.enableV12StructuredListVisibleIcons
153
- }, {
154
- name: "enable-experimental-focus-wrap-without-sentinels",
155
- description: "Enable the new focus wrap behavior that doesn't use sentinel nodes\n",
156
- enabled: enabled$1.enableExperimentalFocusWrapWithoutSentinels
157
- }, {
158
- name: "enable-v12-dynamic-floating-styles",
159
- description: "Enable dynamic setting of floating styles for components like Popover, Tooltip, etc.\n",
160
- enabled: enabled$1.enableV12DynamicFloatingStyles
161
- }];
162
-
163
- function _arrayLikeToArray(r, a) {
164
- (null == a || a > r.length) && (a = r.length);
165
- for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
166
- return n;
167
- }
168
- function _arrayWithHoles(r) {
169
- if (Array.isArray(r)) return r;
170
- }
171
- function _classCallCheck(a, n) {
172
- if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
173
- }
174
- function _defineProperties(e, r) {
175
- for (var t = 0; t < r.length; t++) {
176
- var o = r[t];
177
- o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
178
- }
179
- }
180
- function _createClass(e, r, t) {
181
- return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
182
- writable: !1
183
- }), e;
184
- }
185
- function _createForOfIteratorHelper(r, e) {
186
- var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
187
- if (!t) {
188
- if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
189
- t && (r = t);
190
- var n = 0,
191
- F = function () {};
192
- return {
193
- s: F,
194
- n: function () {
195
- return n >= r.length ? {
196
- done: !0
197
- } : {
198
- done: !1,
199
- value: r[n++]
200
- };
201
- },
202
- e: function (r) {
203
- throw r;
204
- },
205
- f: F
206
- };
207
- }
208
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
117
+ const featureFlagInfo = [
118
+ {
119
+ name: "enable-css-custom-properties",
120
+ description: "Describe what the flag does",
121
+ enabled: enabled$1.enableCssCustomProperties
122
+ },
123
+ {
124
+ name: "enable-css-grid",
125
+ description: "Enable CSS Grid Layout in the Grid and Column React components\n",
126
+ enabled: enabled$1.enableCssGrid
127
+ },
128
+ {
129
+ name: "enable-v11-release",
130
+ description: "Enable the features and functionality for the v11 Release\n",
131
+ enabled: enabled$1.enableV11Release
132
+ },
133
+ {
134
+ name: "enable-experimental-tile-contrast",
135
+ description: "Enable the experimental tile improved contrast styles\n",
136
+ enabled: enabled$1.enableExperimentalTileContrast
137
+ },
138
+ {
139
+ name: "enable-v12-tile-default-icons",
140
+ description: "Enable rendering of default icons in the tile components\n",
141
+ enabled: enabled$1.enableV12TileDefaultIcons
142
+ },
143
+ {
144
+ name: "enable-v12-tile-radio-icons",
145
+ description: "Enable rendering of radio icons in the RadioTile component\n",
146
+ enabled: enabled$1.enableV12TileRadioIcons
147
+ },
148
+ {
149
+ name: "enable-v12-overflowmenu",
150
+ description: "Enable the use of the v12 OverflowMenu leveraging the Menu subcomponents\n",
151
+ enabled: enabled$1.enableV12Overflowmenu
152
+ },
153
+ {
154
+ name: "enable-treeview-controllable",
155
+ description: "Enable the new TreeView controllable API\n",
156
+ enabled: enabled$1.enableTreeviewControllable
157
+ },
158
+ {
159
+ name: "enable-v12-structured-list-visible-icons",
160
+ description: "Enable rendering of radio icons in the StructuredList component\n",
161
+ enabled: enabled$1.enableV12StructuredListVisibleIcons
162
+ },
163
+ {
164
+ name: "enable-experimental-focus-wrap-without-sentinels",
165
+ description: "Enable the new focus wrap behavior that doesn't use sentinel nodes\n",
166
+ enabled: enabled$1.enableExperimentalFocusWrapWithoutSentinels
167
+ },
168
+ {
169
+ name: "enable-v12-dynamic-floating-styles",
170
+ description: "Enable dynamic setting of floating styles for components like Popover, Tooltip, etc.\n",
171
+ enabled: enabled$1.enableV12DynamicFloatingStyles
209
172
  }
210
- var o,
211
- a = !0,
212
- u = !1;
213
- return {
214
- s: function () {
215
- t = t.call(r);
216
- },
217
- n: function () {
218
- var r = t.next();
219
- return a = r.done, r;
220
- },
221
- e: function (r) {
222
- u = !0, o = r;
223
- },
224
- f: function () {
225
- try {
226
- a || null == t.return || t.return();
227
- } finally {
228
- if (u) throw o;
229
- }
230
- }
231
- };
232
- }
233
- function _iterableToArrayLimit(r, l) {
234
- var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
235
- if (null != t) {
236
- var e,
237
- n,
238
- i,
239
- u,
240
- a = [],
241
- f = !0,
242
- o = !1;
243
- try {
244
- if (i = (t = t.call(r)).next, 0 === l) {
245
- if (Object(t) !== t) return;
246
- f = !1;
247
- } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
248
- } catch (r) {
249
- o = !0, n = r;
250
- } finally {
251
- try {
252
- if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
253
- } finally {
254
- if (o) throw n;
255
- }
256
- }
257
- return a;
258
- }
259
- }
260
- function _nonIterableRest() {
261
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
262
- }
263
- function _slicedToArray(r, e) {
264
- return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
265
- }
266
- function _toPrimitive(t, r) {
267
- if ("object" != typeof t || !t) return t;
268
- var e = t[Symbol.toPrimitive];
269
- if (void 0 !== e) {
270
- var i = e.call(t, r || "default");
271
- if ("object" != typeof i) return i;
272
- throw new TypeError("@@toPrimitive must return a primitive value.");
273
- }
274
- return ("string" === r ? String : Number)(t);
275
- }
276
- function _toPropertyKey(t) {
277
- var i = _toPrimitive(t, "string");
278
- return "symbol" == typeof i ? i : i + "";
279
- }
280
- function _unsupportedIterableToArray(r, a) {
281
- if (r) {
282
- if ("string" == typeof r) return _arrayLikeToArray(r, a);
283
- var t = {}.toString.call(r).slice(8, -1);
284
- 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;
285
- }
286
- }
173
+ ];
287
174
 
288
- /**
289
- * Copyright OctaviaFlow. 2025
290
- *
291
- * This source code is licensed under the Apache-2.0 license found in the
292
- * LICENSE file in the root directory of this source tree.
293
- */
294
-
295
- var FeatureFlagScope = /*#__PURE__*/function () {
296
- function FeatureFlagScope(flags) {
297
- var _this = this;
298
- _classCallCheck(this, FeatureFlagScope);
299
- this.flags = new Map();
175
+ class FeatureFlagScope {
176
+ constructor(flags) {
177
+ this.flags = /* @__PURE__ */ new Map();
300
178
  if (flags) {
301
- Object.keys(flags).forEach(function (key) {
302
- _this.flags.set(key, flags[key]);
179
+ Object.keys(flags).forEach((key) => {
180
+ this.flags.set(key, flags[key]);
303
181
  });
304
182
  }
305
183
  }
306
-
307
184
  /**
308
185
  * Check to see if a flag exists
309
186
  * @param {string} name
310
187
  */
311
- return _createClass(FeatureFlagScope, [{
312
- key: "checkForFlag",
313
- value: function checkForFlag(name) {
314
- if (!this.flags.has(name)) {
315
- throw new Error("Unable to find a feature flag with the name: `".concat(name, "`"));
316
- }
317
- }
318
-
319
- /**
320
- * Add a feature flag
321
- * @param {string} name
322
- * @param {boolean} enabled
323
- */
324
- }, {
325
- key: "add",
326
- value: function add(name, enabled) {
327
- if (this.flags.has(name)) {
328
- throw new Error("The feature flag: ".concat(name, " already exists"));
329
- }
330
- this.flags.set(name, enabled);
188
+ checkForFlag(name) {
189
+ if (!this.flags.has(name)) {
190
+ throw new Error(
191
+ `Unable to find a feature flag with the name: \`${name}\``
192
+ );
331
193
  }
332
-
333
- /**
334
- * Enable a feature flag
335
- * @param {string} name
336
- */
337
- }, {
338
- key: "enable",
339
- value: function enable(name) {
340
- this.checkForFlag(name);
341
- this.flags.set(name, true);
342
- }
343
-
344
- /**
345
- * Disable a feature flag
346
- * @param {string} name
347
- */
348
- }, {
349
- key: "disable",
350
- value: function disable(name) {
351
- this.checkForFlag(name);
352
- this.flags.set(name, false);
353
- }
354
-
355
- /**
356
- * Merge the given feature flags with the current set of feature flags.
357
- * Duplicate keys will be set to the value in the given feature flags.
358
- * @param {object} flags
359
- */
360
- }, {
361
- key: "merge",
362
- value: function merge(flags) {
363
- var _this2 = this;
364
- Object.keys(flags).forEach(function (key) {
365
- _this2.flags.set(key, flags[key]);
366
- });
194
+ }
195
+ /**
196
+ * Add a feature flag
197
+ * @param {string} name
198
+ * @param {boolean} enabled
199
+ */
200
+ add(name, enabled) {
201
+ if (this.flags.has(name)) {
202
+ throw new Error(`The feature flag: ${name} already exists`);
367
203
  }
368
-
369
- /**
370
- * @param {FeatureFlagScope} scope
371
- */
372
- }, {
373
- key: "mergeWithScope",
374
- value: function mergeWithScope(scope) {
375
- var _iterator = _createForOfIteratorHelper(scope.flags),
376
- _step;
377
- try {
378
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
379
- var _step$value = _slicedToArray(_step.value, 2),
380
- key = _step$value[0],
381
- value = _step$value[1];
382
- if (this.flags.has(key)) {
383
- continue;
384
- }
385
- this.flags.set(key, value);
386
- }
387
- } catch (err) {
388
- _iterator.e(err);
389
- } finally {
390
- _iterator.f();
204
+ this.flags.set(name, enabled);
205
+ }
206
+ /**
207
+ * Enable a feature flag
208
+ * @param {string} name
209
+ */
210
+ enable(name) {
211
+ this.checkForFlag(name);
212
+ this.flags.set(name, true);
213
+ }
214
+ /**
215
+ * Disable a feature flag
216
+ * @param {string} name
217
+ */
218
+ disable(name) {
219
+ this.checkForFlag(name);
220
+ this.flags.set(name, false);
221
+ }
222
+ /**
223
+ * Merge the given feature flags with the current set of feature flags.
224
+ * Duplicate keys will be set to the value in the given feature flags.
225
+ * @param {object} flags
226
+ */
227
+ merge(flags) {
228
+ Object.keys(flags).forEach((key) => {
229
+ this.flags.set(key, flags[key]);
230
+ });
231
+ }
232
+ /**
233
+ * @param {FeatureFlagScope} scope
234
+ */
235
+ mergeWithScope(scope) {
236
+ for (const [key, value] of scope.flags) {
237
+ if (this.flags.has(key)) {
238
+ continue;
391
239
  }
240
+ this.flags.set(key, value);
392
241
  }
242
+ }
243
+ /**
244
+ * Check if a feature flag is enabled
245
+ * @param {string} name
246
+ * @returns {boolean}
247
+ */
248
+ enabled(name) {
249
+ this.checkForFlag(name);
250
+ return this.flags.get(name);
251
+ }
252
+ }
393
253
 
394
- /**
395
- * Check if a feature flag is enabled
396
- * @param {string} name
397
- * @returns {boolean}
398
- */
399
- }, {
400
- key: "enabled",
401
- value: function enabled(name) {
402
- this.checkForFlag(name);
403
- return this.flags.get(name);
404
- }
405
- }]);
406
- }();
407
-
408
- var FeatureFlags = createScope();
409
- for (var i = 0; i < featureFlagInfo.length; i++) {
410
- var featureFlag = featureFlagInfo[i];
254
+ const FeatureFlags = createScope();
255
+ for (let i = 0; i < featureFlagInfo.length; i++) {
256
+ const featureFlag = featureFlagInfo[i];
411
257
  FeatureFlags.add(featureFlag.name, featureFlag.enabled);
412
258
  }
413
259
  function createScope(flags) {
414
260
  return new FeatureFlagScope(flags);
415
261
  }
416
- function add() {
417
- return FeatureFlags.add.apply(FeatureFlags, arguments);
262
+ function add(...args) {
263
+ return FeatureFlags.add(...args);
418
264
  }
419
- function enable() {
420
- return FeatureFlags.enable.apply(FeatureFlags, arguments);
265
+ function enable(...args) {
266
+ return FeatureFlags.enable(...args);
421
267
  }
422
- function disable() {
423
- return FeatureFlags.disable.apply(FeatureFlags, arguments);
268
+ function disable(...args) {
269
+ return FeatureFlags.disable(...args);
424
270
  }
425
- function enabled() {
426
- return FeatureFlags.enabled.apply(FeatureFlags, arguments);
271
+ function enabled(...args) {
272
+ return FeatureFlags.enabled(...args);
427
273
  }
428
- function merge() {
429
- return FeatureFlags.merge.apply(FeatureFlags, arguments);
274
+ function merge(...args) {
275
+ return FeatureFlags.merge(...args);
430
276
  }
431
277
 
432
278
  export { FeatureFlags, add, createScope, disable, enable, enabled, merge };
package/lib/index.js CHANGED
@@ -4,10 +4,10 @@
4
4
 
5
5
  Object.defineProperty(exports, '__esModule', { value: true });
6
6
 
7
- var enabled$1 = {};
7
+ const enabled$1 = {};
8
8
  try {
9
9
  if (process.env.CARBON_ENABLE_CSS_CUSTOM_PROPERTIES) {
10
- if (process.env.CARBON_ENABLE_CSS_CUSTOM_PROPERTIES === 'true') {
10
+ if (process.env.CARBON_ENABLE_CSS_CUSTOM_PROPERTIES === "true") {
11
11
  enabled$1.enableCssCustomProperties = true;
12
12
  } else {
13
13
  enabled$1.enableCssCustomProperties = false;
@@ -16,7 +16,7 @@ try {
16
16
  enabled$1.enableCssCustomProperties = false;
17
17
  }
18
18
  if (process.env.CARBON_ENABLE_CSS_GRID) {
19
- if (process.env.CARBON_ENABLE_CSS_GRID === 'true') {
19
+ if (process.env.CARBON_ENABLE_CSS_GRID === "true") {
20
20
  enabled$1.enableCssGrid = true;
21
21
  } else {
22
22
  enabled$1.enableCssGrid = false;
@@ -25,7 +25,7 @@ try {
25
25
  enabled$1.enableCssGrid = false;
26
26
  }
27
27
  if (process.env.CARBON_ENABLE_V11_RELEASE) {
28
- if (process.env.CARBON_ENABLE_V11_RELEASE === 'true') {
28
+ if (process.env.CARBON_ENABLE_V11_RELEASE === "true") {
29
29
  enabled$1.enableV11Release = true;
30
30
  } else {
31
31
  enabled$1.enableV11Release = false;
@@ -34,7 +34,7 @@ try {
34
34
  enabled$1.enableV11Release = true;
35
35
  }
36
36
  if (process.env.CARBON_ENABLE_EXPERIMENTAL_TILE_CONTRAST) {
37
- if (process.env.CARBON_ENABLE_EXPERIMENTAL_TILE_CONTRAST === 'true') {
37
+ if (process.env.CARBON_ENABLE_EXPERIMENTAL_TILE_CONTRAST === "true") {
38
38
  enabled$1.enableExperimentalTileContrast = true;
39
39
  } else {
40
40
  enabled$1.enableExperimentalTileContrast = false;
@@ -43,7 +43,7 @@ try {
43
43
  enabled$1.enableExperimentalTileContrast = false;
44
44
  }
45
45
  if (process.env.CARBON_ENABLE_V12_TILE_DEFAULT_ICONS) {
46
- if (process.env.CARBON_ENABLE_V12_TILE_DEFAULT_ICONS === 'true') {
46
+ if (process.env.CARBON_ENABLE_V12_TILE_DEFAULT_ICONS === "true") {
47
47
  enabled$1.enableV12TileDefaultIcons = true;
48
48
  } else {
49
49
  enabled$1.enableV12TileDefaultIcons = false;
@@ -52,7 +52,7 @@ try {
52
52
  enabled$1.enableV12TileDefaultIcons = false;
53
53
  }
54
54
  if (process.env.CARBON_ENABLE_V12_TILE_RADIO_ICONS) {
55
- if (process.env.CARBON_ENABLE_V12_TILE_RADIO_ICONS === 'true') {
55
+ if (process.env.CARBON_ENABLE_V12_TILE_RADIO_ICONS === "true") {
56
56
  enabled$1.enableV12TileRadioIcons = true;
57
57
  } else {
58
58
  enabled$1.enableV12TileRadioIcons = false;
@@ -61,7 +61,7 @@ try {
61
61
  enabled$1.enableV12TileRadioIcons = false;
62
62
  }
63
63
  if (process.env.CARBON_ENABLE_V12_OVERFLOWMENU) {
64
- if (process.env.CARBON_ENABLE_V12_OVERFLOWMENU === 'true') {
64
+ if (process.env.CARBON_ENABLE_V12_OVERFLOWMENU === "true") {
65
65
  enabled$1.enableV12Overflowmenu = true;
66
66
  } else {
67
67
  enabled$1.enableV12Overflowmenu = false;
@@ -70,7 +70,7 @@ try {
70
70
  enabled$1.enableV12Overflowmenu = false;
71
71
  }
72
72
  if (process.env.CARBON_ENABLE_TREEVIEW_CONTROLLABLE) {
73
- if (process.env.CARBON_ENABLE_TREEVIEW_CONTROLLABLE === 'true') {
73
+ if (process.env.CARBON_ENABLE_TREEVIEW_CONTROLLABLE === "true") {
74
74
  enabled$1.enableTreeviewControllable = true;
75
75
  } else {
76
76
  enabled$1.enableTreeviewControllable = false;
@@ -79,7 +79,7 @@ try {
79
79
  enabled$1.enableTreeviewControllable = false;
80
80
  }
81
81
  if (process.env.CARBON_ENABLE_V12_STRUCTURED_LIST_VISIBLE_ICONS) {
82
- if (process.env.CARBON_ENABLE_V12_STRUCTURED_LIST_VISIBLE_ICONS === 'true') {
82
+ if (process.env.CARBON_ENABLE_V12_STRUCTURED_LIST_VISIBLE_ICONS === "true") {
83
83
  enabled$1.enableV12StructuredListVisibleIcons = true;
84
84
  } else {
85
85
  enabled$1.enableV12StructuredListVisibleIcons = false;
@@ -88,7 +88,7 @@ try {
88
88
  enabled$1.enableV12StructuredListVisibleIcons = false;
89
89
  }
90
90
  if (process.env.CARBON_ENABLE_EXPERIMENTAL_FOCUS_WRAP_WITHOUT_SENTINELS) {
91
- if (process.env.CARBON_ENABLE_EXPERIMENTAL_FOCUS_WRAP_WITHOUT_SENTINELS === 'true') {
91
+ if (process.env.CARBON_ENABLE_EXPERIMENTAL_FOCUS_WRAP_WITHOUT_SENTINELS === "true") {
92
92
  enabled$1.enableExperimentalFocusWrapWithoutSentinels = true;
93
93
  } else {
94
94
  enabled$1.enableExperimentalFocusWrapWithoutSentinels = false;
@@ -97,7 +97,7 @@ try {
97
97
  enabled$1.enableExperimentalFocusWrapWithoutSentinels = false;
98
98
  }
99
99
  if (process.env.CARBON_ENABLE_V12_DYNAMIC_FLOATING_STYLES) {
100
- if (process.env.CARBON_ENABLE_V12_DYNAMIC_FLOATING_STYLES === 'true') {
100
+ if (process.env.CARBON_ENABLE_V12_DYNAMIC_FLOATING_STYLES === "true") {
101
101
  enabled$1.enableV12DynamicFloatingStyles = true;
102
102
  } else {
103
103
  enabled$1.enableV12DynamicFloatingStyles = false;
@@ -118,319 +118,165 @@ try {
118
118
  enabled$1.enableExperimentalFocusWrapWithoutSentinels = false;
119
119
  enabled$1.enableV12DynamicFloatingStyles = false;
120
120
  }
121
- var featureFlagInfo = [{
122
- name: "enable-css-custom-properties",
123
- description: "Describe what the flag does",
124
- enabled: enabled$1.enableCssCustomProperties
125
- }, {
126
- name: "enable-css-grid",
127
- description: "Enable CSS Grid Layout in the Grid and Column React components\n",
128
- enabled: enabled$1.enableCssGrid
129
- }, {
130
- name: "enable-v11-release",
131
- description: "Enable the features and functionality for the v11 Release\n",
132
- enabled: enabled$1.enableV11Release
133
- }, {
134
- name: "enable-experimental-tile-contrast",
135
- description: "Enable the experimental tile improved contrast styles\n",
136
- enabled: enabled$1.enableExperimentalTileContrast
137
- }, {
138
- name: "enable-v12-tile-default-icons",
139
- description: "Enable rendering of default icons in the tile components\n",
140
- enabled: enabled$1.enableV12TileDefaultIcons
141
- }, {
142
- name: "enable-v12-tile-radio-icons",
143
- description: "Enable rendering of radio icons in the RadioTile component\n",
144
- enabled: enabled$1.enableV12TileRadioIcons
145
- }, {
146
- name: "enable-v12-overflowmenu",
147
- description: "Enable the use of the v12 OverflowMenu leveraging the Menu subcomponents\n",
148
- enabled: enabled$1.enableV12Overflowmenu
149
- }, {
150
- name: "enable-treeview-controllable",
151
- description: "Enable the new TreeView controllable API\n",
152
- enabled: enabled$1.enableTreeviewControllable
153
- }, {
154
- name: "enable-v12-structured-list-visible-icons",
155
- description: "Enable rendering of radio icons in the StructuredList component\n",
156
- enabled: enabled$1.enableV12StructuredListVisibleIcons
157
- }, {
158
- name: "enable-experimental-focus-wrap-without-sentinels",
159
- description: "Enable the new focus wrap behavior that doesn't use sentinel nodes\n",
160
- enabled: enabled$1.enableExperimentalFocusWrapWithoutSentinels
161
- }, {
162
- name: "enable-v12-dynamic-floating-styles",
163
- description: "Enable dynamic setting of floating styles for components like Popover, Tooltip, etc.\n",
164
- enabled: enabled$1.enableV12DynamicFloatingStyles
165
- }];
166
-
167
- function _arrayLikeToArray(r, a) {
168
- (null == a || a > r.length) && (a = r.length);
169
- for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
170
- return n;
171
- }
172
- function _arrayWithHoles(r) {
173
- if (Array.isArray(r)) return r;
174
- }
175
- function _classCallCheck(a, n) {
176
- if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
177
- }
178
- function _defineProperties(e, r) {
179
- for (var t = 0; t < r.length; t++) {
180
- var o = r[t];
181
- o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
182
- }
183
- }
184
- function _createClass(e, r, t) {
185
- return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
186
- writable: !1
187
- }), e;
188
- }
189
- function _createForOfIteratorHelper(r, e) {
190
- var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
191
- if (!t) {
192
- if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
193
- t && (r = t);
194
- var n = 0,
195
- F = function () {};
196
- return {
197
- s: F,
198
- n: function () {
199
- return n >= r.length ? {
200
- done: !0
201
- } : {
202
- done: !1,
203
- value: r[n++]
204
- };
205
- },
206
- e: function (r) {
207
- throw r;
208
- },
209
- f: F
210
- };
211
- }
212
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
121
+ const featureFlagInfo = [
122
+ {
123
+ name: "enable-css-custom-properties",
124
+ description: "Describe what the flag does",
125
+ enabled: enabled$1.enableCssCustomProperties
126
+ },
127
+ {
128
+ name: "enable-css-grid",
129
+ description: "Enable CSS Grid Layout in the Grid and Column React components\n",
130
+ enabled: enabled$1.enableCssGrid
131
+ },
132
+ {
133
+ name: "enable-v11-release",
134
+ description: "Enable the features and functionality for the v11 Release\n",
135
+ enabled: enabled$1.enableV11Release
136
+ },
137
+ {
138
+ name: "enable-experimental-tile-contrast",
139
+ description: "Enable the experimental tile improved contrast styles\n",
140
+ enabled: enabled$1.enableExperimentalTileContrast
141
+ },
142
+ {
143
+ name: "enable-v12-tile-default-icons",
144
+ description: "Enable rendering of default icons in the tile components\n",
145
+ enabled: enabled$1.enableV12TileDefaultIcons
146
+ },
147
+ {
148
+ name: "enable-v12-tile-radio-icons",
149
+ description: "Enable rendering of radio icons in the RadioTile component\n",
150
+ enabled: enabled$1.enableV12TileRadioIcons
151
+ },
152
+ {
153
+ name: "enable-v12-overflowmenu",
154
+ description: "Enable the use of the v12 OverflowMenu leveraging the Menu subcomponents\n",
155
+ enabled: enabled$1.enableV12Overflowmenu
156
+ },
157
+ {
158
+ name: "enable-treeview-controllable",
159
+ description: "Enable the new TreeView controllable API\n",
160
+ enabled: enabled$1.enableTreeviewControllable
161
+ },
162
+ {
163
+ name: "enable-v12-structured-list-visible-icons",
164
+ description: "Enable rendering of radio icons in the StructuredList component\n",
165
+ enabled: enabled$1.enableV12StructuredListVisibleIcons
166
+ },
167
+ {
168
+ name: "enable-experimental-focus-wrap-without-sentinels",
169
+ description: "Enable the new focus wrap behavior that doesn't use sentinel nodes\n",
170
+ enabled: enabled$1.enableExperimentalFocusWrapWithoutSentinels
171
+ },
172
+ {
173
+ name: "enable-v12-dynamic-floating-styles",
174
+ description: "Enable dynamic setting of floating styles for components like Popover, Tooltip, etc.\n",
175
+ enabled: enabled$1.enableV12DynamicFloatingStyles
213
176
  }
214
- var o,
215
- a = !0,
216
- u = !1;
217
- return {
218
- s: function () {
219
- t = t.call(r);
220
- },
221
- n: function () {
222
- var r = t.next();
223
- return a = r.done, r;
224
- },
225
- e: function (r) {
226
- u = !0, o = r;
227
- },
228
- f: function () {
229
- try {
230
- a || null == t.return || t.return();
231
- } finally {
232
- if (u) throw o;
233
- }
234
- }
235
- };
236
- }
237
- function _iterableToArrayLimit(r, l) {
238
- var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
239
- if (null != t) {
240
- var e,
241
- n,
242
- i,
243
- u,
244
- a = [],
245
- f = !0,
246
- o = !1;
247
- try {
248
- if (i = (t = t.call(r)).next, 0 === l) {
249
- if (Object(t) !== t) return;
250
- f = !1;
251
- } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
252
- } catch (r) {
253
- o = !0, n = r;
254
- } finally {
255
- try {
256
- if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
257
- } finally {
258
- if (o) throw n;
259
- }
260
- }
261
- return a;
262
- }
263
- }
264
- function _nonIterableRest() {
265
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
266
- }
267
- function _slicedToArray(r, e) {
268
- return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
269
- }
270
- function _toPrimitive(t, r) {
271
- if ("object" != typeof t || !t) return t;
272
- var e = t[Symbol.toPrimitive];
273
- if (void 0 !== e) {
274
- var i = e.call(t, r || "default");
275
- if ("object" != typeof i) return i;
276
- throw new TypeError("@@toPrimitive must return a primitive value.");
277
- }
278
- return ("string" === r ? String : Number)(t);
279
- }
280
- function _toPropertyKey(t) {
281
- var i = _toPrimitive(t, "string");
282
- return "symbol" == typeof i ? i : i + "";
283
- }
284
- function _unsupportedIterableToArray(r, a) {
285
- if (r) {
286
- if ("string" == typeof r) return _arrayLikeToArray(r, a);
287
- var t = {}.toString.call(r).slice(8, -1);
288
- 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;
289
- }
290
- }
177
+ ];
291
178
 
292
- /**
293
- * Copyright OctaviaFlow. 2025
294
- *
295
- * This source code is licensed under the Apache-2.0 license found in the
296
- * LICENSE file in the root directory of this source tree.
297
- */
298
-
299
- var FeatureFlagScope = /*#__PURE__*/function () {
300
- function FeatureFlagScope(flags) {
301
- var _this = this;
302
- _classCallCheck(this, FeatureFlagScope);
303
- this.flags = new Map();
179
+ class FeatureFlagScope {
180
+ constructor(flags) {
181
+ this.flags = /* @__PURE__ */ new Map();
304
182
  if (flags) {
305
- Object.keys(flags).forEach(function (key) {
306
- _this.flags.set(key, flags[key]);
183
+ Object.keys(flags).forEach((key) => {
184
+ this.flags.set(key, flags[key]);
307
185
  });
308
186
  }
309
187
  }
310
-
311
188
  /**
312
189
  * Check to see if a flag exists
313
190
  * @param {string} name
314
191
  */
315
- return _createClass(FeatureFlagScope, [{
316
- key: "checkForFlag",
317
- value: function checkForFlag(name) {
318
- if (!this.flags.has(name)) {
319
- throw new Error("Unable to find a feature flag with the name: `".concat(name, "`"));
320
- }
321
- }
322
-
323
- /**
324
- * Add a feature flag
325
- * @param {string} name
326
- * @param {boolean} enabled
327
- */
328
- }, {
329
- key: "add",
330
- value: function add(name, enabled) {
331
- if (this.flags.has(name)) {
332
- throw new Error("The feature flag: ".concat(name, " already exists"));
333
- }
334
- this.flags.set(name, enabled);
192
+ checkForFlag(name) {
193
+ if (!this.flags.has(name)) {
194
+ throw new Error(
195
+ `Unable to find a feature flag with the name: \`${name}\``
196
+ );
335
197
  }
336
-
337
- /**
338
- * Enable a feature flag
339
- * @param {string} name
340
- */
341
- }, {
342
- key: "enable",
343
- value: function enable(name) {
344
- this.checkForFlag(name);
345
- this.flags.set(name, true);
346
- }
347
-
348
- /**
349
- * Disable a feature flag
350
- * @param {string} name
351
- */
352
- }, {
353
- key: "disable",
354
- value: function disable(name) {
355
- this.checkForFlag(name);
356
- this.flags.set(name, false);
357
- }
358
-
359
- /**
360
- * Merge the given feature flags with the current set of feature flags.
361
- * Duplicate keys will be set to the value in the given feature flags.
362
- * @param {object} flags
363
- */
364
- }, {
365
- key: "merge",
366
- value: function merge(flags) {
367
- var _this2 = this;
368
- Object.keys(flags).forEach(function (key) {
369
- _this2.flags.set(key, flags[key]);
370
- });
198
+ }
199
+ /**
200
+ * Add a feature flag
201
+ * @param {string} name
202
+ * @param {boolean} enabled
203
+ */
204
+ add(name, enabled) {
205
+ if (this.flags.has(name)) {
206
+ throw new Error(`The feature flag: ${name} already exists`);
371
207
  }
372
-
373
- /**
374
- * @param {FeatureFlagScope} scope
375
- */
376
- }, {
377
- key: "mergeWithScope",
378
- value: function mergeWithScope(scope) {
379
- var _iterator = _createForOfIteratorHelper(scope.flags),
380
- _step;
381
- try {
382
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
383
- var _step$value = _slicedToArray(_step.value, 2),
384
- key = _step$value[0],
385
- value = _step$value[1];
386
- if (this.flags.has(key)) {
387
- continue;
388
- }
389
- this.flags.set(key, value);
390
- }
391
- } catch (err) {
392
- _iterator.e(err);
393
- } finally {
394
- _iterator.f();
208
+ this.flags.set(name, enabled);
209
+ }
210
+ /**
211
+ * Enable a feature flag
212
+ * @param {string} name
213
+ */
214
+ enable(name) {
215
+ this.checkForFlag(name);
216
+ this.flags.set(name, true);
217
+ }
218
+ /**
219
+ * Disable a feature flag
220
+ * @param {string} name
221
+ */
222
+ disable(name) {
223
+ this.checkForFlag(name);
224
+ this.flags.set(name, false);
225
+ }
226
+ /**
227
+ * Merge the given feature flags with the current set of feature flags.
228
+ * Duplicate keys will be set to the value in the given feature flags.
229
+ * @param {object} flags
230
+ */
231
+ merge(flags) {
232
+ Object.keys(flags).forEach((key) => {
233
+ this.flags.set(key, flags[key]);
234
+ });
235
+ }
236
+ /**
237
+ * @param {FeatureFlagScope} scope
238
+ */
239
+ mergeWithScope(scope) {
240
+ for (const [key, value] of scope.flags) {
241
+ if (this.flags.has(key)) {
242
+ continue;
395
243
  }
244
+ this.flags.set(key, value);
396
245
  }
246
+ }
247
+ /**
248
+ * Check if a feature flag is enabled
249
+ * @param {string} name
250
+ * @returns {boolean}
251
+ */
252
+ enabled(name) {
253
+ this.checkForFlag(name);
254
+ return this.flags.get(name);
255
+ }
256
+ }
397
257
 
398
- /**
399
- * Check if a feature flag is enabled
400
- * @param {string} name
401
- * @returns {boolean}
402
- */
403
- }, {
404
- key: "enabled",
405
- value: function enabled(name) {
406
- this.checkForFlag(name);
407
- return this.flags.get(name);
408
- }
409
- }]);
410
- }();
411
-
412
- var FeatureFlags = createScope();
413
- for (var i = 0; i < featureFlagInfo.length; i++) {
414
- var featureFlag = featureFlagInfo[i];
258
+ const FeatureFlags = createScope();
259
+ for (let i = 0; i < featureFlagInfo.length; i++) {
260
+ const featureFlag = featureFlagInfo[i];
415
261
  FeatureFlags.add(featureFlag.name, featureFlag.enabled);
416
262
  }
417
263
  function createScope(flags) {
418
264
  return new FeatureFlagScope(flags);
419
265
  }
420
- function add() {
421
- return FeatureFlags.add.apply(FeatureFlags, arguments);
266
+ function add(...args) {
267
+ return FeatureFlags.add(...args);
422
268
  }
423
- function enable() {
424
- return FeatureFlags.enable.apply(FeatureFlags, arguments);
269
+ function enable(...args) {
270
+ return FeatureFlags.enable(...args);
425
271
  }
426
- function disable() {
427
- return FeatureFlags.disable.apply(FeatureFlags, arguments);
272
+ function disable(...args) {
273
+ return FeatureFlags.disable(...args);
428
274
  }
429
- function enabled() {
430
- return FeatureFlags.enabled.apply(FeatureFlags, arguments);
275
+ function enabled(...args) {
276
+ return FeatureFlags.enabled(...args);
431
277
  }
432
- function merge() {
433
- return FeatureFlags.merge.apply(FeatureFlags, arguments);
278
+ function merge(...args) {
279
+ return FeatureFlags.merge(...args);
434
280
  }
435
281
 
436
282
  exports.FeatureFlags = FeatureFlags;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@octaviaflow/feature-flags",
3
3
  "description": "Build with feature flags in OctaviaFlow",
4
- "version": "1.0.0",
4
+ "version": "1.1.3",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "module": "es/index.js",
@@ -30,17 +30,14 @@
30
30
  "scripts": {
31
31
  "build": "bun run clean && node tasks/build.js && rollup -c",
32
32
  "clean": "rimraf es lib scss/generated src/generated",
33
+ "test": "bun test .",
33
34
  "watch": "bun run clean && node tasks/build.js && rollup -c -w"
34
35
  },
35
36
  "devDependencies": {
36
- "@babel/core": "^7.24.7",
37
- "@babel/generator": "^7.24.7",
38
- "@babel/preset-env": "^7.24.7",
39
- "@babel/template": "^7.24.7",
40
- "@babel/types": "^7.24.7",
41
37
  "@octaviaflow/scss-generator": "^1.0.0",
42
- "@rollup/plugin-babel": "^6.0.0",
43
38
  "@rollup/plugin-node-resolve": "^15.0.0",
39
+ "esbuild": "^0.27.0",
40
+ "rollup-plugin-esbuild": "^6.2.0",
44
41
  "change-case": "^4.1.2",
45
42
  "fs-extra": "^11.0.0",
46
43
  "js-yaml": "^3.14.0",
@@ -48,10 +45,5 @@
48
45
  "rollup": "^2.79.1",
49
46
  "rollup-plugin-strip-banner": "^3.0.0"
50
47
  },
51
- "sideEffects": false,
52
- "babel": {
53
- "presets": [
54
- "@babel/env"
55
- ]
56
- }
48
+ "sideEffects": false
57
49
  }