@bigbinary/neeto-molecules 5.3.17 → 5.3.19

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": "@bigbinary/neeto-molecules",
3
- "version": "5.3.17",
3
+ "version": "5.3.19",
4
4
  "description": "A package of reusable molecular components for neeto products.",
5
5
  "repository": "git@github.com:bigbinary/neeto-molecules.git",
6
6
  "author": "Amaljith K <amaljith.k@bigbinary.com>",
@@ -4,6 +4,19 @@ type VersionLimits = {
4
4
  softLimit?: number;
5
5
  hardLimit?: number;
6
6
  };
7
+ type BrowserVersionOverrides = {
8
+ Chrome?: VersionLimits;
9
+ MobileChrome?: VersionLimits;
10
+ Edge?: VersionLimits;
11
+ Firefox?: VersionLimits;
12
+ MobileFirefox?: VersionLimits;
13
+ Safari?: VersionLimits;
14
+ MobileSafari?: VersionLimits;
15
+ Opera?: VersionLimits;
16
+ SamsungInternet?: VersionLimits;
17
+ Electron?: VersionLimits;
18
+ WebKit?: VersionLimits;
19
+ };
7
20
  /**
8
21
  *
9
22
  * A wrapper that displays a callout message for partially supported browsers
@@ -29,59 +42,142 @@ type VersionLimits = {
29
42
  * <Main />
30
43
  * )
31
44
  * @endexample
32
- * Minimum supported browser version of a specific browser can be changed using the
45
+ * This placement handles browsers that load the app but cannot render it properly.
46
+ *
47
+ * It cannot help when the browser is too old to parse the app chunk at all — see
48
+ *
49
+ * the next section, which is the placement most products actually want.
50
+ *
51
+ * Wrapping Main in <BrowserSupport> cannot help when the browser is old enough
52
+ *
53
+ * that the app chunk fails to parse. mount() rejects on the dynamic import and
54
+ *
55
+ * React never renders, so the user gets a blank page rather than an explanation.
33
56
  *
34
- * overrides prop like so:
57
+ * For that case call renderBrowserSupportGate from the pack, before mount(),
58
+ *
59
+ * where only the entry chunk has had to parse. It returns true when the browser
60
+ *
61
+ * was blocked, meaning the app must not be mounted:
62
+ *
63
+ * @example
64
+ *
65
+ * import mount from "neetocommons/react-utils/mount";
66
+ * import { renderBrowserSupportGate } from "@bigbinary/neeto-molecules/v2/BrowserSupport";
67
+ *
68
+ * const initializeAndMount = async () => {
69
+ * await initializeApplication();
70
+ *
71
+ * if (renderBrowserSupportGate()) return;
72
+ *
73
+ * mount(componentMap);
74
+ * };
75
+ * @endexample
76
+ * It renders into [data-react-class] by default, the same element mount()
77
+ *
78
+ * uses; pass element to override. When it blocks it also removes
79
+ *
80
+ * #neeto-page-loader, the loader rendered by shared/_page_loader in
81
+ *
82
+ * neeto-commons-backend, which sits outside the react root and would otherwise
83
+ *
84
+ * keep spinning over the message; pass loaderSelector if your product renders a
85
+ *
86
+ * different one. overrides and unsupportedBrowsers behave as they do on the
87
+ *
88
+ * component, and products should not normally need either — the defaults are the
89
+ *
90
+ * floor the shared stack imposes, so a product that overrides them is opting out
91
+ *
92
+ * of the guarantee rather than configuring it. Whatever the pack imports has to
93
+ *
94
+ * stay parseable on the browsers being guarded against, so keep the entry chunk
95
+ *
96
+ * free of syntax newer than the floor you are enforcing.
97
+ *
98
+ * The overrides prop changes the limits for a specific browser. The usual reason
99
+ *
100
+ * to reach for it is to open a partial band, where a browser below softLimit but
101
+ *
102
+ * at or above hardLimit gets a callout and still sees the page:
35
103
  *
36
104
  * @example
37
105
  *
38
106
  * <BrowserSupport
39
107
  * overrides={{
40
- * Chrome: { softLimit: 80, hardLimit: 60 },
41
- * Safari: { softLimit: 14.1, hardLimit: 13.5 },
108
+ * Chrome: { softLimit: 120, hardLimit: 111 },
109
+ * Safari: { softLimit: 17, hardLimit: 16.4 },
42
110
  * }}
43
- * unsupportedBrowsers={["Firefox"]}
111
+ * unsupportedBrowsers={["SamsungInternet"]}
44
112
  * />
45
113
  * @endexample
46
- * In the above code we have changed the minimum supported versions of Chrome &
114
+ * Here Chrome 111 to 119 and Safari 16.4 to 16.6 get the callout along with the
47
115
  *
48
- * Safari. Now if a user has accessed the site using Chrome < 80 or Safari < 14.1
116
+ * page contents. Chrome below 111 and Safari below 16.4 get the full-page message
49
117
  *
50
- * the callout message will be displayed. If a user has accessed the site using
118
+ * and no content. Every version of Samsung Internet is blocked outright.
51
119
  *
52
- * Chrome < 60 or Safari < 13.5, a message will be displayed to update the browser
120
+ * Lowering hardLimit below the defaults is possible but rarely a good idea. The
53
121
  *
54
- * and page contents will not be shown. If a user has accessed the site using any
122
+ * defaults are the point at which the generated CSS stops applying, so lowering
55
123
  *
56
- * version of Firefox, a message will be displayed that the browser is unsupported
124
+ * them serves a visibly broken page instead of a message explaining why.
57
125
  *
58
- * and page contents will not be shown.
126
+ * The default minimum versions are set by Tailwind v4, which hardcodes its
59
127
  *
60
- * The default supported browser names and their versions are given below:
128
+ * Lightning CSS targets to Safari/iOS 16.4, Chrome 111 and Firefox 128 and exposes
61
129
  *
62
- * | Browser Name | Min Supported version |
130
+ * no option to lower them. Below that floor the generated CSS (@property,
131
+ *
132
+ * oklch(), :has(), @container) is dropped by the parser without an error, so
133
+ *
134
+ * the app renders broken rather than degraded. The remaining engines are pinned to
135
+ *
136
+ * the first release built on an equivalent core.
137
+ *
138
+ * | Browser name | Min supported version |
63
139
  *
64
140
  * | :-------------- | :-------------------- |
65
141
  *
66
- * | Chrome | 79 |
142
+ * | Chrome | 111 |
143
+ *
144
+ * | MobileChrome | 111 |
67
145
  *
68
- * | Firefox | 91 |
146
+ * | Edge | 111 |
69
147
  *
70
- * | IE | 11 |
148
+ * | Firefox | 128 |
71
149
  *
72
- * | Opera | 73 |
150
+ * | MobileFirefox | 128 |
73
151
  *
74
- * | Safari | 12.2 |
152
+ * | Safari | 16.4 |
75
153
  *
76
- * | ChromeMobile | 105 |
154
+ * | MobileSafari | 16.4 |
77
155
  *
78
- * | FirefoxMobile | 104 |
156
+ * | Opera | 98 |
79
157
  *
80
- * | UCBrowser | 13.4 |
158
+ * | SamsungInternet | 22 |
81
159
  *
82
- * | SamsungInternet | 4 |
160
+ * | Electron | 24 |
83
161
  *
84
- * The default unsupported browsers are given below:
162
+ * | WebKit | 605 |
163
+ *
164
+ * softLimit and hardLimit are equal by default, so a browser below the floor
165
+ *
166
+ * gets the full-page message rather than a callout. There is no meaningful
167
+ *
168
+ * "degraded but usable" band below it — the CSS either applies or it does not. Set
169
+ *
170
+ * an explicit overrides entry if a product wants a partial band.
171
+ *
172
+ * Safari freezes the WebKit build number in its user agent (605.1.15 since
173
+ *
174
+ * Safari 12), so the WebKit entry cannot discriminate versions. It exists only
175
+ *
176
+ * to keep generic WebKit clients out of the unknown-browser branch.
177
+ *
178
+ * The default unsupported browsers are given below. These cannot reach the floor
179
+ *
180
+ * at any released version, and are blocked before overrides are consulted:
85
181
  *
86
182
  * Any other browser which is not in the above lists will be considered as unknown
87
183
  *
@@ -89,22 +185,15 @@ type VersionLimits = {
89
185
  *
90
186
  */
91
187
  declare const BrowserSupport: React.FC<{
92
- overrides?: {
93
- Chrome?: VersionLimits;
94
- Edge?: VersionLimits;
95
- Firefox?: VersionLimits;
96
- IE?: VersionLimits;
97
- Opera?: VersionLimits;
98
- Safari?: VersionLimits;
99
- AndroidBrowser?: VersionLimits;
100
- OperaMini?: VersionLimits;
101
- MobileChrome?: VersionLimits;
102
- MobileFirefox?: VersionLimits;
103
- UCBrowser?: VersionLimits;
104
- SamsungInternet?: VersionLimits;
105
- };
188
+ overrides?: BrowserVersionOverrides;
106
189
  unsupportedBrowsers?: string[];
107
190
  children?: React.ReactNode | React.ReactNode[];
108
191
  }>;
192
+ declare const renderBrowserSupportGate: (options?: {
193
+ overrides?: BrowserVersionOverrides;
194
+ unsupportedBrowsers?: string[];
195
+ element?: HTMLElement | null;
196
+ loaderSelector?: string;
197
+ }) => boolean;
109
198
 
110
- export { BrowserSupport as default };
199
+ export { BrowserSupport as default, renderBrowserSupportGate };