fluekit 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,8 +3,8 @@ import { BoxDecoration } from './BoxDecoration';
3
3
  import { EdgeInsets } from './EdgeInsets';
4
4
  import { Alignment } from './FlexProps';
5
5
  interface Props {
6
- width?: number;
7
- height?: number;
6
+ width?: number | string;
7
+ height?: number | string;
8
8
  padding?: EdgeInsets;
9
9
  margin?: EdgeInsets;
10
10
  decoration?: BoxDecoration;
package/dist/Border.d.ts CHANGED
@@ -3,7 +3,7 @@ export type BorderStyleType = "none" | "solid" | "dashed" | "dotted" | "double";
3
3
  declare const BORDER_SIDE_SYMBOL: unique symbol;
4
4
  declare const BORDERS_SYMBOL: unique symbol;
5
5
  export type BorderSide = {
6
- width?: number;
6
+ width?: number | string;
7
7
  color?: string;
8
8
  style?: BorderStyleType;
9
9
  [BORDER_SIDE_SYMBOL]?: true;
@@ -15,20 +15,8 @@ export interface Borders {
15
15
  bottom?: BorderSide;
16
16
  [BORDERS_SYMBOL]?: true;
17
17
  }
18
- export declare function Border(side: Omit<BorderSide, typeof BORDER_SIDE_SYMBOL>): BorderSide;
19
- export declare namespace Border {
20
- var all: ({ color, width, style, }?: {
21
- color?: string;
22
- width?: number;
23
- style?: BorderStyleType;
24
- }) => {
25
- top: BorderSide;
26
- bottom: BorderSide;
27
- left: BorderSide;
28
- right: BorderSide;
29
- [BORDERS_SYMBOL]: true;
30
- };
31
- }
18
+ export declare function BorderSide(side: Omit<BorderSide, typeof BORDER_SIDE_SYMBOL>): BorderSide;
19
+ export declare const Border: typeof BorderSide;
32
20
  /**
33
21
  * 类型守卫:检查对象是否通过 Border 构造函数创建(单个边框边)
34
22
  */
@@ -43,5 +31,6 @@ export interface Borders {
43
31
  right?: BorderSide;
44
32
  bottom?: BorderSide;
45
33
  }
34
+ export declare function borderSideToStyle(side?: BorderSide): CSSProperties;
46
35
  export declare function borderToStyle(border: Borders): CSSProperties;
47
36
  export {};
@@ -0,0 +1,30 @@
1
+ import { ButtonStyle } from './ButtonStyle';
2
+ interface Props {
3
+ disabled?: boolean;
4
+ style?: ButtonStyle;
5
+ }
6
+ declare function __VLS_template(): {
7
+ attrs: Partial<{}>;
8
+ slots: {
9
+ default?(_: {}): any;
10
+ };
11
+ refs: {};
12
+ rootEl: any;
13
+ };
14
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
15
+ declare const __VLS_component: import('vue').DefineComponent<Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
16
+ "long-press": () => any;
17
+ pressed: () => any;
18
+ }, string, import('vue').PublicProps, Readonly<Props> & Readonly<{
19
+ "onLong-press"?: (() => any) | undefined;
20
+ onPressed?: (() => any) | undefined;
21
+ }>, {
22
+ disabled: boolean;
23
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
24
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
25
+ export default _default;
26
+ type __VLS_WithTemplateSlots<T, S> = T & {
27
+ new (): {
28
+ $slots: S;
29
+ };
30
+ };
@@ -0,0 +1,22 @@
1
+ import { CSSProperties } from 'vue';
2
+ import { Alignment } from './Alignment';
3
+ import { BorderSide } from './Border';
4
+ import { BorderRadius } from './BorderRadius';
5
+ import { EdgeInsets } from './EdgeInsets';
6
+ import { SizeType } from './Size';
7
+ export interface ButtonStyle {
8
+ backgroundColor?: string;
9
+ foregroundColor?: string;
10
+ overlayColor?: string;
11
+ shadowColor?: string;
12
+ elevation?: number;
13
+ padding?: EdgeInsets;
14
+ minimumSize?: SizeType;
15
+ maximumSize?: SizeType;
16
+ fixedSize?: SizeType;
17
+ side?: BorderSide;
18
+ shape?: BorderRadius;
19
+ alignment?: Alignment;
20
+ }
21
+ export declare const ButtonStyle: (style: ButtonStyle) => ButtonStyle;
22
+ export declare function buttonStyleToStyle(style?: ButtonStyle): CSSProperties;
@@ -3,8 +3,8 @@ import { Alignment } from './Alignment';
3
3
  import { BoxDecoration } from './BoxDecoration';
4
4
  import { EdgeInsets } from './EdgeInsets';
5
5
  interface Props {
6
- width?: number;
7
- height?: number;
6
+ width?: number | string;
7
+ height?: number | string;
8
8
  padding?: EdgeInsets;
9
9
  margin?: EdgeInsets;
10
10
  decoration?: BoxDecoration;
@@ -1,8 +1,8 @@
1
1
  interface Props {
2
2
  flex?: number;
3
3
  alignSelf?: "auto" | "start" | "end" | "center" | "stretch" | "baseline";
4
- minSize?: number;
5
- maxSize?: number;
4
+ minSize?: number | string;
5
+ maxSize?: number | string;
6
6
  }
7
7
  declare function __VLS_template(): {
8
8
  attrs: Partial<{}>;
@@ -3,8 +3,8 @@ interface Props {
3
3
  expanded?: boolean;
4
4
  flexible?: boolean;
5
5
  alignSelf?: "auto" | "start" | "end" | "center" | "stretch" | "baseline";
6
- minSize?: number;
7
- maxSize?: number;
6
+ minSize?: number | string;
7
+ maxSize?: number | string;
8
8
  }
9
9
  declare function __VLS_template(): {
10
10
  attrs: Partial<{}>;
package/dist/Size.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export interface SizeType {
2
- width?: number;
3
- height?: number;
2
+ width?: number | string;
3
+ height?: number | string;
4
4
  }
5
5
  export type Size = SizeType;
6
6
  export declare function Size(props: SizeType): SizeType;
@@ -1,6 +1,6 @@
1
1
  interface Props {
2
- width?: number;
3
- height?: number;
2
+ width?: number | string;
3
+ height?: number | string;
4
4
  }
5
5
  declare function __VLS_template(): {
6
6
  attrs: Partial<{}>;
@@ -99,7 +99,7 @@ export interface TextStyleProps {
99
99
  letterSpacing?: number;
100
100
  wordSpacing?: number;
101
101
  textBaseline?: TextBaseline;
102
- height?: number;
102
+ height?: number | string;
103
103
  leadingDistribution?: any;
104
104
  locale?: any;
105
105
  foreground?: CSSProperties;
@@ -122,9 +122,9 @@ export type TextStyle = TextStyleProps & {
122
122
  [TEXT_STYLE_SYMBOL]?: true;
123
123
  };
124
124
  export declare function toCSSStyle(props?: TextStyleProps): CSSProperties;
125
+ export { toCSSStyle as textStyleToCSSStyle };
125
126
  export declare function TextStyle(initial?: TextStyleProps, cloned?: TextStyleProps): TextStyle;
126
127
  /**
127
128
  * 类型守卫:检查对象是否通过 TextStyle 构造函数创建
128
129
  */
129
130
  export declare function isTextStyle(value: any): value is TextStyle;
130
- export {};
package/dist/index.css CHANGED
@@ -1,2 +1,2 @@
1
- .flutter-list-view[data-v-7ba20c73]{flex-direction:column;display:flex}.list-view-shrink-wrap[data-v-7ba20c73]{flex:none}.flutter-stack[data-v-aefe47c2]>*{grid-area:1/1/2/2}.flutter-transform[data-v-7e66ebaa]{box-sizing:border-box}
1
+ .fluekit-button[data-v-a5efef4c]{appearance:none;cursor:pointer;-webkit-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent;font-family:inherit;font-size:inherit;line-height:inherit;color:inherit;text-align:inherit;box-sizing:border-box;background:0 0;border:0;outline:0;margin:0;padding:0}.fluekit-button[data-v-a5efef4c]:disabled{cursor:default}.flutter-list-view[data-v-7ba20c73]{flex-direction:column;display:flex}.list-view-shrink-wrap[data-v-7ba20c73]{flex:none}.flutter-stack[data-v-aefe47c2]>*{grid-area:1/1/2/2}.flutter-transform[data-v-7e66ebaa]{box-sizing:border-box}
2
2
  /*$vite$:1*/
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export { default as Align } from './Align';
2
2
  export { default as AnimatedContainer } from './AnimatedContainer';
3
3
  export { default as AnimatedOpacity } from './AnimatedOpacity';
4
+ export { default as Button } from './Button';
4
5
  export { default as Center } from './Center';
5
6
  export { default as Column } from './Column';
6
7
  export { default as Container } from './Container';
@@ -27,6 +28,7 @@ export * from './BoxConstraints';
27
28
  export * from './BoxDecoration';
28
29
  export * from './BorderRadius';
29
30
  export * from './BoxShadow';
31
+ export * from './ButtonStyle';
30
32
  export * from './EdgeInsets';
31
33
  export * from './FlexProps';
32
34
  export { Alignment as Alignment } from './FlexProps';
package/dist/index.js CHANGED
@@ -235,7 +235,7 @@ function boxConstraintsToStyle(o) {
235
235
  };
236
236
  }
237
237
  var BORDER_SIDE_SYMBOL = Symbol("borderSide"), BORDERS_SYMBOL = Symbol("borders");
238
- function Border(o) {
238
+ function BorderSide(o) {
239
239
  return {
240
240
  width: o.width ? o.width : 1,
241
241
  color: o.color || "#000",
@@ -243,6 +243,7 @@ function Border(o) {
243
243
  [BORDER_SIDE_SYMBOL]: !0
244
244
  };
245
245
  }
246
+ const Border = BorderSide;
246
247
  Border.all = ({ color: o, width: F, style: I } = {}) => {
247
248
  let L = Border({
248
249
  color: o,
@@ -268,6 +269,11 @@ function borderSideToString(o) {
268
269
  let F = [], { width: I, color: L, style: R } = o;
269
270
  return I && F.push(I > 1 ? px2vw(I) : I + "px"), L && F.push(L), R && F.push(R), `${F.join(" ")}`;
270
271
  }
272
+ function borderSideToStyle(o) {
273
+ if (!o) return {};
274
+ let F = borderSideToString(o);
275
+ return F ? { border: F } : {};
276
+ }
271
277
  function borderToStyle(o) {
272
278
  if (o) return {
273
279
  borderLeft: borderSideToString(o.left),
@@ -789,7 +795,89 @@ var AnimatedContainer_default = /* @__PURE__ */ defineComponent({
789
795
  });
790
796
  return () => h(StyleProvider, { style: I.value }, F);
791
797
  }
792
- }), Center_default = /* @__PURE__ */ defineComponent({
798
+ });
799
+ const ButtonStyle = (o) => o;
800
+ function buttonStyleToStyle(o) {
801
+ if (!o) return {};
802
+ let F = {};
803
+ if (o.backgroundColor && (F.backgroundColor = o.backgroundColor), o.foregroundColor && (F.color = o.foregroundColor), o.padding && Object.assign(F, paddingToStyle(o.padding)), o.minimumSize) {
804
+ let { width: I, height: L } = sizeToStyle(o.minimumSize) || {};
805
+ I && (F.minWidth = I), L && (F.minHeight = L);
806
+ }
807
+ if (o.maximumSize) {
808
+ let { width: I, height: L } = sizeToStyle(o.maximumSize) || {};
809
+ I && (F.maxWidth = I), L && (F.maxHeight = L);
810
+ }
811
+ if (o.fixedSize) {
812
+ let { width: I, height: L } = sizeToStyle(o.fixedSize) || {};
813
+ I && (F.width = I, F.minWidth = I, F.maxWidth = I), L && (F.height = L, F.minHeight = L, F.maxHeight = L);
814
+ }
815
+ return o.side && Object.assign(F, borderSideToStyle(o.side)), o.shape && Object.assign(F, borderRadiusToStyle(o.shape)), o.elevation && (F.boxShadow = `0px ${px2vw(o.elevation)} ${px2vw(o.elevation * 2)} ${o.shadowColor || "rgba(0,0,0,0.2)"}`), o.alignment && (F.display = "flex", F.flexDirection = "column", Object.assign(F, alignmentToFlex(o.alignment, "column"))), F;
816
+ }
817
+ function useChildren(L) {
818
+ if (!L) return [];
819
+ let R = L();
820
+ return R ? R.filter((L) => !(L.type === Comment || L.type === Text && typeof L.children == "string" && !L.children.trim() || L.type === Fragment && Array.isArray(L.children) && L.children.length === 0)) : [];
821
+ }
822
+ function useChild(o) {
823
+ let F = useChildren(o);
824
+ return F.length === 0 ? null : F[0];
825
+ }
826
+ var GestureDetector_default = defineComponent({
827
+ name: "GestureDetector",
828
+ inheritAttrs: !1,
829
+ props: { behavior: {
830
+ type: String,
831
+ default: "deferToChild"
832
+ } },
833
+ emits: events,
834
+ setup(o, { slots: F, emit: R }) {
835
+ let z = useGestures({ emit: R });
836
+ return provideGesture(z, o.behavior), () => {
837
+ let o = useChild(F.default);
838
+ return o ? o.type === Text ? h("span", z, [o]) : isHtmlTag(o) ? cloneVNode(o, z) : o : null;
839
+ };
840
+ }
841
+ }), _hoisted_1$1 = ["disabled"], Button_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
842
+ inheritAttrs: !1,
843
+ __name: "Button",
844
+ props: {
845
+ disabled: {
846
+ type: Boolean,
847
+ default: !1
848
+ },
849
+ style: {}
850
+ },
851
+ emits: ["pressed", "long-press"],
852
+ setup(o, { emit: F }) {
853
+ let I = o, L = F, B = useStyles(), V = useSafeAttrs(), U = useGestureEvents(), W = computed(() => B.value.pointerEvents == "none" ? V.value : {
854
+ ...V.value,
855
+ ...U || {}
856
+ }), G = useGestureStyle(), K = computed(() => {
857
+ let o = { position: "relative" };
858
+ return Object.assign(o, B.value), Object.assign(o, buttonStyleToStyle(I.style)), Object.assign(o, G), o;
859
+ }), J = () => {
860
+ I.disabled || L("pressed");
861
+ }, Y = () => {
862
+ I.disabled || L("long-press");
863
+ };
864
+ return (F, I) => (openBlock(), createBlock(GestureDetector_default, {
865
+ onTap: J,
866
+ onLongPress: Y
867
+ }, {
868
+ default: withCtx(() => [createElementVNode("button", mergeProps({
869
+ class: "fluekit-button",
870
+ style: K.value,
871
+ disabled: o.disabled
872
+ }, W.value), [renderSlot(F.$slots, "default", {}, void 0, !0)], 16, _hoisted_1$1)]),
873
+ _: 3
874
+ }));
875
+ }
876
+ }), __plugin_vue_export_helper_default = (o, F) => {
877
+ let I = o.__vccOpts || o;
878
+ for (let [o, L] of F) I[o] = L;
879
+ return I;
880
+ }, Button_default = /* @__PURE__ */ __plugin_vue_export_helper_default(Button_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-a5efef4c"]]), Center_default = /* @__PURE__ */ defineComponent({
793
881
  inheritAttrs: !1,
794
882
  __name: "Center",
795
883
  props: {
@@ -1001,7 +1089,7 @@ function usePositionStyle(o, F = "absolute") {
1001
1089
  return I.top = px2vw(o.top), I.bottom = px2vw(o.bottom), I.left = px2vw(o.left), I.right = px2vw(o.right), I.width = px2vw(o.width), I.height = px2vw(o.height), I.zIndex = o.zIndex, I;
1002
1090
  });
1003
1091
  }
1004
- var Fixed_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
1092
+ var Fixed_default = /* @__PURE__ */ __plugin_vue_export_helper_default(/* @__PURE__ */ defineComponent({
1005
1093
  inheritAttrs: !1,
1006
1094
  __name: "Fixed",
1007
1095
  props: {
@@ -1020,36 +1108,7 @@ var Fixed_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
1020
1108
  style: normalizeStyle(unref(F))
1021
1109
  }, [renderSlot(o.$slots, "default", {}, void 0, !0)], 4));
1022
1110
  }
1023
- }), __plugin_vue_export_helper_default = (o, F) => {
1024
- let I = o.__vccOpts || o;
1025
- for (let [o, L] of F) I[o] = L;
1026
- return I;
1027
- }, Fixed_default = /* @__PURE__ */ __plugin_vue_export_helper_default(Fixed_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-b47757ec"]]);
1028
- function useChildren(L) {
1029
- if (!L) return [];
1030
- let R = L();
1031
- return R ? R.filter((L) => !(L.type === Comment || L.type === Text && typeof L.children == "string" && !L.children.trim() || L.type === Fragment && Array.isArray(L.children) && L.children.length === 0)) : [];
1032
- }
1033
- function useChild(o) {
1034
- let F = useChildren(o);
1035
- return F.length === 0 ? null : F[0];
1036
- }
1037
- var GestureDetector_default = defineComponent({
1038
- name: "GestureDetector",
1039
- inheritAttrs: !1,
1040
- props: { behavior: {
1041
- type: String,
1042
- default: "deferToChild"
1043
- } },
1044
- emits: events,
1045
- setup(o, { slots: F, emit: R }) {
1046
- let z = useGestures({ emit: R });
1047
- return provideGesture(z, o.behavior), () => {
1048
- let o = useChild(F.default);
1049
- return o ? o.type === Text ? h("span", z, [o]) : isHtmlTag(o) ? cloneVNode(o, z) : o : null;
1050
- };
1051
- }
1052
- }), ScrollView_default = /* @__PURE__ */ defineComponent({
1111
+ }), [["__scopeId", "data-v-b47757ec"]]), ScrollView_default = /* @__PURE__ */ defineComponent({
1053
1112
  inheritAttrs: !1,
1054
1113
  __name: "ScrollView",
1055
1114
  props: {
@@ -1638,4 +1697,4 @@ var Text_default = /* @__PURE__ */ defineComponent({
1638
1697
  }
1639
1698
  });
1640
1699
  setTransform(!1);
1641
- export { Align_default as Align, Alignment, AnimatedContainer_default as AnimatedContainer, AnimatedOpacity_default as AnimatedOpacity, AssetImage, BlurStyle, Border, BorderRadius, BoxAlignment, BoxConstraints, BoxDecoration, BoxFit, BoxShadow, BoxShape, Center_default as Center, Clip, Column_default as Column, Container_default as Container, CrossAxisAlignment, DecorationImage, EdgeInsets, Expanded_default as Expanded, Fixed_default as Fixed, FlexBoxAlignMap, FlexBoxJustifyMap, FontStyle, FontWeight, GestureDetector_default as GestureDetector, GridView_default as GridView, IgnorePointer_default as IgnorePointer, LinearGradient, ListView_default as ListView, MainAxisAlignment, NetworkImage, Opacity_default as Opacity, Padding_default as Padding, Positioned_default as Positioned, RadialGradient, Row_default as Row, SafeArea_default as SafeArea, ScrollView_default as ScrollView, Size, SizedBox_default as SizedBox, Stack_default as Stack, StackFit, Sticky_default as Sticky, Text_default as Text, TextAlign, TextBaseline, TextDecoration, TextDecorationStyle, TextDirection, TextOverflow, TextStyle, TileMode, Transform_default as Transform, Wrap_default as Wrap, alignmentToFlex, alignmentToOrigin, alignmentToStyle, borderRadiusToStyle, borderToStyle, boxConstraintsToStyle, boxDecorationToStyle, boxShadowToCSS, decorationImageToStyle, edgeInsetsToStyle, isBorderRadius, isBorderSide, isBorders, isBoxConstraints, isBoxDecoration, isBoxShadow, isEdgeInsets, isTextStyle, marginToStyle, normalizeSrc, paddingToStyle, px2vw, setBaseUrl, setDefaultVW, setTransform, sizeToStyle, toCSSStyle };
1700
+ export { Align_default as Align, Alignment, AnimatedContainer_default as AnimatedContainer, AnimatedOpacity_default as AnimatedOpacity, AssetImage, BlurStyle, Border, BorderRadius, BorderSide, BoxAlignment, BoxConstraints, BoxDecoration, BoxFit, BoxShadow, BoxShape, Button_default as Button, ButtonStyle, Center_default as Center, Clip, Column_default as Column, Container_default as Container, CrossAxisAlignment, DecorationImage, EdgeInsets, Expanded_default as Expanded, Fixed_default as Fixed, FlexBoxAlignMap, FlexBoxJustifyMap, FontStyle, FontWeight, GestureDetector_default as GestureDetector, GridView_default as GridView, IgnorePointer_default as IgnorePointer, LinearGradient, ListView_default as ListView, MainAxisAlignment, NetworkImage, Opacity_default as Opacity, Padding_default as Padding, Positioned_default as Positioned, RadialGradient, Row_default as Row, SafeArea_default as SafeArea, ScrollView_default as ScrollView, Size, SizedBox_default as SizedBox, Stack_default as Stack, StackFit, Sticky_default as Sticky, Text_default as Text, TextAlign, TextBaseline, TextDecoration, TextDecorationStyle, TextDirection, TextOverflow, TextStyle, TileMode, Transform_default as Transform, Wrap_default as Wrap, alignmentToFlex, alignmentToOrigin, alignmentToStyle, borderRadiusToStyle, borderSideToStyle, borderToStyle, boxConstraintsToStyle, boxDecorationToStyle, boxShadowToCSS, buttonStyleToStyle, decorationImageToStyle, edgeInsetsToStyle, isBorderRadius, isBorderSide, isBorders, isBoxConstraints, isBoxDecoration, isBoxShadow, isEdgeInsets, isTextStyle, marginToStyle, normalizeSrc, paddingToStyle, px2vw, setBaseUrl, setDefaultVW, setTransform, sizeToStyle, toCSSStyle as textStyleToCSSStyle, toCSSStyle };
@@ -1,17 +1,17 @@
1
1
  import { CSSProperties } from 'vue';
2
2
  export interface Props {
3
3
  /** 距离顶部的距离 */
4
- top?: number;
4
+ top?: number | string;
5
5
  /** 距离底部的距离 */
6
- bottom?: number;
6
+ bottom?: number | string;
7
7
  /** 距离左侧的距离 */
8
- left?: number;
8
+ left?: number | string;
9
9
  /** 距离右侧的距离 */
10
- right?: number;
10
+ right?: number | string;
11
11
  /** 宽度 */
12
- width?: number;
12
+ width?: number | string;
13
13
  /** 高度 */
14
- height?: number;
14
+ height?: number | string;
15
15
  /** z-index 层级 */
16
16
  zIndex?: number;
17
17
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fluekit",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "A Flutter-style Layout UI kit for Vue",
5
5
  "repository": {
6
6
  "type": "git",