@shoplflow/base 0.13.0 → 0.13.2

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.mjs DELETED
@@ -1,1755 +0,0 @@
1
- import React3, { createContext, forwardRef, useState, useId, useCallback, useEffect, useContext, useMemo } from 'react';
2
- import styled5 from '@emotion/styled';
3
- import { motion, AnimatePresence } from 'framer-motion';
4
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
- import { createPortal } from 'react-dom';
6
- import { noop, useParentElementClick, useResizeObserver, isNullOrUndefined } from '@shoplflow/utils';
7
- import { css } from '@emotion/react';
8
- import Scrollbars from 'react-custom-scrollbars-2';
9
- import { useFloating } from '@floating-ui/react-dom';
10
- import { autoUpdate, offset, autoPlacement, FloatingPortal } from '@floating-ui/react';
11
- import * as ShoplAssets from '@shoplflow/shopl-assets';
12
- import * as HadaAssets from '@shoplflow/hada-assets';
13
-
14
- // src/hooks/useDomain.ts
15
- var useDomain = (domain = "SHOPL") => {
16
- const [domainType, setDomainType] = useState(void 0);
17
- useEffect(() => {
18
- if (domain) {
19
- setDomainType(domain);
20
- }
21
- }, [domain]);
22
- useEffect(() => {
23
- if (!domainType) {
24
- return;
25
- }
26
- document.documentElement.dataset.shoplflow = domainType?.toLowerCase();
27
- }, [domainType]);
28
- return [domainType];
29
- };
30
- var getDomain = () => {
31
- return document.documentElement.dataset.shoplflow;
32
- };
33
-
34
- // src/animation/fadeInOut.ts
35
- var fadeInOut = {
36
- initial: {
37
- opacity: 0
38
- },
39
- animate: {
40
- opacity: 1,
41
- transition: {
42
- duration: 0.1
43
- }
44
- },
45
- exit: {
46
- opacity: 0,
47
- transition: {
48
- duration: 0.1
49
- }
50
- }
51
- };
52
- var BackDropStyled = styled5(motion.div)`
53
- display: flex;
54
- align-items: center;
55
- justify-content: center;
56
- position: fixed;
57
- top: 0;
58
- left: 0;
59
- z-index: 20000;
60
- width: 100%;
61
- height: 100%;
62
- background: rgba(51, 51, 51, 0.6);
63
- `;
64
- var BackDrop = ({ children }) => {
65
- return /* @__PURE__ */ jsx(
66
- BackDropStyled,
67
- {
68
- variants: fadeInOut,
69
- initial: "initial",
70
- animate: "animate",
71
- exit: "exit",
72
- "data-shoplflow": "BackDrop",
73
- children
74
- }
75
- );
76
- };
77
- var BackDrop_default = BackDrop;
78
- var ModalHandlerContext = createContext({
79
- addModal: noop,
80
- removeModal: noop
81
- });
82
- var ModalContext = createContext([]);
83
- var SpaceMarginWrapper = styled5(motion.div)`
84
- position: relative;
85
- display: flex;
86
- align-items: center;
87
- justify-content: center;
88
- flex-grow: 1;
89
- z-index: 101;
90
- padding: 32px 20px;
91
- width: 100%;
92
- height: 100%;
93
- `;
94
- var ModalPortal = () => {
95
- const modal = useContext(ModalContext);
96
- return /* @__PURE__ */ jsx(Fragment, { children: createPortal(
97
- /* @__PURE__ */ jsx(AnimatePresence, { children: modal.map((item, index) => /* @__PURE__ */ jsx(BackDrop_default, { children: /* @__PURE__ */ jsx(SpaceMarginWrapper, { children: item.component }) }, index)) }),
98
- document.body
99
- ) });
100
- };
101
- var ModalPortal_default = ModalPortal;
102
- var ModalProvider = ({ children }) => {
103
- const [openedModals, setOpenedModals] = useState([]);
104
- const addModal = (component, id) => {
105
- setOpenedModals((modals) => {
106
- if (modals) {
107
- return [...modals, { component, id }];
108
- }
109
- return [{ component, id }];
110
- });
111
- };
112
- const removeModal = (props) => {
113
- const { id, deps } = props || {
114
- id: void 0,
115
- deps: void 0
116
- };
117
- const isIncludeAllProps = Boolean(id && deps);
118
- const isIncludeId = Boolean(id);
119
- const isNotIncludeAllProps = !id && Boolean(isNullOrUndefined(deps));
120
- const isIncludeDeps = Boolean(Boolean(!isNullOrUndefined(deps)) && !id);
121
- if (isIncludeAllProps) {
122
- throw new Error("id\uC640 deps\uB294 \uB3D9\uC2DC\uC5D0 \uC0AC\uC6A9\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4.");
123
- }
124
- if (isIncludeId) {
125
- setOpenedModals((modal) => {
126
- const filterModal = modal.filter((modal2) => modal2.id !== id);
127
- return [...filterModal];
128
- });
129
- return;
130
- }
131
- if (isNotIncludeAllProps || deps === 1) {
132
- setOpenedModals((modal) => {
133
- const removeModal2 = modal.slice(0, -1);
134
- return [...removeModal2];
135
- });
136
- return;
137
- }
138
- if (isIncludeDeps) {
139
- if (deps === 0 || deps === void 0) {
140
- return;
141
- }
142
- setOpenedModals((modal) => {
143
- const removeDeps = modal.slice(0, -deps);
144
- return [...removeDeps];
145
- });
146
- return;
147
- }
148
- };
149
- const dispatch = useMemo(() => ({ addModal, removeModal }), []);
150
- return /* @__PURE__ */ jsx(ModalContext.Provider, { value: openedModals, children: /* @__PURE__ */ jsx(ModalHandlerContext.Provider, { value: dispatch, children }) });
151
- };
152
- var ModalProvider_default = ModalProvider;
153
- var ShoplflowProvider = ({ children, domain = "SHOPL" }) => {
154
- useDomain(domain);
155
- return /* @__PURE__ */ jsxs(ModalProvider_default, { children: [
156
- /* @__PURE__ */ jsx(ModalPortal_default, {}),
157
- children
158
- ] });
159
- };
160
- var ShoplflowProvider_default = ShoplflowProvider;
161
- var useHandleModal = () => {
162
- const { addModal, removeModal } = useContext(ModalHandlerContext);
163
- return {
164
- addModal,
165
- removeModal
166
- };
167
- };
168
- var useModalValue = () => {
169
- const modal = useContext(ModalContext);
170
- return {
171
- modal
172
- };
173
- };
174
-
175
- // src/styles/tokens.ts
176
- var fontWeightRegular = "var(--font-weight-regular)";
177
- var fontWeightMedium = "var(--font-weight-medium)";
178
- var fontWeightBold = "var(--font-weight-bold)";
179
- var fontWeightTokens = {
180
- fontWeightRegular,
181
- fontWeightMedium,
182
- fontWeightBold
183
- };
184
- var borderRadius04 = "var(--border-radius04)";
185
- var borderRadius06 = "var(--border-radius06)";
186
- var borderRadius08 = "var(--border-radius08)";
187
- var borderRadius12 = "var(--border-radius12)";
188
- var borderRadius16 = "var(--border-radius16)";
189
- var borderRadius20 = "var(--border-radius20)";
190
- var borderRadiusTokens = {
191
- borderRadius04,
192
- borderRadius06,
193
- borderRadius08,
194
- borderRadius12,
195
- borderRadius16,
196
- borderRadius20
197
- };
198
- var coolgray300 = "var(--coolgray300)";
199
- var coolgray200 = "var(--coolgray200)";
200
- var coolgray100 = "var(--coolgray100)";
201
- var coolgray50 = "var(--coolgray50)";
202
- var navy400 = "var(--navy400)";
203
- var navy300 = "var(--navy300)";
204
- var neutral0 = "var(--neutral0)";
205
- var neutral100 = "var(--neutral100)";
206
- var neutral150 = "var(--neutral150)";
207
- var neutral200 = "var(--neutral200)";
208
- var neutral300 = "var(--neutral300)";
209
- var neutral350 = "var(--neutral350)";
210
- var neutral400 = "var(--neutral400)";
211
- var neutral500 = "var(--neutral500)";
212
- var neutral600 = "var(--neutral600)";
213
- var neutral700 = "var(--neutral700)";
214
- var neutral400_5 = "var(--neutral400_5)";
215
- var red300 = "var(--red300)";
216
- var red200 = "var(--red200)";
217
- var red100 = "var(--red100)";
218
- var ocean300 = "var(--ocean300)";
219
- var ocean200 = "var(--ocean200)";
220
- var ocean100 = "var(--ocean100)";
221
- var purple400 = "var(--purple400)";
222
- var purple300 = "var(--purple300)";
223
- var purple100 = "var(--purple100)";
224
- var yellow300 = "var(--yellow300)";
225
- var yellow200 = "var(--yellow200)";
226
- var yellow100 = "var(--yellow100)";
227
- var green300 = "var(--green300)";
228
- var green200 = "var(--green200)";
229
- var green100 = "var(--green100)";
230
- var shopl400 = "var(--shopl400)";
231
- var shopl300 = "var(--shopl300)";
232
- var shopl200 = "var(--shopl200)";
233
- var shopl150 = "var(--shopl150)";
234
- var shopl100 = "var(--shopl100)";
235
- var hada400 = "var(--hada400)";
236
- var hada300 = "var(--hada300)";
237
- var hada200 = "var(--hada200)";
238
- var hada150 = "var(--hada150)";
239
- var hada100 = "var(--hada100)";
240
- var background = "var(--background)";
241
- var primary100 = "var(--primary100)";
242
- var primary150 = "var(--primary150)";
243
- var primary200 = "var(--primary200)";
244
- var primary300 = "var(--primary300)";
245
- var primary400 = "var(--primary400)";
246
- var colorTokens = {
247
- coolgray300,
248
- coolgray200,
249
- coolgray100,
250
- coolgray50,
251
- navy400,
252
- navy300,
253
- neutral0,
254
- neutral100,
255
- neutral150,
256
- neutral200,
257
- neutral300,
258
- neutral350,
259
- neutral400,
260
- neutral500,
261
- neutral600,
262
- neutral700,
263
- neutral400_5,
264
- red300,
265
- red200,
266
- red100,
267
- ocean300,
268
- ocean200,
269
- ocean100,
270
- purple400,
271
- purple300,
272
- purple100,
273
- yellow300,
274
- yellow200,
275
- yellow100,
276
- green300,
277
- green200,
278
- green100,
279
- shopl400,
280
- shopl300,
281
- shopl200,
282
- shopl150,
283
- shopl100,
284
- hada400,
285
- hada300,
286
- hada200,
287
- hada150,
288
- hada100,
289
- background,
290
- primary100,
291
- primary150,
292
- primary200,
293
- primary300,
294
- primary400
295
- };
296
- var spacing04 = "var(--spacing04)";
297
- var spacing06 = "var(--spacing06)";
298
- var spacing08 = "var(--spacing08)";
299
- var spacing12 = "var(--spacing12)";
300
- var spacing16 = "var(--spacing16)";
301
- var spacing20 = "var(--spacing20)";
302
- var spacing24 = "var(--spacing24)";
303
- var spacing30 = "var(--spacing30)";
304
- var spacing32 = "var(--spacing32)";
305
- var spacing40 = "var(--spacing40)";
306
- var spacingTokens = {
307
- spacing04,
308
- spacing06,
309
- spacing08,
310
- spacing12,
311
- spacing16,
312
- spacing20,
313
- spacing24,
314
- spacing30,
315
- spacing32,
316
- spacing40
317
- };
318
- var dropShadow = "var(--dropShadow)";
319
- var boxShadowTokens = {
320
- dropShadow
321
- };
322
- var heading1_700 = ".heading1_700";
323
- var heading1_400 = ".heading1_400";
324
- var heading2_700 = ".heading2_700";
325
- var heading2_400 = ".heading2_400";
326
- var heading3_700 = ".heading3_700";
327
- var heading3_400 = ".heading3_400";
328
- var title1_700 = ".title1_700";
329
- var title1_400 = ".title1_400";
330
- var title2_700 = ".title2_700";
331
- var title2_500 = ".title2_500";
332
- var title2_400 = ".title2_400";
333
- var body1_700 = ".body1_700";
334
- var body1_500 = ".body1_500";
335
- var body1_400 = ".body1_400";
336
- var body2_700 = ".body2_700";
337
- var body2_500 = ".body2_500";
338
- var body2_400 = ".body2_400";
339
- var body3_400 = ".body3_400";
340
- var body3_500 = ".body3_500";
341
- var caption_700 = ".caption_700";
342
- var caption_400 = ".caption_400";
343
- var typographyTokens = {
344
- heading1_700,
345
- heading1_400,
346
- heading2_700,
347
- heading2_400,
348
- heading3_700,
349
- heading3_400,
350
- title1_700,
351
- title1_400,
352
- title2_700,
353
- title2_500,
354
- title2_400,
355
- body1_700,
356
- body1_500,
357
- body1_400,
358
- body2_700,
359
- body2_500,
360
- body2_400,
361
- body3_400,
362
- body3_500,
363
- caption_700,
364
- caption_400
365
- };
366
- var StyledStack = styled5.div`
367
- display: flex;
368
- width: ${({ width }) => width};
369
- height: ${({ height }) => height};
370
- flex-direction: ${({ direction }) => direction};
371
- align-items: ${({ align }) => align};
372
- justify-content: ${({ justify }) => justify};
373
- gap: ${({ spacing }) => spacing && spacingTokens[spacing]};
374
- flex-wrap: ${({ flexWrap }) => flexWrap};
375
- flex: ${({ flex }) => flex};
376
- background: ${({ background: background2 }) => background2 ? colorTokens[background2] : "transparent"};
377
- border-radius: ${({ radius }) => radius && borderRadiusTokens[radius]};
378
- animation: 0.2s all ease-in-out;
379
- `;
380
- var createStackComponent = (stackOption) => forwardRef(function Stack2({
381
- as = "div",
382
- spacing = stackOption?.spacing,
383
- direction = stackOption?.direction ?? "column",
384
- align = stackOption?.align ?? "flex-start",
385
- justify = stackOption?.justify ?? "flex-start",
386
- width = stackOption?.width ?? "initial",
387
- height = stackOption?.height ?? "initial",
388
- flexWrap = stackOption?.flexWrap ?? "initial",
389
- flex = stackOption?.flex ?? "initial",
390
- radius = stackOption?.radius,
391
- background: background2 = stackOption?.background,
392
- ...rest
393
- }, ref) {
394
- return /* @__PURE__ */ jsx(
395
- StyledStack,
396
- {
397
- as,
398
- spacing,
399
- ref,
400
- direction,
401
- align,
402
- justify,
403
- width,
404
- height,
405
- flexWrap,
406
- flex,
407
- background: background2,
408
- radius,
409
- ...rest,
410
- "data-shoplflow": "Stack",
411
- children: rest.children
412
- }
413
- );
414
- });
415
- var Stack = createStackComponent();
416
- Stack.Vertical = createStackComponent({ direction: "column" });
417
- Stack.Horizontal = createStackComponent({ direction: "row" });
418
- var MotionStack = motion(Stack);
419
- MotionStack.Vertical = motion(Stack.Vertical);
420
- MotionStack.Horizontal = motion(Stack.Horizontal);
421
- var Stack_default = Stack;
422
- var setEllipsis = (maxLines) => {
423
- return css`
424
- display: -webkit-box;
425
- line-clamp: ${maxLines};
426
- -webkit-line-clamp: ${maxLines};
427
- -webkit-box-orient: vertical;
428
- overflow: hidden;
429
- text-overflow: ellipsis;
430
- `;
431
- };
432
- var StyledText = styled5.span`
433
- display: ${({ display }) => display && display};
434
- align-items: center;
435
- color: ${({ color }) => color && colorTokens[color]};
436
- ${({ lineClamp }) => lineClamp && setEllipsis(lineClamp)};
437
- text-align: ${({ textAlign }) => textAlign && textAlign};
438
- white-space: ${({ whiteSpace }) => whiteSpace && whiteSpace};
439
- ${({ textDecorations }) => textDecorations && css`
440
- text-decoration: ${textDecorations};
441
- `};
442
- ${({ opacity }) => opacity && css`
443
- opacity: ${opacity};
444
- `}
445
- ${({ wordBreak }) => wordBreak && css`
446
- word-break: ${wordBreak};
447
- `};
448
- `;
449
- var Text = forwardRef(
450
- ({
451
- children,
452
- typography = "body1_400",
453
- whiteSpace,
454
- color = "neutral700",
455
- display = "inline-block",
456
- textAlign = "start",
457
- className,
458
- as,
459
- ...rest
460
- }, ref) => {
461
- return /* @__PURE__ */ jsx(
462
- StyledText,
463
- {
464
- ref,
465
- whiteSpace,
466
- className: className ? `${typography} ${className}` : typography,
467
- color,
468
- display,
469
- textAlign,
470
- as,
471
- ...rest,
472
- "data-shoplflow": "Text",
473
- children
474
- }
475
- );
476
- }
477
- );
478
- var Text_default = Text;
479
- var MODAL_SIZE_XXS = 400;
480
- var MODAL_SIZE_XS = 500;
481
- var MODAL_SIZE_S = 560;
482
- var MODAL_SIZE_M = 640;
483
- var MODAL_SIZE_L = 768;
484
- var MODAL_SIZE_XL = 1040;
485
- var MODAL_SIZE_XXL = 1280;
486
- var getModalWidthFromSize = (size) => {
487
- switch (size) {
488
- case "XXS":
489
- return MODAL_SIZE_XXS;
490
- case "XS":
491
- return MODAL_SIZE_XS;
492
- case "S":
493
- return MODAL_SIZE_S;
494
- case "M":
495
- return MODAL_SIZE_M;
496
- case "L":
497
- return MODAL_SIZE_L;
498
- case "XL":
499
- return MODAL_SIZE_XL;
500
- case "XXL":
501
- return MODAL_SIZE_XXL;
502
- default:
503
- return MODAL_SIZE_M;
504
- }
505
- };
506
- var getModalBodyTopBottomPadding = (isIncludeHeader) => {
507
- if (isIncludeHeader) {
508
- return css`
509
- padding-top: 16px;
510
- padding-bottom: 24px;
511
- `;
512
- }
513
- return css`
514
- padding-top: 24px;
515
- padding-bottom: 24px;
516
- `;
517
- };
518
- var Container = styled5.div`
519
- display: flex;
520
- flex-direction: column;
521
- border-radius: ${borderRadiusTokens.borderRadius08};
522
- background: ${colorTokens.neutral0};
523
- box-shadow: ${boxShadowTokens.dropShadow};
524
- overflow: hidden;
525
- flex-grow: 1;
526
- height: ${({ height }) => height ? `${height}px` : "initial"};
527
- min-height: 180px;
528
- max-height: 1200px;
529
- width: ${({ sizeVar }) => getModalWidthFromSize(sizeVar)}px;
530
- max-width: ${({ sizeVar }) => getModalWidthFromSize(sizeVar)}px;
531
- `;
532
- var HeaderContainer = styled5.div`
533
- display: flex;
534
- width: 100%;
535
- min-height: 64px;
536
- justify-content: space-between;
537
- align-items: center;
538
- padding: 12px 16px 12px 24px;
539
- gap: 10px;
540
- `;
541
- var BodyContainer = styled5.div`
542
- display: flex;
543
- width: 100%;
544
- height: 100%;
545
- overflow: hidden;
546
- flex-direction: column;
547
- background: ${colorTokens.neutral0};
548
- min-height: 112px;
549
- min-height: ${({ height }) => height};
550
- flex: 1;
551
- ${({ isIncludeHeader }) => getModalBodyTopBottomPadding(isIncludeHeader)}
552
- `;
553
- var ModalBodyContent = styled5.div`
554
- display: flex;
555
- flex-direction: column;
556
- width: 100%;
557
- max-width: ${({ sizeVar }) => getModalWidthFromSize(sizeVar)}px;
558
- box-sizing: border-box;
559
- padding: 0 24px;
560
- overflow: hidden;
561
- background: ${colorTokens.neutral0};
562
- `;
563
- var FooterContainer = styled5.div`
564
- display: flex;
565
- width: 100%;
566
- flex-direction: row;
567
- align-items: center;
568
- justify-content: flex-end;
569
- padding: 16px 24px;
570
- gap: 12px;
571
- border-top: 1px solid ${colorTokens.neutral300};
572
- background: ${colorTokens.neutral0};
573
- `;
574
-
575
- // src/components/Modal/Modal.types.ts
576
- var ModalSize = {
577
- XXS: "XXS",
578
- XS: "XS",
579
- S: "S",
580
- M: "M",
581
- L: "L",
582
- XL: "XL",
583
- XXL: "XXL"
584
- };
585
- var MODAL_HEADER_KEY = Symbol("MODAL_HEADER");
586
- var MODAL_FOOTER_KEY = Symbol("MODAL_FOOTER");
587
- var ModalContainer = ({ children, outsideClick = noop, ...rest }) => {
588
- const ref = useParentElementClick(outsideClick);
589
- const childrenArray = React3.Children.toArray(children);
590
- const findHeader = childrenArray.find((child) => {
591
- if (!React3.isValidElement(child)) {
592
- return child;
593
- }
594
- if (child.type[MODAL_HEADER_KEY]) {
595
- return child;
596
- }
597
- });
598
- const findFooter = childrenArray.find((child) => {
599
- if (!React3.isValidElement(child)) {
600
- return child;
601
- }
602
- if (child.type[MODAL_FOOTER_KEY]) {
603
- return child;
604
- }
605
- });
606
- const addPropInChildren = React3.Children.map(childrenArray, (child) => {
607
- if (!React3.isValidElement(child)) {
608
- return child;
609
- }
610
- return React3.cloneElement(child, {
611
- isIncludeHeader: Boolean(findHeader),
612
- isIncludeFooter: Boolean(findFooter),
613
- sizeVar: rest.sizeVar,
614
- height: rest.height
615
- });
616
- });
617
- return /* @__PURE__ */ jsx(Container, { ref, ...rest, "data-shoplflow": "Modal", children: addPropInChildren });
618
- };
619
- var ModalContainer_default = ModalContainer;
620
- var ModalFooter = ({ children }) => {
621
- return /* @__PURE__ */ jsx(FooterContainer, { children });
622
- };
623
- ModalFooter[MODAL_FOOTER_KEY] = true;
624
- var ModalFooter_default = ModalFooter;
625
- var ModalBody = ({
626
- children,
627
- isIncludeHeader = false,
628
- isIncludeFooter = false,
629
- sizeVar,
630
- height: modalContainerHeight
631
- }) => {
632
- const { height: windowHeight } = useResizeObserver(document.body, {
633
- trackHeight: true
634
- });
635
- const headerHeight = 64;
636
- const footerHeight = 64;
637
- const topBottomMargin = 64;
638
- const getHeaderFooterHeight = useCallback(() => {
639
- let result = 0;
640
- if (isIncludeHeader) {
641
- result += headerHeight;
642
- }
643
- if (isIncludeFooter) {
644
- result += footerHeight;
645
- }
646
- return result;
647
- }, [isIncludeFooter, isIncludeHeader]);
648
- const headerFooterHeight = useMemo(() => getHeaderFooterHeight(), [getHeaderFooterHeight]);
649
- const setAutoHeightMin = () => {
650
- if (modalContainerHeight) {
651
- return modalContainerHeight - headerFooterHeight;
652
- } else {
653
- return "100%";
654
- }
655
- };
656
- const heightUnderMaxHeight = windowHeight - topBottomMargin - headerFooterHeight;
657
- const heightOverMaxHeight = 1200 - topBottomMargin - headerFooterHeight;
658
- return /* @__PURE__ */ jsx(BodyContainer, { isIncludeHeader, height: setAutoHeightMin(), children: /* @__PURE__ */ jsx(
659
- Scrollbars,
660
- {
661
- id: `scrollbar`,
662
- autoHeight: !modalContainerHeight,
663
- autoHeightMin: setAutoHeightMin(),
664
- autoHeightMax: windowHeight > 1200 ? heightOverMaxHeight : heightUnderMaxHeight,
665
- autoHide: true,
666
- autoHideTimeout: 1e3,
667
- autoHideDuration: 200,
668
- style: {
669
- height: "100%",
670
- overflow: "hidden"
671
- },
672
- children: /* @__PURE__ */ jsx(ModalBodyContent, { isIncludeHeader, sizeVar, children })
673
- }
674
- ) });
675
- };
676
- var ModalBody_default = ModalBody;
677
- var ModalHeader = ({ children }) => {
678
- return /* @__PURE__ */ jsx(HeaderContainer, { children });
679
- };
680
- ModalHeader[MODAL_HEADER_KEY] = true;
681
- var ModalHeader_default = ModalHeader;
682
-
683
- // src/components/Modal/index.ts
684
- var Modal = {
685
- Container: ModalContainer_default,
686
- Header: ModalHeader_default,
687
- Body: ModalBody_default,
688
- Footer: ModalFooter_default
689
- };
690
- var SwitchContainer = styled5.div`
691
- width: 32px;
692
- height: 32px;
693
- border-radius: 6px;
694
- display: flex;
695
- align-items: center;
696
- justify-content: center;
697
- opacity: ${({ isDisabled }) => isDisabled && 0.3};
698
-
699
- &:hover {
700
- background: ${({ isDisabled }) => !isDisabled && colorTokens.neutral400_5};
701
- }
702
- `;
703
- var StyledSwitch = styled5.input`
704
- appearance: none;
705
- border: none;
706
- border-radius: 12px;
707
- width: 28px;
708
- height: 18px;
709
- cursor: pointer;
710
- position: relative;
711
- display: flex;
712
- align-items: center;
713
- background: ${colorTokens.neutral350};
714
- padding: 2px;
715
- margin: 0;
716
-
717
- // slider
718
- &:before {
719
- content: '';
720
- left: 2px;
721
- display: block;
722
- position: absolute;
723
- width: 14px;
724
- height: 14px;
725
- background: ${colorTokens.neutral0};
726
- border-radius: 50%;
727
- transition: left 0.2s ease-in-out;
728
- }
729
-
730
- // selected
731
- &:checked {
732
- background: ${({ activeColor }) => colorTokens[activeColor]};
733
- &:before {
734
- left: 12px;
735
- }
736
- }
737
-
738
- // disabled
739
- &:disabled {
740
- cursor: auto;
741
- }
742
- `;
743
- var useOnToggle = (selected, defaultSelected) => {
744
- const [isToggle, setIsToggle] = useState(false);
745
- const isControlled = selected !== void 0;
746
- const handleToggle = () => {
747
- !isControlled && setIsToggle((prev) => !prev);
748
- };
749
- useEffect(() => {
750
- if (isControlled) {
751
- setIsToggle(selected);
752
- }
753
- }, [isControlled, selected]);
754
- useEffect(() => {
755
- if (defaultSelected) {
756
- setIsToggle(defaultSelected);
757
- }
758
- }, [defaultSelected, isControlled]);
759
- return [isToggle, handleToggle];
760
- };
761
- var Switch = ({
762
- onChange,
763
- isSelected,
764
- disabled = false,
765
- activeColor = "primary300",
766
- defaultSelected = false,
767
- ...rest
768
- }) => {
769
- const [isToggled, handleToggle] = useOnToggle(isSelected, defaultSelected);
770
- const handleOnChange = (e) => {
771
- handleToggle();
772
- onChange && onChange(e);
773
- };
774
- return /* @__PURE__ */ jsx(SwitchContainer, { isDisabled: disabled, children: /* @__PURE__ */ jsx(
775
- StyledSwitch,
776
- {
777
- type: "checkbox",
778
- checked: isToggled,
779
- disabled,
780
- onChange: handleOnChange,
781
- activeColor,
782
- ...rest,
783
- "data-shoplflow": "Switch"
784
- }
785
- ) });
786
- };
787
- var Switch_default = Switch;
788
-
789
- // src/components/Chips/ChipToggle/ChipToggle.types.ts
790
- var ChipToggleStyleVariants = {
791
- SOLID: "SOLID"
792
- };
793
- var ChipToggleSizeVariants = {
794
- S: "S",
795
- XS: "XS"
796
- };
797
- var getDisabledStyle = (disabled) => {
798
- if (!disabled) {
799
- return;
800
- }
801
- return css`
802
- opacity: 50%;
803
- cursor: not-allowed;
804
- `;
805
- };
806
-
807
- // src/components/Chips/ChipToggle/ChipToggle.styled.ts
808
- var getLineTypographyBySizeVar = (sizeVar) => {
809
- switch (sizeVar) {
810
- case "XS":
811
- return "body3_400";
812
- case "S":
813
- return "body2_400";
814
- default:
815
- return "body2_400";
816
- }
817
- };
818
- var solidStyle = ({ isSelected, color, radius }) => css`
819
- padding: 7px 12px;
820
- gap: 4px;
821
- background: ${colorTokens.neutral150};
822
- border-radius: ${borderRadiusTokens.borderRadius06};
823
- & > span {
824
- color: ${colorTokens.neutral400};
825
- }
826
- &:hover {
827
- background: ${colorTokens.neutral200};
828
- }
829
-
830
- ${radius && css`
831
- border-radius: ${borderRadiusTokens.borderRadius16};
832
- `};
833
- ${isSelected && css`
834
- background: ${colorTokens[color]};
835
- & > span {
836
- color: ${colorTokens["neutral0"]};
837
- }
838
- &:hover {
839
- background: ${colorTokens[color]};
840
- }
841
- `};
842
- `;
843
- var StyledChip = styled5.button`
844
- display: flex;
845
- align-items: center;
846
- justify-content: center;
847
- border: none;
848
- width: fit-content;
849
- user-select: none;
850
- cursor: pointer;
851
- ${(props) => props.styleVar === "SOLID" && solidStyle(props)};
852
- ${({ disabled }) => getDisabledStyle(disabled)};
853
- `;
854
- var ChipToggle = ({
855
- text,
856
- isSelected,
857
- defaultSelected,
858
- color = "neutral600",
859
- styleVar = ChipToggleStyleVariants.SOLID,
860
- sizeVar,
861
- leftSource,
862
- rightSource,
863
- onClick = noop,
864
- disabled = false,
865
- ...rest
866
- }) => {
867
- const [isToggled, handleToggle] = useOnToggle(isSelected, defaultSelected);
868
- const handleClick = (e) => {
869
- !disabled && handleToggle();
870
- !disabled && onClick && onClick(e);
871
- };
872
- return /* @__PURE__ */ jsxs(
873
- StyledChip,
874
- {
875
- ...rest,
876
- color,
877
- isSelected: isToggled,
878
- styleVar,
879
- sizeVar,
880
- onClick: handleClick,
881
- disabled,
882
- "data-shoplflow": "ChipToggle",
883
- children: [
884
- leftSource,
885
- /* @__PURE__ */ jsx(Text_default, { typography: getLineTypographyBySizeVar(sizeVar), children: text }),
886
- rightSource
887
- ]
888
- }
889
- );
890
- };
891
- var ChipToggle_default = ChipToggle;
892
-
893
- // src/utils/getNextColor.ts
894
- var getNextColor = (color, step = 1) => {
895
- const colorName = color.replace(/[0-9]|_/g, "");
896
- const colorNumber = color.replace(/[a-z]|_/g, "");
897
- const nextColorNumber = Number(colorNumber) + 100 * step;
898
- const nextColorToken = `${colorName}${nextColorNumber}`;
899
- const colorKeysOfColorName = Object.keys(colorTokens).filter((colorToken) => colorToken.includes(colorName)).sort((a, b) => Number(a.replace(/[a-z]|_/g, "")) - Number(b.replace(/[a-z]|_/g, "")));
900
- const colorTokenKeys = Object.keys(colorTokens);
901
- const findColorToken = colorTokenKeys.find((colorToken) => colorToken === nextColorToken);
902
- const lastColorToken = colorKeysOfColorName[colorKeysOfColorName.length - 1];
903
- return findColorToken ? findColorToken : lastColorToken;
904
- };
905
-
906
- // src/components/Chips/ChipButton/ChipButton.styled.ts
907
- var getLineTypographyBySizeVar2 = (sizeVar) => {
908
- switch (sizeVar) {
909
- case "XS":
910
- return "caption_400";
911
- case "S":
912
- return "body3_400";
913
- default:
914
- return "body3_400";
915
- }
916
- };
917
- var lineStyle = ({ color }) => css`
918
- background: ${colorTokens.neutral0};
919
- border: 1px solid ${colorTokens[color]};
920
- border-radius: ${borderRadiusTokens.borderRadius20};
921
- &:hover {
922
- border: 1px solid ${colorTokens[getNextColor(color, 2)]};
923
- }
924
- & > span {
925
- color: ${colorTokens[getNextColor(color, 4)]};
926
- }
927
- `;
928
- var getStyleBySizeVar = (sizeVar) => {
929
- switch (sizeVar) {
930
- case "XS":
931
- return css`
932
- padding: 4px 8px;
933
- `;
934
- case "S":
935
- return css`
936
- padding: 7px 12px;
937
- `;
938
- default:
939
- return css`
940
- padding: 7px 12px;
941
- `;
942
- }
943
- };
944
- var StyledChipButton = styled5.button`
945
- display: flex;
946
- align-items: center;
947
- justify-content: center;
948
- border: none;
949
- width: fit-content;
950
- gap: 4px;
951
- cursor: pointer;
952
- background: ${({ background: background2 }) => background2 && colorTokens[background2]};
953
- ${({ sizeVar }) => getStyleBySizeVar(sizeVar)};
954
- ${(props) => props.styleVar === "LINE" && lineStyle(props)};
955
- ${({ disabled }) => getDisabledStyle(disabled)};
956
- `;
957
-
958
- // src/components/Chips/ChipButton/ChipButton.types.ts
959
- var ChipButtonStyleVariants = {
960
- LINE: "LINE"
961
- };
962
- var ChipButtonSizeVariants = {
963
- S: "S",
964
- XS: "XS"
965
- };
966
- var ChipButton = ({
967
- styleVar = ChipButtonStyleVariants.LINE,
968
- color = "neutral200",
969
- sizeVar = ChipButtonSizeVariants.S,
970
- text,
971
- onClick = noop,
972
- disabled = false,
973
- ...rest
974
- }) => {
975
- const handleOnClick = (e) => {
976
- !disabled && onClick(e);
977
- };
978
- return /* @__PURE__ */ jsx(
979
- StyledChipButton,
980
- {
981
- styleVar,
982
- color,
983
- ...rest,
984
- onClick: handleOnClick,
985
- disabled,
986
- "data-shoplflow": "ChipButton",
987
- children: /* @__PURE__ */ jsx(Text_default, { typography: getLineTypographyBySizeVar2(sizeVar), children: text })
988
- }
989
- );
990
- };
991
- var ChipButton_default = ChipButton;
992
- var getStyleByStyleVar = (styleVar, disabled) => {
993
- switch (styleVar) {
994
- case "PRIMARY":
995
- return css`
996
- border: 1px solid ${colorTokens.primary400};
997
- background-color: ${colorTokens.primary300};
998
- :hover {
999
- background-color: ${!disabled && colorTokens.primary400};
1000
- }
1001
- `;
1002
- case "SECONDARY":
1003
- return css`
1004
- border: 1px solid ${colorTokens.neutral350};
1005
- background-color: ${colorTokens.neutral0};
1006
- :hover {
1007
- background-color: ${!disabled && colorTokens.neutral100};
1008
- }
1009
- `;
1010
- case "SOLID":
1011
- return css`
1012
- border: 1px solid ${colorTokens.coolgray100};
1013
- background-color: ${colorTokens.coolgray50};
1014
- :hover {
1015
- background-color: ${!disabled && colorTokens.coolgray100};
1016
- }
1017
- `;
1018
- case "GHOST":
1019
- return css`
1020
- border: 1px solid transparent;
1021
- background-color: transparent;
1022
- :hover {
1023
- background-color: ${!disabled && colorTokens.neutral400_5};
1024
- }
1025
- `;
1026
- default:
1027
- return css`
1028
- border: 1px solid ${colorTokens.primary400};
1029
- background-color: ${colorTokens.primary300};
1030
- `;
1031
- }
1032
- };
1033
- var getStyleBySizeVar2 = (sizeVar) => {
1034
- switch (sizeVar) {
1035
- case "M":
1036
- return css`
1037
- min-width: 72px;
1038
- min-height: 40px;
1039
- `;
1040
- case "S":
1041
- return css`
1042
- min-width: 54px;
1043
- min-height: 32px;
1044
- `;
1045
- default:
1046
- return css`
1047
- min-width: 72px;
1048
- min-height: 40px;
1049
- `;
1050
- }
1051
- };
1052
- var StyledButton = styled5.button`
1053
- display: flex;
1054
- align-items: center;
1055
- justify-content: center;
1056
- height: fit-content;
1057
- gap: 4px;
1058
- padding: 0 12px;
1059
- border-radius: 6px;
1060
- cursor: pointer;
1061
- ${({ styleVar, disabled }) => getStyleByStyleVar(styleVar, disabled)};
1062
- ${({ sizeVar }) => getStyleBySizeVar2(sizeVar)};
1063
- ${({ disabled }) => getDisabledStyle(disabled)};
1064
- `;
1065
- var Button = forwardRef(
1066
- ({
1067
- styleVar = "PRIMARY",
1068
- sizeVar = "M",
1069
- style,
1070
- color,
1071
- as,
1072
- children,
1073
- leftSource,
1074
- rightSource,
1075
- ...rest
1076
- }, ref) => {
1077
- return /* @__PURE__ */ jsxs(
1078
- StyledButton,
1079
- {
1080
- styleVar,
1081
- sizeVar,
1082
- className: styleVar,
1083
- style,
1084
- as,
1085
- ref,
1086
- color,
1087
- ...rest,
1088
- "data-shoplflow": "Button",
1089
- children: [
1090
- leftSource,
1091
- /* @__PURE__ */ jsx(
1092
- Text_default,
1093
- {
1094
- wordBreak: "keep-all",
1095
- whiteSpace: "nowrap",
1096
- color: styleVar === "PRIMARY" ? "neutral0" : "neutral700",
1097
- typography: sizeVar === "M" ? "body1_400" : "body2_400",
1098
- children
1099
- }
1100
- ),
1101
- rightSource
1102
- ]
1103
- }
1104
- );
1105
- }
1106
- );
1107
- var Button_default = Button;
1108
-
1109
- // src/components/Buttons/Button/Button.types.ts
1110
- var buttonSizeVar = {
1111
- S: "S",
1112
- M: "M"
1113
- };
1114
- var buttonStyleVar = {
1115
- PRIMARY: "PRIMARY",
1116
- SECONDARY: "SECONDARY",
1117
- SOLID: "SOLID",
1118
- GHOST: "GHOST"
1119
- };
1120
- var getWidthAndHeightFromSizeVar = (sizeVar) => {
1121
- switch (sizeVar) {
1122
- case "M":
1123
- return css`
1124
- width: 40px;
1125
- min-width: 40px;
1126
- height: 40px;
1127
- min-height: 40px;
1128
- `;
1129
- case "S":
1130
- return css`
1131
- width: 32px;
1132
- min-width: 32px;
1133
- height: 32px;
1134
- min-height: 32px;
1135
- `;
1136
- default:
1137
- return css`
1138
- width: 40px;
1139
- min-width: 40px;
1140
- height: 40px;
1141
- min-height: 40px;
1142
- `;
1143
- }
1144
- };
1145
- var getStyleByStyleVar2 = (styleVar) => {
1146
- switch (styleVar) {
1147
- case "SOLID":
1148
- return css`
1149
- border: 1px solid ${colorTokens.neutral200};
1150
- &:hover {
1151
- background-color: ${colorTokens.neutral100};
1152
- }
1153
- `;
1154
- case "GHOST":
1155
- return css`
1156
- border: 1px solid transparent;
1157
- &:hover {
1158
- background-color: ${colorTokens.neutral400_5};
1159
- }
1160
- `;
1161
- default:
1162
- return css`
1163
- border: 1px solid ${colorTokens.neutral200};
1164
- &:hover {
1165
- background-color: ${colorTokens.neutral100};
1166
- }
1167
- `;
1168
- }
1169
- };
1170
- var StyledIconButton = styled5.button`
1171
- display: flex;
1172
- flex-shrink: 0;
1173
- border-radius: ${borderRadiusTokens.borderRadius06};
1174
- justify-content: center;
1175
- align-items: center;
1176
- background-color: ${colorTokens.neutral0};
1177
- cursor: pointer;
1178
- ${({ styleVar }) => getStyleByStyleVar2(styleVar)};
1179
- ${({ sizeVar }) => getWidthAndHeightFromSizeVar(sizeVar)};
1180
- ${({ disabled }) => getDisabledStyle(disabled)};
1181
- & > svg {
1182
- width: 20px;
1183
- height: 20px;
1184
- }
1185
- `;
1186
- var IconButton = forwardRef(
1187
- ({ styleVar, sizeVar, disabled, as, children, ...rest }, ref) => {
1188
- return /* @__PURE__ */ jsx(
1189
- StyledIconButton,
1190
- {
1191
- styleVar,
1192
- sizeVar,
1193
- disabled,
1194
- as,
1195
- ref,
1196
- ...rest,
1197
- "data-shoplflow": "IconButton",
1198
- children
1199
- }
1200
- );
1201
- }
1202
- );
1203
- var IconButton_default = IconButton;
1204
-
1205
- // src/components/Buttons/IconButton/IconButton.types.ts
1206
- var iconButtonSizeVar = {
1207
- S: "S",
1208
- M: "M"
1209
- };
1210
- var iconButtonStyleVar = {
1211
- SOLID: "SOLID",
1212
- GHOST: "GHOST"
1213
- };
1214
- var informationStyle = css`
1215
- background: ${colorTokens.neutral100};
1216
- & > span {
1217
- color: ${colorTokens.neutral600};
1218
- }
1219
- & > svg > path {
1220
- fill: ${colorTokens.neutral600};
1221
- }
1222
- `;
1223
- var alertStyle = css`
1224
- background: ${colorTokens.red100};
1225
- & > span {
1226
- align-self: center;
1227
- color: ${colorTokens.red300};
1228
- }
1229
- & > svg > path {
1230
- fill: ${colorTokens.red300};
1231
- }
1232
- `;
1233
- var StyledCallout = styled5.div`
1234
- display: flex;
1235
- justify-content: flex-start;
1236
- align-items: start;
1237
- padding: 6px 8px;
1238
- gap: 4px;
1239
- border-radius: ${borderRadiusTokens.borderRadius08};
1240
- ${({ styleVar }) => styleVar === "INFORMATION" && informationStyle}
1241
- ${({ styleVar }) => styleVar === "ALERT" && alertStyle}
1242
- `;
1243
- var StyledCalloutIcon = styled5.svg`
1244
- display: flex;
1245
- min-height: 20px;
1246
- min-width: 20px;
1247
- `;
1248
- styled5.div`
1249
- padding: 2px 0;
1250
- `;
1251
- var Callout = ({ children, styleVar = "INFORMATION", ...rest }) => {
1252
- return /* @__PURE__ */ jsx(StyledCallout, { ...rest, styleVar, "data-shoplflow": "Callout", children });
1253
- };
1254
- var CalloutText = ({ children, ...rest }) => {
1255
- return /* @__PURE__ */ jsx(Text_default, { ...rest, typography: "body3_400", children });
1256
- };
1257
- var CalloutIcon = ({ iconSource }) => {
1258
- return /* @__PURE__ */ jsx(StyledCalloutIcon, { as: iconSource });
1259
- };
1260
- Callout.Text = CalloutText;
1261
- Callout.Icon = CalloutIcon;
1262
- var Callout_default = Callout;
1263
-
1264
- // src/components/Callout/Callout.types.ts
1265
- var CalloutTypes = {
1266
- INFORMATION: "INFORMATION",
1267
- ALERT: "ALERT"
1268
- };
1269
- var StyledPopper = styled5.div`
1270
- display: flex;
1271
- flex-direction: row;
1272
- width: ${({ width }) => width ?? "fit-content"};
1273
- height: ${({ height }) => height ?? "fit-content"};
1274
- `;
1275
- var Popper = ({
1276
- trigger,
1277
- popper,
1278
- isOpen = false,
1279
- placement,
1280
- offset: initialOffset = 0,
1281
- autoPlacement: initialAutoPlacement,
1282
- strategy = "absolute",
1283
- middlewares,
1284
- animation: initialAnimation,
1285
- ...rest
1286
- }) => {
1287
- const { refs, floatingStyles } = useFloating({
1288
- strategy,
1289
- placement,
1290
- whileElementsMounted: autoUpdate,
1291
- middleware: [
1292
- offset(initialOffset),
1293
- autoPlacement({
1294
- crossAxis: false,
1295
- ...initialAutoPlacement
1296
- }),
1297
- ...middlewares ?? []
1298
- ]
1299
- });
1300
- const animation = initialAnimation ?? fadeInOut;
1301
- return /* @__PURE__ */ jsxs(Fragment, { children: [
1302
- /* @__PURE__ */ jsx(StyledPopper, { ref: refs.setReference, "data-shoplflow": "Popper", ...rest, children: trigger }),
1303
- /* @__PURE__ */ jsx(FloatingPortal, { children: /* @__PURE__ */ jsx(AnimatePresence, { children: isOpen && /* @__PURE__ */ jsx(
1304
- motion.div,
1305
- {
1306
- initial: animation.initial,
1307
- animate: animation.animate,
1308
- exit: animation.exit,
1309
- ref: refs.setFloating,
1310
- style: floatingStyles,
1311
- children: popper
1312
- }
1313
- ) }) })
1314
- ] });
1315
- };
1316
- var Popper_default = Popper;
1317
-
1318
- // src/components/Icon/Icon.types.ts
1319
- var IconSizeVariants = {
1320
- X_SMALL: "X_SMALL",
1321
- SMALL: "SMALL",
1322
- MEDIUM: "MEDIUM",
1323
- LARGE: "LARGE",
1324
- X_LARGE: "X_LARGE"
1325
- };
1326
-
1327
- // src/components/Icon/Icon.styled.ts
1328
- var getIconSize = (size) => {
1329
- switch (size) {
1330
- case IconSizeVariants.X_SMALL:
1331
- return "12px";
1332
- case IconSizeVariants.SMALL:
1333
- return "20px";
1334
- case IconSizeVariants.MEDIUM:
1335
- return "24px";
1336
- case IconSizeVariants.LARGE:
1337
- return "30px";
1338
- case IconSizeVariants.X_LARGE:
1339
- return "36px";
1340
- default:
1341
- return "24px";
1342
- }
1343
- };
1344
- var StyledIcon = styled5.svg`
1345
- width: ${({ sizeVar }) => sizeVar && getIconSize(sizeVar)};
1346
- min-width: ${({ sizeVar }) => sizeVar && getIconSize(sizeVar)};
1347
- height: ${({ sizeVar }) => sizeVar && getIconSize(sizeVar)};
1348
- min-height: ${({ sizeVar }) => sizeVar && getIconSize(sizeVar)};
1349
-
1350
- & > path {
1351
- fill: ${({ color }) => color && colorTokens[color]};
1352
- }
1353
- `;
1354
- var Icon = forwardRef(({ iconSource, ...rest }, ref) => {
1355
- return /* @__PURE__ */ jsx(StyledIcon, { as: iconSource, ref, ...rest, "data-shoplflow": "Icon" });
1356
- });
1357
- var Icon_default = Icon;
1358
- var StyledInput = styled5.input`
1359
- padding: 4px 0 4px 12px;
1360
- background-color: transparent;
1361
- width: 100%;
1362
- border: none;
1363
- box-sizing: border-box;
1364
- &::placeholder {
1365
- color: ${colorTokens.neutral350};
1366
- }
1367
- `;
1368
- var RightElementWrapper = styled5.div`
1369
- display: flex;
1370
- flex-direction: row;
1371
- align-items: center;
1372
- padding: 0 8px 0 0;
1373
- `;
1374
- var Wrapper = styled5.div`
1375
- display: flex;
1376
- width: 100%;
1377
- justify-content: flex-end;
1378
- align-items: center;
1379
- gap: 2px;
1380
- `;
1381
- var TextCounter = ({ currentLength, maxLength }) => {
1382
- return /* @__PURE__ */ jsxs(Wrapper, { children: [
1383
- /* @__PURE__ */ jsx(Text_default, { typography: "caption_400", color: "neutral400", children: currentLength }),
1384
- /* @__PURE__ */ jsx(Text_default, { typography: "caption_400", color: "neutral350", children: "/" }),
1385
- /* @__PURE__ */ jsx(Text_default, { typography: "caption_400", color: "neutral350", children: maxLength })
1386
- ] });
1387
- };
1388
- var TextCounter_default = TextCounter;
1389
- createContext({
1390
- domain: "SHOPL",
1391
- handleToggleTheme: () => {
1392
- }
1393
- });
1394
-
1395
- // src/styles/IconAssets.tsx
1396
- var assetFunction = (iconName, domainProps) => {
1397
- const domain = domainProps ?? getDomain();
1398
- const HadaIcon = HadaAssets[iconName];
1399
- const ShoplIcon = ShoplAssets[iconName];
1400
- return domain === "hada" ? HadaIcon : ShoplIcon;
1401
- };
1402
- function assignRef(ref, value) {
1403
- if (ref == null) {
1404
- return;
1405
- }
1406
- if (typeof ref === "function") {
1407
- ref(value);
1408
- return;
1409
- }
1410
- try {
1411
- ref.current = value;
1412
- } catch (error) {
1413
- throw new Error(`Cannot assign value '${value}' to ref '${ref}'`);
1414
- }
1415
- }
1416
- function mergeRefs(...refs) {
1417
- return (node) => {
1418
- refs.forEach((ref) => {
1419
- assignRef(ref, node);
1420
- });
1421
- };
1422
- }
1423
- function useMergeRefs(...refs) {
1424
- return useMemo(() => mergeRefs(...refs), refs);
1425
- }
1426
- var getBorderColorByStatus = ({ isFocused, isError, isHovered, disabled }) => {
1427
- if (!disabled) {
1428
- if (isError) {
1429
- return colorTokens.red300;
1430
- }
1431
- if (isFocused) {
1432
- return colorTokens.primary300;
1433
- }
1434
- if (isHovered) {
1435
- return colorTokens.neutral700;
1436
- }
1437
- }
1438
- return colorTokens.neutral300;
1439
- };
1440
- var InputWrapper = styled5.label`
1441
- display: flex;
1442
- align-items: center;
1443
- width: 100%;
1444
- flex-direction: ${({ direction }) => direction || "row"};
1445
- justify-content: space-between;
1446
- min-height: 40px;
1447
- margin: 1px;
1448
- gap: 8px;
1449
- box-shadow: 0 0 0 1px ${(props) => getBorderColorByStatus(props)};
1450
- border-radius: 6px;
1451
- background-color: ${colorTokens.neutral0};
1452
- overflow: hidden;
1453
- ${({ disabled }) => getDisabledStyle(disabled)};
1454
- `;
1455
- forwardRef(
1456
- ({
1457
- onFocus,
1458
- onBlur,
1459
- onChange,
1460
- onClear,
1461
- defaultValue,
1462
- value,
1463
- isError,
1464
- disabled,
1465
- type: initialType,
1466
- maxLength,
1467
- className,
1468
- ...rest
1469
- }, ref) => {
1470
- const [text, setText] = useState("");
1471
- const [isFocused, setIsFocused] = useState(false);
1472
- const [type, setType] = useState("text");
1473
- const [isHovered, setIsHovered] = useState(false);
1474
- const uniqueId = useId();
1475
- const inputRef = React3.useRef(null);
1476
- const refs = useMergeRefs(ref, inputRef);
1477
- const convertToString = useCallback((value2) => {
1478
- if (typeof value2 !== "number") {
1479
- return typeof value2 === "string" ? value2 : value2.join("");
1480
- }
1481
- return String(value2);
1482
- }, []);
1483
- const sliceText = useCallback(
1484
- (value2) => {
1485
- if (maxLength && value2.length > maxLength) {
1486
- return value2.slice(0, maxLength);
1487
- }
1488
- return value2;
1489
- },
1490
- [maxLength]
1491
- );
1492
- const handleOnMouseEnter = () => {
1493
- setIsHovered(true);
1494
- };
1495
- const handleOnMouseLeave = () => {
1496
- setIsHovered(false);
1497
- };
1498
- const handleOnFocus = (event) => {
1499
- onFocus && onFocus(event);
1500
- setIsFocused(true);
1501
- };
1502
- const handleOnBlur = (event) => {
1503
- onBlur && onBlur(event);
1504
- !isHovered && setIsFocused(false);
1505
- };
1506
- const handleOnChange = (event) => {
1507
- onChange && onChange(event);
1508
- const slicedText = sliceText(event.target.value);
1509
- setText(slicedText);
1510
- };
1511
- const handleOnClear = () => {
1512
- onClear && onClear();
1513
- if (inputRef.current) {
1514
- setText("");
1515
- inputRef.current.value = "";
1516
- }
1517
- };
1518
- const handleTogglePasswordType = () => {
1519
- if (type === "password") {
1520
- setType("text");
1521
- } else {
1522
- setType("password");
1523
- }
1524
- };
1525
- useEffect(() => {
1526
- if (defaultValue) {
1527
- const convertString = convertToString(defaultValue);
1528
- const slicedText = sliceText(convertString);
1529
- setText(slicedText);
1530
- }
1531
- }, [convertToString, defaultValue, maxLength, sliceText]);
1532
- useEffect(() => {
1533
- if (value) {
1534
- const convertString = convertToString(value);
1535
- const slicedText = sliceText(convertString);
1536
- setText(slicedText);
1537
- }
1538
- }, [convertToString, maxLength, sliceText, value]);
1539
- useEffect(() => {
1540
- setType(initialType);
1541
- }, [initialType]);
1542
- return /* @__PURE__ */ jsxs(
1543
- InputWrapper,
1544
- {
1545
- htmlFor: uniqueId,
1546
- isFocused,
1547
- disabled,
1548
- isError,
1549
- isHovered,
1550
- onMouseEnter: handleOnMouseEnter,
1551
- onMouseLeave: handleOnMouseLeave,
1552
- "data-shoplflow": "input",
1553
- children: [
1554
- /* @__PURE__ */ jsx(
1555
- StyledInput,
1556
- {
1557
- onFocus: handleOnFocus,
1558
- onBlur: handleOnBlur,
1559
- onChange: handleOnChange,
1560
- maxLength,
1561
- disabled,
1562
- value: text,
1563
- type,
1564
- id: uniqueId,
1565
- ref: refs,
1566
- className: "body1_400" + (className ? ` ${className}` : ""),
1567
- ...rest
1568
- }
1569
- ),
1570
- /* @__PURE__ */ jsxs(RightElementWrapper, { children: [
1571
- maxLength && isFocused && /* @__PURE__ */ jsx(TextCounter_default, { currentLength: String(text).length, maxLength }),
1572
- isFocused && Boolean(String(text).length > 0) && /* @__PURE__ */ jsx(IconButton_default, { sizeVar: "S", onClick: handleOnClear, styleVar: "GHOST", children: /* @__PURE__ */ jsx(Icon_default, { iconSource: assetFunction("DeleteIcon"), color: "neutral600" }) }),
1573
- initialType === "password" && /* @__PURE__ */ jsx(IconButton_default, { sizeVar: "S", onClick: handleTogglePasswordType, styleVar: "GHOST", children: /* @__PURE__ */ jsx(
1574
- Icon_default,
1575
- {
1576
- color: "neutral600",
1577
- iconSource: assetFunction(type === "password" ? "ViewOffIcon" : "ViewOnIcon")
1578
- }
1579
- ) })
1580
- ] })
1581
- ]
1582
- }
1583
- );
1584
- }
1585
- );
1586
- var BottomElementWrapper = styled5.div`
1587
- display: flex;
1588
- width: 100%;
1589
- flex-direction: row;
1590
- padding: 8px 12px;
1591
- gap: 8px;
1592
- background-color: ${colorTokens.neutral0};
1593
- `;
1594
- var StyledTextarea = styled5.textarea`
1595
- padding: 8px 12px 0 12px;
1596
- background-color: transparent;
1597
- resize: none;
1598
- width: 100%;
1599
- height: ${({ minHeight }) => minHeight ? `${minHeight}px` : "300px"};
1600
- flex: 1;
1601
- word-break: break-all;
1602
- ${({ disabled }) => getDisabledStyle(disabled)};
1603
- &::placeholder {
1604
- color: ${colorTokens.neutral350};
1605
- }
1606
- `;
1607
- var TextArea = forwardRef(
1608
- ({
1609
- name,
1610
- maxLength,
1611
- placeholder,
1612
- disabled = false,
1613
- isError = false,
1614
- onChange,
1615
- value,
1616
- defaultValue,
1617
- onBlur,
1618
- onFocus,
1619
- minHeight = 100,
1620
- className,
1621
- ...rest
1622
- }, ref) => {
1623
- const [text, setText] = useState("");
1624
- const [isFocused, setIsFocused] = useState(false);
1625
- const [isHovered, setIsHovered] = useState(false);
1626
- const handleOnMouseEnter = () => {
1627
- setIsHovered(true);
1628
- };
1629
- const handleOnMouseLeave = () => {
1630
- setIsHovered(false);
1631
- };
1632
- const handleOnFocus = (event) => {
1633
- onFocus && onFocus(event);
1634
- setIsFocused(true);
1635
- };
1636
- const handleOnBlur = (event) => {
1637
- onBlur && onBlur(event);
1638
- !isHovered && setIsFocused(false);
1639
- };
1640
- const handleOnChange = (event) => {
1641
- onChange && onChange(event);
1642
- setText(event.target.value);
1643
- };
1644
- const convertToString = (value2) => {
1645
- if (typeof value2 !== "number") {
1646
- return typeof value2 === "string" ? value2 : value2.join("");
1647
- }
1648
- return String(value2);
1649
- };
1650
- useEffect(() => {
1651
- if (defaultValue) {
1652
- const convertString = convertToString(defaultValue);
1653
- if (maxLength && convertString.length > maxLength) {
1654
- setText(convertString);
1655
- }
1656
- setText(convertString);
1657
- }
1658
- }, [defaultValue, maxLength]);
1659
- useEffect(() => {
1660
- if (value) {
1661
- const convertString = convertToString(value);
1662
- if (maxLength && convertString.length > maxLength) {
1663
- setText(convertString);
1664
- }
1665
- setText(convertToString(value));
1666
- }
1667
- }, [maxLength, value]);
1668
- const uniqueId = useId();
1669
- return /* @__PURE__ */ jsxs(
1670
- InputWrapper,
1671
- {
1672
- htmlFor: uniqueId,
1673
- isFocused,
1674
- disabled,
1675
- isHovered,
1676
- isError,
1677
- direction: "column",
1678
- onMouseEnter: handleOnMouseEnter,
1679
- onMouseLeave: handleOnMouseLeave,
1680
- "data-shoplflow": "text-area",
1681
- children: [
1682
- /* @__PURE__ */ jsx(
1683
- StyledTextarea,
1684
- {
1685
- className: "body1_400" + (className ? ` ${className}` : ""),
1686
- placeholder,
1687
- onFocus: handleOnFocus,
1688
- onBlur: handleOnBlur,
1689
- onChange: handleOnChange,
1690
- name,
1691
- id: uniqueId,
1692
- value,
1693
- ref,
1694
- maxLength,
1695
- disabled,
1696
- minHeight,
1697
- ...rest
1698
- }
1699
- ),
1700
- /* @__PURE__ */ jsx(BottomElementWrapper, { children: maxLength && /* @__PURE__ */ jsx(TextCounter_default, { currentLength: String(text).length, maxLength }) })
1701
- ]
1702
- }
1703
- );
1704
- }
1705
- );
1706
- var TextArea_default = TextArea;
1707
- var Container2 = styled5.div`
1708
- width: 32px;
1709
- height: 32px;
1710
- padding: 7px;
1711
- `;
1712
- var IconButton2 = styled5.button`
1713
- display: flex;
1714
- width: 16px;
1715
- height: 16px;
1716
- flex-direction: column;
1717
- justify-content: center;
1718
- align-items: center;
1719
- border-radius: ${borderRadiusTokens.borderRadius04};
1720
- border: none;
1721
- background: ${({ color }) => colorTokens[color]};
1722
- cursor: pointer;
1723
- transition:
1724
- transform 0.1s ease-out,
1725
- background 0.1s ease;
1726
-
1727
- &:hover {
1728
- background: ${({ color }) => colorTokens[getNextColor(color, 1)]};
1729
- }
1730
- `;
1731
- var MinusButton = forwardRef(({ onClick, color = "neutral300", ...rest }, ref) => {
1732
- return /* @__PURE__ */ jsx(Container2, { "data-shoplflow": "minusButton", children: /* @__PURE__ */ jsx(IconButton2, { color, onClick, ref, ...rest, children: /* @__PURE__ */ jsxs("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
1733
- /* @__PURE__ */ jsx(
1734
- "path",
1735
- {
1736
- d: "M0 4C0 1.79086 1.79086 0 4 0H12C14.2091 0 16 1.79086 16 4V12C16 14.2091 14.2091 16 12 16H4C1.79086 16 0 14.2091 0 12V4Z",
1737
- fill: "none"
1738
- }
1739
- ),
1740
- /* @__PURE__ */ jsx(
1741
- "path",
1742
- {
1743
- fillRule: "evenodd",
1744
- clipRule: "evenodd",
1745
- d: "M3 8C3 7.44772 3.44772 7 4 7H12C12.5523 7 13 7.44772 13 8C13 8.55228 12.5523 9 12 9H4C3.44772 9 3 8.55228 3 8Z",
1746
- fill: "white"
1747
- }
1748
- )
1749
- ] }) }) });
1750
- });
1751
- var MinusButton_default = MinusButton;
1752
-
1753
- export { Button_default as Button, Callout_default as Callout, CalloutTypes, ChipButton_default as ChipButton, ChipButtonSizeVariants, ChipButtonStyleVariants, ChipToggle_default as ChipToggle, ChipToggleSizeVariants, ChipToggleStyleVariants, Icon_default as Icon, IconButton_default as IconButton, IconSizeVariants, MODAL_FOOTER_KEY, MODAL_HEADER_KEY, MinusButton_default as MinusButton, Modal, ModalPortal_default as ModalProvider, ModalSize, MotionStack, Popper_default as Popper, ShoplflowProvider_default as ShoplflowProvider, Stack_default as Stack, StyledIcon, StyledPopper, StyledStack, Switch_default as Switch, Text_default as Text, TextArea_default as TextArea, borderRadiusTokens, boxShadowTokens, buttonSizeVar, buttonStyleVar, colorTokens, fontWeightTokens, getDomain, iconButtonSizeVar, iconButtonStyleVar, spacingTokens, typographyTokens, useDomain, useHandleModal, useModalValue };
1754
- //# sourceMappingURL=out.js.map
1755
- //# sourceMappingURL=index.mjs.map