@cleartrip/ct-design-spinner 4.0.0-TEST.1 → 5.0.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.
@@ -1,793 +1,51 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react/jsx-runtime'), require('@emotion/styled'), require('react'), require('@emotion/react')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'react/jsx-runtime', '@emotion/styled', 'react', '@emotion/react'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.CTDesignSystemSpinner = {}, global.jsxRuntime, global.styled, global.React, global.react$1));
5
- })(this, (function (exports, jsxRuntime, styled, react, react$1) { 'use strict';
6
-
7
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
-
9
- var styled__default = /*#__PURE__*/_interopDefault(styled);
10
-
11
- /******************************************************************************
12
- Copyright (c) Microsoft Corporation.
13
-
14
- Permission to use, copy, modify, and/or distribute this software for any
15
- purpose with or without fee is hereby granted.
16
-
17
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
18
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
19
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
20
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
21
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
22
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
23
- PERFORMANCE OF THIS SOFTWARE.
24
- ***************************************************************************** */
25
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
26
-
27
- var __assign = function () {
28
- __assign = Object.assign || function __assign(t) {
29
- for (var s, i = 1, n = arguments.length; i < n; i++) {
30
- s = arguments[i];
31
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
32
- }
33
- return t;
34
- };
35
- return __assign.apply(this, arguments);
36
- };
37
- function __makeTemplateObject(cooked, raw) {
38
- if (Object.defineProperty) {
39
- Object.defineProperty(cooked, "raw", {
40
- value: raw
41
- });
42
- } else {
43
- cooked.raw = raw;
44
- }
45
- return cooked;
46
- }
47
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
48
- var e = new Error(message);
49
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
50
- };
51
-
52
- var border = {
53
- radius: {
54
- 0: 0,
55
- 2: 2,
56
- 4: 4,
57
- 6: 6,
58
- 8: 8,
59
- 12: 12,
60
- 16: 16,
61
- 20: 20,
62
- 24: 24,
63
- 30: 30,
64
- 32: 32,
65
- '50P': '50%',
66
- 60: 60
67
- },
68
- width: {
69
- none: 0,
70
- sm: 1,
71
- md: 1.5,
72
- lg: 2,
73
- xl: 5
74
- },
75
- style: {
76
- solid: 'solid',
77
- dotted: 'dotted',
78
- none: 'none'
79
- }
80
- };
81
- var colors = {
82
- alert: '#DF9641',
83
- alert100: '#FFF8D4',
84
- alert500: '#A06800',
85
- alertBg: '#FCF7F0',
86
- alertText: '#DF9641',
87
- aqua100: '#082395',
88
- aqua250: '#081C82',
89
- bgPrimary: '#ED6521',
90
- bgPrimaryHover: '#CE4501',
91
- black: '#1A1A1A',
92
- blue100: '#ECF3FF',
93
- blue500: '#0F6BFF',
94
- blue900: '#0E3A81',
95
- bluePrimary500: '#2A55E5',
96
- blueSecondary: '#F0F5FF',
97
- blueSky500: '#3C6CE6',
98
- brand: '#FF4F17',
99
- brandBg: '#FEF3ED',
100
- brandText: '#FF4F17',
101
- brown: '#231B18',
102
- coralpink: '#F48B6E',
103
- curacao250: '#9FE3EA',
104
- curacao900: '#032529',
105
- darkGrey: '#313131',
106
- darkNeutral300: '#E0E0E0',
107
- disabled100: '#E6E6E6',
108
- disabled250: '#DDDDDD',
109
- disabledLight: '#EFEFEF',
110
- disabledText: '#B3B3B3',
111
- grapetini900: '#5f1ab6',
112
- gray100: '#2E3042',
113
- gray250: '#1A1C23',
114
- gray500: '#ffffffb1',
115
- greenFresh500: '#61C149',
116
- highlightBg: 'rgba(255, 255, 255, 0.2)',
117
- lightCyan: '#ECF9FB',
118
- lightSkyBlue: '#88CDFF',
119
- line: '#E7E7E7',
120
- lineDarkNeutral300: '#E0E0E0',
121
- link: '#0F6BFF',
122
- link2: '#3366CC',
123
- link2Hover: '#1A469D',
124
- linkBg: '#EFF3FB',
125
- linkText: '#0F6BFF',
126
- margarita100: '#F2FAF0',
127
- margarita250: '#C0E6B6',
128
- margarita750: '#3A742C',
129
- mintCream: '#F0FAF6',
130
- neutral50: '#FFFFFF80',
131
- neutral100: '#FFFFFF',
132
- neutral200: '#FAFAFD',
133
- neutral300: '#F3F3F3',
134
- neutral350: '#DBDBDB',
135
- neutral400: '#CAC9C9',
136
- neutral500: '#B3B3B3',
137
- neutral700: '#808080',
138
- neutral900: '#1A1A1A',
139
- orange100: '#FFF1EC',
140
- orange200: '#FFF1ED',
141
- orange250: '#FFB8A5',
142
- orange500: '#FF4F17',
143
- pinaColada100: '#FFF9EC',
144
- pinaColada250: '#FEE3A0',
145
- pinaColada750: '#98700B',
146
- pinkVibrant500: '#EF4E9B',
147
- primaryNeutral900: '#212121',
148
- purple100: '#350041',
149
- purple250: '#130016',
150
- purpleRoyal500: '#8B39F1',
151
- sandGrey100: '#fef5f2',
152
- shadow: '#1a1a1a14',
153
- success: '#11A670',
154
- success500: '#11A670',
155
- success600: '#0DA86D',
156
- successBg: '#ECF8F4',
157
- successText: '#11A670',
158
- superBlue25: '#EBEFFF',
159
- superBlue500: '#4D43FE',
160
- superGreen500: '#B5EF85',
161
- superGrey50: '#F9FAFB',
162
- superGrey200: '#EAECF0',
163
- superGrey300: '#D0D5DD',
164
- superGrey400: '#98A2B3',
165
- superGrey500: '#667085',
166
- superGrey700: '#344054',
167
- superGrey800: '#1D2939',
168
- systemGreen500: '#12B76A',
169
- systemRed500: '#FA2617',
170
- transparent: '#00000000',
171
- warning: '#C83232',
172
- warningBg: '#FBEFEF',
173
- warningText: '#C83232',
174
- yellowSecondary: '#FFC200',
175
- yellowSun500: '#FDBA12'
176
- };
177
- var elevation = {
178
- bottomE1: '0px 1px 0px #E7E7E7',
179
- bottomE2: '0px 4px 16px rgba(26, 26, 26, 0.08)',
180
- bottomE3: '0px 8px 24px rgba(26, 26, 26, 0.1)',
181
- bottomE4: '0px 10px 32px rgba(26, 26, 26, 0.2)',
182
- topE1: '0px -1px 0px #E7E7E7',
183
- topE2: '0px -4px 16px rgba(26, 26, 26, 0.08)',
184
- topE3: '0px -8px 24px rgba(26, 26, 26, 0.1)',
185
- topE4: '0px -10px 32px rgba(26, 26, 26, 0.2)',
186
- modalBlurLight: 'rgb(0 0 0 / 20%) 0px 11px 15px -7px',
187
- modalBlurMedium: 'rgb(0 0 0 / 14%) 0px 24px 38px 3px',
188
- modalBlurHeavy: 'rgb(0 0 0 / 12%) 0px 9px 22px 18px'
189
- };
190
- var size = {
191
- 0: 0,
192
- 0.5: 2,
193
- 1: 4,
194
- 2: 8,
195
- '2.5': 10,
196
- 3: 12,
197
- 4: 16,
198
- 5: 20,
199
- 6: 24,
200
- 7: 28,
201
- 8: 32,
202
- 9: 36,
203
- 10: 40,
204
- 11: 44,
205
- 12: 48,
206
- 13: 52,
207
- 14: 56,
208
- 15: 60,
209
- 16: 64,
210
- 19: 76,
211
- 20: 80,
212
- 50: 200,
213
- 55: 220,
214
- '50P': '50%',
215
- '100P': '100%'
216
- };
217
- var spacing = {
218
- 0: 0,
219
- 0.5: 2,
220
- 0.75: 3,
221
- 1: 4,
222
- 1.5: 6,
223
- 2: 8,
224
- 3: 12,
225
- 4: 16,
226
- 5: 20,
227
- 6: 24,
228
- 7: 28,
229
- 8: 32,
230
- 9: 36,
231
- 10: 40,
232
- 11: 44,
233
- 12: 48,
234
- 13: 52,
235
- 14: 56,
236
- 16: 64
237
- };
238
- var typography = {
239
- weight: {
240
- bold: 700,
241
- semibold: 600,
242
- medium: 500,
243
- normal: 400
244
- },
245
- size: {
246
- 10: 10,
247
- 12: 12,
248
- 14: 14,
249
- 16: 16,
250
- 20: 20,
251
- 24: 24,
252
- 32: 32,
253
- 40: 40,
254
- 48: 48
255
- },
256
- lineHeight: {
257
- 12: 12,
258
- 14: 14,
259
- 16: 16,
260
- 18: 18,
261
- 20: 20,
262
- 22: 22,
263
- 24: 24,
264
- 28: 28,
265
- 32: 32,
266
- 40: 40,
267
- 48: 48,
268
- 56: 56
269
- },
270
- letterSpacing: {
271
- nPoint75: -0.75,
272
- nPoint5: -0.5,
273
- nPoint4: -0.4,
274
- nPoint25: -0.25,
275
- zero: 0,
276
- point4: 0.4,
277
- point5: 0.5,
278
- point75: 0.75
279
- }
280
- };
281
-
282
- var duration = {
283
- shortest: 150,
284
- shorter: 200,
285
- short: 250,
286
- standard: 300,
287
- complex: 375,
288
- enteringScreen: 225,
289
- leavingScreen: 195
290
- };
291
- var easing = {
292
- easeInOut: 'cubic-bezier(0.4, 0, 0.2, 1)',
293
- easeOut: 'cubic-bezier(0.0, 0, 0.2, 1)',
294
- easeIn: 'cubic-bezier(0.4, 0, 1, 1)',
295
- sharp: 'cubic-bezier(0.4, 0, 0.6, 1)'
296
- };
297
- function getAutoHeightDuration(height) {
298
- if (!height) {
299
- return 0;
300
- }
301
- var constant = height / 36;
302
- return Math.round((4 + 15 * Math.pow(constant, 0.25) + constant / 5) * 10);
303
- }
304
- var create = function (props, options) {
305
- if (props === void 0) {
306
- props = ['all'];
307
- }
308
- if (options === void 0) {
309
- options = {};
310
- }
311
- var _a = options.duration,
312
- durationOption = _a === void 0 ? duration.standard : _a,
313
- _b = options.easing,
314
- easingOption = _b === void 0 ? easing.easeInOut : _b,
315
- _c = options.delay,
316
- delay = _c === void 0 ? 0 : _c;
317
- return (Array.isArray(props) ? props : [props]).map(function (animatedProp) {
318
- return "".concat(animatedProp, " ").concat(typeof durationOption === 'string' ? durationOption : "".concat(durationOption, "ms"), " ").concat(easingOption, " ").concat(typeof delay === 'string' ? delay : "".concat(delay, "ms"));
319
- }).join(',');
320
- };
321
- var hover$3 = function (key) {
322
- var _a;
323
- var bg = (_a = {}, _a[colors.neutral100] = colors.neutral100, _a[colors.neutral900] = colors.neutral900, _a[colors.neutral900] = colors.neutral900, _a[colors.neutral100] = colors.neutral100, _a[colors.brand] = colors.bgPrimaryHover, _a[colors.neutral100] = colors.neutral100, _a[colors.disabledText] = colors.disabledText, _a[colors.neutral300] = colors.neutral300, _a[colors.neutral100] = colors.neutral100, _a[colors.link2] = colors.link2Hover, _a[colors.neutral100] = colors.neutral100, _a[colors.neutral900] = colors.neutral900, _a[colors.neutral100] = colors.neutral100, _a[colors.disabledText] = colors.disabledText, _a[colors.neutral300] = colors.neutral300, _a);
324
- return bg[key];
325
- };
326
- var zIndex = {
327
- drawer: 1200,
328
- modal: 1300,
329
- popOver: 1300,
330
- tooltip: 1500,
331
- sideNav: 100,
332
- toolbar: 50,
333
- bottomSheet: 100
334
- };
335
- var counter$1 = {
336
- enabled: {
337
- stroke: colors.neutral900
338
- },
339
- disabled: {
340
- stroke: colors.neutral500
341
- }
342
- };
343
- var BaseTheme = {
344
- color: {
345
- text: {
346
- primary: colors.neutral900,
347
- secondary: colors.brandText,
348
- tertiary: colors.neutral500,
349
- heading: colors.neutral900,
350
- subHeading: colors.neutral700,
351
- disabled: colors.disabledText,
352
- success: colors.successText,
353
- alert: colors.alertText,
354
- alert500: colors.alert500,
355
- warning: colors.warningText,
356
- link: colors.linkText,
357
- brand: colors.brandText,
358
- neutral: colors.neutral100,
359
- link2: colors.link2,
360
- margarita: colors.margarita750,
361
- primary2: colors.grapetini900,
362
- secondary2: colors.blue100,
363
- grapetini900: colors.grapetini900,
364
- pinaColada750: colors.pinaColada750,
365
- neutral50: colors.neutral50,
366
- coralpink: colors.coralpink
367
- },
368
- button: {
369
- outlinedPrimaryLabel: colors.neutral900,
370
- outlinedPrimaryBorder: colors.neutral900,
371
- outlinedPrimaryBg: colors.neutral100,
372
- outlinedSecondaryLabel: colors.brand,
373
- outlinedSecondaryBorder: colors.brand,
374
- outlinedSecondaryBg: colors.neutral100,
375
- outlinedTertiaryLabel: colors.link,
376
- outlinedTertiaryBorder: colors.link,
377
- outlinedTertiaryBg: colors.neutral100,
378
- outlinedNeutralLabel: colors.neutral100,
379
- outlinedNeutralBorder: colors.neutral100,
380
- outlinedNeutralBg: colors.transparent,
381
- outlinedDisabledLabel: colors.disabledText,
382
- outlinedDisabledBg: colors.neutral300,
383
- containedPrimaryLabel: colors.neutral100,
384
- containedPrimaryBg: colors.neutral900,
385
- containedSecondaryLabel: colors.neutral100,
386
- containedSecondaryBg: colors.brand,
387
- containedTertiaryLabel: colors.neutral100,
388
- containedTertiaryBg: colors.link,
389
- containedDisabledLabel: colors.disabledText,
390
- containedDisabledBg: colors.neutral300,
391
- containedNeutralLabel: colors.neutral900,
392
- containedNeutralBg: colors.neutral100,
393
- hover: hover$3
394
- },
395
- chip: {
396
- nonSelectedPrimaryLabel: colors.neutral900,
397
- disabledPrimaryLabel: colors.disabledText,
398
- selectedPrimaryLabel: colors.neutral900,
399
- selectedPrimaryBorder: colors.neutral900,
400
- selectedPrimaryBg: colors.neutral300,
401
- disabledPrimaryBg: colors.neutral100
402
- },
403
- dropdown: {
404
- shadow: colors.shadow
405
- },
406
- tab: {
407
- nonSelectedPrimaryLabel: colors.neutral700,
408
- selectedPrimaryLabel: colors.neutral900
409
- },
410
- sidenav: {
411
- primaryBg: colors.neutral900,
412
- selectedTabBg: colors.highlightBg
413
- },
414
- tooltip: {
415
- primaryBg: colors.neutral900
416
- },
417
- background: {
418
- primary: colors.neutral900,
419
- secondary: colors.brand,
420
- tertiary: colors.link,
421
- brand: colors.brand,
422
- brandLightBg: colors.brandBg,
423
- link: colors.link,
424
- link2: colors.link2,
425
- linkLightBg: colors.linkBg,
426
- success: colors.success,
427
- successLightBg: colors.successBg,
428
- alert: colors.alert,
429
- alertLightBg: colors.alertBg,
430
- alertSoft: colors.alert100,
431
- warning: colors.warning,
432
- warningLightBg: colors.warningBg,
433
- neutral: colors.neutral100,
434
- disabled: colors.neutral300,
435
- disabledSecondaryLight: colors.neutral350,
436
- disabledSecondary: colors.neutral400,
437
- disabledDark: colors.disabled100,
438
- defaultDark: colors.neutral700,
439
- defaultDarkest: colors.neutral900,
440
- grey: colors.neutral500,
441
- secondary2: colors.blue100,
442
- sandGrey100: colors.sandGrey100
443
- },
444
- border: {
445
- primary: colors.neutral900,
446
- secondary: colors.brand,
447
- tertiary: colors.link,
448
- brand: colors.brand,
449
- neutral: colors.neutral900,
450
- link: colors.link,
451
- default: colors.line,
452
- defaultDark: colors.neutral700,
453
- disabled: colors.neutral500,
454
- disabledDark: colors.disabled100,
455
- warning: colors.warning,
456
- divider: colors.neutral300
457
- },
458
- spinner: {
459
- primary: colors.neutral700,
460
- primaryBg: colors.alertBg
461
- },
462
- shimmer: {
463
- disabledLight: colors.disabledLight,
464
- disabledDark: colors.disabled250
465
- },
466
- coupon: {
467
- primaryBg: colors.blue100
468
- },
469
- alert: {
470
- success: colors.successBg,
471
- warning: colors.alertBg,
472
- info: colors.blue100,
473
- error: colors.orange100,
474
- neutral: colors.neutral100
475
- },
476
- badge: {
477
- curacao: colors.curacao250,
478
- curacao900: colors.curacao900,
479
- pinaColada: colors.pinaColada250,
480
- margarita250: colors.margarita250,
481
- default: colors.neutral300,
482
- green: colors.successBg,
483
- margarita100: colors.margarita100,
484
- yellow: colors.alertBg,
485
- orange100: colors.orange100,
486
- orange250: colors.orange250,
487
- orange500: colors.orange500,
488
- red: colors.warningBg,
489
- green500: colors.success500,
490
- green600: colors.success600,
491
- purple100: colors.purple100,
492
- purple250: colors.purple250,
493
- gray100: colors.gray100,
494
- gray250: colors.gray250,
495
- aqua100: colors.aqua100,
496
- aqua250: colors.aqua250,
497
- black: colors.black,
498
- link: colors.link,
499
- linkText: colors.linkText,
500
- blue100: colors.blue100,
501
- blue500: colors.blue500,
502
- blue900: colors.blue900,
503
- neutral100: colors.neutral100,
504
- pinaColada750: colors.pinaColada750,
505
- pinaColada100: colors.pinaColada100,
506
- brown: colors.brown
507
- },
508
- counter: counter$1,
509
- calendar: {
510
- accent: colors.neutral900,
511
- background: colors.neutral300,
512
- selected: colors.neutral900
513
- }
514
- },
515
- elevation: __assign({}, elevation),
516
- border: __assign({}, border),
517
- spacing: __assign({}, spacing),
518
- typography: __assign({}, typography),
519
- size: __assign({}, size),
520
- transitions: {
521
- duration: duration,
522
- easing: easing,
523
- create: create,
524
- getAutoHeightDuration: getAutoHeightDuration
525
- },
526
- underline: {
527
- link: '',
528
- primary: '',
529
- secondary: '',
530
- tertiary: '',
531
- disabled: '',
532
- heading: '',
533
- subHeading: '',
534
- success: '',
535
- warning: '',
536
- neutral: '',
537
- link2: '',
538
- primary2: '',
539
- secondary2: '',
540
- grapetini900: '',
541
- pinaColada750: '',
542
- alert: ''
543
- },
544
- zIndex: zIndex
545
- };
546
- var B2CTheme = __assign({}, BaseTheme);
547
- var hover$2 = function (key) {
548
- var _a;
549
- var bg = (_a = {}, _a[colors.neutral100] = colors.neutral100, _a[colors.neutral900] = colors.neutral900, _a[colors.neutral900] = colors.neutral900, _a[colors.neutral100] = colors.neutral100, _a[colors.brand] = colors.bgPrimaryHover, _a[colors.neutral100] = colors.neutral100, _a[colors.disabledText] = colors.disabledText, _a[colors.neutral300] = colors.neutral300, _a[colors.neutral100] = colors.neutral100, _a[colors.link2] = colors.link2Hover, _a[colors.neutral100] = colors.neutral100, _a[colors.neutral900] = colors.neutral900, _a[colors.neutral100] = colors.neutral100, _a[colors.disabledText] = colors.disabledText, _a[colors.neutral300] = colors.neutral300, _a);
550
- return bg[key];
551
- };
552
- __assign(__assign({}, BaseTheme), {
553
- color: __assign(__assign({}, BaseTheme.color), {
554
- text: __assign(__assign({}, BaseTheme.color.text), {
555
- secondary: colors.link2,
556
- tertiary: colors.neutral500
557
- }),
558
- button: __assign(__assign({}, BaseTheme.color.button), {
559
- outlinedPrimaryLabel: colors.link2,
560
- outlinedPrimaryBorder: colors.link2,
561
- outlinedPrimaryBg: colors.neutral100,
562
- outlinedSecondaryLabel: colors.neutral900,
563
- outlinedSecondaryBorder: colors.neutral900,
564
- outlinedSecondaryBg: colors.neutral100,
565
- outlinedTertiaryLabel: colors.brand,
566
- outlinedTertiaryBorder: colors.brand,
567
- outlinedTertiaryBg: colors.neutral100,
568
- outlinedDisabledLabel: colors.disabledText,
569
- outlinedDisabledBg: colors.neutral300,
570
- containedPrimaryLabel: colors.neutral100,
571
- containedPrimaryBg: colors.link2,
572
- containedSecondaryLabel: colors.neutral100,
573
- containedSecondaryBg: colors.neutral900,
574
- containedTertiaryLabel: colors.neutral100,
575
- containedTertiaryBg: colors.brand,
576
- containedDisabledLabel: colors.disabledText,
577
- containedDisabledBg: colors.neutral300,
578
- hover: hover$2
579
- }),
580
- chip: __assign(__assign({}, BaseTheme.color.chip), {
581
- selectedPrimaryLabel: colors.link2,
582
- selectedPrimaryBorder: colors.link2,
583
- selectedPrimaryBg: colors.linkBg
584
- }),
585
- tab: __assign(__assign({}, BaseTheme.color.tab), {
586
- nonSelectedPrimaryLabel: colors.neutral900,
587
- selectedPrimaryLabel: colors.link2
588
- }),
589
- background: __assign(__assign({}, BaseTheme.color.background), {
590
- primary: colors.link2,
591
- secondary: colors.neutral900,
592
- tertiary: colors.brand
593
- }),
594
- border: __assign(__assign({}, BaseTheme.color.border), {
595
- primary: colors.link2,
596
- secondary: colors.neutral900,
597
- tertiary: colors.brand,
598
- divider: colors.line
599
- }),
600
- spinner: {
601
- primary: colors.link2,
602
- primaryBg: colors.alertBg
603
- },
604
- calendar: {
605
- accent: '',
606
- background: '',
607
- selected: colors.link2
608
- }
609
- })
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react/jsx-runtime'), require('react'), require('@cleartrip/ct-design-style-manager'), require('@emotion/css')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'react/jsx-runtime', 'react', '@cleartrip/ct-design-style-manager', '@emotion/css'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.CTDesignSystemSpinner = {}, global.jsxRuntime, global.React, global.ctDesignStyleManager, global.css));
5
+ })(this, (function (exports, jsxRuntime, react, ctDesignStyleManager, css) { 'use strict';
6
+
7
+ const spinnerStaticStyles = ctDesignStyleManager.makeStyles((theme) => ({
8
+ root: {
9
+ position: 'relative',
10
+ borderWidth: theme.border.width.lg,
11
+ borderStyle: 'solid',
12
+ borderColor: 'rgba(0, 0, 0, 0.3)',
13
+ borderRadius: theme.border.radius[32],
14
+ borderTopColor: theme.color.background.neutral,
15
+ },
16
+ }));
17
+
18
+ const spinAnimation = css.keyframes `
19
+ 0% { transform: rotate(0deg); }
20
+ 100% { transform: rotate(360deg); }
21
+ `;
22
+ const animationClass = css.css({
23
+ animation: `${spinAnimation} 800ms linear infinite`,
610
24
  });
611
- var hover$1 = function (key) {
612
- var _a;
613
- var bg = (_a = {}, _a[colors.neutral100] = colors.neutral100, _a[colors.neutral900] = colors.neutral900, _a[colors.neutral900] = colors.neutral900, _a[colors.neutral100] = colors.neutral100, _a[colors.brand] = colors.bgPrimaryHover, _a[colors.neutral100] = colors.neutral100, _a[colors.disabledText] = colors.disabledText, _a[colors.neutral300] = colors.neutral300, _a[colors.neutral100] = colors.neutral100, _a[colors.link2] = colors.link2Hover, _a[colors.neutral100] = colors.neutral100, _a[colors.neutral900] = colors.neutral900, _a[colors.neutral100] = colors.neutral100, _a[colors.disabledText] = colors.disabledText, _a[colors.neutral300] = colors.neutral300, _a[colors.bluePrimary500] = colors.bluePrimary500, _a[colors.yellowSecondary] = colors.yellowSecondary, _a);
614
- return bg[key];
615
- };
616
- var counter = {
617
- enabled: {
618
- stroke: colors.bluePrimary500
619
- },
620
- disabled: {
621
- stroke: colors.neutral500
622
- }
623
- };
624
- __assign(__assign({}, BaseTheme), {
625
- color: __assign(__assign({}, BaseTheme.color), {
626
- text: __assign(__assign({}, BaseTheme.color.text), {
627
- link: colors.bluePrimary500
628
- }),
629
- button: __assign(__assign({}, BaseTheme.color.button), {
630
- outlinedPrimaryLabel: colors.primaryNeutral900,
631
- outlinedPrimaryBg: colors.neutral100,
632
- containedPrimaryLabel: colors.neutral100,
633
- containedPrimaryBg: colors.bluePrimary500,
634
- containedSecondaryLabel: colors.primaryNeutral900,
635
- containedSecondaryBg: colors.yellowSecondary,
636
- hover: hover$1
637
- }),
638
- chip: __assign(__assign({}, BaseTheme.color.chip), {
639
- selectedPrimaryLabel: colors.link2,
640
- selectedPrimaryBorder: colors.link2,
641
- selectedPrimaryBg: colors.linkBg,
642
- nonSelectedPrimaryLabel: colors.neutral900
643
- }),
644
- tab: __assign(__assign({}, BaseTheme.color.tab), {
645
- nonSelectedPrimaryLabel: colors.neutral900,
646
- selectedPrimaryLabel: colors.bluePrimary500
647
- }),
648
- background: __assign(__assign({}, BaseTheme.color.background), {
649
- primary: colors.bluePrimary500,
650
- secondary: colors.neutral900,
651
- tertiary: colors.brand,
652
- linkLightBg: colors.blueSecondary
653
- }),
654
- border: __assign(__assign({}, BaseTheme.color.border), {
655
- primary: colors.bluePrimary500,
656
- brand: colors.bluePrimary500
657
- }),
658
- spinner: {
659
- primary: colors.link2,
660
- primaryBg: colors.alertBg
661
- },
662
- counter: counter,
663
- calendar: {
664
- accent: colors.bluePrimary500,
665
- background: colors.blueSecondary,
666
- selected: colors.bluePrimary500
25
+ const STROKE_DASH_RATIO = 0.65;
26
+ const DEFAULT_STROKE_WIDTH = 2;
27
+ const Spinner = ({ width = 30, height = 30, gradientColors }) => {
28
+ const gradientId = react.useId();
29
+ const hasGradient = Array.isArray(gradientColors) && gradientColors.length > 0;
30
+ const dynamicStyles = ctDesignStyleManager.useStyles(() => ({
31
+ size: {
32
+ width,
33
+ height,
34
+ },
35
+ }), [width, height]);
36
+ const rootClassName = ctDesignStyleManager.useWebMergeStyles([spinnerStaticStyles.root, dynamicStyles.size, animationClass], [dynamicStyles.size, animationClass]);
37
+ const gradientWrapperClassName = ctDesignStyleManager.useWebMergeStyles([dynamicStyles.size, animationClass], [dynamicStyles.size, animationClass]);
38
+ if (hasGradient) {
39
+ const size = Math.min(width, height);
40
+ const center = size / 2;
41
+ const radius = (size - DEFAULT_STROKE_WIDTH) / 2;
42
+ const circumference = 2 * Math.PI * radius;
43
+ const strokeUrl = `url(#${gradientId})`;
44
+ return (jsxRuntime.jsx("span", { className: gradientWrapperClassName, role: 'status', "aria-label": 'Loading', children: jsxRuntime.jsxs("svg", { width: size, height: size, viewBox: `0 0 ${size} ${size}`, fill: 'none', children: [jsxRuntime.jsx("defs", { children: jsxRuntime.jsx("linearGradient", { id: gradientId, x1: '0%', y1: '0%', x2: '100%', y2: '0%', children: gradientColors.map((color, index) => (jsxRuntime.jsx("stop", { offset: `${(index / (gradientColors.length - 1)) * 100}%`, stopColor: color }, index))) }) }), jsxRuntime.jsx("circle", { cx: center, cy: center, r: radius, stroke: strokeUrl, strokeWidth: DEFAULT_STROKE_WIDTH, strokeLinecap: 'round', strokeDasharray: `${circumference * STROKE_DASH_RATIO} ${circumference * (1 - STROKE_DASH_RATIO)}`, fill: 'none' })] }) }));
667
45
  }
668
- })
669
- });
670
- var hover = function (key) {
671
- var _a;
672
- var bg = (_a = {}, _a[colors.neutral100] = colors.neutral100, _a[colors.brand] = colors.bgPrimaryHover, _a[colors.disabledText] = colors.disabledText, _a[colors.neutral300] = colors.neutral300, _a[colors.link2] = colors.link2Hover, _a[colors.neutral100] = colors.neutral100, _a[colors.neutral900] = colors.neutral900, _a[colors.superGrey700] = colors.superGrey700, _a[colors.superGrey300] = colors.superGrey300, _a[colors.superGrey800] = colors.superGrey800, _a[colors.superGreen500] = colors.superGreen500, _a);
673
- return bg[key];
46
+ return jsxRuntime.jsx("span", { role: 'status', "aria-label": 'Loading', className: rootClassName });
674
47
  };
675
- __assign(__assign({}, BaseTheme), {
676
- color: __assign(__assign({}, BaseTheme.color), {
677
- text: __assign(__assign({}, BaseTheme.color.text), {
678
- primary: colors.superGrey800,
679
- secondary: colors.superGrey500,
680
- tertiary: colors.superGrey400,
681
- warning: colors.systemRed500,
682
- disabled: colors.superGrey400,
683
- subHeading: colors.superGrey400,
684
- success: colors.systemGreen500,
685
- link: colors.superBlue500,
686
- link2: colors.superBlue500
687
- }),
688
- button: __assign(__assign({}, BaseTheme.color.button), {
689
- outlinedPrimaryLabel: colors.superGrey700,
690
- outlinedPrimaryBorder: colors.superGrey300,
691
- outlinedTertiaryLabel: colors.superGrey700,
692
- outlinedTertiaryBorder: colors.superGrey300,
693
- outlinedDisabledLabel: colors.disabledText,
694
- containedSecondaryLabel: colors.superGrey800,
695
- containedPrimaryBg: colors.superBlue500,
696
- containedSecondaryBg: colors.superGreen500,
697
- containedTertiaryLabel: colors.superGrey300,
698
- containedDisabledLabel: colors.disabledText,
699
- containedPrimaryLabel: colors.neutral100,
700
- hover: hover
701
- }),
702
- chip: __assign(__assign({}, BaseTheme.color.chip), {
703
- selectedPrimaryLabel: colors.superBlue500,
704
- selectedPrimaryBorder: colors.superBlue500,
705
- selectedPrimaryBg: colors.superBlue25,
706
- disabledPrimaryLabel: colors.superGrey400,
707
- nonSelectedPrimaryLabel: colors.superGrey700,
708
- disabledPrimaryBg: colors.superGrey200
709
- }),
710
- tab: __assign(__assign({}, BaseTheme.color.tab), {
711
- nonSelectedPrimaryLabel: colors.superGrey500,
712
- selectedPrimaryLabel: colors.superBlue500
713
- }),
714
- background: __assign(__assign({}, BaseTheme.color.background), {
715
- primary: colors.superBlue500,
716
- disabled: colors.superGrey50,
717
- disabledDark: colors.superGrey300,
718
- warning: colors.systemRed500
719
- }),
720
- border: __assign(__assign({}, BaseTheme.color.border), {
721
- primary: colors.superBlue500,
722
- secondary: colors.neutral900,
723
- disabledDark: colors.superGrey300,
724
- defaultDark: colors.superGrey400,
725
- default: colors.superGrey300,
726
- disabled: colors.superGrey200
727
- })
728
- })
729
- });
730
- var ThemeContext = react.createContext({
731
- theme: B2CTheme,
732
- platform: 'mobile'
733
- });
734
- var useTheme = function () {
735
- var themeContext = react.useContext(ThemeContext);
736
- var theme = (themeContext || {
737
- theme: B2CTheme
738
- }).theme;
739
- return theme;
740
- };
741
- var ThemeManagerClass = function () {
742
- function ThemeManagerClass() {
743
- if (ThemeManagerClass.instance) {
744
- throw new Error('You can only create one instance!');
745
- }
746
- ThemeManagerClass.instance = this;
747
- this.theme = B2CTheme;
748
- }
749
- ThemeManagerClass.prototype.set = function (theme) {
750
- switch (theme) {
751
- case 'B2C':
752
- default:
753
- {
754
- this.theme = B2CTheme;
755
- break;
756
- }
757
- }
758
- };
759
- ThemeManagerClass.prototype.get = function () {
760
- return this.theme;
761
- };
762
- return ThemeManagerClass;
763
- }();
764
- Object.freeze(new ThemeManagerClass());
765
-
766
- var StyledSpinner = styled__default.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n border: ", ";\n border-radius: 50%;\n border-top: ", ";\n width: ", ";\n height: ", ";\n -webkit-animation: spin 2s linear infinite;\n animation: spin 2s linear infinite;\n\n @-webkit-keyframes spin {\n 0% {\n -webkit-transform: rotate(0deg);\n }\n 100% {\n -webkit-transform: rotate(360deg);\n }\n }\n\n @keyframes spin {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n }\n ", "\n"], ["\n border: ", ";\n border-radius: 50%;\n border-top: ", ";\n width: ", ";\n height: ", ";\n -webkit-animation: spin 2s linear infinite;\n animation: spin 2s linear infinite;\n\n @-webkit-keyframes spin {\n 0% {\n -webkit-transform: rotate(0deg);\n }\n 100% {\n -webkit-transform: rotate(360deg);\n }\n }\n\n @keyframes spin {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n }\n ", "\n"])), function (_a) {
767
- var theme = _a.theme, height = _a.height;
768
- var spinerHeight = parseInt(height || theme.size[12]) / 6;
769
- return "".concat(spinerHeight > 0 ? spinerHeight : 8, "px solid ").concat(theme.color.spinner.primaryBg);
770
- }, function (_a) {
771
- var theme = _a.theme, height = _a.height, borderColor = _a.borderColor;
772
- var spinerHeight = parseInt(height || theme.size[12]) / 6;
773
- return "".concat(spinerHeight > 0 ? spinerHeight : 8, "px solid ").concat(borderColor || theme.color.spinner.primary);
774
- }, function (_a) {
775
- var width = _a.width, theme = _a.theme;
776
- return width || theme.size[12];
777
- }, function (_a) {
778
- var height = _a.height, theme = _a.theme;
779
- return height || theme.size[12];
780
- }, function (_a) {
781
- var css = _a.css;
782
- return css && react$1.css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n\t", "\n "], ["\n\t", "\n "])), css);
783
- });
784
- var templateObject_1, templateObject_2;
785
-
786
- function Spinner(_a) {
787
- var _b = _a.height, height = _b === void 0 ? '16px' : _b, _c = _a.width, width = _c === void 0 ? '16px' : _c, _d = _a.borderColor, borderColor = _d === void 0 ? '' : _d;
788
- var theme = useTheme();
789
- return jsxRuntime.jsx(StyledSpinner, { theme: theme, height: height, width: width, borderColor: borderColor });
790
- }
48
+ Spinner.displayName = 'Spinner';
791
49
 
792
50
  exports.Spinner = Spinner;
793
51