@adobe-commerce/elsie 1.6.0-alpha1 → 1.6.0-alpha2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe-commerce/elsie",
3
- "version": "1.6.0-alpha1",
3
+ "version": "1.6.0-alpha2",
4
4
  "license": "SEE LICENSE IN LICENSE.md",
5
5
  "description": "Domain Package SDK",
6
6
  "engines": {
@@ -27,8 +27,8 @@
27
27
  },
28
28
  "devDependencies": {
29
29
  "@adobe-commerce/event-bus": "~1.0.1",
30
- "@adobe-commerce/fetch-graphql": "1.2.0-beta1",
31
- "@adobe-commerce/recaptcha": "1.0.2-beta1",
30
+ "@adobe-commerce/fetch-graphql": "~1.2.0",
31
+ "@adobe-commerce/recaptcha": "~1.0.2",
32
32
  "@adobe-commerce/storefront-design": "~1.0.0",
33
33
  "@dropins/build-tools": "~1.0.1",
34
34
  "preact": "~10.22.1",
@@ -8,7 +8,7 @@
8
8
  *******************************************************************/
9
9
 
10
10
  import '@adobe-commerce/elsie/components/Field/Field.css';
11
- import { classes } from '@adobe-commerce/elsie/lib';
11
+ import { classes, VComponent } from '@adobe-commerce/elsie/lib';
12
12
  import { FunctionComponent, VNode } from 'preact';
13
13
  import { HTMLAttributes } from 'preact/compat';
14
14
 
@@ -36,8 +36,23 @@ export const Field: FunctionComponent<FieldProps> = ({
36
36
  }) => {
37
37
  const id =
38
38
  children?.props?.id ?? `dropin-field-${Math.random().toString(36)}`;
39
- const ChildComponent =
40
- children && typeof children.type !== 'string' ? children.type : null;
39
+
40
+ let fieldContent: VNode | string | null = null;
41
+
42
+ if (children && typeof children !== 'string') {
43
+ fieldContent = (
44
+ <VComponent
45
+ node={children}
46
+ id={id}
47
+ key={children.key}
48
+ disabled={disabled}
49
+ size={size}
50
+ error={!!error}
51
+ success={!!success && !error}
52
+ />
53
+ );
54
+ }
55
+
41
56
 
42
57
  return (
43
58
  <div {...props} className={classes(['dropin-field', className])}>
@@ -55,17 +70,7 @@ export const Field: FunctionComponent<FieldProps> = ({
55
70
  )}
56
71
 
57
72
  <div className={classes(['dropin-field__content'])}>
58
- {ChildComponent && children && (
59
- <ChildComponent
60
- {...children.props}
61
- id={id}
62
- key={children.key}
63
- disabled={disabled}
64
- size={size}
65
- error={!!error}
66
- success={!!success && !error}
67
- />
68
- )}
73
+ {fieldContent}
69
74
  </div>
70
75
 
71
76
  <div
@@ -23,6 +23,7 @@ interface Config {
23
23
 
24
24
  // Private state
25
25
  let config: Config | null = null;
26
+ let options: { match?: (key: string) => boolean } | null = null;
26
27
  let rootPath: string | null = null;
27
28
  let rootConfig: ConfigRoot | null = null;
28
29
 
@@ -31,6 +32,7 @@ let rootConfig: ConfigRoot | null = null;
31
32
  */
32
33
  function resetConfig() {
33
34
  config = null;
35
+ options = null;
34
36
  rootPath = null;
35
37
  rootConfig = null;
36
38
  }
@@ -40,7 +42,7 @@ function resetConfig() {
40
42
  * @param {Object} [configObj=config] - The config object.
41
43
  * @returns {string} - The root path.
42
44
  */
43
- function getRootPath(configObj: Config | null = config, options?: { match?: (key: string) => boolean }): string {
45
+ function getRootPath(configObj: Config | null = config, optionsObj: { match?: (key: string) => boolean } | null = options): string {
44
46
  if (!configObj) {
45
47
  console.warn('No config found. Please call initializeConfig() first.');
46
48
  return '/';
@@ -56,7 +58,7 @@ function getRootPath(configObj: Config | null = config, options?: { match?: (key
56
58
  .find(
57
59
  (key) =>
58
60
  window.location.pathname === key ||
59
- (options?.match?.(key) ?? window.location.pathname.startsWith(key))
61
+ (optionsObj?.match?.(key) ?? window.location.pathname.startsWith(key))
60
62
  );
61
63
 
62
64
  return value ?? '/';
@@ -131,9 +133,10 @@ function applyConfigOverrides(
131
133
  * @param {Function} [options.match] - The function to match the path to the config.
132
134
  * @returns {Object} The initialized root configuration
133
135
  */
134
- function initializeConfig(configObj: Config, options?: { match?: (key: string) => boolean }): ConfigRoot {
136
+ function initializeConfig(configObj: Config, optionsObj?: { match?: (key: string) => boolean }): ConfigRoot {
135
137
  config = configObj;
136
- rootPath = getRootPath(config, { match: options?.match });
138
+ options = optionsObj ?? null;
139
+ rootPath = getRootPath(config, { match: optionsObj?.match });
137
140
  rootConfig = applyConfigOverrides(config, rootPath);
138
141
  return rootConfig;
139
142
  }