/* Kole UI Mobile · Search 样式 — 对齐移动端规格 §28 搜索框:整行高不小于 44px,输入即过滤(不等回车); 放大镜是 CSS 画的(圆 + 45° 短柄),不引入图标字体(零运行时依赖); round=false 时是方角,round=true 时是胶囊;取消动作始终 44px 热区。 */ .kole-m-search { /* 组件级变量:业务侧可在容器上覆盖 */ --kole-m-search-height: var(--kole-m-touch-target); /* 搜索框高度(≥ 44px 触控最小边长) */ --kole-m-search-radius: var(--kole-radius-base); /* round=false 时的圆角 */ --kole-m-search-icon-size: 14px; /* 放大镜视觉尺寸 */ box-sizing: border-box; display: flex; align-items: center; gap: var(--kole-space-8); width: 100%; } /* 变体 round=true:胶囊形(页面顶部常用) */ .kole-m-search--round { --kole-m-search-radius: 999px; } .kole-m-search__form { flex: 1 1 auto; min-width: 0; box-sizing: border-box; display: flex; align-items: center; gap: var(--kole-space-8); min-height: var(--kole-m-search-height); padding: 0 var(--kole-space-12); border: 1px solid var(--kole-color-border); border-radius: var(--kole-m-search-radius); background: var(--kole-color-card-bg); color: var(--kole-color-text-body); font-size: var(--kole-m-font-size-body); transition: border-color 150ms var(--kole-ease-standard); } .kole-m-search__form:focus-within { border-color: var(--kole-color-brand); } /* 整行热区(放大镜 + 输入区):点框内任意位置即聚焦。 label 里不能放 labelable 元素(button 就是),所以清除按钮在 label 外 —— 否则点击清除会连带激活 label,既触发两次语义又是不合法嵌套。 */ .kole-m-search__hit { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: var(--kole-space-8); cursor: text; } /* 放大镜:圆(::before)+ 45° 短柄(::after),用 currentColor 跟随文字色 */ .kole-m-search__icon { position: relative; flex: 0 0 auto; display: inline-block; width: var(--kole-m-search-icon-size); height: var(--kole-m-search-icon-size); color: var(--kole-color-text-secondary); } .kole-m-search__icon::before { content: ''; position: absolute; top: 0; left: 0; box-sizing: border-box; width: 10px; height: 10px; border: 2px solid currentColor; border-radius: 50%; } .kole-m-search__icon::after { content: ''; position: absolute; right: 0; bottom: 1px; width: 6px; height: 2px; background: currentColor; transform: rotate(45deg); transform-origin: right center; } .kole-m-search__control { flex: 1 1 auto; min-width: 0; height: var(--kole-m-search-height); padding: 0; border: 0; outline: none; background: transparent; color: inherit; font-family: inherit; font-size: var(--kole-m-font-size-body); line-height: 1.4; /* iOS 上 type=search 自带的内阴影与圆角会破坏外框视觉,这里清掉 */ appearance: none; -webkit-appearance: none; } .kole-m-search__control::placeholder { color: var(--kole-color-text-placeholder); } .kole-m-search__control::-webkit-search-decoration, .kole-m-search__control::-webkit-search-cancel-button { -webkit-appearance: none; } .kole-m-search__control:disabled { color: var(--kole-color-text-disabled); cursor: not-allowed; } /* 清除按钮:视觉 16px、热区补到 44px;有值(is-filled)时才出现 */ .kole-m-search__clear { flex: 0 0 auto; display: none; align-items: center; justify-content: center; box-sizing: border-box; width: var(--kole-m-touch-target); height: var(--kole-m-touch-target); margin-right: calc(var(--kole-space-12) * -1); padding: 0; border: 0; background: none; color: var(--kole-color-text-placeholder); font-size: var(--kole-m-font-size-label); line-height: 1; cursor: pointer; touch-action: manipulation; } .kole-m-search.is-filled .kole-m-search__clear { display: inline-flex; } .kole-m-search__clear:active { color: var(--kole-color-text-secondary); } .kole-m-search__clear:focus-visible { outline: 2px solid var(--kole-color-focus-ring); outline-offset: -2px; } /* 取消动作:只有 showCancel(is-cancelable)时才出现;文字按钮,触屏比图标好点 */ .kole-m-search__cancel { display: none; flex: 0 0 auto; align-items: center; justify-content: center; box-sizing: border-box; min-width: var(--kole-m-touch-target); min-height: var(--kole-m-touch-target); padding: 0 var(--kole-space-8); border: 0; background: none; color: var(--kole-color-brand); font-family: inherit; font-size: var(--kole-m-font-size-body); line-height: 1; cursor: pointer; touch-action: manipulation; } .kole-m-search.is-cancelable .kole-m-search__cancel { display: inline-flex; } .kole-m-search__cancel:active { color: var(--kole-color-brand-active); } .kole-m-search__cancel:focus-visible { outline: 2px solid var(--kole-color-focus-ring); outline-offset: -2px; } /* 状态 disabled:整框置灰 */ .kole-m-search.is-disabled .kole-m-search__form { background: var(--kole-color-disabled-bg); color: var(--kole-color-text-disabled); cursor: not-allowed; } /* 禁用态:整行不再是文本光标 */ .kole-m-search.is-disabled .kole-m-search__hit { cursor: not-allowed; }