123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132(** Touch-action utilities
@see <https://tailwindcss.com/docs/touch-action>
Tailwind CSS Touch Action documentation *)moduleCss=Cascade.CssmoduleHandler=structopenStyleopenCss(* The ten values a [touch-*] class names, spelled as the utility's own type
rather than as a [Css.touch_action]. A composed list, a CSS-wide keyword
and a [var()] are all touch-action values and none of them is a utility, so
carrying the CSS type here would leave [data] partial and [to_class]
raising on a value it was handed. *)typet=|Auto|Manipulation|No_action|Pan_left|Pan_right|Pan_x|Pan_down|Pan_up|Pan_y|Pinch_zoomletname="touch"(* Touch-action follows cursor and opens the shared interaction band. *)letpriority_=11(* CSS Variables for composable touch-action values *)lettw_pan_x_var=Var.channel~needs_property:true~property_order:50Touch_action"tw-pan-x"lettw_pan_y_var=Var.channel~needs_property:true~property_order:51Touch_action"tw-pan-y"lettw_pinch_zoom_var=Var.channel~needs_property:true~property_order:52Touch_action"tw-pinch-zoom"lettouch_props=List.filter_mapVar.property_rule[tw_pan_x_var;tw_pan_y_var;tw_pinch_zoom_var]|>concat(* Create a touch-action value that references all three vars with empty
fallbacks *)letcomposable_touch_action()=letpan_x_ref=Var.reference_with_empty_fallbacktw_pan_x_varinletpan_y_ref=Var.reference_with_empty_fallbacktw_pan_y_varinletpinch_zoom_ref=Var.reference_with_empty_fallbacktw_pinch_zoom_varintouch_action(Vars[pan_x_ref;pan_y_ref;pinch_zoom_ref])(* Helper for composable touch styles *)letcomposable_stylevarvalue=letdecl=Var.setvarvalueinstyle~property_rules:touch_props[decl;composable_touch_action()](* Class suffix and style of one utility. One match covers both, so a
constructor added to [t] without an entry here is a compile error. *)letdata:t->string*Style.t=function|Auto->("auto",style[touch_actionCss.Auto])|Manipulation->("manipulation",style[touch_actionCss.Manipulation])|No_action->("none",style[touch_actionCss.None])|Pan_left->("pan-left",composable_styletw_pan_x_varCss.Pan_left)|Pan_right->("pan-right",composable_styletw_pan_x_varCss.Pan_right)|Pan_x->("pan-x",composable_styletw_pan_x_varCss.Pan_x)|Pan_down->("pan-down",composable_styletw_pan_y_varCss.Pan_down)|Pan_up->("pan-up",composable_styletw_pan_y_varCss.Pan_up)|Pan_y->("pan-y",composable_styletw_pan_y_varCss.Pan_y)|Pinch_zoom->("pinch-zoom",composable_styletw_pinch_zoom_varCss.Pinch_zoom)(* Every value a class names, for the class-name lookup. *)letall=[Auto;Manipulation;No_action;Pan_left;Pan_right;Pan_x;Pan_down;Pan_up;Pan_y;Pinch_zoom;]letto_classv=letsuffix,_=datavin"touch-"^suffixletto_style_themev=let_,s=datavinsletsuborder=function(* Composed values carry a second property-order key, so they precede the
direct touch-action values. Candidate names settle ties within a key. *)|Pan_left|Pan_right|Pan_x->500_000|Pan_down|Pan_up|Pan_y->500_001|Pinch_zoom->500_002|Auto|Manipulation|No_action->500_003letof_class_map=List.map(funv->(to_classv,v))allletof_class_themecls=matchList.assoc_optclsof_class_mapwith|Somet->Okt|None->Error(`Msg"Not a touch-action utility")letexamples=[Auto]endopenHandlermoduleUtility_factory=Utility.Make(Handler)letutility=Utility_factory.vlettouch_auto=utilityAutolettouch_none=utilityNo_actionlettouch_manipulation=utilityManipulationlettouch_pan_x=utilityPan_xlettouch_pan_y=utilityPan_ylettouch_pan_left=utilityPan_leftlettouch_pan_right=utilityPan_rightlettouch_pan_up=utilityPan_uplettouch_pan_down=utilityPan_downlettouch_pinch_zoom=utilityPinch_zoom