@inf-monkeys-tech/monkeys-design 0.4.36 → 0.4.38

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.js CHANGED
@@ -5,6 +5,8 @@ var jsxRuntime = require('react/jsx-runtime');
5
5
  var ContextMenu = require('@radix-ui/react-context-menu');
6
6
  var DropdownMenu3 = require('@radix-ui/react-dropdown-menu');
7
7
  var core = require('@dnd-kit/core');
8
+ require('@dnd-kit/sortable');
9
+ require('@dnd-kit/utilities');
8
10
  var sonner = require('sonner');
9
11
  var Tooltip = require('@radix-ui/react-tooltip');
10
12
 
@@ -20373,6 +20375,265 @@ registerTheme(
20373
20375
  version: "1.0.0"
20374
20376
  }
20375
20377
  );
20378
+ var LOGIN_LOGO_POSITIONS = ["top", "middle", "bottom"];
20379
+ var normalizeCssValue = (value) => {
20380
+ const trimmed = value?.trim();
20381
+ return trimmed || void 0;
20382
+ };
20383
+ var createBackgroundImage = (gradient, imageUrl) => {
20384
+ const resolvedGradient = normalizeCssValue(gradient);
20385
+ const resolvedImageUrl = normalizeCssValue(imageUrl);
20386
+ return [resolvedGradient, resolvedImageUrl ? `url(${JSON.stringify(resolvedImageUrl)})` : void 0].filter(Boolean).join(", ");
20387
+ };
20388
+ var normalizeLogoPosition = (position) => position && LOGIN_LOGO_POSITIONS.includes(position) ? position : "bottom";
20389
+ var normalizeLogoScale = (scale) => typeof scale === "number" && Number.isFinite(scale) && scale > 0 ? scale : void 0;
20390
+ function LoginPage({
20391
+ className,
20392
+ style,
20393
+ background,
20394
+ logo,
20395
+ primaryColor,
20396
+ radius,
20397
+ customCss,
20398
+ toolbar,
20399
+ title,
20400
+ backAction,
20401
+ methods,
20402
+ activeMethodId,
20403
+ defaultMethodId,
20404
+ onMethodChange,
20405
+ externalLabel,
20406
+ externalMethods = [],
20407
+ callout
20408
+ }) {
20409
+ const availableMethods = React.useMemo(() => methods.filter((method) => !method.hidden), [methods]);
20410
+ const fallbackMethodId = defaultMethodId ?? availableMethods[0]?.id;
20411
+ const [internalMethodId, setInternalMethodId] = React.useState(fallbackMethodId);
20412
+ const currentMethodId = activeMethodId ?? internalMethodId;
20413
+ const activeMethod = availableMethods.find((method) => method.id === currentMethodId) ?? availableMethods[0];
20414
+ const hasTabs = availableMethods.length > 1;
20415
+ const backgroundImage = createBackgroundImage(background?.gradient, background?.imageUrl);
20416
+ const backgroundMode = backgroundImage ? "custom" : "default";
20417
+ const logoPosition = normalizeLogoPosition(logo?.position);
20418
+ const logoScale = normalizeLogoScale(logo?.scale);
20419
+ React.useEffect(() => {
20420
+ if (!availableMethods.length) {
20421
+ setInternalMethodId(void 0);
20422
+ return;
20423
+ }
20424
+ if (!currentMethodId || !availableMethods.some((method) => method.id === currentMethodId)) {
20425
+ setInternalMethodId(fallbackMethodId ?? availableMethods[0]?.id);
20426
+ }
20427
+ }, [availableMethods, currentMethodId, fallbackMethodId]);
20428
+ const rootStyle = React.useMemo(
20429
+ () => ({
20430
+ ...primaryColor ? { ["--login-page-theme-primary-color"]: primaryColor } : null,
20431
+ ...radius ? { ["--login-page-theme-radius"]: radius } : null,
20432
+ ...style
20433
+ }),
20434
+ [primaryColor, radius, style]
20435
+ );
20436
+ const handleMethodChange = (methodId) => {
20437
+ if (activeMethodId === void 0) {
20438
+ setInternalMethodId(methodId);
20439
+ }
20440
+ onMethodChange?.(methodId);
20441
+ };
20442
+ const renderExternalMethod = (method) => {
20443
+ const button = /* @__PURE__ */ jsxRuntime.jsxs(
20444
+ "button",
20445
+ {
20446
+ type: "button",
20447
+ className: "login-page__oauth-button",
20448
+ "data-login-part": "external-button",
20449
+ "data-login-method-id": method.id,
20450
+ onClick: method.onClick,
20451
+ disabled: method.disabled,
20452
+ children: [
20453
+ method.icon ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "login-page__oauth-icon", "data-login-part": "external-icon", children: method.icon }) : null,
20454
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: method.label })
20455
+ ]
20456
+ }
20457
+ );
20458
+ return /* @__PURE__ */ jsxRuntime.jsx(React__default.default.Fragment, { children: method.render ? method.render(button) : button }, method.id);
20459
+ };
20460
+ return /* @__PURE__ */ jsxRuntime.jsxs(
20461
+ "main",
20462
+ {
20463
+ className: ["login-page", className].filter(Boolean).join(" "),
20464
+ "data-login-page": true,
20465
+ "data-login-part": "root",
20466
+ "data-login-background": backgroundMode,
20467
+ style: rootStyle,
20468
+ children: [
20469
+ customCss ? /* @__PURE__ */ jsxRuntime.jsx("style", { "data-login-page-custom-css": true, children: customCss }) : null,
20470
+ /* @__PURE__ */ jsxRuntime.jsx(
20471
+ "div",
20472
+ {
20473
+ className: "login-page__background",
20474
+ "data-login-part": "background",
20475
+ "data-login-background": backgroundMode,
20476
+ style: backgroundImage ? { backgroundImage } : void 0,
20477
+ "aria-hidden": "true"
20478
+ }
20479
+ ),
20480
+ toolbar ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "login-page__toolbar", "data-login-part": "toolbar", children: toolbar }) : null,
20481
+ logo?.url ? /* @__PURE__ */ jsxRuntime.jsx(
20482
+ "div",
20483
+ {
20484
+ className: `login-page__logo login-page__logo--${logoPosition}`,
20485
+ "data-login-part": "logo",
20486
+ "data-logo-position": logoPosition,
20487
+ children: /* @__PURE__ */ jsxRuntime.jsx(
20488
+ "img",
20489
+ {
20490
+ className: "login-page__logo-image",
20491
+ "data-login-part": "logo-image",
20492
+ src: logo.url,
20493
+ alt: logo.alt ?? "",
20494
+ style: logoScale ? { transform: `scale(${logoScale})` } : void 0
20495
+ }
20496
+ )
20497
+ }
20498
+ ) : null,
20499
+ /* @__PURE__ */ jsxRuntime.jsxs(
20500
+ "section",
20501
+ {
20502
+ className: "login-page__form",
20503
+ "data-login-part": "panel",
20504
+ "aria-label": typeof title === "string" ? title : void 0,
20505
+ children: [
20506
+ backAction ? /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "login-page__back", "data-login-part": "back", onClick: backAction.onClick, children: [
20507
+ backAction.icon ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "login-page__back-icon", "data-login-part": "back-icon", children: backAction.icon }) : null,
20508
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: backAction.label })
20509
+ ] }) : null,
20510
+ title ? /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "login-page__title", "data-login-part": "title", children: title }) : null,
20511
+ hasTabs ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "login-page__tabs", "data-login-part": "tabs", role: "tablist", children: availableMethods.map((method) => {
20512
+ const selected = method.id === activeMethod?.id;
20513
+ return /* @__PURE__ */ jsxRuntime.jsxs(
20514
+ "button",
20515
+ {
20516
+ type: "button",
20517
+ role: "tab",
20518
+ "aria-selected": selected,
20519
+ className: `login-page__tab ${selected ? "login-page__tab--active" : ""}`,
20520
+ "data-login-part": "tab",
20521
+ "data-login-method-id": method.id,
20522
+ "data-active": selected ? "true" : "false",
20523
+ onClick: () => handleMethodChange(method.id),
20524
+ children: [
20525
+ method.icon ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "login-page__tab-icon", "data-login-part": "tab-icon", children: method.icon }) : null,
20526
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: method.label })
20527
+ ]
20528
+ },
20529
+ method.id
20530
+ );
20531
+ }) }) : null,
20532
+ activeMethod ? /* @__PURE__ */ jsxRuntime.jsxs(
20533
+ "form",
20534
+ {
20535
+ className: "login-page__form-fields",
20536
+ "data-login-part": "form",
20537
+ "data-login-method-id": activeMethod.id,
20538
+ onSubmit: activeMethod.onSubmit,
20539
+ children: [
20540
+ activeMethod.fields.map((field) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "login-page__field", "data-login-part": "field", "data-login-field-name": field.name, children: /* @__PURE__ */ jsxRuntime.jsx(
20541
+ "input",
20542
+ {
20543
+ id: field.id,
20544
+ name: field.name,
20545
+ type: field.type ?? "text",
20546
+ value: field.value,
20547
+ placeholder: field.placeholder,
20548
+ autoComplete: field.autoComplete,
20549
+ inputMode: field.inputMode,
20550
+ maxLength: field.maxLength,
20551
+ pattern: field.pattern,
20552
+ disabled: activeMethod.disabled || activeMethod.isLoading || field.disabled,
20553
+ required: field.required,
20554
+ className: "login-page__input",
20555
+ "data-login-part": "input",
20556
+ onChange: (event) => field.onChange(event.target.value)
20557
+ }
20558
+ ) }, field.name)),
20559
+ activeMethod.checkbox ? /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "login-page__remember", "data-login-part": "checkbox-label", htmlFor: activeMethod.checkbox.id, children: [
20560
+ /* @__PURE__ */ jsxRuntime.jsx(
20561
+ "input",
20562
+ {
20563
+ id: activeMethod.checkbox.id,
20564
+ type: "checkbox",
20565
+ className: "login-page__checkbox",
20566
+ "data-login-part": "checkbox",
20567
+ checked: activeMethod.checkbox.checked,
20568
+ disabled: activeMethod.disabled || activeMethod.isLoading || activeMethod.checkbox.disabled,
20569
+ onChange: (event) => activeMethod.checkbox?.onChange(event.target.checked)
20570
+ }
20571
+ ),
20572
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: activeMethod.checkbox.label })
20573
+ ] }) : null,
20574
+ activeMethod.footer || activeMethod.footerAction ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "login-page__method-footer", "data-login-part": "method-footer", children: [
20575
+ activeMethod.footer,
20576
+ activeMethod.footerAction ? /* @__PURE__ */ jsxRuntime.jsx(
20577
+ "button",
20578
+ {
20579
+ type: "button",
20580
+ className: "login-page__method-footer-action",
20581
+ "data-login-part": "method-footer-action",
20582
+ "data-login-method-id": activeMethod.id,
20583
+ onClick: activeMethod.footerAction.onClick,
20584
+ disabled: activeMethod.disabled || activeMethod.isLoading || activeMethod.footerAction.disabled,
20585
+ children: activeMethod.footerAction.label
20586
+ }
20587
+ ) : null
20588
+ ] }) : null,
20589
+ /* @__PURE__ */ jsxRuntime.jsx(
20590
+ "button",
20591
+ {
20592
+ type: "submit",
20593
+ className: "login-page__submit",
20594
+ "data-login-part": "submit-button",
20595
+ disabled: activeMethod.disabled || activeMethod.isLoading,
20596
+ children: activeMethod.isLoading && activeMethod.loadingLabel ? activeMethod.loadingLabel : activeMethod.submitLabel
20597
+ }
20598
+ )
20599
+ ]
20600
+ }
20601
+ ) : null,
20602
+ callout ? /* @__PURE__ */ jsxRuntime.jsxs(
20603
+ "div",
20604
+ {
20605
+ className: `login-page__callout login-page__callout--${callout.tone ?? "info"}`,
20606
+ "data-login-part": "callout",
20607
+ "data-tone": callout.tone ?? "info",
20608
+ children: [
20609
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "login-page__callout-title", "data-login-part": "callout-title", children: callout.title }),
20610
+ callout.description ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "login-page__callout-description", "data-login-part": "callout-description", children: callout.description }) : null,
20611
+ callout.detail ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "login-page__callout-detail", "data-login-part": "callout-detail", children: callout.detail }) : null,
20612
+ callout.action ? /* @__PURE__ */ jsxRuntime.jsx(
20613
+ "button",
20614
+ {
20615
+ type: "button",
20616
+ className: "login-page__callout-action",
20617
+ "data-login-part": "callout-action",
20618
+ onClick: callout.action.onClick,
20619
+ disabled: callout.action.disabled,
20620
+ children: callout.action.label
20621
+ }
20622
+ ) : null
20623
+ ]
20624
+ }
20625
+ ) : null,
20626
+ externalMethods.length ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "login-page__oauth-section", "data-login-part": "external-methods", children: [
20627
+ externalLabel ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "login-page__oauth-label", "data-login-part": "external-label", children: externalLabel }) : null,
20628
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "login-page__oauth-list", "data-login-part": "external-list", children: externalMethods.map(renderExternalMethod) })
20629
+ ] }) : null
20630
+ ]
20631
+ }
20632
+ )
20633
+ ]
20634
+ }
20635
+ );
20636
+ }
20376
20637
  var containerStyle = {
20377
20638
  display: "flex",
20378
20639
  alignItems: "center",
@@ -25251,6 +25512,7 @@ exports.InteractiveTableEditableTextCell = InteractiveTableEditableTextCell;
25251
25512
  exports.InteractiveTableReadonlyCell = InteractiveTableReadonlyCell;
25252
25513
  exports.InteractiveTableSelectCell = InteractiveTableSelectCell;
25253
25514
  exports.LoginLayout = LoginLayout;
25515
+ exports.LoginPage = LoginPage;
25254
25516
  exports.MonkeysToastProvider = MonkeysToastProvider;
25255
25517
  exports.MonkeysToaster = MonkeysToaster;
25256
25518
  exports.NavButton = NavButton;