This commit is contained in:
2026-05-16 05:33:26 +08:00
parent 0f23a8f7a0
commit 3bee6aaf18
52 changed files with 458 additions and 458 deletions

View File

@@ -1,6 +1,9 @@
{ {
"files.associations": { "files.associations": {
"packages/ui-web/**/*.css": "tailwindcss" "packages/ui-web-tw/**/*.css": "tailwindcss"
},
"tailwindCSS.experimental.configFile": {
"packages/ui-web-tw/src/index.css": "packages/ui-web-tw/src/**"
}, },
"editor.quickSuggestions": { "editor.quickSuggestions": {
"strings": "on" "strings": "on"

View File

@@ -1,9 +1,7 @@
import { ComponentPropsWithRef } from "react"; import { Slot } from "../../utils/Slot";
type ButtonIconProps = ComponentPropsWithRef<"span">; export const ButtonIcon = (props: any) => {
export const ButtonIcon = (props: ButtonIconProps) => {
const { children, ...rest } = props; const { children, ...rest } = props;
return <span {...rest}>{children}</span>; return <Slot {...rest}>{children}</Slot>;
}; };
ButtonIcon.displayName = "ButtonIcon"; ButtonIcon.displayName = "ButtonIcon";

View File

@@ -1,9 +1,7 @@
import { ComponentPropsWithRef } from "react"; import { Slot } from "../../utils/Slot";
type ButtonLoadingProps = ComponentPropsWithRef<"span">; export const ButtonLoading = (props: any) => {
export const ButtonLoading = (props: ButtonLoadingProps) => {
const { children, ...rest } = props; const { children, ...rest } = props;
return <span {...rest}>{children}</span>; return <Slot {...rest}>{children}</Slot>;
}; };
ButtonLoading.displayName = "ButtonLoading"; ButtonLoading.displayName = "ButtonLoading";

View File

@@ -396,6 +396,6 @@
--padding-xl: calc(var(--spacing) * 2); --padding-xl: calc(var(--spacing) * 2);
--padding-2xl: calc(var(--spacing) * 2); --padding-2xl: calc(var(--spacing) * 2);
--drop-shadow: drop-shadow(0 0 4px rgba(0, 0, 0, 0.12)) --drop-shadow-md: drop-shadow(0 0 4px rgba(0, 0, 0, 0.12))
drop-shadow(0 8px 16px rgba(0, 0, 0, 0.14)); drop-shadow(0 8px 16px rgba(0, 0, 0, 0.14));
} }

View File

@@ -0,0 +1,15 @@
import { cvr } from "../utils/cvr";
export const inlineSizeRecipe = cvr({
base: "flex flex-nowrap justify-center items-center",
variants: {
size: {
xs: "text-xs h-inline-xs gap-xs",
sm: "text-sm h-inline-sm gap-sm",
md: "text-md h-inline-md gap-md",
lg: "text-lg h-inline-lg gap-lg",
xl: "text-xl h-inline-xl gap-xl",
"2xl": "text-2xl h-inline-2xl gap-2xl",
},
},
});

View File

@@ -1,7 +1,7 @@
import { cvr } from "../utils/cvr"; import { cvr } from "../utils/cvr";
export const itemSizeRecipe = cvr({ export const itemSizeRecipe = cvr({
base: "relative select-none flex flex-nowrap justify-center items-center", base: "relative select-none display-flex flex-nowrap justify-center items-center",
variants: { variants: {
size: { size: {
xs: "text-xs h-item-xs gap-xs px-xs", xs: "text-xs h-item-xs gap-xs px-xs",
@@ -29,6 +29,7 @@ export const itemSizeRecipe = cvr({
{ iconOnly: false, size: "xl", class: "px-xl" }, { iconOnly: false, size: "xl", class: "px-xl" },
{ iconOnly: false, size: "2xl", class: "px-2xl" }, { iconOnly: false, size: "2xl", class: "px-2xl" },
{ shape: "rounded", size: "xs", class: "rounded-sm" }, { shape: "rounded", size: "xs", class: "rounded-sm" },
// ==================================================
{ {
shape: "rounded", shape: "rounded",
size: "sm", size: "sm",
@@ -54,7 +55,7 @@ export const itemSizeRecipe = cvr({
size: "2xl", size: "2xl",
class: "rounded-3xl", class: "rounded-3xl",
}, },
// -------------------------------------------------- // ==================================================
{ {
iconOnly: true, iconOnly: true,
size: "xs", size: "xs",

View File

@@ -1,37 +1,37 @@
@layer utility { @layer utility {
.align-content-normal { .align-content--normal {
align-content: normal; align-content: normal;
} }
.align-content-center { .align-content--center {
align-content: center; align-content: center;
} }
.align-content-start { .align-content--start {
align-content: flex-start; align-content: flex-start;
} }
.align-content-end { .align-content--end {
align-content: flex-end; align-content: flex-end;
} }
.align-content-between { .align-content--between {
align-content: space-between; align-content: space-between;
} }
.align-content-around { .align-content--around {
align-content: space-around; align-content: space-around;
} }
.align-content-evenly { .align-content--evenly {
align-content: space-evenly; align-content: space-evenly;
} }
.align-content-baseline { .align-content--baseline {
align-content: baseline; align-content: baseline;
} }
.align-content-stretch { .align-content--stretch {
align-content: stretch; align-content: stretch;
} }
} }

View File

@@ -1,33 +1,33 @@
@layer utility { @layer utility {
.items-start { .items--start {
align-items: flex-start; align-items: flex-start;
} }
.items-end { .items--end {
align-items: flex-end; align-items: flex-end;
} }
.items-end-safe { .items-end--safe {
align-items: safe flex-end; align-items: safe flex-end;
} }
.items-center { .items--center {
align-items: center; align-items: center;
} }
.items-center-safe { .items--center-safe {
align-items: safe center; align-items: safe center;
} }
.items-baseline { .items--baseline {
align-items: baseline; align-items: baseline;
} }
.items-baseline-last { .items--baseline-last {
align-items: last baseline; align-items: last baseline;
} }
.items-stretch { .items--stretch {
align-items: stretch; align-items: stretch;
} }
} }

View File

@@ -1,37 +1,37 @@
@layer utility { @layer utility {
.align-self-auto { .align-self--auto {
align-self: auto; align-self: auto;
} }
.align-self-start { .align-self--start {
align-self: flex-start; align-self: flex-start;
} }
.align-self-end { .align-self--end {
align-self: flex-end; align-self: flex-end;
} }
.align-self-end-safe { .align-self--end-safe {
align-self: safe flex-end; align-self: safe flex-end;
} }
.align-self-center { .align-self--center {
align-self: center; align-self: center;
} }
.align-self-center-safe { .align-self--center-safe {
align-self: safe center; align-self: safe center;
} }
.align-self-stretch { .align-self--stretch {
align-self: stretch; align-self: stretch;
} }
.align-self-baseline { .align-self--baseline {
align-self: baseline; align-self: baseline;
} }
.align-self-baseline-last { .align-self--baseline-last {
align-self: last baseline; align-self: last baseline;
} }
} }

View File

@@ -1,5 +1,5 @@
@layer utility { @layer utility {
.animate-fade-in-down { .animate--fade-in-down {
animation: var(--animate-fade-in-down); animation: var(--animate-fade-in-down);
@keyframes fade-in-down { @keyframes fade-in-down {
@@ -13,7 +13,7 @@
} }
} }
} }
.animate-fade-out-down { .animate--fade-out-down {
animation: var(--animate-fade-out-down); animation: var(--animate-fade-out-down);
} }
@@ -27,7 +27,7 @@
transform: translate3d(0, 100%, 0); transform: translate3d(0, 100%, 0);
} }
} }
.animate-fade-in-up { .animate--fade-in-up {
animation: var(--animate-fade-in-up); animation: var(--animate-fade-in-up);
} }
@@ -41,7 +41,7 @@
transform: translate3d(0, 0, 0); transform: translate3d(0, 0, 0);
} }
} }
.animate-fade-out-up { .animate--fade-out-up {
animation: var(--animate-fade-out-up); animation: var(--animate-fade-out-up);
} }
@@ -55,7 +55,7 @@
transform: translate3d(0, -100%, 0); transform: translate3d(0, -100%, 0);
} }
} }
.animate-spin { .animate--spin {
animation: var(--animate-spin); animation: var(--animate-spin);
@keyframes spin { @keyframes spin {
@@ -64,7 +64,7 @@
} }
} }
} }
.animate-ping { .animate--ping {
animation: var(--animate-ping); animation: var(--animate-ping);
@keyframes ping { @keyframes ping {
@@ -75,7 +75,7 @@
} }
} }
} }
.animate-pulse { .animate--pulse {
animation: var(--animate-pulse); animation: var(--animate-pulse);
@keyframes pulse { @keyframes pulse {
@@ -84,7 +84,7 @@
} }
} }
} }
.animate-bounce { .animate--bounce {
animation: var(--animate-bounce); /* bounce 1s infinite */ animation: var(--animate-bounce); /* bounce 1s infinite */
@keyframes bounce { @keyframes bounce {
@@ -99,7 +99,7 @@
} }
} }
} }
.animate-none { .animate--none {
animation: none; animation: none;
} }
} }

View File

@@ -1,9 +1,9 @@
@layer utility { @layer utility {
.box-decoration-clone { .box-decoration--clone {
box-decoration-break: clone; box-decoration-break: clone;
} }
.box-decoration-slice { .box-decoration--slice {
box-decoration-break: slice; box-decoration-break: slice;
} }
} }

View File

@@ -1,17 +1,17 @@
@layer utility { @layer utility {
.break-inside-auto { .break-inside--auto {
break-inside: auto; break-inside: auto;
} }
.break-inside-avoid { .break-inside--avoid {
break-inside: avoid; break-inside: avoid;
} }
.break-inside-avoid-page { .break-inside--avoid-page {
break-inside: avoid-page; break-inside: avoid-page;
} }
.break-inside-avoid-column { .break-inside--avoid-column {
break-inside: avoid-column; break-inside: avoid-column;
} }
} }

View File

@@ -1,9 +1,9 @@
@layer utility { @layer utility {
.box-sizing-border { .box-sizing--border {
box-sizing: border-box; box-sizing: border-box;
} }
.box-sizing-content { .box-sizing--content {
box-sizing: content-box; box-sizing: content-box;
} }
} }

View File

@@ -1,5 +1,5 @@
@layer utility { @layer utility {
.brand-info { .brand--info {
--brand-bg: var(--info-bg); --brand-bg: var(--info-bg);
--brand-bg-hover: var(--info-bg-hover); --brand-bg-hover: var(--info-bg-hover);
--brand-bg-active: var(--info-bg-active); --brand-bg-active: var(--info-bg-active);
@@ -7,7 +7,7 @@
--brand-bg-low-hover: var(--info-bg-low-hover); --brand-bg-low-hover: var(--info-bg-low-hover);
--brand-bg-low-active: var(--info-bg-low-active); --brand-bg-low-active: var(--info-bg-low-active);
} }
.brand-danger { .brand--danger {
--brand-bg: var(--danger-bg); --brand-bg: var(--danger-bg);
--brand-bg-hover: var(--danger-bg-hover); --brand-bg-hover: var(--danger-bg-hover);
--brand-bg-active: var(--danger-bg-active); --brand-bg-active: var(--danger-bg-active);
@@ -15,7 +15,7 @@
--brand-bg-low-hover: var(--danger-bg-low-hover); --brand-bg-low-hover: var(--danger-bg-low-hover);
--brand-bg-low-active: var(--danger-bg-low-active); --brand-bg-low-active: var(--danger-bg-low-active);
} }
.brand-success { .brand--success {
--brand-bg: var(--success-bg); --brand-bg: var(--success-bg);
--brand-bg-hover: var(--success-bg-hover); --brand-bg-hover: var(--success-bg-hover);
--brand-bg-active: var(--success-bg-active); --brand-bg-active: var(--success-bg-active);
@@ -23,7 +23,7 @@
--brand-bg-low-hover: var(--success-bg-low-hover); --brand-bg-low-hover: var(--success-bg-low-hover);
--brand-bg-low-active: var(--success-bg-low-active); --brand-bg-low-active: var(--success-bg-low-active);
} }
.brand-warning { .brand--warning {
--brand-bg: var(--warning-bg); --brand-bg: var(--warning-bg);
--brand-bg-hover: var(--warning-bg-hover); --brand-bg-hover: var(--warning-bg-hover);
--brand-bg-active: var(--warning-bg-active); --brand-bg-active: var(--warning-bg-active);
@@ -31,7 +31,7 @@
--brand-bg-low-hover: var(--warning-bg-low-hover); --brand-bg-low-hover: var(--warning-bg-low-hover);
--brand-bg-low-active: var(--warning-bg-low-active); --brand-bg-low-active: var(--warning-bg-low-active);
} }
.brand-default { .brand--default {
--brand-bg: var(--default-bg); --brand-bg: var(--default-bg);
--brand-bg-hover: var(--default-bg-hover); --brand-bg-hover: var(--default-bg-hover);
--brand-bg-active: var(--default-bg-active); --brand-bg-active: var(--default-bg-active);

View File

@@ -1,33 +1,33 @@
@layer utility { @layer utility {
.break-after-auto { .break-after--auto {
break-after: auto; break-after: auto;
} }
.break-after-avoid { .break-after--avoid {
break-after: avoid; break-after: avoid;
} }
.break-after-all { .break-after--all {
break-after: all; break-after: all;
} }
.break-after-avoid-page { .break-after--avoid-page {
break-after: avoid-page; break-after: avoid-page;
} }
.break-after-page { .break-after--page {
break-after: page; break-after: page;
} }
.break-after-left { .break-after--left {
break-after: left; break-after: left;
} }
.break-after-right { .break-after--right {
break-after: right; break-after: right;
} }
.break-after-column { .break-after--column {
break-after: column; break-after: column;
} }
} }

View File

@@ -1,33 +1,33 @@
@layer utility { @layer utility {
.break-before-auto { .break-before--auto {
break-before: auto; break-before: auto;
} }
.break-before-avoid { .break-before--avoid {
break-before: avoid; break-before: avoid;
} }
.break-before-all { .break-before--all {
break-before: all; break-before: all;
} }
.break-before-avoid-page { .break-before--avoid-page {
break-before: avoid-page; break-before: avoid-page;
} }
.break-before-page { .break-before--page {
break-before: page; break-before: page;
} }
.break-before-left { .break-before--left {
break-before: left; break-before: left;
} }
.break-before-right { .break-before--right {
break-before: right; break-before: right;
} }
.break-before-column { .break-before--column {
break-before: column; break-before: column;
} }
} }

View File

@@ -1,111 +1,111 @@
@layer utility { @layer utility {
/* ===== 基础光标 ===== */ /* ===== 基础光标 ===== */
.cursor-auto { .cursor--auto {
cursor: auto; cursor: auto;
} }
.cursor-default { .cursor--default {
cursor: default; cursor: default;
} }
.cursor-pointer { .cursor--pointer {
cursor: pointer; cursor: pointer;
} }
.cursor-wait { .cursor--wait {
cursor: wait; cursor: wait;
} }
.cursor-text { .cursor--text {
cursor: text; cursor: text;
} }
.cursor-move { .cursor--move {
cursor: move; cursor: move;
} }
.cursor-help { .cursor--help {
cursor: help; cursor: help;
} }
.cursor-not-allowed { .cursor--not-allowed {
cursor: not-allowed; cursor: not-allowed;
} }
/* ===== 拖拽 / 抓取 ===== */ /* ===== 拖拽 / 抓取 ===== */
.cursor-grab { .cursor--grab {
cursor: grab; cursor: grab;
} }
.cursor-grabbing { .cursor--grabbing {
cursor: grabbing; cursor: grabbing;
} }
/* ===== 调整大小(通用 & 方向)===== */ /* ===== 调整大小(通用 & 方向)===== */
.cursor-resize { .cursor--resize {
cursor: resize; cursor: resize;
} }
.cursor-ew-resize { .cursor--ew-resize {
cursor: ew-resize; cursor: ew-resize;
} }
.cursor-ns-resize { .cursor--ns-resize {
cursor: ns-resize; cursor: ns-resize;
} }
.cursor-nesw-resize { .cursor--nesw-resize {
cursor: nesw-resize; cursor: nesw-resize;
} }
.cursor-nwse-resize { .cursor--nwse-resize {
cursor: nwse-resize; cursor: nwse-resize;
} }
.cursor-col-resize { .cursor--col-resize {
cursor: col-resize; cursor: col-resize;
} }
.cursor-row-resize { .cursor--row-resize {
cursor: row-resize; cursor: row-resize;
} }
.cursor-n-resize { .cursor--n-resize {
cursor: n-resize; cursor: n-resize;
} }
.cursor-e-resize { .cursor--e-resize {
cursor: e-resize; cursor: e-resize;
} }
.cursor-s-resize { .cursor--s-resize {
cursor: s-resize; cursor: s-resize;
} }
.cursor-w-resize { .cursor--w-resize {
cursor: w-resize; cursor: w-resize;
} }
.cursor-ne-resize { .cursor--ne-resize {
cursor: ne-resize; cursor: ne-resize;
} }
.cursor-nw-resize { .cursor--nw-resize {
cursor: nw-resize; cursor: nw-resize;
} }
.cursor-se-resize { .cursor--se-resize {
cursor: se-resize; cursor: se-resize;
} }
.cursor-sw-resize { .cursor--sw-resize {
cursor: sw-resize; cursor: sw-resize;
} }
/* ===== 视觉反馈 ===== */ /* ===== 视觉反馈 ===== */
.cursor-crosshair { .cursor--crosshair {
cursor: crosshair; cursor: crosshair;
} }
.cursor-progress { .cursor--progress {
cursor: progress; cursor: progress;
} }
.cursor-no-drop { .cursor--no-drop {
cursor: no-drop; cursor: no-drop;
} }
.cursor-vertical-text { .cursor--vertical-text {
cursor: vertical-text; cursor: vertical-text;
} }
/* ===== 现代 / 扩展光标 ===== */ /* ===== 现代 / 扩展光标 ===== */
.cursor-zoom-in { .cursor--zoom-in {
cursor: zoom-in; cursor: zoom-in;
} }
.cursor-zoom-out { .cursor--zoom-out {
cursor: zoom-out; cursor: zoom-out;
} }
.cursor-alias { .cursor--alias {
cursor: alias; cursor: alias;
} }
.cursor-copy { .cursor--copy {
cursor: copy; cursor: copy;
} }
} }

View File

@@ -1,90 +1,90 @@
@layer utility { @layer utility {
/* 基础 display */ /* 基础 display */
.display-inline { .display--inline {
display: inline; display: inline;
} }
.display-block { .display--block {
display: block; display: block;
} }
.display-inline-block { .display--inline-block {
display: inline-block; display: inline-block;
} }
.display-flow-root { .display--flow-root {
display: flow-root; display: flow-root;
} }
.display-contents { .display--contents {
display: contents; display: contents;
} }
.display-none { .display--none {
display: none; display: none;
} }
/* Flex */ /* Flex */
.display-flex { .display--flex {
display: flex; display: flex;
} }
.display-inline-flex { .display--inline-flex {
display: inline-flex; display: inline-flex;
} }
/* Grid */ /* Grid */
.display-grid { .display--grid {
display: grid; display: grid;
} }
.display-inline-grid { .display--inline-grid {
display: inline-grid; display: inline-grid;
} }
/* Table */ /* Table */
.display-table { .display--table {
display: table; display: table;
} }
.display-inline-table { .display--inline-table {
display: inline-table; display: inline-table;
} }
.display-table-caption { .display--table-caption {
display: table-caption; display: table-caption;
} }
.display-table-cell { .display--table-cell {
display: table-cell; display: table-cell;
} }
.display-table-column { .display--table-column {
display: table-column; display: table-column;
} }
.display-table-column-group { .display--table-column-group {
display: table-column-group; display: table-column-group;
} }
.display-table-footer-group { .display--table-footer-group {
display: table-footer-group; display: table-footer-group;
} }
.display-table-header-group { .display--table-header-group {
display: table-header-group; display: table-header-group;
} }
.display-table-row-group { .display--table-row-group {
display: table-row-group; display: table-row-group;
} }
.display-table-row { .display--table-row {
display: table-row; display: table-row;
} }
/* List */ /* List */
.display-list-item { .display--list-item {
display: list-item; display: list-item;
} }
} }

View File

@@ -1,5 +1,5 @@
@layer utility { @layer utility {
.drop-shadow { .drop-shadow--md {
filter: var(--drop-shadow); filter: var(--drop-shadow-md);
} }
} }

View File

@@ -1,14 +1,14 @@
@layer utility { @layer utility {
.flex-direction-row { .flex-direction--row {
flex-direction: row; flex-direction: row;
} }
.flex-direction-row-reverse { .flex-direction--row-reverse {
flex-direction: row-reverse; flex-direction: row-reverse;
} }
.flex-direction-col { .flex-direction--col {
flex-direction: column; flex-direction: column;
} }
.flex-direction-col-reverse { .flex-direction--col-reverse {
flex-direction: column-reverse; flex-direction: column-reverse;
} }
} }

View File

@@ -1,13 +1,13 @@
@layer utility { @layer utility {
.flex-nowrap { .flex--nowrap {
flex-wrap: nowrap; flex-wrap: nowrap;
} }
.flex-wrap { .flex--wrap {
flex-wrap: wrap; flex-wrap: wrap;
} }
.flex-wrap-reverse { .flex--wrap-reverse {
flex-wrap: wrap-reverse; flex-wrap: wrap-reverse;
} }
} }

View File

@@ -1,11 +1,11 @@
@layer utility { @layer utility {
.font-family-sans { .font-family--sans {
font-family: var(--font-sans); font-family: var(--font-sans);
} }
.font-family-serif { .font-family--serif {
font-family: var(--font-serif); font-family: var(--font-serif);
} }
.font-family-mono { .font-family--mono {
font-family: var(--font-mono); font-family: var(--font-mono);
} }
} }

View File

@@ -1,45 +1,45 @@
@layer utility { @layer utility {
.justify-start { .justify--start {
justify-content: flex-start; justify-content: flex-start;
} }
.justify-end { .justify--end {
justify-content: flex-end; justify-content: flex-end;
} }
.justify-end-safe { .justify--end-safe {
justify-content: safe flex-end; justify-content: safe flex-end;
} }
.justify-center { .justify--center {
justify-content: center; justify-content: center;
} }
.justify-center-safe { .justify--center-safe {
justify-content: safe center; justify-content: safe center;
} }
.justify-between { .justify--between {
justify-content: space-between; justify-content: space-between;
} }
.justify-around { .justify--around {
justify-content: space-around; justify-content: space-around;
} }
.justify-evenly { .justify--evenly {
justify-content: space-evenly; justify-content: space-evenly;
} }
.justify-stretch { .justify--stretch {
justify-content: stretch; justify-content: stretch;
} }
.justify-baseline { .justify--baseline {
justify-content: baseline; justify-content: baseline;
} }
.justify-normal { .justify--normal {
justify-content: normal; justify-content: normal;
} }
} }

View File

@@ -1,29 +1,29 @@
@layer utility { @layer utility {
.justify-items-start { .justify-items--start {
justify-items: start; justify-items: start;
} }
.justify-items-end { .justify-items--end {
justify-items: end; justify-items: end;
} }
.justify-items-end-safe { .justify-items--end-safe {
justify-items: safe end; justify-items: safe end;
} }
.justify-items-center { .justify-items--center {
justify-items: center; justify-items: center;
} }
.justify-items-center-safe { .justify-items--center-safe {
justify-items: safe center; justify-items: safe center;
} }
.justify-items-stretch { .justify-items--stretch {
justify-items: stretch; justify-items: stretch;
} }
.justify-items-normal { .justify-items--normal {
justify-items: normal; justify-items: normal;
} }
} }

View File

@@ -1,29 +1,29 @@
@layer utility { @layer utility {
.justify-self-auto { .justify-self--auto {
justify-self: auto; justify-self: auto;
} }
.justify-self-start { .justify-self--start {
justify-self: start; justify-self: start;
} }
.justify-self-center { .justify-self--center {
justify-self: center; justify-self: center;
} }
.justify-self-center-safe { .justify-self--center-safe {
justify-self: safe center; justify-self: safe center;
} }
.justify-self-end { .justify-self--end {
justify-self: end; justify-self: end;
} }
.justify-self-end-safe { .justify-self--end-safe {
justify-self: safe end; justify-self: safe end;
} }
.justify-self-stretch { .justify-self--stretch {
justify-self: stretch; justify-self: stretch;
} }
} }

View File

@@ -1,61 +1,61 @@
@layer utility { @layer utility {
.overflow-auto { .overflow--auto {
overflow: auto; overflow: auto;
} }
.overflow-hidden { .overflow--hidden {
overflow: hidden; overflow: hidden;
} }
.overflow-clip { .overflow--clip {
overflow: clip; overflow: clip;
} }
.overflow-visible { .overflow--visible {
overflow: visible; overflow: visible;
} }
.overflow-scroll { .overflow--scroll {
overflow: scroll; overflow: scroll;
} }
.overflow-x-auto { .overflow--x--auto {
overflow-x: auto; overflow-x: auto;
} }
.overflow-y-auto { .overflow--y--auto {
overflow-y: auto; overflow-y: auto;
} }
.overflow-x-hidden { .overflow--x--hidden {
overflow-x: hidden; overflow-x: hidden;
} }
.overflow-y-hidden { .overflow--y--hidden {
overflow-y: hidden; overflow-y: hidden;
} }
.overflow-x-clip { .overflow--x--clip {
overflow-x: clip; overflow-x: clip;
} }
.overflow-y-clip { .overflow--y--clip {
overflow-y: clip; overflow-y: clip;
} }
.overflow-x-visible { .overflow--x--visible {
overflow-x: visible; overflow-x: visible;
} }
.overflow-y-visible { .overflow--y--visible {
overflow-y: visible; overflow-y: visible;
} }
.overflow-x-scroll { .overflow--x--scroll {
overflow-x: scroll; overflow-x: scroll;
} }
.overflow-y-scroll { .overflow--y--scroll {
overflow-y: scroll; overflow-y: scroll;
} }
} }

View File

@@ -1,37 +1,37 @@
@layer utility { @layer utility {
.overscroll-auto { .overscroll--auto {
overscroll-behavior: auto; overscroll-behavior: auto;
} }
.overscroll-contain { .overscroll--contain {
overscroll-behavior: contain; overscroll-behavior: contain;
} }
.overscroll-none { .overscroll--none {
overscroll-behavior: none; overscroll-behavior: none;
} }
.overscroll-x-auto { .overscroll--x--auto {
overscroll-behavior-x: auto; overscroll-behavior-x: auto;
} }
.overscroll-x-contain { .overscroll--x--contain {
overscroll-behavior-x: contain; overscroll-behavior-x: contain;
} }
.overscroll-x-none { .overscroll--x--none {
overscroll-behavior-x: none; overscroll-behavior-x: none;
} }
.overscroll-y-auto { .overscroll--y--auto {
overscroll-behavior-y: auto; overscroll-behavior-y: auto;
} }
.overscroll-y-contain { .overscroll--y--contain {
overscroll-behavior-y: contain; overscroll-behavior-y: contain;
} }
.overscroll-y-none { .overscroll--y--none {
overscroll-behavior-y: none; overscroll-behavior-y: none;
} }
} }

View File

@@ -1,21 +1,21 @@
@layer utility { @layer utility {
.position-static { .position--static {
position: static; position: static;
} }
.position-fixed { .position--fixed {
position: fixed; position: fixed;
} }
.position-absolute { .position--absolute {
position: absolute; position: absolute;
} }
.position-relative { .position--relative {
position: relative; position: relative;
} }
.position-sticky { .position--sticky {
position: sticky; position: sticky;
} }
} }

View File

@@ -10,7 +10,7 @@
white-space: nowrap; white-space: nowrap;
border-width: 0; border-width: 0;
} }
.sr-only-cancel { .sr-only--cancel {
position: static; position: static;
width: auto; width: auto;
height: auto; height: auto;

View File

@@ -1,10 +1,10 @@
@layer utility { @layer utility {
.theme-light { .theme--light {
--base-fg: var(--color-gray-950); --base-fg: var(--color-gray-950);
--base-bg: var(--color-white); --base-bg: var(--color-white);
} }
.theme-dark { .theme--dark {
--base-fg: var(--color-gray-50); --base-fg: var(--color-gray-50);
--base-bg: var(--color-black); --base-bg: var(--color-black);
} }

View File

@@ -1,14 +1,14 @@
@layer utility { @layer utility {
.select-none { .select--none {
user-select: none; user-select: none;
} }
.select-text { .select--text {
user-select: text; user-select: text;
} }
.select-all { .select--all {
user-select: all; user-select: all;
} }
.select-auto { .select--auto {
user-select: auto; user-select: auto;
} }
} }

View File

@@ -1,43 +1,43 @@
@layer utility { @layer utility {
/* 自动 & 零 */ /* 自动 & 零 */
.z-auto { .z--auto {
z-index: auto; z-index: auto;
} }
.z-0 { .z--0 {
z-index: 0; z-index: 0;
} }
/* 正值 */ /* 正值 */
.z-10 { .z--10 {
z-index: 10; z-index: 10;
} }
.z-20 { .z--20 {
z-index: 20; z-index: 20;
} }
.z-30 { .z--30 {
z-index: 30; z-index: 30;
} }
.z-40 { .z--40 {
z-index: 40; z-index: 40;
} }
.z-50 { .z--50 {
z-index: 50; z-index: 50;
} }
/* 负值negative */ /* 负值negative */
.z-n-10 { .z--n--10 {
z-index: -10; z-index: -10;
} }
.z-n-20 { .z--n--20 {
z-index: -20; z-index: -20;
} }
.z-n-30 { .z--n--30 {
z-index: -30; z-index: -30;
} }
.z-n-40 { .z--n--40 {
z-index: -40; z-index: -40;
} }
.z-n-50 { .z--n--50 {
z-index: -50; z-index: -50;
} }
} }

View File

@@ -1,26 +1,26 @@
@layer utility { @layer utility {
.rounded-full { .rounded--full {
border-radius: 9999px; border-radius: 9999px;
} }
.rounded-none { .rounded--none {
border-radius: 0; border-radius: 0;
} }
.rounded-xs { .rounded--xs {
border-radius: var(--radius-xs); border-radius: var(--radius-xs);
} }
.rounded-sm { .rounded--sm {
border-radius: var(--radius-sm); border-radius: var(--radius-sm);
} }
.rounded-md { .rounded--md {
border-radius: var(--radius-md); border-radius: var(--radius-md);
} }
.rounded-lg { .rounded--lg {
border-radius: var(--radius-lg); border-radius: var(--radius-lg);
} }
.rounded-xl { .rounded--xl {
border-radius: var(--radius-xl); border-radius: var(--radius-xl);
} }
.rounded-2xl { .rounded--2xl {
border-radius: var(--radius-2xl); border-radius: var(--radius-2xl);
} }
} }

View File

@@ -1,35 +1,35 @@
@layer utility { @layer utility {
.text-xs { .text--xs {
/* 12px 支持rem字体放大 */ /* 12px 支持rem字体放大 */
font-size: var(--font-size-xs); font-size: var(--font-size-xs);
/* 不能超过 16px */ /* 不能超过 16px */
line-height: var(--line-height-xs); line-height: var(--line-height-xs);
} }
.text-sm { .text--sm {
/* 14px 支持rem字体放大 */ /* 14px 支持rem字体放大 */
font-size: var(--font-size-sm); font-size: var(--font-size-sm);
/* 不能超过 20px */ /* 不能超过 20px */
line-height: var(--line-height-sm); line-height: var(--line-height-sm);
} }
.text-md { .text--md {
/* 16px 支持rem字体放大 */ /* 16px 支持rem字体放大 */
font-size: var(--font-size-md); font-size: var(--font-size-md);
/* 不能超过 24px */ /* 不能超过 24px */
line-height: var(--line-height-md); line-height: var(--line-height-md);
} }
.text-lg { .text--lg {
/* 18px 支持rem字体放大 */ /* 18px 支持rem字体放大 */
font-size: var(--font-size-lg); font-size: var(--font-size-lg);
/* 不能超过 28px */ /* 不能超过 28px */
line-height: var(--line-height-lg); line-height: var(--line-height-lg);
} }
.text-xl { .text--xl {
/* 24px 支持rem字体放大 */ /* 24px 支持rem字体放大 */
font-size: var(--font-size-2xl); font-size: var(--font-size-2xl);
/* 不能超过 32px */ /* 不能超过 32px */
line-height: var(--line-height-2xl); line-height: var(--line-height-2xl);
} }
.text-2xl { .text--2xl {
/* 30px 支持rem字体放大 */ /* 30px 支持rem字体放大 */
font-size: var(--font-size-2xl); font-size: var(--font-size-2xl);
/* 不能超过 36px */ /* 不能超过 36px */

View File

@@ -1,20 +1,20 @@
@layer utility { @layer utility {
.font-weight-light { .font-weight--light {
font-weight: 300; font-weight: 300;
} }
.font-weight-normal { .font-weight--normal {
font-weight: 400; font-weight: 400;
} }
.font-weight-extranormal { .font-weight--extranormal {
font-weight: 500; font-weight: 500;
} }
.font-weight-semibold { .font-weight--semibold {
font-weight: 600; font-weight: 600;
} }
.font-weight-bold { .font-weight--bold {
font-weight: 700; font-weight: 700;
} }
.font-weight-extrabold { .font-weight--extrabold {
font-weight: 700; font-weight: 700;
} }
} }

View File

@@ -1,23 +1,23 @@
@layer utility { @layer utility {
.gap-xs { .gap--xs {
/* 2px */ /* 2px */
gap: calc(var(--spacing)); gap: calc(var(--spacing));
} }
.gap-sm { .gap--sm {
/* 4px */ /* 4px */
gap: calc(var(--spacing) * 2); gap: calc(var(--spacing) * 2);
} }
.gap-md { .gap--md {
/* 6px */ /* 6px */
gap: calc(var(--spacing) * 3); gap: calc(var(--spacing) * 3);
} }
.gap-lg { .gap--lg {
gap: calc(var(--spacing) * 2); gap: calc(var(--spacing) * 2);
} }
.gap-xl { .gap--xl {
gap: calc(var(--spacing) * 2.5); gap: calc(var(--spacing) * 2.5);
} }
.gap-2xl { .gap--2xl {
gap: calc(var(--spacing) * 2.5); gap: calc(var(--spacing) * 2.5);
} }
} }

View File

@@ -1,47 +1,47 @@
@layer utility { @layer utility {
.h-item-xs { .h--item--xs {
/* 24px minimum touch size for text line */ /* 24px minimum touch size for text line */
height: var(--height-item-xs); height: var(--height-item-xs);
} }
.h-item-sm { .h--item--sm {
/* 28px save space for most used size */ /* 28px save space for most used size */
height: var(--height-item-sm); height: var(--height-item-sm);
} }
.h-item-md { .h--item--md {
/* 34px most used size */ /* 34px most used size */
height: var(--height-item-md); height: var(--height-item-md);
} }
.h-item-lg { .h--item--lg {
/* 44px maximum touch size without waste */ /* 44px maximum touch size without waste */
height: var(--height-item-lg); height: var(--height-item-lg);
} }
.h-item-xl { .h--item--xl {
/* 56px section-header bar */ /* 56px section-header bar */
height: var(--height-item-xl); height: var(--height-item-xl);
} }
.h-item-2xl { .h--item--2xl {
/* 64px navigation bar */ /* 64px navigation bar */
height: var(--height-item-2xl); height: var(--height-item-2xl);
} }
/* -------------- */ /* -------------- */
.h-inline-xs { .h--inline--xs {
/* 16px */ /* 16px */
height: calc(var(--font-size-xs) * var(--line-height-xs)); height: calc(var(--font-size-xs) * var(--line-height-xs));
} }
.h-inline-sm { .h--inline--sm {
/* 20px */ /* 20px */
height: calc(var(--font-size-sm) * var(--line-height-sm)); height: calc(var(--font-size-sm) * var(--line-height-sm));
} }
.h-inline-md { .h--inline--md {
height: calc(var(--font-size-md) * var(--line-height-md)); height: calc(var(--font-size-md) * var(--line-height-md));
} }
.h-inline-lg { .h--inline--lg {
height: calc(var(--font-size-lg) * var(--line-height-lg)); height: calc(var(--font-size-lg) * var(--line-height-lg));
} }
.h-inline-xl { .h--inline--xl {
height: calc(var(--font-size-xl) * var(--line-height-xl)); height: calc(var(--font-size-xl) * var(--line-height-xl));
} }
.h-inline-2xl { .h--inline--2xl {
height: calc(var(--font-size-2xl) * var(--line-height-2xl)); height: calc(var(--font-size-2xl) * var(--line-height-2xl));
} }
} }

View File

@@ -1,67 +1,67 @@
@layer utility { @layer utility {
.my-e-none { .my--e--none {
margin-block-end: 0; margin-block-end: 0;
} }
.my-e-xs { .my--e--xs {
margin-block-end: var(--margin-xs); margin-block-end: var(--margin-xs);
} }
.my-e-sm { .my--e--sm {
margin-block-end: var(--margin-sm); margin-block-end: var(--margin-sm);
} }
.my-e-md { .my--e--md {
margin-block-end: var(--margin-md); margin-block-end: var(--margin-md);
} }
.my-e-lg { .my--e--lg {
margin-block-end: var(--margin-lg); margin-block-end: var(--margin-lg);
} }
.my-e-xl { .my--e--xl {
margin-block-end: var(--margin-xl); margin-block-end: var(--margin-xl);
} }
.my-e-2xl { .my--e--2xl {
margin-block-end: var(--margin-2xl); margin-block-end: var(--margin-2xl);
} }
/* ------------------ */ /* ------------------ */
.my-s-none { .my--s--none {
margin-block-start: 0; margin-block-start: 0;
} }
.my-s-xs { .my--s--xs {
margin-block-start: var(--margin-xs); margin-block-start: var(--margin-xs);
} }
.my-s-sm { .my--s--sm {
margin-block-start: var(--margin-sm); margin-block-start: var(--margin-sm);
} }
.my-s-md { .my--s--md {
margin-block-start: var(--margin-md); margin-block-start: var(--margin-md);
} }
.my-s-lg { .my--s--lg {
margin-block-start: var(--margin-lg); margin-block-start: var(--margin-lg);
} }
.my-s-xl { .my--s--xl {
margin-block-start: var(--margin-xl); margin-block-start: var(--margin-xl);
} }
.my-s-2xl { .my--s--2xl {
margin-block-start: var(--margin-2xl); margin-block-start: var(--margin-2xl);
} }
/* --------------------- */ /* --------------------- */
.my-none { .my--none {
margin-block: 0; margin-block: 0;
} }
.my-xs { .my--xs {
margin-block: var(--margin-xs); margin-block: var(--margin-xs);
} }
.my-sm { .my--sm {
margin-block: var(--margin-sm); margin-block: var(--margin-sm);
} }
.my-md { .my--md {
margin-block: var(--margin-md); margin-block: var(--margin-md);
} }
.my-lg { .my--lg {
margin-block: var(--margin-lg); margin-block: var(--margin-lg);
} }
.my-xl { .my--xl {
margin-block: var(--margin-xl); margin-block: var(--margin-xl);
} }
.my-2xl { .my--2xl {
margin-block: var(--margin-2xl); margin-block: var(--margin-2xl);
} }
} }

View File

@@ -1,67 +1,67 @@
@layer utility { @layer utility {
.mx-e-none { .mx--e--none {
margin-inline-end: 0; margin-inline-end: 0;
} }
.mx-e-xs { .mx--e--xs {
margin-inline-end: var(--margin-xs); margin-inline-end: var(--margin-xs);
} }
.mx-e-sm { .mx--e--sm {
margin-inline-end: var(--margin-sm); margin-inline-end: var(--margin-sm);
} }
.mx-e-md { .mx--e--md {
margin-inline-end: var(--margin-md); margin-inline-end: var(--margin-md);
} }
.mx-e-lg { .mx--e--lg {
margin-inline-end: var(--margin-lg); margin-inline-end: var(--margin-lg);
} }
.mx-e-xl { .mx--e--xl {
margin-inline-end: var(--margin-xl); margin-inline-end: var(--margin-xl);
} }
.mx-e-2xl { .mx--e--2xl {
margin-inline-end: var(--margin-2xl); margin-inline-end: var(--margin-2xl);
} }
/* ------------------ */ /* ------------------ */
.mx-s-none { .mx--s--none {
margin-inline-start: 0; margin-inline-start: 0;
} }
.mx-s-xs { .mx--s--xs {
margin-inline-start: var(--margin-xs); margin-inline-start: var(--margin-xs);
} }
.mx-s-sm { .mx--s--sm {
margin-inline-start: var(--margin-sm); margin-inline-start: var(--margin-sm);
} }
.mx-s-md { .mx--s--md {
margin-inline-start: var(--margin-md); margin-inline-start: var(--margin-md);
} }
.mx-s-lg { .mx--s--lg {
margin-inline-start: var(--margin-lg); margin-inline-start: var(--margin-lg);
} }
.mx-s-xl { .mx--s--xl {
margin-inline-start: var(--margin-xl); margin-inline-start: var(--margin-xl);
} }
.mx-s-2xl { .mx--s--2xl {
margin-inline-start: var(--margin-2xl); margin-inline-start: var(--margin-2xl);
} }
/* --------------------- */ /* --------------------- */
.mx-none { .mx--none {
margin-inline: 0; margin-inline: 0;
} }
.mx-xs { .mx--xs {
margin-inline: var(--margin-xs); margin-inline: var(--margin-xs);
} }
.mx-sm { .mx--sm {
margin-inline: var(--margin-sm); margin-inline: var(--margin-sm);
} }
.mx-md { .mx--md {
margin-inline: var(--margin-md); margin-inline: var(--margin-md);
} }
.mx-lg { .mx--lg {
margin-inline: var(--margin-lg); margin-inline: var(--margin-lg);
} }
.mx-xl { .mx--xl {
margin-inline: var(--margin-xl); margin-inline: var(--margin-xl);
} }
.mx-2xl { .mx--2xl {
margin-inline: var(--margin-2xl); margin-inline: var(--margin-2xl);
} }
} }

View File

@@ -1,24 +1,24 @@
@layer utility { @layer utility {
.px-long-xs { .px--long--xs {
/* 6px */ /* 6px */
padding-inline: var(--padding-long-xs); padding-inline: var(--padding-long-xs);
} }
.px-long-sm { .px--long--sm {
/* 8px */ /* 8px */
padding-inline: var(--padding-long-sm); padding-inline: var(--padding-long-sm);
} }
.px-long-md { .px--long--md {
/* 10px */ /* 10px */
padding-inline: var(--padding-long-md); padding-inline: var(--padding-long-md);
} }
.px-long-lg { .px--long--lg {
/* 16px */ /* 16px */
padding-inline: var(--padding-long-lg); padding-inline: var(--padding-long-lg);
} }
.px-long-xl { .px--long--xl {
padding-inline: var(--padding-long-xl); padding-inline: var(--padding-long-xl);
} }
.px-long-2xl { .px--long--2xl {
padding-inline: var(--padding-long-2xl); padding-inline: var(--padding-long-2xl);
} }
} }

View File

@@ -1,49 +1,49 @@
@layer utility { @layer utility {
.px-none { .px--none {
padding-inline: 0px; padding-inline: 0px;
} }
.px-xs { .px--xs {
/* 4px, 24px - 16px = 8px */ /* 4px, 24px - 16px = 8px */
padding-inline: var(--padding-xs); padding-inline: var(--padding-xs);
} }
.px-sm { .px--sm {
/* 4px, 28px - 20px = 8px */ /* 4px, 28px - 20px = 8px */
padding-inline: var(--padding-sm); padding-inline: var(--padding-sm);
} }
.px-md { .px--md {
/* 10px */ /* 10px */
padding-inline: var(--padding-md); padding-inline: var(--padding-md);
} }
.px-lg { .px--lg {
/* 16px */ /* 16px */
padding-inline: var(--padding-lg); padding-inline: var(--padding-lg);
} }
.px-xl { .px--xl {
padding-inline: var(--padding-xl); padding-inline: var(--padding-xl);
} }
.px-2xl { .px--2xl {
padding-inline: var(--padding-2xl); padding-inline: var(--padding-2xl);
} }
/* ------------------------ */ /* ------------------------ */
.py-none { .py--none {
padding-block: 0px; padding-block: 0px;
} }
.py-xs { .py--xs {
padding-block: var(--padding-xs); padding-block: var(--padding-xs);
} }
.py-sm { .py--sm {
padding-block: var(--padding-sm); padding-block: var(--padding-sm);
} }
.py-md { .py--md {
padding-block: var(--padding-md); padding-block: var(--padding-md);
} }
.py-lg { .py--lg {
padding-block: var(--padding-lg); padding-block: var(--padding-lg);
} }
.py-xl { .py--xl {
padding-block: var(--padding-xl); padding-block: var(--padding-xl);
} }
.py-2xl { .py--2xl {
padding-block: var(--padding-2xl); padding-block: var(--padding-2xl);
} }
} }

View File

@@ -1,45 +1,45 @@
@layer utility { @layer utility {
.w-item-xs { .w--item--xs {
/* 24px minimum touch size for text line */ /* 24px minimum touch size for text line */
width: var(--height-item-xs); width: var(--height-item-xs);
} }
.w-item-sm { .w--item--sm {
/* 30px save space for most used size */ /* 30px save space for most used size */
width: var(--height-item-sm); width: var(--height-item-sm);
} }
.w-item-md { .w--item--md {
/* 34px most used size */ /* 34px most used size */
width: var(--height-item-lg); width: var(--height-item-lg);
} }
.w-item-lg { .w--item-lg {
/* 44px maximum touch size without waste */ /* 44px maximum touch size without waste */
width: var(--height-item-lg); width: var(--height-item-lg);
} }
.w-item-xl { .w--item--xl {
/* 56px section-header bar */ /* 56px section-header bar */
width: var(--height-item-xl); width: var(--height-item-xl);
} }
.w-item-2xl { .w--item--2xl {
/* 64px navigation bar */ /* 64px navigation bar */
width: var(--height-item-xl); width: var(--height-item-xl);
} }
/* ---------------------------------------------------- */ /* ---------------------------------------------------- */
.w-inline-xs { .w--inline--xs {
width: calc(var(--font-size-xs) * var(--line-height-xs)); width: calc(var(--font-size-xs) * var(--line-height-xs));
} }
.w-inline-sm { .w--inline--sm {
width: calc(var(--font-size-sm) * var(--line-height-sm)); width: calc(var(--font-size-sm) * var(--line-height-sm));
} }
.w-inline-md { .w--inline--md {
width: calc(var(--font-size-md) * var(--line-height-md)); width: calc(var(--font-size-md) * var(--line-height-md));
} }
.w-inline-lg { .w--inline--lg {
width: calc(var(--font-size-lg) * var(--line-height-lg)); width: calc(var(--font-size-lg) * var(--line-height-lg));
} }
.w-inline-xl { .w--inline--xl {
width: calc(var(--font-size-xl) * var(--line-height-xl)); width: calc(var(--font-size-xl) * var(--line-height-xl));
} }
.w-inline-xl { .w--inline--xl {
width: calc(var(--font-size-2xl) * var(--line-height-2xl)); width: calc(var(--font-size-2xl) * var(--line-height-2xl));
} }
} }

View File

@@ -1,61 +1,49 @@
import { defaultPrefixList } from "./prefix-list"; export function cpm(...classes: (string[] | string)[]) {
function matchLongestPrefix(cls: string, prefixList: string[]): string {
let bestPrefix: string | undefined;
for (const prefix of prefixList) {
const reg = new RegExp(`^${prefix}(?:-|$)`);
if (reg.test(cls) && (!bestPrefix || prefix.length > bestPrefix.length)) {
bestPrefix = prefix;
}
}
return bestPrefix ?? cls;
}
// 重载 1
export function cpm(...classes: Array<string | string[]>): string;
// 重载 2
export function cpm(
options: { extendedPrefixList?: string[] },
...classes: Array<string | string[]>
): string;
export function cpm(
arg1: { extendedPrefixList?: string[] } | string | string[],
...rest: Array<string | string[]>
): string {
const map = new Map<string, string>(); const map = new Map<string, string>();
let options: { extendedPrefixList?: string[] } = {}; function dealClass(cls: string) {
let classes: Array<string | string[]>; // 提取多段 prefix以“--”为分隔符
const fragments = cls.split("--");
// 前缀后面剩下的部分
const suffix = fragments.pop() ?? "";
// ['1', '1--2', '1--2--3']
const stepwisePrefixList = fragments.map((_, index, array) => {
if (index === 0) return array[0];
// 截取子数组(注意不是子字符串)
return array.slice(0, index + 1).join("--");
});
if (typeof arg1 === "object" && !Array.isArray(arg1)) { // 覆盖,短前缀
options = arg1 as { extendedPrefixList?: string[] }; stepwisePrefixList.forEach((key) => {
classes = rest; map.delete(key);
} else { });
classes = [arg1, ...rest]; // 覆盖延长前缀overflow--x 会覆盖 overflow--x--l
// 不覆盖分支前缀overflow--x 不会覆盖 overfl--y
for (const key of map.keys()) {
if (key.includes(stepwisePrefixList[-1])) {
// 包含 overflow--x 的全部删除
map.delete(key);
}
}
// 把本次值加进去
map.set(stepwisePrefixList[-1], suffix);
} }
const mergedPrefixList: string[] = [
...new Set([...(options.extendedPrefixList ?? []), ...defaultPrefixList]),
];
classes.forEach((item) => { classes.forEach((item) => {
if (Array.isArray(item)) { // 如果是 string 直接处理
item.forEach((i) => {
const bestPrefix = matchLongestPrefix(i, mergedPrefixList);
map.set(bestPrefix, i);
});
return;
}
if (typeof item === "string") { if (typeof item === "string") {
const bestPrefix = matchLongestPrefix(item, mergedPrefixList); dealClass(item);
map.set(bestPrefix, item); } else {
// 否则肯定是 string[]
item.forEach((i) => {
dealClass(i);
});
} }
}); });
return Object.values(map).join(" "); const resultString = [...map]
.map(([key, value]) => `${key}--${value}`)
.join(" ");
return resultString;
} }

View File

@@ -1,6 +1,7 @@
// 1. 允许变体值的键可以是字符串,也可以是布尔值(为了开发体验,允许传 true/false
import { cpm } from "./cpm"; import { cpm } from "./cpm";
// 1. 允许变体值的键可以是字符串,也可以是布尔值(为了开发体验,允许传 true/false
// 但底层存储我们统一视为字符串处理 // 但底层存储我们统一视为字符串处理
type VariantValue = string | boolean; type VariantValue = string | boolean;

View File

@@ -1,38 +0,0 @@
export const defaultPrefixList = [
"align-content",
"items",
"align-self",
"animate",
"rounded",
"box-decoration",
"break-inside",
"box-sizing",
"brand",
"break-after",
"break-before",
"cursor",
"display",
"flex-direction",
"flex",
"font-family",
"font-weight",
"text",
"gap",
"h",
"justify",
"justify-items",
"justify-self",
"mx",
"my",
"px",
"py",
"overflow",
"overscroll",
"position",
"sr",
"theme",
"w",
"z",
"drop-shadow",
"select",
];

View File

@@ -0,0 +1,14 @@
import { cloneElement, isValidElement } from "react";
import { mergeProps } from "./mergeProps";
export const Slot = (props: any) => {
const { children, ...rest } = props;
if (!isValidElement(children)) {
throw new Error("Slot requires a single valid React element");
}
const mergedProps = mergeProps(children.props as Record<string, any>, rest);
return cloneElement(children, mergedProps);
};

View File

@@ -16,11 +16,6 @@
"noEmit": true, "noEmit": true,
"jsx": "react-jsx", "jsx": "react-jsx",
/* Linting */
"noUnusedLocals": true,
"noUnusedParameters": true,
"erasableSyntaxOnly": true,
"noFallthroughCasesInSwitch": true
}, },
"include": ["src", "scripts", "vite.config.ts"] "include": ["src", "scripts", "vite.config.ts"]
} }

View File

@@ -0,0 +1,7 @@
function App() {
return <div></div>;
}
export default App;

View File

@@ -0,0 +1,12 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>vite-project</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/main.tsx"></script>
</body>
</html>

View File

@@ -0,0 +1,9 @@
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import App from './App.tsx'
createRoot(document.getElementById('root')!).render(
<StrictMode>
<App />
</StrictMode>,
)

View File

@@ -16,11 +16,6 @@
"noEmit": true, "noEmit": true,
"jsx": "react-jsx", "jsx": "react-jsx",
/* Linting */
"noUnusedLocals": true,
"noUnusedParameters": true,
"erasableSyntaxOnly": true,
"noFallthroughCasesInSwitch": true
}, },
"include": ["src", "scripts", "vite.config.ts"] "include": ["src", "scripts", "vite.config.ts"]
} }

View File

@@ -2,38 +2,40 @@ import { defineConfig } from "vite";
import react from "@vitejs/plugin-react"; import react from "@vitejs/plugin-react";
import path from "path"; import path from "path";
export default defineConfig({ export default defineConfig(({ command }) => {
// d.ts 由 tsc 完成,使用专门配置 tsconfig.build.json if (command === "serve") {
// 转换由 oxc 完成 return {
// 打包由 rolldown 完成 plugins: [react()],
plugins: [react()], root: "playground",
};
}
build: { return {
cssMinify: false, plugins: [react()],
lib: {
entry: path.resolve(import.meta.dirname, "src/index.ts"), build: {
// 不写 vite 默认是 index.mjs 和 index.js不方便识别 cssMinify: false,
formats: ["es", "cjs"],
// package.json 管别人怎么使用, lib: {
// build.lib 管怎么打包,生成什么 entry: path.resolve(import.meta.dirname, "src/index.ts"),
// 如果不一致,就会报错,指向文件不存在 formats: ["es", "cjs"],
fileName: (format) => `index.${format}.js`, fileName: (format) => `index.${format}.js`,
}, },
rolldownOptions: {
// 避免这些被打包peerDependencies 对 rolldown 是无效的,不会自动 external rolldownOptions: {
external: ["react", "react-dom", "react/jsx-runtime"], external: ["react", "react-dom", "react/jsx-runtime"],
// 专门给 UMD / IIFE 的映射表 output: {
output: { globals: {
globals: { react: "React",
react: "React", "react-dom": "ReactDOM",
"react-dom": "ReactDOM", },
}, },
}, },
},
emptyOutDir: true, // 防止旧产物残留 emptyOutDir: true,
sourcemap: true, // 方便调试 sourcemap: true,
cssCodeSplit: false, // 合并成一个css文件 cssCodeSplit: false,
outDir: "dist", // 专管打包输出目录tsconfig.build.json 中的 outDir 管的是 d.ts 输出目录 outDir: "dist",
}, },
};
}); });