@equinor/cpl-feature-flag-react 2.0.9 → 2.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.
- package/dist/index.d.mts +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.js +36 -25
- package/dist/index.mjs +36 -25
- package/package.json +11 -11
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { PropsWithChildren } from 'react';
|
|
3
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
3
|
|
|
5
4
|
type BaseConfig<Key extends string, Env extends string> = Record<Key, Record<Env, boolean>>;
|
|
6
5
|
type inferFeatureFlagKey<T extends BaseConfig<string, string>> = keyof T;
|
|
@@ -19,10 +18,10 @@ interface Props<Key extends string, Env extends string> {
|
|
|
19
18
|
useCurrentEnvironment: () => string | undefined;
|
|
20
19
|
}
|
|
21
20
|
declare function buildFeatureFlagModule<Env extends string, Key extends string>({ config, storage, storageKey, environments, useCurrentEnvironment, }: Props<Key, Env>): {
|
|
22
|
-
FeatureFlagProvider: ({ children }: PropsWithChildren) =>
|
|
21
|
+
FeatureFlagProvider: ({ children }: PropsWithChildren) => react.JSX.Element;
|
|
23
22
|
useFeatureFlagValue: (featureFlagKey: Key) => boolean;
|
|
24
23
|
useSetFeatureFlag: (featureFlagKey: Key) => (newValue: boolean) => void;
|
|
25
|
-
DevPanel: () =>
|
|
24
|
+
DevPanel: () => react.JSX.Element;
|
|
26
25
|
FeatureFlag: ({ featureFlagKey, showWhen, children, }: PropsWithChildren<{
|
|
27
26
|
showWhen: "enabled" | "disabled";
|
|
28
27
|
featureFlagKey: Key;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { PropsWithChildren } from 'react';
|
|
3
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
3
|
|
|
5
4
|
type BaseConfig<Key extends string, Env extends string> = Record<Key, Record<Env, boolean>>;
|
|
6
5
|
type inferFeatureFlagKey<T extends BaseConfig<string, string>> = keyof T;
|
|
@@ -19,10 +18,10 @@ interface Props<Key extends string, Env extends string> {
|
|
|
19
18
|
useCurrentEnvironment: () => string | undefined;
|
|
20
19
|
}
|
|
21
20
|
declare function buildFeatureFlagModule<Env extends string, Key extends string>({ config, storage, storageKey, environments, useCurrentEnvironment, }: Props<Key, Env>): {
|
|
22
|
-
FeatureFlagProvider: ({ children }: PropsWithChildren) =>
|
|
21
|
+
FeatureFlagProvider: ({ children }: PropsWithChildren) => react.JSX.Element;
|
|
23
22
|
useFeatureFlagValue: (featureFlagKey: Key) => boolean;
|
|
24
23
|
useSetFeatureFlag: (featureFlagKey: Key) => (newValue: boolean) => void;
|
|
25
|
-
DevPanel: () =>
|
|
24
|
+
DevPanel: () => react.JSX.Element;
|
|
26
25
|
FeatureFlag: ({ featureFlagKey, showWhen, children, }: PropsWithChildren<{
|
|
27
26
|
showWhen: "enabled" | "disabled";
|
|
28
27
|
featureFlagKey: Key;
|
package/dist/index.js
CHANGED
|
@@ -193,7 +193,7 @@ function DevPanelPure({
|
|
|
193
193
|
return Object.keys(featureFlagConfig);
|
|
194
194
|
}, [featureFlagConfig]);
|
|
195
195
|
const currentEnvironment = useCurrentEnvironment();
|
|
196
|
-
if (!currentEnvironment ||
|
|
196
|
+
if (!currentEnvironment || !["dev", "local"].includes(currentEnvironment)) {
|
|
197
197
|
return null;
|
|
198
198
|
}
|
|
199
199
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_eds_core_react2.EdsProvider, { density: "compact", children: [
|
|
@@ -211,30 +211,41 @@ function DevPanelPure({
|
|
|
211
211
|
]
|
|
212
212
|
}
|
|
213
213
|
),
|
|
214
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
214
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
215
|
+
import_eds_core_react2.Popover,
|
|
216
|
+
{
|
|
217
|
+
open: isOpen,
|
|
218
|
+
anchorEl: (
|
|
219
|
+
// eslint-disable-next-line react-hooks/refs -- current EDS implementation
|
|
220
|
+
buttonRef.current
|
|
221
|
+
),
|
|
222
|
+
onClose: handleClose,
|
|
223
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(StyledPopoverContent, { children: [
|
|
224
|
+
featureFlagKeys.map((featureFlagKey) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
225
|
+
FeatureFlagItem,
|
|
226
|
+
{
|
|
227
|
+
featureFlagKey,
|
|
228
|
+
useFeatureFlagValue,
|
|
229
|
+
useSetFeatureFlag
|
|
230
|
+
},
|
|
231
|
+
`feature-flag-item-${featureFlagKey}`
|
|
232
|
+
)),
|
|
233
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
234
|
+
import_eds_core_react2.Button,
|
|
235
|
+
{
|
|
236
|
+
variant: "ghost",
|
|
237
|
+
color: "danger",
|
|
238
|
+
onClick: () => {
|
|
239
|
+
localStorage.clear();
|
|
240
|
+
sessionStorage.clear();
|
|
241
|
+
window.location.reload();
|
|
242
|
+
},
|
|
243
|
+
children: "Delete cache and reload"
|
|
244
|
+
}
|
|
245
|
+
)
|
|
246
|
+
] })
|
|
247
|
+
}
|
|
248
|
+
)
|
|
238
249
|
] }) });
|
|
239
250
|
}
|
|
240
251
|
var StyledButton = (0, import_styled_components2.default)(import_eds_core_react2.Button)`
|
package/dist/index.mjs
CHANGED
|
@@ -157,7 +157,7 @@ function DevPanelPure({
|
|
|
157
157
|
return Object.keys(featureFlagConfig);
|
|
158
158
|
}, [featureFlagConfig]);
|
|
159
159
|
const currentEnvironment = useCurrentEnvironment();
|
|
160
|
-
if (!currentEnvironment ||
|
|
160
|
+
if (!currentEnvironment || !["dev", "local"].includes(currentEnvironment)) {
|
|
161
161
|
return null;
|
|
162
162
|
}
|
|
163
163
|
return /* @__PURE__ */ jsx3(Fragment, { children: /* @__PURE__ */ jsxs(EdsProvider, { density: "compact", children: [
|
|
@@ -175,30 +175,41 @@ function DevPanelPure({
|
|
|
175
175
|
]
|
|
176
176
|
}
|
|
177
177
|
),
|
|
178
|
-
/* @__PURE__ */ jsx3(
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
178
|
+
/* @__PURE__ */ jsx3(
|
|
179
|
+
Popover,
|
|
180
|
+
{
|
|
181
|
+
open: isOpen,
|
|
182
|
+
anchorEl: (
|
|
183
|
+
// eslint-disable-next-line react-hooks/refs -- current EDS implementation
|
|
184
|
+
buttonRef.current
|
|
185
|
+
),
|
|
186
|
+
onClose: handleClose,
|
|
187
|
+
children: /* @__PURE__ */ jsxs(StyledPopoverContent, { children: [
|
|
188
|
+
featureFlagKeys.map((featureFlagKey) => /* @__PURE__ */ jsx3(
|
|
189
|
+
FeatureFlagItem,
|
|
190
|
+
{
|
|
191
|
+
featureFlagKey,
|
|
192
|
+
useFeatureFlagValue,
|
|
193
|
+
useSetFeatureFlag
|
|
194
|
+
},
|
|
195
|
+
`feature-flag-item-${featureFlagKey}`
|
|
196
|
+
)),
|
|
197
|
+
/* @__PURE__ */ jsx3(
|
|
198
|
+
Button,
|
|
199
|
+
{
|
|
200
|
+
variant: "ghost",
|
|
201
|
+
color: "danger",
|
|
202
|
+
onClick: () => {
|
|
203
|
+
localStorage.clear();
|
|
204
|
+
sessionStorage.clear();
|
|
205
|
+
window.location.reload();
|
|
206
|
+
},
|
|
207
|
+
children: "Delete cache and reload"
|
|
208
|
+
}
|
|
209
|
+
)
|
|
210
|
+
] })
|
|
211
|
+
}
|
|
212
|
+
)
|
|
202
213
|
] }) });
|
|
203
214
|
}
|
|
204
215
|
var StyledButton = styled2(Button)`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/cpl-feature-flag-react",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -16,17 +16,17 @@
|
|
|
16
16
|
"dist/**"
|
|
17
17
|
],
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@equinor/eds-core-react": "2.
|
|
20
|
-
"@storybook/react-vite": "10.
|
|
21
|
-
"@types/react": "19.2.
|
|
19
|
+
"@equinor/eds-core-react": "2.6.1",
|
|
20
|
+
"@storybook/react-vite": "10.4.3",
|
|
21
|
+
"@types/react": "19.2.17",
|
|
22
22
|
"@types/react-dom": "19.2.3",
|
|
23
23
|
"@types/styled-components": "5.1.36",
|
|
24
|
-
"eslint": "10.
|
|
25
|
-
"react": "19.2.
|
|
26
|
-
"react-dom": "19.2.
|
|
27
|
-
"styled-components": "6.4.
|
|
24
|
+
"eslint": "10.4.1",
|
|
25
|
+
"react": "19.2.7",
|
|
26
|
+
"react-dom": "19.2.7",
|
|
27
|
+
"styled-components": "6.4.2",
|
|
28
28
|
"tsup": "8.5.1",
|
|
29
|
-
"@equinor/cpl-eslint-config": "1.0.
|
|
29
|
+
"@equinor/cpl-eslint-config": "1.0.11",
|
|
30
30
|
"@equinor/cpl-typescript-config": "0.0.8"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@equinor/eds-icons": "1.
|
|
43
|
-
"@equinor/eds-tokens": "2.
|
|
42
|
+
"@equinor/eds-icons": "1.5.0",
|
|
43
|
+
"@equinor/eds-tokens": "2.3.0"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "tsup src/index.ts --format esm,cjs --dts --external react",
|